Howdy, Stranger!

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

I want to insert Text that if "true" triggers a new path

Hello everybody,

I want to know if it is possible to insert a textfield, were players can to insert the correct answer to a riddle for example. If it is the right answer, it gives them a new path to continue the story.

I'm using Harlow and Twine 2.0.11

Is something like this possible?

Thanks
Gman

Comments

  • edited March 2016
    I don't know about inserting text. That's kind of not what Twine is meant for. I could be wrong.

    What you can do is set up a variable and then check if they have accumulated X of it.

    Like this:

    (set: $Fragmentsofanswer to false)
    (if: $acummulatedanswerfragments is X[
    (set: $Fragmentsofanswer to true)
    ]
    (if: $Fragmentsofaswner is true)[
    PUT SOME CODE HERE
    ]

    Of course, you would use whatever variable makes sense to you.

    With this code, you can let the player discover the answer by visiting passages or taking items, and giving them 1 of $variable each time, in this case, $accumulatedanswerfragments.

    This is one way to make branching stories. For instance, you can use this code in one passage with two versions. For instance, if they only have 3 of X, you can use a link to send them back to the beginning or w/e. If they have 5 of x, then, you could let them proceed. You can also use this check to assign them a count of a different variable, say, to make them lose health or gain stress or w/e other variable you have set up.

  • edited March 2016
    It's not what I want to do, but it could be usefull later.

    What I want is exactly this makro <<textinput $variable passage name >>, which unfortunately does not exist for Twine 2.0 and Harlow.

    I saw that there has already been a lot of discussion about this topic: http://twinery.org/forum/discussion/2702/how-to-use-textinput-macro-in-twine-2-0/p1

    In the end I came close with this skript:

    Please enter the codeword
    <script type="text/javascript">
    function sesame(element){
    var wort = element.value;
    if (wort.toLowerCase() == "codeword") {
    // insert here what should happen
    document.write("Well done! Next passage");
    }
    }
    </script>
    <input type="password" onchange="sesame(this)" />

    ...which almost worked.

    The problem is that if I frame the output-value like this Well done! Next passage - Twine does automatically create a link in the storyboard. But when I play it, I can't press on the text and get directed further.

    It seems like a very small thing left to do, but I have no idea how to fix this.

    Anyone got any ideas?
  • Please use the C button in the toolbar above the comment field to wrap your code examples in a code tag, it makes them easier to read.

    There is one major issue with the way you have used the document.write() method in your example, it will erase the contents of your story as well as the Harlowe engine.

    The following modifies your example to use a span element to hide the link and a jQuery show method to unhide it again once the input is correct.
    <script type="text/javascript">
    function sesame(element){
    	var wort = element.value;
    	if (wort.toLowerCase() == "codeword") {
    		// Display the hidden link.
    		$('#link').show();
    	}
    }
    </script>
    <input type="password" onchange="sesame(this)" />
    
    <span id="link" style="display: none;">[[Well done! Next passage]]</span>
    
  • greyelf wrote: »

    The following modifies your example to use a span element to hide the link and a jQuery show method to unhide it again once the input is correct.
    <script type="text/javascript">
    function sesame(element){
    	var wort = element.value;
    	if (wort.toLowerCase() == "codeword") {
    		// Display the hidden link.
    		$('#link').show();
    	}
    }
    </script>
    <input type="password" onchange="sesame(this)" />
    
    <span id="link" style="display: none;">[[Well done! Next passage]]</span>
    

    That did it! Beautifull! Thanks a lot greyelf. From the threads I've been reading, I imagine this could be interesting for other people too. I leave it up to you to decide. You seem to know this forum well ;D

    Thanks again. So exited to try it out.
Sign In or Register to comment.