Adding Menu Functionality to a Gamebook

fogmike
24 Jun 2014, 15:45
Hi there, I'd like to add menu functionality into gamebook mode if possible. I'm already using this piece of code that was helpfully provided to me for the ShowMenu function, which is slightly modified since I don't want it to display the numbers:
 <function name="ShowMenu" parameters="caption, options, allowCancel, callback"><![CDATA[
outputsection = StartNewOutputSection()
msg (caption)
count = 0
game.menuoptionskeys = NewStringList()
foreach (option, options) {
list add (game.menuoptionskeys, option)
count = count + 1
if (TypeOf(options) = "stringlist") {
optionText = option
}
else {
optionText = StringDictionaryItem(options, option)
}
msg ("<a class=\"cmdlink\" style=\"" + GetCurrentLinkTextFormat() + "\" onclick=\"ASLEvent('ShowMenuResponse','" + option + "')\">" + optionText + "</a>")
}
EndOutputSection (outputsection)
game.menuoptions = options
game.menuallowcancel = allowCancel
game.menucallback = callback
game.menuoutputsection = outputsection
]]></function>

However, I'm missing the helper functions (the one it complains at is ShowMenuResponse), and can't seem to open the Core file in Quest like I thought you could to find them myself to copy over into my gamebook file. Anyone able to help?

jaynabonne
24 Jun 2014, 19:26
Here is ShowMenuResponse and a function it calls called ClearMenu. They live in Core.aslx.

  <function name="ShowMenuResponse" parameters="option">
if (game.menucallback = null) {
error ("Unexpected menu response")
}
else {
parameters = NewStringDictionary()
dictionary add (parameters, "result", option)
script = game.menucallback
ClearMenu
invoke (script, parameters)
}
</function>

<function name="ClearMenu">
HideOutputSection(game.menuoutputsection)
game.menuoutputsection = null
game.menuoptions = null
game.menucallback = null
</function>

fogmike
24 Jun 2014, 20:06
Thank you very much! That's exactly what I needed. I thought you could open Core.aslx in Quest, but mine threw an error when I tried to.

jaynabonne
24 Jun 2014, 20:27
You can't open it in Quest as it's a library file instead of a game file. But you can open it in any text editor (e.g. Notepad or Notepad++).