Howdy, Stranger!

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

How to do choice? Anyone help please?

edited June 2015 in Help! with 2.0
Hi guys I am new to twine, and i love using twine 2. Love the interface and other few bits. However I noticed there is hardly anything out there on Twine 2 Harlowe . To help me start a story for example.

I want to do a few things in my story, I need choice, which I cant seem to find online as it says the syntax is from twine one. I want to buy items from my shop so for example.

<<choice "Drink">>
<<choice "Bar of Chocolate">>

This does not work in twine 2, and i cant find any help online or on this forum on how to do choice.

Also when i pick a choice i want it to be greyed out. So it cannot be picked. And how would u get a message from it also? so instead of a link to another page, I would want a message that says: You buyed 1 drink. Which comes after say the choice drink or replaces it when you click it?

Thanks.

Comments

  • edited June 2015
    These are setter links. You use them to set variables when the player clicks a link
    (link: "text on page")[(set: $variable to "value")(goto: "page name")]
    
    (link: "text on page")[(set: $variable to it + 1)(goto: "page name")]
    

    This is a normal link. It just gets you to another page
    (link: "text on page")[(goto: "page name")]
    

    For dissapearing links, you can set "if" conditios using variables.
  • Rafe wrote: »
    This is a normal link. It just gets you to another page
    (link: "text on page")[(goto: "page name")]
    

    That is a macro based link, a (normal?) markup link looks like the following:
    [[Text on page->Passage Name]]
    
  • greyelf wrote: »
    That is a macro based link, a (normal?) markup link looks like the following:
    [[Text on page->Passage Name]]
    

    That, or
    [[Text on page|Passage Name]]
    
    I was just refering to "normal" links as the ones that do not set any variable on click.
  • Thanks for the reply guys but, sorry I might be a real newbie at this I don't know. but I still don't understand. I did do those 2 lines to see what happens.

    (link: "text on page")[(set: $variable to "value")(goto: "page name")]
    (link: "text on page")[(set: $variable to it + 1)(goto: "page name")]

    Yes the value 0 comes on both pages when you go to them. However it dosnt add up? They stay at 0, on both pages. I put this $value on both goto pages. Just trying to understand this, but its confusing me. Could u give me a further explanation with a simple example with anything?


    Also for the If statement, how would i go about making this? for example

    shop
    park
    train station

    When you click shop, park and train station disappear or are greyed out. Also when you click shop it does not take you to another page, it replaces the word shop with more words.

    For example, when you click Shop it disspears and the sentence "you went to the shop" comes up. Im guessing a replace code would be needed? Could you give an example?

    Thanks, really sorry im not very good at this trying to learn.
  • You have to set a value for the variable first.

    This is an example on how to set several variables at once, and different kinds of ways to set them.
    (set: $variable1 to "word", $variable2 to 5, $variable3 to $variable2 + 4, $variable5 to it + 1)
    

    Remember to set them in a passage that is only visited once, or they will reset every time you visit the passage where they are set.
  • A (set:) macro within the container associated with a (link:) macro only gets executed after the link is clicked, until the link is clicked the $variable's value is unchanged.

    Take the following example:
    (set: $variable to "here")
    
    (link: "text on page")[(set: $variable to "there")]
    
    In this case $variable will equal "here" until the "text on page" link is clicked and then $variable will equal "there". In general it is a good idea to initialize all your $variables at the start of your story and not rely on them defaulting to zero.

    If I added your example to my main passage:
    (link: "text on page")[(set: $variable to "value")(goto: "page name")]
    (link: "text on page")[(set: $variable to it + 1)(goto: "page name")]
    
    .. and I created a second passage named page name containing the following:
    Variable equals: $variable
    
    .. and I then clicked on each of the two links in the order that they appeared, the second passage showed the following two outputs:
    Variable equals: value

    Variable equals: 1

    dabest1259 wrote: »
    Also for the If statement, how would i go about making this? for example
    You can do what you want using a tagged hook, like the following:
    Where would you like to go?
    
    |opts>[(link: "shop")[(replace: ?opts)[you went to the shop]]
    (link: "park")[(replace: ?opts)[you went to the park]]
    (link: "train station")[(replace: ?opts)[you went to the train station]]]
    
    ... the above opts tagged hook reformatted to make it easier to read:
    |opts>[
    	(link: "shop")[
    		(replace: ?opts)[you went to the shop]
    	]
    	(link: "park")[
    		(replace: ?opts)[you went to the park]
    	]
    	(link: "train station")[
    		(replace: ?opts)[you went to the train station]
    	]
    ]
    
  • Thanks Greywolf.

    I understood both better now. I checked out some other stuff you said about live and timing, which has helped me even more you very knowledgeable.

    Just one last thing.

    It changes the answer, but how do i continue? To the next passage? because it has to be in the same passage right? somthing like this? Didn't work.

    |opts>[(link: "shop")[(replace: ?opts)[you went to the shop]]
    Continue
    (link: "park")[(replace: ?opts)[you went to the park]]
    (link: "train station")[(replace: ?opts)[you went to the train station]]]

    So basically how do i keep going because it just stops there.
  • Anything you want to happen/appear after the Reader clicks on one of your links needs to be within the container associated with the (link:) macro.

    A simple way to show a Continue markup link after the click is to add it to each of the three (replace:) macros:
    Where would you like to go?
    
    |opts>[(link: "shop")[(replace: ?opts)[you went to the shop
    
    [[Continue]]]]
    (link: "park")[(replace: ?opts)[you went to the park
    
    [[Continue]]]]
    (link: "train station")[(replace: ?opts)[you went to the train station
    
    [[Continue]]]]]
    
    note: be careful not to leave out any of the open/close square-brackets, and I am using line-breaks to format the text within the (replace:) macros.
Sign In or Register to comment.