Menu Choices Not Always Working ??

I am building the startup menus for a new story / game. The following menu and all of its options work just fine

ShowMenu ("Info", options, true) {
  switch (result) {
    case ("Help") {
      MoveObject (player, Commands)
    }
    case ("I Got This") {
      MoveObjectHere (player)
    }
    case ("Synopsis") {
      MoveObject (player, Premise)
    }
  }
}

When I run the following menu only the first option works, the second option returns no response

ShowMenu ("<br/>What is your gender?<br/>", gender, false) {
  switch (result) {
    case ("Male") {
      SetObjectFlagOn (player, "Sex_1")
    }
    case ("Female") {
      SetObjectFlagOn (player, "Sex_2")
    }
  }

I'm not sure what the difference is. The program added the "" on the second menu options but it did not for the first menu options. Any help figuring this out will be much appreciated.


Are the options in the gender variable exactly "Male" and "Female"?

Usually when one option doesn't work, it's because they don't exactly match. Could be a capital letter, a typo in the option, or an extra space.


Yep, they were identical. I looked at it a thousand times for any minute error in syntax, spelling, order, etc. I also kept trying various combinations or sets of object attributes and variables. Ultimately what ended up working was using the open / closed object attribute as shown here.

ShowMenu ("<br/>What is your gender?<br/>", Split("Male;Female<br/>", ";"), false) {
  switch (result) {
    case ("Male") {
      HelperOpenObject (player)
    }
    case ("Female") {
      HelperCloseObject (player)
    }
  }

Yep, they were identical. I looked at it a thousand times for any minute error in syntax, spelling, order, etc.

You mean the 11 characters Female<br/> and the 6 characters Female are the exact same set of characters?

The second clause still doesn't run; but it makes no difference because the player object is already closed.


Thanks mrangel, I didn't realize the br/ became part of the key. All is working fine now.


Having problems with menus again. First problem with code example - All options work except "I Got This" only works if the numeral key is pressed, clicking the hyper link for option 3 gives no response. (In Quest the options list themselves with Synopsis as the third in code but second in game - this doesn't appear to alter the functionality of Synopsis at all, only I Got This. I have re-ordered them in code and they simply reset themselves to this order)

options = Split("Help;Synopsis;I Got This<br/>", ";")
ShowMenu ("Info", options, true) {
  switch (result) {
    case ("Help") {
      MoveObject (player, Commands)
    }
    case ("I Got This<br/>") {
      MoveObject (player, Fairfax)
    }
    case ("Synopsis") {
      MoveObject (player, Premise)
    }
  }
}

Second problem with code example - All options work as intended with the same issue as above. Option 4 in this list will only work if the numerical key for that option is pressed.

wait {
  dudeoptions1 = Split("And you got a helluva knack for assuming people need saving.;South of here, a place called nowhere.;You guys aint much on introductions are you?;This dump got a name?<br/>", ";")
  ShowMenu ("", dudeoptions1, false) {
    switch (result) {
      case ("And you got a helluva knack for assuming people need saving.") {
        msg ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
      }
      case ("South of here, a place called nowhere.") {
        msg ("bbbbbbbbbbbbbbbbbbbbbbbbbbbbb")
      }
      case ("You guys aint much on introductions are you?") {
        msg ("ccccccccccccccccccccccccccccccccc")
      }
      case ("This dump got a name?<br/>") {
        msg ("ddddddddddddddddddddddddddd")
      }
    }
  }
}

Thank in advance for any help with this


I'd guess that having a <br/> in the option gets mangled somewhere in the process of being sent from Quest to the frontend and back.

Hmm… I just tried a copy of the third option, and it looks like the value seen in the javascript is I Got This<br/></a> for some reason. I'd assume it is trying to unmangle the string going the other way as well, which is stopping Quest from giving a sensible error message.

If you really want to have a line break as part of a menu option, you would probably want to use a dictionary for the options instead.

For example:

options = NewStringDictionary()
dictionary add (options, "option1", "Help")
dictionary add (options, "option2", "Synopsis")
dictionary add (options, "option3", "I Got This<br/>")
ShowMenu ("Info", options, true) {
  switch (result) {
    case ("option1") {
      MoveObject (player, Commands)
    }
    case ("option3") {
      MoveObject (player, Fairfax)
    }
    case ("option2") {
      MoveObject (player, Premise)
    }
  }
}

In this case, the dictionary key is the part that the case statement matches, and the value is what is shown to the player. You can make them the same if you want; I just used option1 so it's clearer to see how the code works.

However, I don't really think you should need this. I suspect that you really want to display a newline after the menu, rather than as part of the last option. In which case, why not just do that?

ShowMenu ("Info", Split("Help;Synopsis;I Got This"), true) {
  switch (result) {
    case ("Help") {
      MoveObject (player, Commands)
    }
    case ("I Got This") {
      MoveObject (player, Fairfax)
    }
    case ("Synopsis") {
      MoveObject (player, Premise)
    }
  }
}
msg ("")

mrangel - Thanks again for your help with this. All is working well now.


Log in to post a reply.

Support

Forums