MoveObject having trouble with comma
Thickar
27 Nov 2018, 02:35So I'm trying to use two variables each one set by the answer to move one of four objects to a specific room.
But I get this error when I run the game
Error running script: Error compiling expression 'lion_rw, forest': SyntaxError: Unexpected token ","; expected one of
here is my code
ShowMenu ("Finally, if you could talk to animals would you want that?", Split ("Yes;No",";"), false) {
if (result = "Yes") {
player.magic = "yes"
if player.intent = good {
MoveObject (lion_mw, forest)
}
else if player.intent = bad {
MoveObject (lion_muw, forest)
}
}
else if (result = "No") {
player.magic = "no"
if player.intent = good {
MoveObject (lion_rw, forest)
}
else if player.intent = bad {
MoveObject (lion_ruw, forest)
}
}
I can't figure out what comma or lack of it's talking about?
Pertex
27 Nov 2018, 07:46Don't forget the brackets within the If statement!
if player.intent = good
if (player.intent = good)
respectively
if (player.intent = "good")
The Pixie
27 Nov 2018, 07:50I think the basic problem is that your conditions for the if
statements need to go in brackets. You are also missing the final curly brace (perhaps you just missed it when copy-and-pasting), and I would guess good
and bad
should be strings.
ShowMenu ("Finally, if you could talk to animals would you want that?", Split ("Yes;No",";"), false) {
if (result = "Yes") {
player.magic = "yes"
if (player.intent = "good") {
MoveObject (lion_mw, forest)
}
else if (player.intent = "bad") {
MoveObject (lion_muw, forest)
}
}
else if (result = "No") {
player.magic = "no"
if (player.intent = "good") {
MoveObject (lion_rw, forest)
}
else if (player.intent = "bad") {
MoveObject (lion_ruw, forest)
}
}
}
If player intent can only be good or bad, I would suggest you use a Boolean (flag) called intent_good instead of a string.
ShowMenu ("Finally, if you could talk to animals would you want that?", Split ("Yes;No",";"), false) {
if (result = "Yes") {
player.magic = "yes"
if (player.intent_good) {
MoveObject (lion_mw, forest)
}
else {
MoveObject (lion_muw, forest)
}
}
else if (result = "No") {
player.magic = "no"
if (player.intent_ good) {
MoveObject (lion_rw, forest)
}
else {
MoveObject (lion_ruw, forest)
}
}
}