Is there a way to set a maximum and a minimum for a attribute

For an attribute like health is there a way to ensure that a player can't get more than the maximum intended amount of health but still be able to up that later in the game? For example, you can give the player 40 hitpoints but when they level up you can up that to 60 without letting the player go above either amount.

The normal way to do this would be to have two attributes, health and maxhealth. Then you'd give health a changescript (which is actually just a script attribute named changedhealth). You'd make it something like:

if ( > this.maxhealth) { = this.maxhealth
else if ( <= 0) {
  // whatever code you want to use
  // for telling the player they are dead or KO

How would I sent the player to a room, I want to let a player have a save point in an area that can be changeable, I was thinking about using an attribute but I don't think that would work.

If you want to send them to a room, just move them to that room.
There's a built in function to do that:

MovePlayer (kitchen)

although that's actually the same as

MoveObject (game.pov, kitchen)

which is the same as

game.pov.parent = kitchen

(the first one is obvious what it does when you read it, which is why that's the code the GUI creates. The last one is the most efficient, but might be harder to understand until you get used to it. game.pov is an attribute that contains the current player object)

If you want to send them to a different place each time, you can just store the room in an attribute. For example, when the player uses a save point, you would run the script:

game.savepoint  = game.pov.parent

and then to go back there, you would use:

game.pov.parent = game.savepoint

Log in to post a reply.