Howdy, Stranger!

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

How Do I Make An Inventory (from the Ground up) on Twine2/Sugarcube?

edited June 2016 in Help! with 2.0
Hi, I'm new to Twine & coding (like newnew, Really-LOST-N00B-new, I-know-nothing-new) and I've read the tutorial (when trying them out like, half of them worked? I think...) and have finally figured out how to add links to the Sidebar (entirely by accident, none of the tutorials mentioned that the Storymenu passage shouldn't be connected to the other passages in order to not put links on the current passage itself?)... Anyways, I have decided to learn one thing at a time and eventually have enough Twine/coding knowledge to cobble together something passable enough to qualify as a game someday.

Assume I have nothing, assume I just opened up a new, blank project thing and have stared into the depths of the Twine wiki's inventory tutorial, got frustrated when copy-pasting example code in order to test it have garnered nothing but error messages, have looked into other questions/forums and understand a little less than 50% of what the people were talking about giving advice for this problem/techniques(?) and therefore have only retained how to make links & how to add links or text to the sidebar(reliably), I have 2 questions:

- I have made a 'Inventory' passage thing on my sidebar, but how do I add things to it? Assume I only have 2 existing passages in this project, a first page (that I've left blank for my own learning purposes) and an 'Inventory' passage. Do i need to add other free-standing passages for some reason? Resources or something? Again, assume I know nothing, because, really lost.

- Second question: Is it possible to make a game where in the game the 'Inventory/Phone/whatever' link (located on the sidebar) doesn't appear/isn't available for use until a certain item is picked up/obtained? Like, grabbing a backpack off the floor or whatever? If so, how?

Any help/advice is appreciated, thanks.

Comments

  • edited June 2016
    You'd use <<if>> and <<set> statements.

    Eg

    <<set $backpack to true>> when picked up in the passage. Then in the inventory:

    <<if $backpack is true>>inventory passage<</if>>

    Remember to <<set $backpack to false>> in the StoryInit passage first.
  • Claretta wrote: »
    You'd use <<if>> and <<set> statements.

    Eg

    <<set $backpack to true>> when picked up in the passage. Then in the inventory:

    <<if $backpack is true>>inventory passage<</if>>

    Remember to <<set $backpack to false>> in the StoryInit passage first.


    I'm confused, I have these 5 passages:
    -StoryMenu: Inventory

    -Inventory: <<if $backpack is true>>inventory passage<</if>>

    -StoryInit (what is this? Is this the 1st passage where I wrote 'pick up the thing?' or is this a separate passage? Should I put another passage) which isn't connected to anything: <<set $backpack to false>>

    -Pass1: Pick up the Backpack (no links, no arrows/connections, IDK at this point)

    -inventory passage (this was created by the Inventory passage code you gave me, what is this? Is this the place where I put things in? Do I type them out here? Why is there another passage? Am I supposed to re-write all possible item combo's in another passage? Am I supposed to put the Inventory contents here? Or is 'inventory passage' just a substitute word thing that I was supposed to change & there isn't supposed to be another passage in the 1st place?)

    I just want a passage where I can click on a thing --> that thing I clicked gets added to Inventory (which has a link on the sidebar to check whenever player wants, I can't even begin to imagine how the f*ck I'm going to attempt to put conditional text like 'You are carrying nothing' in there when there is nothing, if I can't even make 3 lines of instructions come to life). I'm just confused about everything now, I've been trying for 6 hrs and I still don't get it, I'm sorry. Here's a picture of what I've got:

    <img src="https://twinery.org/forum/uploads/Uploader/f8/f94ea26cecfe5c2b3de1befda15c41.png"; />
  • Should I just delete everything and start over? Would it be too much to ask for step-by-step instructions including all the things that most coders wouldn't write out b/c they 'know it already'? Like making a new passage, or what the heck a macro is, or essentially assuming the I know less than nothing & am totally coding illiterate (knowing how to make a link doesn't count)?
  • edited June 2016
    You should start by reading the documentation for sugarcube if you're getting confused by those instructions.

    http://www.motoslave.net/sugarcube/2/

    Making an inventory, and a game that needs an inventory, is above your current knowledge level, so I would work through the basics first. There's little value in getting a step by step guide to making an inventory without this basic knowledge, since any game that uses an inventory will be way too complex to finish without knowing your way around SugarCube.

    You might make an inventory, but then you'll find bugs that need fixing, and without knowledge, you won't be able to do it. And an inventory implies choice, exploration and puzzle solving, and you need to understand <<set>> and <<if>> macros to do that.

    This is why my instructions were as basic as they were - making this kind of thing needs prerequisite understanding.

  • edited June 2016
    The main issue with your request is your level of experience with creating Twine based stories, and this is why Claretta suggested you start with doing the different tutorials (even the ones designed for other Story Formats) so that you could increase your experience.

    I would start by reading the Twine 2 Guide found on the Twine Wiki, this will help you become more familiar with the concepts and functionality of the Twine 2 application.

    Next I would view the Screencasts by Dan Cox and following along with the instructions by pausing the video and actually implementing each of the steps he explains within your own story(ies). Even though they use the Harlowe story format they will help you become more experienced with with using the Twine 2 application and with concepts like macros, variables, conditional statements and the such.

    Next I would look at Anna Anthropy's introduction in the Twine 1 section of the wiki, even though it was created for the Twine 1 application you can following alone with her instructions using the Twine 2 application.
    The code she uses in her tutorial is very similar to that used by SugarCube so it should help increase your experience and make using Twine 2's SugarCube easier.

    By now you should have knowledge of how to use variables to track the actions of the Reader (like picking up an item) and how to use an if macro to conditionally show something within your story.

    You should also be more ready to learn about advanced topics like implementing a inventory that supports picking things up, dropping things, and displaying a list of what you are carrying.

    notes:
    1. There are many ways to implement an Inventory system, depending on what sort of features you want it have. The more features the more complex the solution becomes to implement.
    eg.
    1a. Can only the main character carry things or can other NPC's do so as well?
    1b. If an item is dropped does it disappear from the game or in the current location.
    1c. Is it possible to carry more that one of each item.
    1d. Is there a limit on how many items can be carried? (by number, by weight, by size)

    2. The code contain on the Add an Inventory System wiki page is Javascript which in Twine 2 goes within your Story Javascript area, and not within a standard passage.

    3. Creating a step-by-step instruction guild to the level you have asked for will take many hours (maybe days) to do so, so you are asking someone else to undertake a fair amount of time and effort on your behalf. You showing that you are willing to put your time and effort in to learning more about how to use Twine and it's story formats may help to convince them to spend their time and effort.
  • To explain specifically.

    StoryInit is the passage where you initialise all variables in the story. This is explained in the SugarCube manual.

    You said you wanted a player to pick up a backpack in the story. Well when they choose the option to pick it up, you'd tell the game that the player now has a backpack with the variable setting <<set $backpack to true>>.

    Then you'd want an item listing to appear in the StoryMenu inventory thing you're using, so you'd write <<if $backpack is true>>Has backpack<</if>>. That writes "Has backpack" in the StoryMenu section of your game when the <<set $backpack to true>> variable is triggered.
  • Oh... Okay, thanks guys.
Sign In or Register to comment.