Howdy, Stranger!

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

Change Link and/or Passage on Click

I'm trying to get some effects to happen without changing to a new passage by clicking a link. I have part of what I hoped for by finding the <<cyclinglink>> macro (updated for use with SugarCube) shared by Ludas Novus' blog... this makes it possible to set variables and text on the same link by clicking it.

However, I was also hoping for a way to elicit other effects on clicking a link and have it be able to cycle "infinitely." Basically, I was hoping that I could add something similar to <<replace>> inside the cycling link (not necessary to actually use <<cyclinglink>> just a "cycling link", however this can be made to work).

Essentially, if there is a link that says "Option1", the use clicks this and gets "Option 2," but in addition, the text color changes even though the link stays "in place." This is made famous on the Castle, Forest, Island, Sea Twine... but beyond this, I'd like to be able to make it so that if the user clicks "Option1" and the text changes to "Option 2" that not only effects like changing that link are available, but that it would do something else, like change the background color of the page, or run a replace-type function on text elsewhere in the passage...

I've tried fiddling with nested <<click>><<replace>> macros, and that isn't seeming to work, and even if it did, it's kind of a messy nightmare...

If anyone has a way to do something like this, please let me know!

Comments

  • I hate to double post my first post, but if the above is completely incomprehensible, perhaps this will help... this is a way to accomplish the basic aspects of this effect with some inline javascript, but I would rather not have to write something like this every time I want to do this, as I plan on using it a lot. Is there a more Twine macro way to do this:

    <<nobr>>
    <span id="1">
    <<click "1">><<script>>document.getElementById("1").style.display = "none";document.getElementById("2").style.display = "inline";<</script>><</click>></span>
    <span id="2" style="display:none">
    <<click "2">><<script>>document.getElementById("2").style.display = "none";document.getElementById("3").style.display = "inline";<</script>><</click>></span>
    <span id="3" style="display:none">
    <<click "3">><<script>>document.getElementById("3").style.display = "none";document.getElementById("1").style.display = "inline";<</script>><</click>></span>
    <</nobr>>

    I would also add different text colors to the spans and could use more inline javascript to do other things to other parts of the passage... but the more inline javascript I use the more I'm just writing javascript instead of writing in Twine...
Sign In or Register to comment.