Howdy, Stranger!

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

call a function each passage

edited June 2015 in Help! with 2.0
Hi everybody!
I am using twine 2 and Harlowe.
Do you know how can I call a function in my twine story at the beginning of each passage?
without having to press any button or similar. I have tried to do it with the onload event but it doesnt work.


Thank you!

Comments

  • By "function" I am going to assume you mean a Javascript function like the following:
    window.sayHello = function() {
    	console.log('Hello there');
    };
    
    Normally in HTML you would use a <script> element but Harlowe does not currently support this so you will need to use some other method.

    One such other method is the img element's onerror event hack, which works by telling the web-browser to loads an image that does not exists and when it fails to does so to call your function instead.
    <div style="display:none;"><img src="!@#$"; onerror="sayHello();" /></div>
    
  • Thank you very much!! @greyelf
Sign In or Register to comment.