Howdy, Stranger!

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

How do I make items?

Yeah so brand new.

I would like to have an inventory and for different choices to become available depending on what item you have. Like say you get a choice between picking up a dagger or a cake, later on in the game you encounter an event which will change depending on what item you picked up earlier.

Comments

  • You need to state which story format you are using, as answers can be different for each one. I am going to assume you are using the default which in Twine 1 is Sugarcane.

    The Twine 1 Wiki has a section on Variables. You could use a variable to track which item was picked up and then check the value of the variable later to determine what should be done.

    There are many ways to use variables, from the simple to the complex, the following example uses a single variable to track which item the Reader is currently holding. If they are holding nothing then the variable is empty, otherwise it contains the name of the item:
    Assign a empty value to the variable when the Reader is holding nothing.
    <<set $holding to "">>
    
    If the Reader picked up the dagger then change the variable to indicate this.
    <<set $holding to "dagger">>
    
    If the Reader picked up the cake then change the variable to indicate this.
    <<set $holding to "cake">>
    
    ... later on you could use an <<if>> macro to check what item the Reader is holding:
    <<if $holding is "dagger">>You are holding a dagger
    <<else if $holding is "cake">>You are holding a cake
    <<else>>You are not holding anything
    <<endif>>
    
  • great I'l try it
  • edited November 2015
    I'm afraid I don't know anything about story format as I just went with the default

    okay I tried <<set $holding to "dagger">> and get the error message "Twine 2 macros use a different syntax to Twine 1 macros."
  • You posted your question in the Twine 1 Category so the answer I gave you was about Twine 1, that error message indicates that you are using Twine 2.

    The default story format of Twine 2 is Harlowe and that perticular story format uses a different macro syntax than the Twine 1 story formats. The Twine 1 wiki links I gave will be less useful for Harlowe, information about it can be found in it's documentation and project overview, and you should also read the Twine 2 guide.

    The Harlowe equivalent of the examples I gave are:
    Assign a empty value to the variable when the Reader is holding nothing.
    (set: $holding to "")
    
    If the Reader picked up the dagger then change the variable to indicate this.
    (set: $holding to "dagger")
    
    If the Reader picked up the cake then change the variable to indicate this.
    (set: $holding to "cake")
    
    ... and:
    (if: $holding is "dagger")[You are holding a dagger]
    (elseif: $holding is "cake")[You are holding a cake]
    (else:)[You are not holding anything]
    
    ... note the different macro syntax, Harlowe uses a single open parentheses at the start of the macro, a full colon after the macro name and a single close parentheses at the end of the macro.
    (macroname:)
    
    ... some macros like (if:) have an associated hook which encloses the content the macro is applied to, a hook starts with a single open square bracket and ends with a single close square bracket.
    [The contents of a hook]
    
  • I was under the impression I was using twine 1. I just went online and googled game makes, twine came up and I went to the website. I checked out twine 2 but it looked like an online one so I didn't want to use that and stuck with twine 1.
  • You're not (using Twine 1). If you're seeing that particular error (i.e. "Twine 2 macros use a different syntax to Twine 1 macros."), then you're using the Harlowe story format—which only exists for Twine 2. Twine 2 has both an online version and an offline/executable version, you must be using the latter.

    That the error message is misleading doesn't help (it would be better as "Harlowe macros use a different syntax to Twine 1 macros.").
  • That the error message is misleading doesn't help (it would be better as "Harlowe macros use a different syntax to Twine 1 macros.").
    I agree.
  • Apologies for the unfortunately parochial wording of that one. For that matter, there are still a few places in Harlowe's documentation that expose internal terminology (specifically, references to "TwineScript", referring to HL's macro syntax as distinct from its markup syntax).
Sign In or Register to comment.