Howdy, Stranger!

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

Different Passages depending on how long you take to answer (using a timer)... Is this possible?

Hi, I'm new to twine and have very little knowledge of programming... ha. Sooo, onwards. Um, I've been playing around with this macro - https://www.glorioustrainwrecks.com/node/5108. It's the <<timedgoto>> stuff. My question is - Is there anyway, in this, or in another macro that anyone knows of, that I can create something whereby, the player is given 10 seconds to act and depending on how long they take to answer, is taken to a different passage? Say 0-3 seconds you go to passage 1, 3-6 seconds you go to passage 2, 6-10 seconds you go to passage 3? Anything like that? Thanks and fingers crossed!

Comments

  • edited May 2015
    You need the replace macro set instead and write something like this if using SugarCube using its click macro:
    <<click "Click here to advance">><<if $choice is 0>><<goto "Passage 1">><<elseif $choice is 1>><<goto "Passage 2">><<elseif $choice is 2>><<goto "Passage 3">><<elseif $choice is 3>><<goto "Passage 4">><</if>><</click>>
    
    <<silently>>
    <<set $choice to 0>>
    <<timedcontinue 3s>>
    <<set $choice to 1>>
    <<timedcontinue 3s>>
    <<set $choice to 2>>
    <<timedcontinue 3s>>
    <<set $choice to 3>>
    <</silently>>
    


    You can't use a normal passage link like <<if $choice is 1>>Passage 2<</if>> because the game measures values for displaying the if statements on passage load, so you need something like a click macro that measures what variable you have on the click.

    Alternatively you could also ways do something like forward the player to a transitional passage containing a <<goto>> macro that redirects the player instantly based on what variable they have now.

    E.g. instead of that click macro write:
    [[Click here to advance|transitional passage]]
    

    And in transitional passage write:
    <<if $choice is 0>><<goto "Passage 1">><</if>>
    
    etc
    


    Just be careful with <<timedcontinue>> adjusting variables because it will do so in the background even after you leave the passage, so $choice in that example will always eventually end up at 3 after 9 seconds, so you may also need later code to reset the variable back to the chosen choice, or just not use that variable again for anything.
  • Excellent! I'll have a play around with that. Thanks for your help!!
  • edited July 2015
    Just be careful with <<timedcontinue>> adjusting variables because it will do so in the background even after you leave the passage, so $choice in that example will always eventually end up at 3 after 9 seconds, so you may also need later code to reset the variable back to the chosen choice, or just not use that variable again for anything.

    @Claretta ... So... if it keeps running in the background, is there a "Stop" call or something? I ask because I want to keep presenting the choices... and yes, I am always seeing it hit the last mark.

    Any ideas?

    Thanks in advance.
    Sage

    EDIT: I am already doing the following, but it keeps running anyway.
    <<silently>>
    	<<set $choice to 0>>
    	<<timed 4s>><<set $choice to 1>><</timed>>
    	<<timed 6s>><<set $choice to 2>><</timed>>
    	<<timed 8s>><<set $choice to 3>><</timed>>
    <</silently>>\
    
  • edited July 2015
    Sage wrote: »
    EDIT: I am already doing the following, but it keeps running anyway.
    <<silently>>
    	<<set $choice to 0>>
    	<<timed 4s>><<set $choice to 1>><</timed>>
    	<<timed 6s>><<set $choice to 2>><</timed>>
    	<<timed 8s>><<set $choice to 3>><</timed>>
    <</silently>>\
    

    Hmm. I should update <<timed>> to die on passage navigation.

    For now, you could do something like the following:
    <<silently>>
    	<<set $timedTurn to turns()>>
    	<<set $choice to 0>>
    	<<timed 4s>><<if $timedTurn is turns()>><<set $choice to 1>><</if>><</timed>>
    	<<timed 6s>><<if $timedTurn is turns()>><<set $choice to 2>><</if>><</timed>>
    	<<timed 8s>><<if $timedTurn is turns()>><<set $choice to 3>><</if>><</timed>>
    <</silently>>\
    
    The timers will still run if the player navigates away, but they won't modify $choice this way.
  • Thanks Bro!

    Wait.... are we on a "bro" basis? Hmm....


    Thanks Mr. @TheMadExile
  • This gives back an error that I haven't set turn()... so I went and added it into the js as just an empty function
    function turn() {
    }
    
    and it still didn't solve the problem.

    /headdesk
    I agree...

    I just don't know where it would go otherwise.
  • edited July 2015
    Hmm. I should update <<timed>> to die on passage navigation.
    .

    I actually use the feature of <<timedcontinue>> not updating on passage navigation. For example, for a spam blocker on voice acting. I want to set a spam blocker to last 2 seconds after a player leaves a passage while voice is playing so when they go to another passage, a voice doesn't start, but is sufficiently delayed for the previous to fade out. Timedcontinue does this easily at present due to it lasting beyond passage transitions.

    I also use the feature to control graphics transitions, which might not be smooth if they were in lockstep to passage transitions. I can understand that some people may want it to die on transitions, but for me it is a highly useful feature.

    Sage wrote: »
    @Claretta ... So... if it keeps running in the background, is there a "Stop" call or something? I ask because I want to keep presenting the choices... and yes, I am always seeing it hit the last mark.

    At first glance I think you're trying to control it only in 1 passage? You need to set a variable in the next passage.

    Say you want to do some real time mechanics where you set a time limit to make a decision otherwise the player gets booted:
    <<timedcontinue 20s>><<goto "New Passage">>
    
    But you don't want that to happen if they click on the link to "Decision Passage" before 20 seconds is up.

    So then you write instead:
    <<timedcontinue 20s>><<if $decision is 0>><<goto "New Passage">><</if>>
    

    And then in "Decision Passage" write:
    <<set $decision to 1>>
    

    That way when the timed continue macro reaches 20, it won't activate the goto after the player visits Decision Passage.

    Alternatively you can do the same thing with the (visited) command. So
    <<if visited("Decision Passage") is 0>><<goto "New Passage">>
    

    That way the player will never be moved to New Passage if they have visited Decision Passage first.
  • edited July 2015
    Sage wrote: »
    This gives back an error that I haven't set turn()...
    Whoops. It's actually turns(), with an s. Mea culpa.

    And due to the power of not being able to edit your posts, the mistake will sink a thousand newbies. Why did we switch away from the old forums again? /sigh
  • And due to the power of not being able to edit your posts, the mistake will sink a thousand newbies.
    I believe I got all the turn()'s changed to turns().
  • edited July 2015
    Yeah.... so...... I'm drawing a blank. Sorry @TheMadExile
    I truly am. I should be able to take that and run... but it doesn't perform as expected.

    Don't get me wrong, your work is fantastic. Maybe I'm just too new at this.
    Now it doesn't work at all. I mean, you know, it works but the timer is blown to hell.

    Here is the upshot of the code (and there are samples and gameplay below, but the gist is important for the sake of expediency)

    This is a fight mini-game. You're reading a glorified novel, you get to a fight scene, then you act out the fight. After which, you go back to reading. This is a largely word-based experience.

    The in-game goes like this: The word "Fight" appears on screen and it moves. The faster you click it, the more likely you hit the guy. The slower you click it, the more likely he hits you.

    The sliding scale of the 0 - 3 goes like this:
    (0 - 3 being reaction times, and 0 is the fastest)

    0 - you hit him for 2 points of damage
    1 - you both miss
    2 - he hits you for 1 point of damage
    3 - he hits you for 2 points of damage

    TL;DR: you click fast, you hit him. If not, you don't.

    For some reason, the timer does practically the opposite it seems. I'm sure it's just still running in the background or something... but still.

    I even added <<set $choice to 0>> on every new "result of your combat" page. Still nothing.

    EDIT: Not only that, but there is a kill-switch at 1 health that is supposed to incapacitate you. It used to work. Now... with the new turns() code in place... it doesn't. For either character.

    So... here is the link to the playable mini-game:
    superheropress.com/fight

    And here is the link to the exported file so you can see where I may have screwed it up:
    .zip of 1 document

    Notice of Copyright : The music is from our in-house composer so yes, it's copyrighted, but (obviously) since he is our composer, I do have permission to use it. Forum users please be kind and don't reuse his work. You can take this mini-game and use it as you like—hell, at this point it's more of TheMadExile's work than mine anyway—but please don't take the music. It's not mine to give. Thank you for understanding.
  • First up, big problem. Do not tag the StoryInit special passage, or any special passage for that matter, as a widget passage. They're listed as special for a reason (i.e. they have their own special behaviors which you should, generally, not be combining with other special behaviors).

    You should create a separate passage for your widgets and tag that with widget, then move your widgets to it and remove the widget tag from StoryInit.

    Sage wrote: »
    Now it doesn't work at all. I mean, you know, it works but the timer is blown to hell.

    […]

    EDIT: Not only that, but there is a kill-switch at 1 health that is supposed to incapacitate you. It used to work. Now... with the new turns() code in place... it doesn't. For either character.
    I'd forgotten what you were working on. The problem is that since you're going back to the same passage again and again ("Fight"), you keep resetting the value of $timedTurn. Meaning that, except for a very brief window, the test ($timedTurn is turns()) will always be true and thus <<timed>> macros from a previous instance of "Fight" can still alter $choice. So, for what you're doing, specifically, the situation with code I gave here is pretty much the same as without it unfortunately. Basically, you're still hosed until I publish a new release. Sorry.

    That said, I do plan to release another 2.x beta soon, probably today, so you won't have to wait long for a fix.

    Also, I'm not seeing the kill-switch problem in the version I compiled myself. It could be caused by something else you had tried to fix this problem and thus isn't in the archive.

    Sage wrote: »
    Notice of Copyright : The music is from our in-house composer so yes, it's copyrighted, but (obviously) since he is our composer, I do have permission to use it. Forum users please be kind and don't reuse his work. You can take this mini-game and use it as you like—hell, at this point it's more of TheMadExile's work than mine anyway—but please don't take the music. It's not mine to give. Thank you for understanding.
    Well, the audio isn't compiled into the file, and you didn't include it in the archive, so you don't have to worry about it. ;}
  • edited July 2015
    Claretta wrote: »
    Hmm. I should update <<timed>> to die on passage navigation.
    I actually use the feature of <<timedcontinue>> not updating on passage navigation.

    […]

    I can understand that some people may want it to die on transitions, but for me it is a highly useful feature.
    I'm unsure how this relates to the <<timed>> macro. You don't use SugarCube 2.x, and, even if you did, you could still use the macros from the <<replacelink>> set, including <<timedcontinue>>.

    So…???
  • Dude you're a champ! Like, seriously. Thank you.

    As for the kill-switch I had it set with an "if/else" based on health and if you had anything less than a 2, the fight was stopped and you were shown different things. Strangely, I now get to negative 3 and I'm still in the fight. Which, yay, great tenacity... but not how it was supposed to work.

    Thank you again, I will look into what I broke in the if/else.

    Thank you also for the upcoming update!
  • Oh, Also... thanks for the tip about not combining special passages. The things I don't know can fill the Staples Center!
  • edited July 2015
    Using the updated <<timed>> macro. I'd suggest using it this way:
    <<silently>>
    	<<audio "Chaotic_Disagreement" play>>
    
    	<<set $choice to 0>>
    	<<timed 4s>>
    		<<set $choice to 1>>
    	<<next 2s>>/* Happens 2s after the previous case. */
    		<<set $choice to 2>>
    	<<next>>/* No delay specified so defaults to the last delay, so 2s after the previous case. */
    		<<set $choice to 3>>
    	<</timed>>
    <</silently>>\
    

    Fully updated Fight 2 example attached (including updated Bleached style and some cleanup).
  • That works incredibly well. I saw the use of the "next" in the <<timed>>. Good stuff!

    So... stupid question... you don't have to answer it: How are you compensated? Because seriously! You help a lot of people! Like, many.

    Or... or... and this is my personal favorite. You're Mark Zuckerberg and you just do it because you like it and you don't need the money!

    I'm going with that one.
  • edited July 2015
    I'm neither compensated (in any fiscal or physical sense), nor am I wealthy (oh, if only).

    Well, actually, that's not entirely true now that I think about. I did once have someone gift me something off of my Steam wishlist as payment/thank you/whatever for some bit of Twine work I did for them.

    I've though about adding some kind of voluntary tipping thing to my website, but I don't know. It just seems boorish to wave a tip jar in peoples faces for something I'd probably be doing anyway. /shrug

    And we're kind of veering way off-topic. :)
  • edited July 2015
    I'm unsure how this relates to the <<timed>> macro. You don't use SugarCube 2.x, and, even if you did, you could still use the macros from the <<replacelink>> set, including <<timedcontinue>>.

    So…???

    I thought you were saying you had updated your replace macro set. I didn't realise you had created an entirely new macro. <<timed>> and <<timedcontinue>> sound suspiciously similiar. ;)
  • I only make the SugarCube compatible version of the set, they're Leon's macros. And yes, <<timed>> is similar to several macros from the set, though it's closest in function to <<timedinsert>> (if I'm recalling what it does accurately).
  • Ugh. I'm an idiot for not thinking of this sooner.

    @Sage: As an FYI. You could also write the Fight passage without using <<timed>> at all by using the time() story function. For example (the entire Fight passage):
    <<audio "Chaotic_Disagreement" play>>\
    <div class="aFight">\
    <<click "Fight!">>
    	<<if time() lt 4000>>
    		<<goto "He takes damage">>
    	<<elseif time() lt 6000>>
    		<<goto "He missed you">>
    	<<elseif time() lt 8000>>
    		<<goto "He hit you">>
    	<<else>>
    		<<goto "You take damage">>
    	<</if>>
    <</click>>\
    </div>
    

    It's really bad when you look at the example I give for the time() function, which is exactly what you are doing here. I swear, some days I think I must have left my brain on the nightstand.
  • Wow! That is LITERALLY half the size. Maybe even smaller.

    Awesome. Much more simple to read as well.

    Thank you.
Sign In or Register to comment.