Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Inventory in sugarcane

how do i set up and use an inventory in sugarcube? i have seen examples for harlowe but not sugarcube..

Comments

  • Sugarcane, as noted in the OP title, or SugarCube, as noted in the OP? They are not the same story format and the distinction is important, as the code you linked does not work properly in SugarCube.

    There's a SugarCube-compatible version on these forums if you need it.
  • thanks Mad i saw that after the fact.. im using sugarcane right now..
  • I've found a relatively easy way to code an Inventory in Sugarcube. Even though the questions already answered, I'll just tell you what I've figured out on my own anyways.

    At the top of every passage the player can access, put <<set $RoomID to InsertPassageTitleHere>>

    For instance, if the passage is titled Room1, then <<set $RoomID to "Room1">>

    Then, if you want to include the Inventory either in the StoryMenu passage or just in every passage, you can just a link to a passage called Inventory. Then have a link in the inventory passage that says $RoomID

    This will return you to the passage you were just in, without having to futz around with passage history or any of that confusing business. I personally like to make very large games and like this one-all solution of "return to the room you just came from"

    From there it's a simple matter of just assigning variables to items that go into the inventory and displaying them in the inventory passage. Like, You find an apple <<set $apple += 1>> and then Apples: <<print $apple>>.
  • At the top of every passage the player can access, put <<set $RoomID to InsertPassageTitleHere>>
    If you need to store the title of the current passage then you could use the built-in passage() function like so:
    <<set $RoomID to passage()>>
    
Sign In or Register to comment.