Created
April 27, 2025 00:39
-
-
Save kyrathasoft/a95249a6cb28dabc638eac6d0022ba35 to your computer and use it in GitHub Desktop.
Here is code for a YourInventory passage in Sugarcube
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* the contents for your inventory passage (remember, it needs a 'noreturn' tag so it can use the ALR fn) */ | |
<<nobr>> | |
<<if $inventory eq undefined>> | |
Inventory is undefined | |
<<else>> | |
<<InventoryItemCount>> | |
<<InventoryItemListing>> | |
<</if>> | |
<</nobr>> | |
/* below is the InventoryItemCount widget */ | |
<<widget "InventoryItemCount">> | |
/* This widget prints a message to the browser window telling the player how many items are in her inventory. */ | |
<<nobr>>Your inventory contains: | |
<<if $inventory.length lt 1>> | |
nothing | |
<<elseif $inventory.length eq 1>> | |
1 item | |
<<else>> | |
<<= $inventory.length>> items | |
<</if>> | |
<</nobr>><</widget>> | |
/* and here is the InventoryItemListing widget */ | |
<<widget "InventoryItemListing">> | |
/* This widget prints the inventory's items, one per line */ | |
<<nobr>><<if $inventory.length eq 1>> | |
$inventory[0] | |
<</if>> | |
<<if $inventory.length gt 1>> | |
<<= $inventory.join(`<br>`)>><br> | |
<</if>> | |
<</nobr>><</widget>> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment