From adc46615a521ca8324394cf5c10c6cd0412194a7 Mon Sep 17 00:00:00 2001 From: Alexander Yakovlev Date: Thu, 15 Dec 2016 20:44:32 +0700 Subject: [PATCH] Execute timers early, print them late --- package.json | 2 +- src/salet.coffee | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 72e249a..c11de0c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "salet", - "version": "1.6.12", + "version": "1.6.13", "description": "A general client-side framework for cybertext interactive fiction games.", "keywords": ["ifiction", "interactive fiction", "games", "coffee-script", "text", "menu"], "homepage": "http://salet.oreolek.ru", diff --git a/src/salet.coffee b/src/salet.coffee index 60c615a..1ad8225 100644 --- a/src/salet.coffee +++ b/src/salet.coffee @@ -249,6 +249,10 @@ class Salet console.error code return + # timer is called before executing an action, but an action can clear + # the content, so we put the timer's response in a buffer + timerResponse = @checkTimer() + situation = match[1] action = match[3] @@ -272,7 +276,7 @@ class Salet if @afterAction @afterAction(room, action) - @checkTimer() + @view.append timerResponse # This gets called when the user clicks a link to carry out an action. @processClick = (code) -> @@ -478,13 +482,14 @@ class Salet @checkTimer = () -> if Object.keys(@timers).length == 0 - return 1 + return "" + response = "" for tname, timer of @timers if ((@progress.sequence.length - timer.set) == timer.step) - @view.append timer.action.fcall(this) + response += "\n\n"+timer.action.fcall(this) if !timer.repeatable @dropTimer(tname) - return 1 + return response for index, value of spec this[index] = value