How do I make more than two choices in a text box using figures?

From OHRRPGCE-Wiki

Jump to: navigation, search

Currently, textboxs only support two choices, which trigger tags. Future versions of the OHRRPGCE will hopefully implement customisable menus which will be callable from textboxs, to bypass this limit and allowing a lot more actions. However if you want more than two choices and you want it now!(or you just want the user to input a number or letter for another reason) users get around this limitation by using a script that listens for keypresses and a textbox that asks the player to press a key.

For example, your textbox might say

What action do you take?

1. Work on gaming master piece
2. Work on wiki
3. Lay back and sip fruit juice

Your textbox might call the following script (change the number of choices an fill out the actions. It requires that you include scancode.hsi in your script file (which you should use when using keyispressed). If your script is not called from a textbox, add a showtextbox command at the beginning.

script, mychoicebox, begin
  variable (i, choice, number of choices)

  number of choices := 3  #you may change this anywhere up to 9

  suspend box advance  #force the player to input a number

  while (choice == 0) do (
    for (i, 0, number of choices -- 1) do (
      if (key is pressed (key:1 + i)) then (choice := i + 1)
    )
    wait
  )

  advance textbox  #the player has made their choice, get rid of the box

  resume box advance  #don't forget this!

  if (choice == 1) then (  #player pressed 1
    #show a textbox, set a tag, etc
  )

  if (choice == 2) then (  #player pressed 2
    #another choice
  )

  if (choice == 3) then (  #player pressed 3
    #yet more activity
  )
)
Personal tools