idmillington / undum

A client-side framework for narrative hypertext interactive fiction.
https://idmillington.github.com/undum
MIT License
336 stars 80 forks source link

doLink() calls outside actions and situations aren't saved #11

Closed juhana closed 12 years ago

juhana commented 12 years ago

If I have on the UI itself a button that calls system.doLink(), Undum doesn't remember that click when loading the game. For example:

undum.game.init = function( character, system ) {
    $( '#myButton' ).click( function() {
        system.doLink( 'home' );
    });
};

The button works fine but the click isn't saved in the turn sequence so when the game is loaded the system forgets that we've clicked on the button and skips that turn.

I can see why this is (if you have doLinks inside situations/actions they'd be executed twice), but is there a workaround? Would it be reasonable to have a separate function that both executes the link and saves it into the turn sequence?

idmillington commented 12 years ago

It didn't occur to me that would be needed!

Internally, we distinguish between the two with the functions processLink and processClick (neither are available from outside the undum module). doLink is then a thin wrapper around processLink, so we should probably add a similar wrapper around processClick (which is at https://github.com/idmillington/undum/blob/master/games/media/js/undum.js#L1106)

I'm on my iPad so I can't change it tonight, but I'll add it tomorrow, or feel free to put it in yourself if you're in a rush.

idmillington commented 12 years ago

Fixed in commit 3a3f2287