If Score >10 cEgo.ChangeRoom(x); else stop

Started by Barn Owl, Mon 14/04/2025 01:19:27

Previous topic - Next topic

Barn Owl

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

Code: ags
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!

Gilbert

The correct name of the variable is game.score.
You may just search for "score" in the help file to find it.

Crimson Wizard

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.

Khris

#3
The lines also have to be indented correctly for this to work:
Code: ags
  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.

Barn Owl

You guys all rock, I've got it working.

May the great potato of adventure smile upon you all!

SMF spam blocked by CleanTalk