diff options
Diffstat (limited to 'scripts/toy.groovy')
-rw-r--r-- | scripts/toy.groovy | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/scripts/toy.groovy b/scripts/toy.groovy index 3d32f62..1fb02ae 100644 --- a/scripts/toy.groovy +++ b/scripts/toy.groovy @@ -274,10 +274,25 @@ return new Object() { }; }; + final triggerHandlers = []; + final addTriggerHandler = { String triggerName, func, defArg = null -> + triggerHandlers << [ + triggerName: triggerName, + func: func, + defaultArg: defArg + ]; + }; + final executeTrigger = { String triggerName, arg = null -> + triggerHandlers + .findAll { th -> th.triggerName == triggerName } + .forEach { th -> th.func(arg ?: th.defaultArg) }; + }; + // Session def sessionSummon = { imageSpec -> final limit = 5; final timeMax = 10; + executeTrigger("toySummoned"); for (def n = 1; n <= limit; n++) { switch (n) { @@ -300,12 +315,14 @@ return new Object() { } playBackgroundSound(n == limit ? "shortwhip.wav" : "bell.wav"); if (showButton("Yes, ${dommeTitle()}?", timeMax) < timeMax) { + executeTrigger("toySummonSuccess", n); return true; }; } showLounge(); show(null); adjustPunish(5); + executeTrigger("toySummonFail"); return false; }; def setSessionAbort = { String r = null -> sessionAborted = r }; @@ -412,10 +429,12 @@ return new Object() { return "toy"; } addAvail(clickTime); + executeTrigger("toyLoungeTime", clickTime); } def eStart = getTime(); execEvents(true); addAvail(getTime() - eStart); + executeTrigger("toyEventTime", getTime() - eStart); } } }.main(); |