Twine Version: V2.3.5
Story Format: SugarCube 2.30.0
I’m trying to set up an array that I can add items to. I want it to appear in my sidebar so I created a “StoryMenu” passage and added a link to my “Inventory”.
In this “Inventory” passage, I’ve typed:
<<silently>><<set $bag =["notebook"]>><<endsilently>> You have <<print $bag.length>> item(s). You are carrying <<print $bag>>
In my story, there is a passage where you acquire an apple and add it to your inventory so the passage is written like this:
<<set $bag.push("apple")>> You got an apple.
[[You exit this area]]
When I play the story, the inventory shows up on the sidebar, and everything prints correctly. When I continue through the story and get to the passage where you get the apple, I get this error message:
Error: <<set>>: bad evaluation: undefined is not an object (evaluating 'State.variables.bag.push')
I’ve tried all the different resources and I still can’t seem to figure out what’s going wrong.
My secondary question (provided I can get this first part to work) is am I able to link an item in the array to a description passage? The notebook has several pages in it that I’d like the player to be able to reference throughout the game if needed.
Thanks in advance!