:: StoryTitle Arrays in SugarCube :: StoryInit /% it is always a good idea to initialize your variables, but with arrays it is particularly important %/ <> <> <> :: PassageHeader You are currently carrying: /% if the inventory contains nothing, show "nothing" %/\ <>\ nothing. <>\ /% the Array#join() method combines all array elements into a single string, with each element separated by the argument given %/\ <<= $inventory.join(', ')>>. <> ----- :: Start /% we use the Array#push() method to add new items to our inventory array %/\ You find yourself inside a small room. In the corner, you see a sword, and decide to pick it up. <>\ [[Continue|hallway]] :: hallway You see a chest here in the hallway. \ <>\ Do you want to open it? <> /% concatenating the arrays and setting the result to $inventory moves all the items from the $chest array into the $inventory array %/ <> <> <> <>\ It's open, and there's nothing inside. <> [[Move on.|dart trap]] :: chest You open the chest and find <<= $chest.join(' and ')>>. [[Okay.|previous()]] :: dart trap Several darts shoot out of a wall at you! /% we can check to see if the player has a given item with Array#includes() %/ <>\ Luckily, your shield will protect you. <>\ With no way to defend yourself, you die. <>