Hey Shades,
Declaring an array, at least, is somewhat straightforward:
<<set $inventory = ['stone', 'hammer']>>
<<print $inventory>>
<<print $inventory[0]>>
<<set $inventory[0] = ['ice']>>
<<print $inventory>>
This will print the following:
stone,hammer
stone
ice,hammer
Where this gets dicey is trying to find specific items.
What I'm about to suggest is slightly voodoo, so I should also point out that I'm working on an engine that has direct <<pickup>> and <<putdown>> style macros. (If you're interested in that send me an email!) In the meantime...
<<set $carrying={}>>
<<set $carrying['axe'] = true>>
<<if $carrying['sword']>>
You are carrying a sword
<<endif>>
<<if $carrying['axe']>>
You are carrying an axe
<<endif>>
On Thursday, January 31, 2013 11:01:32 PM UTC-5, Shades wrote:
Hi there,
I'm new to both Twine and Google groups so forgive me in advance if I'm overlooking something obvious. I'm attempting to write a small gamebook style adventure using Twine and would like to use an array to keep track of some inventory items. Is this possible, and if so, how does one go about creating and accessing the array?
Thank you! :)