Howdy, Stranger!

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

Sugarcube - Having a linked passage set multiple variables.

Hello forum people. I am forcing myself to use 2.0.5 maintly because it works at work. I cannot install 1.4.2 on my work computer. That being said I am trying to get a passage transition to set 2 variables instead of just one. I got one to work fine but 2 will not.
[[tap|bed1Window][$tapWindow to 1]]
The above works just fine. I want to make it so if you pound on the window it takes tap out as an option so I tried
[[Pound|bed1Window][$poundWindow to 1][$tapWindow to 1]]
The above just shows up as bed1Window][0 to 1][0 to 1 on the line.

I have a StoryInit that sets the variables to 0 as default. Not sure if that matters. Ill put the full code for the passage below. The extra <br> and "/" are me trying to format around the carriage returns. Not my primary issue though. I am new so go easy on me :)
::bed1Window
<<display "StatusBar">>
------
Looking out the window you can see nothing but forest in all directions.  This scares you even more than your current predicament.  The window does not appear to open. You stare out the window for a moment hoping to see something that gives you hope, but that never happens.
<<if $tapWindow is 1>><br>You tap on the glass with a nuckle and notice that it doesn't sound quite right.  This glass appears to be thicker than normal.<<endif>>\
<<if $poundWindow is 1>><br><br>You pound on the window with both hands as hard as you can and realize that was a terrible idea.  You might as well be pounding on concrete.  The glass doesn't sound like normal glass and is clearly not going to break for you or anyone else.<<endif>>\

<<if $tapWindow is 0>><br>At this point you [[tap|bed1Window][$tapWindow to 1]] the window.<<endif>>
<<if $poundWindow is 0>><br>[[[Pound|bed1Window][$poundWindow to 1][$tapWindow to 1]]] on the window frantically.<<endif>>
[[Assess|bed1]] your options.

Comments

  • edited May 2015
    @Novalith

    I have had success with doing that in SugarCube using the following:
    You have to do something. Either \
    <span id="fight">\
    	<<click "fight">>\
    		<<replace "#fight">>fight <</replace>>\
    		<<replace "#run">>run<</replace>>\
    		<<replace "#output">>
            You have chosen to fight. He begins to remove his jacket.<</replace>>\ 
    	<</click>> \
    </span>\
    the strange man or \
    <span id="run">\
    		<<click "run">>\
    		<<replace "#fight">>fight <</replace>>\
    		<<replace "#run">>run<</replace>>\
    		<<replace "#output">>
            You have chosen to run. He takes out his radio.<</replace>>\ 
    	<</click>> \
    </span>.\
    
    <span id="output"></span>\
    

    The backslashes are for removing the linebreaks.

    Also... not my original code, but I don't remember who first wrote it. I think it was GreyElf modifying someone's broken code... so... credit goes to him.

    PS, You still have version one syntax going in what you pasted it looks like.

    —Sage.
  • PS, You still have version one syntax going in there it looks like.

    I might be. The problem is I cannot get to the sugarcube help pages because they are blocked. I have been trying to get my information from a multitude of sources to work around it but consolidated help is locked away for the moment. I will admit that I am struggling a bit.

    As for what you have written I am looking over it now to see if I can understand it enough to replicate it in my story. From my initial perusal it looks like it is close to what I want but not exactly.

    If they tap, they can then chose to pound but if they pound they cannot choose to tap. It looks like yours only lets me pick one and removes the other as in option not matter what it is I pick. If that is the case it doesn't exactly solve my issue.
  • @Novalith

    You can just NOT use replace on that one. You'll still get the results.

    My suggestion: make a new twine story, paste in ONLY what I sent you. Then remove tap from the choices.
  • edited May 2015
    OK, I see what you did there. It solves my issue for this particular passage. It doesn't help with setting multiple variables with a setter link which I am still wondering if you can do. I did learn something new even if it looks kind of complicated. I will have to play around with it to get it to fit within the context of my story but overall I am satisfied. Thanks. Also if you have any information about good sugarcube references off the main site I would appreciate it. I hate government filters.

    EDIT: I will post my completed code below when I am finished so others can use it if they need it.
  • Well.... the FOLLOWING is why I gave you the workaround I did.

    You may want to read it @Novalith

    http://twinery.org/forum/discussion/comment/8835/#Comment_8835
  • I did, it's how I got the links to work in the first place.

    That being said I am posting up my final code (minus possible revisions to make the passage flow better as far as readability goes. It gets the job done and when you come back it prevents you from pounding on the same glass again.
    <<if $windowtest is 0>>Looking out the window you can see nothing but forest in all directions.  This scares you even more than your current predicament.  The window does not appear to open. You stare out the window for a moment hoping to see something that gives you hope, but that never happens. 
    
    At this point you decide to \
    <span id="tap">\
    	<<click "tap">>\
    		<<replace "#tap">>tap <</replace>>\
    		<<replace "#output">>
            You tap on the glass with a nuckle and notice that it doesn't sound quite right.  This glass appears to be thicker than normal.<</replace>>\ 
    	<</click>> \
    </span>\
    on the window, \
    <span id="pound">\
    		<<click "pound">>\
            <<set $windowtest to 1>>
    		<<replace "#tap">>tap <</replace>>\
    		<<replace "#pound">>pound<</replace>>\
    		<<replace "#output">>
            You pound on the window with both hands as hard as you can and realize that was a terrible idea.  You might as well be pounding on concrete.  The glass doesn't sound like normal glass and is clearly not going to break for you or anyone else.<</replace>>\ 
    	<</click>>\
    </span>\
     on the window, or [[Assess|bed1]] your options.
    <span id="output"></span>\<<endif>>
    <<if $windowtest is 1>>Looking out the window you can see nothing but forest in all directions.  This scares you even more than your current predicament.  The window does not appear to open. You stare out the window for a moment hoping to see something that gives you hope, but that never happens. You already know you can't break the glass either and standing here wishing you could get out won't help.  You [[return|bed1]] to the problem at hand.<<endif>>
    
  • So... I missed the spot in the link help for 1.4.2 where it says that you can use a semicolon for multiple entries. The fix was far simpler than I could have imagined though a veteran coder might have noticed it before I did.
    [[Checktest|The Room][$testa to "it"; $testb to "works"]]
    
  • You just need to place a coma between each variable/value pair:
    [[Pound|bed1Window][$poundWindow to 1, $tapWindow to 1]]
    
  • greyelf wrote: »
    You just need to place a coma between each variable/value pair:
    [[Pound|bed1Window][$poundWindow to 1, $tapWindow to 1]]
    

    I used a semicolon but yes, I eventually figured that out. I like the other solution better because it actually allowed me to do something a bit different and it fit what I was going for better. However I am sure I will come to need this knowledge anyway. Thanks for taking the time to respond!
  • You tap on the glass with a nuckle and notice that it doesn't sound quite right.
    Spelling: nuckle → knuckle
  • You tap on the glass with a nuckle and notice that it doesn't sound quite right.
    Spelling: nuckle → knuckle

    I haven't published yet!!!! Besides this is mostly a tech demo of sorts. Just getting my feet wet. Thanks though.
Sign In or Register to comment.