Can Gamebooks Use ShowMenu?

Erinneen
30 Apr 2018, 02:55

I keep looking for answers, but all I find on the forums is "you should use Text Adventures". However, I hate them way too much. The design feels way too clunky and trying to write stories with it is as easy as trying to do surgery on a bull for the first time. I'm assuming that it doesn't, as I have tried multiple times to get errors, even though I have succeeded doing the exact same in a Text Adventure. I just want confirmation if I am right in my assumptions.


XanMag
30 Apr 2018, 03:00

I never mess with gamebooks, but Pixie has a nice thread here that might be helpful if you are interested in having some advanced functionality of a text adventure, with the limited dynamics of the gamebook.

https://textadventures.co.uk/forum/samples/topic/4772/how-to-make-a-text-adventure-look-like-a-gamebook

Best of luck.

And, surgery on a bull, as long as it is sedated isn't all that tough if you have ever had any medical training (or have been in XanMag's Zoology class - it's just a big frog).


K.V.
30 Apr 2018, 04:17

You can do it like this if you are using the desktop version of Quest:

You need to add this code to your game in Full Code View. Add it just before the last line, which is </asl>.

  <function name="ShowMenu" parameters="caption, options, allowCancel, callback"><![CDATA[
    outputsection = StartNewOutputSection()
    msg (caption)
    count = 0
    game.menuoptionskeys = NewStringList()
    foreach (option, options) {
      count = count + 1
      if (TypeOf(options) = "stringdictionary") {
        optionText = StringDictionaryItem(options, option)
        optiontag = option
        style = GetCurrentLinkTextFormat()
        list add (game.menuoptionskeys, option)
      }
      else if (TypeOf(option) = "string") {
        optionText = option
        optiontag = option
        style = GetCurrentLinkTextFormat()
        list add (game.menuoptionskeys, option)
      }
      else if (TypeOf(option) = "object") {
        optionText = GetDisplayAlias(option)
        optiontag = option.name
        colour = ""
        if (HasString(option, "linkcolour") and GetUIOption("UseGameColours") = "true") {
          colour = option.linkcolour
        }
        else {
          colour = GetLinkTextColour()
        }
        style = GetCurrentTextFormat(colour)
        list add (game.menuoptionskeys, option.name)
      }
      else {
        error ("ShowMenu cannot handle a " + TypeOf(option))
      }
      msg (count + ": <a class=\"cmdlink\" style=\"" + style + "\" onclick=\"ASLEvent('ShowMenuResponse','" + EscapeQuotes(optiontag) + "')\">" + optionText + "</a>")
    }
    EndOutputSection (outputsection)
    game.menuoptions = options
    game.menuallowcancel = allowCancel
    game.menucallback = callback
    game.menuoutputsection = outputsection
  ]]></function>
  <function name="ShowMenuResponse" parameters="option">
    if (game.menucallback = null) {
      error ("Unexpected menu response")
    }
    else {
      parameters = NewStringDictionary()
      dictionary add (parameters, "result", UnescapeQuotes(option))
      script = game.menucallback
      ClearMenu
      invoke (script, parameters)
    }
  </function>
  <function name="EscapeQuotes" parameters="s" type="string">
    s = Replace(s, "\"", "@@@doublequote@@@")
    s = Replace(s, "\'", "@@@singlequote@@@")
    return (s)
  </function>
  <function name="UnescapeQuotes" parameters="s" type="string">
    s = Replace(s, "@@@doublequote@@@", "\"")
    s = Replace(s, "@@@singlequote@@@", "\'")
    return (s)
  </function>
  <function name="ClearMenu">
    HideOutputSection (game.menuoutputsection)
    game.menuoutputsection = null
    game.menuoptions = null
    game.menucallback = null
  </function>


jmnevil54
30 Apr 2018, 13:37

From what I've seen, no.

Edit: Oh. Apparently KV did it.