Jump - why does 'not' work

Hi guys,

In my game, I want to be able to stand on a bed and jump, this then gets me into the attic

I have a local command called jump set up in the room, as follows

if (player.posture = "stand" and player.posture_object = "bed") {
  MoveObject (player, attic)
}
else {
  msg ("You jump in the air.")
}

which doesn't work, but...

if (not player.posture = "stand" and not player.posture_object = "bed") {
  msg ("You jump in the air.")
}
else {
  MoveObject (player, attic)
}

does.
Why? They look essentially the same apart from the fact that they are reversed with the included 'not'


I think you need some more parenthesis?

If ((player.posture = "stand") and (player.posture_object = "bed")) 

I can't remember for sure. Or it might be that "and" needs to be uppercase?


Note:
not(player.posture = "stand" and player.posture_object = "bed") = (not player.posture = "stand" OR not player.posture_object = "bed")


Ok. Tried

if ((player.posture = "stand") and (player.posture_object = "bed")) {
  MoveObject (player, attic)
}
else {
  msg ("You jump in the air.")
}

as suggested by Ip Man above - No movement of player to attic, just kept printing the message "You jump in the air."

Also tried

if (not (player.posture = "stand" and player.posture_object = "bed")) {
  MoveObject (player, attic)
}
else {
  msg ("You jump in the air.")
}

As suggested by DavyB. You're able to jump to the attic, regardless of standing on the bed or not.
I wanted to 'stand' on the 'bed' and jump to the attic.


Are you sure that player.posture and player.posture_object have the correct values when this code is executed? If not, just put a debugging print statement before the code: msg(player.posture + ", " + player.posture_object)


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums