How to compare if an attribute is greater or lesser than another attribute #1617
-
|
Hello, in the game I am currently making, I need to find out if a certain attribute (integer) is less than another attribute (integer). I thought I could do it with something like: But that returns an error as soon as I start the game (even if the turnscript isn't enabled), so I'm clearly doing something wrong, but I couldn't find an example in previous documentation explaining why it doesn't work. While I'm at it I'd also like some tips for how to tell if an attribute is between the values of two other attributes. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
I think the operator might have been the issue. (Meaning Change your Tested with this: player.example = 19
player.example2 = 42
if (player.example <= player.example2) {
msg ("EXAMPLE IS LESS THAN OR EQUAL TO EXAMPLE2")
}
else {
msg ("LESS THAN")
}
Something like: if (player.att1 < player.att2 and player.att2 < player.att3) {
//player.att2 is between player.att1 and player.att3
}Tested with: player.att1 = 1
player.att2 = 2
player.att3 = 3
if (player.att1 < player.att2 and player.att2 < player.att3) {
msg("player.att2 is between player.att1 and player.att3")
} |
Beta Was this translation helpful? Give feedback.
I think the operator might have been the issue. (Meaning
= <, not you, ha-ha.)Change your
if (player.example = < player.example2)toif (player.example <= player.example2), and I bet it works.Tested with this:
Something like:
Tested with: