How do you create a list for players to see when they click on something they can interact with?
Taru
25 Jan 2019, 14:47I'm making a gamebook and am a little stuck on this one thing.

Io
25 Jan 2019, 15:55This sounds like you're looking for Menu.
What Menu does is it takes a string list - maybe it works with other types but I've never tried - and makes a list of hyperlinks for the player to click on/enter. It then creates a variable called 'result' equal to what you typed, for which you can use the Switch code. So for example, you can have a stringlist:
StringList = "Yes", "No"
Pardon my psuedocode.
And then, you call the menu:
Show Menu taking from the list called StringList.
After Player Picks an Option:
Switch(based on result)
case("Yes"): print("You picked yes!")
case("No"): print("You picked no.")
Hope this helps.
Taru
25 Jan 2019, 16:52I'm not exactly sure where to put that... Like I said, I'm making my game using the gamebook rather than a text adventure.
I'm trying to get something like this https://gyazo.com/64c79253e27ff5a86930d0f120650731
mrangel
25 Jan 2019, 17:27I'm not exactly sure where to put that... Like I said, I'm making my game using the gamebook rather than a text adventure.
You'd put the script at the point where you want the menu to be displayed (presumably a script or script-and-text page).
In code view it would look more like:
ShowMenu ("What would you like to do?", Split("Whistle;Tumble;Fart"), false) {
switch (result) {
case ("Whistle") {
MovePlayer (page to go to if the player whistles)
}
case ("Tumble") {
MovePlayer (page to go to if the player tumbles)
}
case ("Fart") {
MovePlayer (you get the idea by now)
}
}
}
(I don't know what it looks like in the GUI script editor, but you can enter the code in code-view and then see for yourself)
That's a verb list. It's only available in text adventures.
But… it might be possible to make the javascript work.
Warning: I haven't tested this, I've only skim-read some of the Quest source. And I think it might work, if you just want to have one or two command links
msg ("<a class=\"cmdlink elementmenu\" data-elementid=\"some_objectname\">Click here!</a>")
JS.eval("$('#divOutput a.elementmenu').last().data('ElementId', 'some_objectname').data('ElementName', 'some_objectname');")
data = NewStringDictionary()
dictionary add (data, "some_objectname", "Option1/Option2")
JS.updateObjectLinks (data)
This should create a link that says "Click here!". When the player clicks it, it should pop up a little menu giving them the choice of "Option1" or "Option2".
When the player clicks on one of those options, it will look for a function called "HandleCommand". I've had a quick look through the Quest source code, and I think this should still work in gamebook mode. But you will need to write your own HandleCommand function to handle those responses. It will receive 2 parameters; the first one will be a string which is "option1 some_objectname"
or similar, indicating which link was clicked, and which option was chosen.
I don't think the objectname has to be an actual object in this case; it's the text-adventure version of the HandleCommand function that deals with that. So you can just use the objectname as a way for your function to track which link the player clicked on.
Note that where the line dictionary add (data, "some_objectname", "Option1/Option2")
is - you can repeat this line using the names of previously created links to change the options that come from clicking them. Any that aren't listed will have the links disabled.
Taru
25 Jan 2019, 18:06Oh, thank you for that. Works great~