Howdy, Stranger!

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

Is it possible to change passages by script instead of clicked link?

Is it possible to change passages by javascript instead of clicked link?
A function to call when (for example) a timer runs out?

Thanks.

Comments

  • radian wrote:

    Is it possible to change passages by javascript instead of clicked link?
    A function to call when (for example) a timer runs out?

    Thanks.


    It's definitely possible. I have a similar thing going on in my current story, though, unfortunately, I feel is implemented in a very poor and crude way.

    You can use Leon's Macro's (I think TimedCycle is to me, the most useful), and TimedGoTo, which redirects the player to a specified passage at a specified time. You can find all of them http://www.glorioustrainwrecks.com/node/5108.

    As far as a function call as a passage-changer (I don't know what else to call it, lol) I personally just call a function and set it's return to a string version of whatever macro I want to run. Here's a quick example.

    Example:
    window.PassageFunction = function(PassageToGoTo, OptionalText) {
    var OptionalText = OptionalText || "Default Text";
    return "[[" + OptionalText + "|" + PassageToGoTo + "]]";
    };
    Usage:
    <<print PassageFunction("Start", "Press This To Test My Function!">>
    I'm using SugarCube and this works (and I don't see any reason it shouldn't on any other header). But I must stress that this is a very elementary way to handle stuff like that, and can get kind of messy depending on how big your story is and how dynamic you want the link system to be. If it's not a big deal, it works. But I wouldn't make a habit of it until you get TheMadExile's opinion on it, which you most likely will.



     
  • If your using SugarCube I believe you can make a call to state.display("Name of Passage To Display") from within your java-script.
  • Thanks. Yeah, that works.
Sign In or Register to comment.