Howdy, Stranger!

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

can i use goto combined with different ifs?

hi there.
i am really new here and english is not my first language, so please excuse expression mistakes.

at the moment i attend a game design class at my university and we have to built quite simple games with twine2.0

so now i have the following problem:
i want to build a simple structure where you have to make 5 decisions (one after the other). each is either a or b. for each time you chose a the $var gets plus1, if you chose b, it remains constant.
so after 5 decisions the $var can be everything from 0 till 5.
now i need something that does the following:
if $var is 0 it should lead you (goto) to result1
if $var is 1, 2, 3 or 4 it should lead you to result2
and if $var is 5 it should lead you to result3

i tried different combinations of (if:) and (goto:) versions, but it just does not work.

so is there anyone who has a good idea that might help me?

thanks a lot!

Comments

  • edited May 2015
    Sorry. Next post...
  • edited May 2015
    That's totally possible by doing something like this:
    (if $var is 0)
    [
    (link-goto: "Link", "result1")
    ] (elseif: $var > 0 and $var < 5)
    [
    (link-goto: "Link", "result2")
    ] (else:)
    [
    (link-goto: "Link", "result3")
    ]
    
    Tim
  • edited May 2015
    hi tim,

    thanks. i just tried out your suggestion, but it just doesn't work. and i don't really understand why.
    that is what twine shows me:

    http://twinery.org/forum/uploads/Uploader/31/fee4cc7ff1eac9ca26d347a1d3bd88.jpg

    do you or anyone else understand what's wrong?

    thanks for all your help!
  • edited May 2015
    The first line is missing a colon after the if, it should be:
    (if: $var is 0)
    

    The Harlowe story format documentation is here
  • edited May 2015
    Oops! Many apologies.
  • well that i already found out before and changed it, but it still did not work...
    the thing is that different "if"s work with simple text to be shown, e.g. (if: $var is 0)[text]
    that works in different combinations. but as soon as i add a (goto:) or a link it just does not work anymore and shows what you can see in the picture above..

    i guess i have to try out a little more.. but maybe someone has a sudden inspiration.

    but thank you all for your help!
  • I just realized that my code is a bit too complex for what it needs to be. So:
    (if: $var is 0)
    [
    (link-goto: "Link", "result1")
    ] (elseif: $var is 5)
    [
    (link-goto: "Link", "result3")
    ] (else:)
    [
    (link-goto: "Link", "result2")
    ]
    
    Anyway, put the following into a single passage called "Go!" and you’ll see that it’s working:
    (set: $var to (random: 0,5))
    (if: $var is 0) [
    A random pick from 0 - 5 is (print: $var).
    Result 1
    (link-goto: "Link", "Go!")]
    (elseif: $var is 5) [
    A random pick from 0 - 5 is (print: $var).
    Result 3
    (link-goto: "Link", "Go!")]
    (else:) [
    A random pick from 0 - 5 is (print: $var).
    Result 2
    (link-goto: "Link", "Go!")]
    
  • wow that works!!! thanks a lot!!!
Sign In or Register to comment.