Issue with menu
J_J
06 Aug 2018, 06:35I know there is an issue in my programming, but I don't know where. It pops up an error message that says error compiling expression (unknown object or variable)
if (not Got(Athrin Book)) {
if (not GetBoolean(player, "drunk")) {
options = Split("1;Tell a story about your dad;Tell a story about Athri", ";")
ShowMenu ("\"What do you tell a story about?\"", options, false) {
switch (result) {
case (1) {
msg ("Bla bla")
}
case (Tell a story about your dad) {
msg ("bla bla2")
}
case (Tell a story about Athri) {
msg("bla bla bla 3")
}
}
}
}
else {
options = Split("Tell a story about Jantasha;Tell a story about Space Punk;Tell a story about Athri", ";")
ShowMenu ("\"What do you tell a story about?\"", options, false) {
switch (result) {
case (Tell a story about Jantasha) {
msg ("Bla bla bla.")
SetObjectFlagOn (player, "pinkwillfix")
}
case (Tell a story about Space Punk) {
msg ("Bla bla bla bad story 2")
options = Split("Tell a story about Jantasha;Continue story about Space Punk;Tell a story about Athri", ";")
ShowMenu ("\"What do you tell a story about?\"", options, false) {
switch (result) {
case (Tell a story about Jantasha) {
msg ("Bla bla")
SetObjectFlagOn (player, "pinkwillfix")
}
case (Continue story about Space Punk) {
msg ("Bla bla bla2")
SetObjectFlagOn (player, "pinkwillfix")
}
case (Tell a story about Athri) {
msg ("Bla bla bla)
SetObjectFlagOn (player, "pinkwillfix")
}
}
}
}
case (Tell a story about Athri.) {
msg ("Bla bla bla2")
SetObjectFlagOn (player, "pinkwillfix")
}
}
}
}
}
The weird thing is that when I changed the first example to just 1, it works. So, it is currently the only one that works. But if I use a single word or a phrase, it won't work. Am I making some sort of obvious error?
Thanks!
mrangel
06 Aug 2018, 08:20case (Tell a story about your dad) {
This checks whether the result
variable is a reference to the object whose name is Tell a story about your dad
.
If there is no such object, it tells you there's no such object.
Even if the object exists, this won't do anything. Because ShowMenu never sets the result
variable to an object.
I think you want:
case ("Tell a story about your dad") {
which checks if the result
variable is that sequence of letters.
J_J
06 Aug 2018, 10:04'-' thank you