Howdy, Stranger!

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

Sugarcube lists

edited June 2015 in Help! with 2.0
I'm trying to make a string of <<if $var >= x>>words<</if>> <<if $var2 >= y>><</if>> functions, so that my game will list the effects of changes to the character if the player's stats exceed or equal certain values, one after the other. The problem is that it always defaults to the last listed <<if>> function and ignores the prior ones. Any ideas?

An example of the problem passage:

It's not just your ears either, you're getting a little taller, <<nobr>>
<<if $sen >= 4>>your senses are steadily growing sharper, <</if>>
<<if $str >= 4>>you're getting fitter and more flexible, even showing a little muscle for the first time in your life, <</if>>
<<if $mag >= 4>>something strange and wonderful keeps tugging at your consciousness, <</if>>
<</nobr>>and you can't shake the feeling that this is just the start.

Comments

  • An example of what you're actually doing would help.
  • edited June 2015
    I plugged your example passage into a sugarcube story and it worked fine as long as I defined the variables beforehand.

    Are you initialising everything? If you haven't yet defined any of the prior variables than it won't display them.
  • Claretta wrote: »
    I plugged your example passage into a sugarcube story and it worked fine as long as I defined the variables beforehand.

    Are you initialising everything? If you haven't yet defined any of the prior variables than it won't display them.

    I've initialized everything; I made sure of it. The only passage that displays however is the "something strange and wonderful keeps tugging at your consciousness," one, no matter how high I set the other variables.
  • edited June 2015
    Where are you setting the variables? Copy this code directly into a passage and see if it works.
    <<set $sen to 5>><<set $str to 5>><<set $mag to 5>>
    
    It's not just your ears either, you're getting a little taller, <<nobr>>
    <<if $sen >= 4>>your senses are steadily growing sharper, <</if>>
    <<if $str >= 4>>you're getting fitter and more flexible, even showing a little muscle for the first time in your life, <</if>>
    <<if $mag >= 4>>something strange and wonderful keeps tugging at your consciousness, <</if>>
    <</nobr>>and you can't shake the feeling that this is just the start.
    
  • Claretta wrote: »
    Where are you setting the variables? Copy this code directly into a passage and see if it works.

    I initialize the variables two passages away and while now the variable for strength is displaying properly when I test it, the variable for senses still doesn't seem to work.
    <<set $sen = 5>>
    <<set $str = 5>>
    <<set $mag = 5>>
    <<set $time = 1>>
    <<set $mystery = 1>>
    <<set $exercised = false>>
    <<set $hungry = true>>
    
    [[Start test|Day1]]<<set $luv = 1>>
    

    I wrote that little segment and inserted it for ease of testing; it's not the actual first passage.
  • Are you pasting this into Twine 2 from a word processor? Seems to be a required question these days.

    Anyway, you say that you're setting them "two passages away", are you using the <<back>> macro between them being set and going to the problem passage?

    Also, FYI. I'm unsure why you put a <<set>> macro directly after the link like that, e.g. the following:
    <<set $hungry = true>>
    
    [[Start test|Day1]]<<set $luv = 1>>
    
    But that's effectively the same as doing this:
    <<set $hungry = true>>
    <<set $luv = 1>>
    
    [[Start test|Day1]]
    
    If you were trying to make a setter link, a link that also sets $variables, then that would look like the following:
    [[Start test|Day1][$luv = 1]]
    
    Though, I believe Twine 2 will still do something stupid with that syntax.
  • Whoops, that's a fragment of code that's not supposed to be there. It's part of an older build. Nothing relevant to this issue.

    And no, I'm copying this all into Twine 2 manually and double-checking my work every time.

    When I say "Two passages away" I mean I start my bug test on the passage I posted, click to Day1, then click the link that takes me to the problem passage, the same way a player would in a full play-through. I basically created that testing entry to skip the introduction and initial character set-up.
  • What version of Twine 2 and type (if post-2.0.4: NW.js or browser-based)? And SugarCube (the built-in copy or…)?

    Can you post an example file which displays the issue?

    I cannot fathom a reason for what you're describing to be happening. I created a new story using the code that's been flying around here and I cannot replicate your issue. Could you import and try the attached Twine 2 archive to see if you get the same results.
  • The issue's been resolved. Thank you very much everyone; that was tremendously embarrassing.

    Let this be a lesson to myself and other newbs: Always clean up your code!
Sign In or Register to comment.