trouble with show menu and switch

scarletrose
08 Jun 2013, 16:05
Hi, I'm trying to make my first game with quest and I'm having a problem creating a tutorial for some features of the game.
I made a function called tutorial that you can call from anywhere in the game. I placed a list of topics in a menu list, offered the menu to the player and tried to put it in a switch to respond to every case, that's where things seems to go wrong.

Error running script: Error compiling expression 'souls': Unknown object or variable 'souls'

I have tried to put a message with the + result before the switch and the choice is displayed correctly, still I cannot use that in a switch to give the appropriate answer to each case

here is the code of the function
  <function name="tutorial">
menulist = NewStringList()
list add (menulist, "souls")
list add (menulist, "brimstones")
list add (menulist, "prestige")
list add (menulist, "surface")
list add (menulist, "improving")
list add (menulist, "thrall")
list add (menulist, "end")
ShowMenu ("choose a topic", menulist, false) {
ClearScreen
switch (result) {
case (souls) {
msg ("bla bla bla souls bla bla")
tutorial
}
}
}
</function>


what am i doing wrong?

also, there is a way to show the description of the room you are in as if you just entered? I would like to clean the screen and rewrite it when the tutorial ends

Liam315
08 Jun 2013, 16:36
As your menu options are strings, you need to enter your cases within "quotation marks."

    list add (menulist, "end")
ShowMenu ("choose a topic", menulist, false) {
ClearScreen
switch (result) {
case ("souls") {
msg ("bla bla bla souls bla bla")


As for showing the room description again, it depends on whether or not you use any scripts for room descriptions. If you only have text for all rooms, it's as simple as:

msg (game.pov.parent.description)


If you have scripts for some room descriptions, then you need to use an if script to distinguish between the two.


if (HasString(game.pov.parent,"description")) {
msg (game.pov.parent.description)
}
else {
do (game.pov.parent,"description")
}


There's probably a function already built in that someone might know about, but if you wanted to write the script yourself that's how you could achieve it.

jaynabonne
08 Jun 2013, 17:06
To show the room description, call ShowRoomDescriptionI(). :)