Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Barn Owl on Mon 14/04/2025 01:19:27

Title: If Score >10 cEgo.ChangeRoom(x); else stop
Post by: Barn Owl on Mon 14/04/2025 01:19:27
Hi all, hope everyone is well.

Thanks again for recent help. Twice I've come back to ask another question, and ended up figuring out the solution as I was typing here. That feels good.

However, I find myself momentarily stumped once again.

Let's say dDoor is a dialog where if cEgo has a score of 10 or more, cEgo will change rooms. If cEgo has a score of less than 10, the dialog will stop.

I've got something like

if (player.Score >= 10) {
    cEgo.ChangeRoom(X);
} else {
   stop
}

player.score, or cEgo.Score does not seem to be correct. Can anyone point me in the direction of the script to check the score value?


Thanks again, may everyone create excellence!
Title: Re: If Score >10 cEgo.ChangeRoom(x); else stop
Post by: Gilbert on Mon 14/04/2025 01:44:58
The correct name of the variable is game.score.
You may just search for "score" in the help file to find it.
Title: Re: If Score >10 cEgo.ChangeRoom(x); else stop
Post by: Crimson Wizard on Mon 14/04/2025 01:52:14
There's a problem with the manual, in the description to GiveScore it never mentions or references game variables, but sais "Adds SCORE to the player's score." I suppose it's easy to misunderstand that as that score is a part of the "player" object in script.

I will add a correction there.
Title: Re: If Score >10 cEgo.ChangeRoom(x); else stop
Post by: Khris on Mon 14/04/2025 09:55:03
The lines also have to be indented correctly for this to work:
  if (game.score >= 10) {
    player.ChangeRoom(X);
  } else {
stop
  }

stop is a dialog script command and therefore the only line that cannot be indented. All others have to be indented by at least one space.
Title: Re: If Score >10 cEgo.ChangeRoom(x); else stop
Post by: Barn Owl on Tue 15/04/2025 01:07:11
You guys all rock, I've got it working.

May the great potato of adventure smile upon you all!