This should be simple (and probably is)....

CheeseMyBaby
08 Apr 2018, 21:49

When I run this:

if (GetBoolean(player, "talkbj2")) {
  if (player.health = 1) {
    msg ("You're in B.J's bedroom <small>(AKA the dumpster)</small>. Hurt within an inch of your life.")
  }
  else if (player.health > 26) {
    msg ("Feeling good enough.")
  }
  else if (player.health > 10) {
    msg ("Feeling better but not good enough.")
  }
}
else {
  msg ("here be else statement.")
}

I get this:

Error running script: Error compiling expression 'player.health => 26': SyntaxError: Unexpected token ">"; expected one of "-", <INTEGER>, <REAL>, <STRING_LITERAL>, "True", "False", <HEX_LITERAL>, <CHAR_LITERAL>, "null", <DATETIME>, <TIMESPAN>, "(", <IDENTIFIER>, "if", or "cast"Line: 1, Column: 24

In the error message I get this 'player.health => 26' but I typed in this (player.health > 26)

And it make me feel like this:



CheeseMyBaby
08 Apr 2018, 21:55

When reading my code I get a haunting feeling this will end in embarrassment. So be it.


jmnevil54
08 Apr 2018, 22:23

Alright try entering the code in again. And refreshing the page.

Maybe you have a problem with your formating, it appears to be the 'health > 20' part. Every once in a while, the game thinks that the code is formatted improperly when it isn't check to see if the code is formatted correctly. Alternatively, the player's health attribute is not set up right. If those fail, copy the code into word or another function, delete the code, and then make the code again.


K.V.
08 Apr 2018, 22:56

I bet it's in a different script.

Open the game in full code view, then hit CTRL+F and search for player.health => 26.

Try changing it to player.health >= 26


hegemonkhan
09 Apr 2018, 01:15

ya, KV's probably got it right, as the formatting requires for the equal sign to be on the RIGHT SIDE (just something to memorize), when doing:

greater than or equal to: >=
lesser than or equal to: <=
// here's an example (max to min):

if (test.score >= 90) {
  test.grade = "A"
} else if (test.score >= 80) {
  test.grade = "B"
} else if (test.score >= 70) {
  test.grade = "C"
} else if (test.score >= 60) {
  test.grade = "D"
} else {
  test.grade = "F"
}

// or the reverse (min to max) example:

if (test.score <= 59) {
  test.grade = "F"
} else if (test.score <= 69) {
  test.grade = "D"
} else if (test.score <= 79) {
  test.grade = "C"
} else if (test.score <= 89) {
  test.grade = "B"
} else {
  test.grade = "A"
}

as this (having the equal sign on the LEFT side of a greater than sign) is a Script Attribute Assignment operation/operator:

create ("example_object")

example_object.example_script_attribute => {
  msg ("blah blah blah")
}

do (example_object, "example_script_attribute")

// output: blah blah blah

CheeseMyBaby
09 Apr 2018, 04:39

I probably would not have figured that out on my own.
Thanks guys!!!


hegemonkhan
09 Apr 2018, 05:44

I myself always forgot which side the equal sign vs the greater/lesser than sign... lol... I always have to look it up... so it's just something you got to remember (and which I have a hard time at remembering, lol)


CheeseMyBaby
09 Apr 2018, 07:33

@hegemonkhan
I bookmarked this thread for future reference. I'll forget too!


mrangel
09 Apr 2018, 10:06

I always make that mistake in Perl after I've not used it for a while. (In Perl, the arrow operator is weird. It acts like a comma in an argument list, except that if the item to the left of it is a single word it gets treated as a string rather than an identifier)