This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
twine2:add_an_inventory_system [2015/04/08 18:11] nicolem |
twine2:add_an_inventory_system [2017/10/09 20:39] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
=====Add an Inventory System===== | =====Add an Inventory System===== | ||
- | These macros will work as-is in SugarCube for Twine 1.x or Twine 2.x. | + | These macros will work as-is in **SugarCube** for Twine 1.x or Twine 2.x. [[http://strugglingwithtwine.blogspot.ca/2014/03/handling-inventory.html|Original code by F2Andy]]. |
(If you're using another story format in Twine 1.x, you have to replace every instance of 'state.active.variables' in the the below code with 'state.history[0].variables'.) | (If you're using another story format in Twine 1.x, you have to replace every instance of 'state.active.variables' in the the below code with 'state.history[0].variables'.) | ||
- | They will require significant modification to work in Harlowe or Snowman on Twine 2.x. | + | They will require significant modification to work in **Harlowe** or **Snowman** on Twine 2.x. |
<code>// Begin Inventory Macros | <code>// Begin Inventory Macros | ||
Line 18: | Line 18: | ||
// 2. In a passage, check if there's an item in the inventory.. | // 2. In a passage, check if there's an item in the inventory.. | ||
// ...if so, give the user a choice to progress to a new passage: | // ...if so, give the user a choice to progress to a new passage: | ||
- | // <<if $inventory.indexOf("The Golden Key") == -1>>[[Unlock the door.]]<<endif>> | + | // <<if $inventory.indexOf("The Golden Key") != -1>>[[Unlock the door.]]<<endif>> |
// | // | ||
// 3. To add an "Inventory" link in your sidebar menu, create a passage named "StoryMenu". | // 3. To add an "Inventory" link in your sidebar menu, create a passage named "StoryMenu". |