How to present list of inventory items as a menu?

I would like to give the player a Menu of options, showing only their current inventory items. I'm familiar with using string lists to show static options, but not something dynamic where the player could hold anything.

The scenario is to put the player in a do-or-die situation but not make them guess the verb or have a time limit.

So suppose there's an object on fire, and the game prompts "Quick! Use one of your items!" And because the player is holding "Banana", "Chewing gum", and "Fire Extinguisher", the game displays:

  1. Banana
  2. Chewing gum
  3. Fire Extinguisher

I've read the documentation on string lists, but I didn't see anything about taking from inventory.


there's the 'Scope' Functions which generate Objectlists for you, which can then be sued by the built-in 'show menu / ShowMenu' Functions:

http://docs.textadventures.co.uk/quest/scopes.html
http://docs.textadventures.co.uk/quest/functions/index_allfunctions.html (also can be found here, but the above link separating them out is very nice for us, lol)

and specifically for what you want:

http://docs.textadventures.co.uk/quest/functions/corelibrary/scopeinventory.html

a quick-brief-simple-skeleton example:

http://docs.textadventures.co.uk/quest/functions/corelibrary/displaylist.html

inventory_objectlist_variable = ScopeInventory ()

show menu ("Item?", inventory_objectlist_variable, false) {
  // the 'show menu / ShowMenu / ask / Ask / get input' Functions, stores your typed-in or menu-selected input into the built-in 'result' String Variable)
  DisplayList (inventory_objectlist_variable, true) // or: DisplayList (inventory_objectlist_variable, 1) // or: DisplayList (inventory_objectlist_variable, false) // or: DisplayList (inventory_objectlist_variable, 0)
  // scripting
}

// or:

inventory_objectlist_variable = ScopeInventory ()

foreach (item_object_variable, inventory_objectlist_variable) {
  // scripting
}

if you want to manually create your own displayment (instead of using the built-in 'DisplayList()' Function):

(by manually creating your own menu displayment, you can do lots of cool stuff, but the below doesn't show any of that cool stuff)

inventory_objectlist_variable = ScopeInventory ()

numbering_integer_variable = 0
foreach (item_object_variable, inventory_objectlist_variable) {
  numbering_integer_variable = numbering_integer_variable + 1
  msg (numbering_integer_variable + ". " + item_object_variable)
}

// it'll display:

  1. BLAH_1
  2. BLAH_2
  3. BLAH_3
  4. ETC_ETC_ETC

Thanks for the quick answer! I got it working exactly how I want it.


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums