Howdy, Stranger!

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

Using javascript to extend or edit an already existing story without touching the original twee code

by experimenting i have figured out that i can edit variables and make them keep thier value between passages via
$(document).click(function(){

   state.history[0].variables.<variablenamehere>=<value>

});
but i would like to know how deep i can go before i actually need to edit the source code of the story using only JavaScript to create additional passages. The reason i dont want to edit the original story is because this extension is going to be developed separately and im hoping to package it up into something like a javascript bookmarklet that can be run at the beginning of the story to add the extension to it.

Comments

  • edited June 2016
    well i seem to have succeeded in this endeavor at least partially and i have a proof of concept.
    jQuery('#storeArea').append('<div tiddler="Hax" tags="nobr" created="0" modifier="twee" twine-position="0,0"> &quot;Alas! &lt;&lt;print visited()&gt;&gt; time(s) you&#39;ve fallen in this damned pit!&quot; </div>')
    
    the line above adds a passage to the passage storage area named hax
    tale.constructor()
    
    this reloads the tale object so the hax passage can be loaded by the story
    state.display('Hax')
    
    this code forces the new passage to be displayed.

    sorry for all the weird html escaping it was how i had to put it in the chrome javascript dev console
  • thanks to the knowledge i gained researching this i made a kind of modloader for it. https://github.com/jfmherokiller/TwineJavascriptExaimination
Sign In or Register to comment.