mirror of
https://gitlab.com/Oreolek/salet-module.git
synced 2024-05-18 08:58:31 +03:00
Execute timers early, print them late
This commit is contained in:
parent
6b5bbe3b72
commit
adc46615a5
|
@ -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",
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue