From fb288e4259c66de978917e529eac308c1ad68d63 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 9 Jul 2019 16:45:56 +0100 Subject: Basic trigger point event system --- scripts/toy.groovy | 19 +++++++++++++++++++ scripts/toy/imagery.groovy | 1 + scripts/toy/orgasmControl.groovy | 9 +++++++++ scripts/toy/play.groovy | 2 ++ scripts/toy/sleep.groovy | 5 +++++ scripts/toy/social.groovy | 12 ++++++++---- scripts/toy/tease.groovy | 1 + 7 files changed, 45 insertions(+), 4 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(); diff --git a/scripts/toy/imagery.groovy b/scripts/toy/imagery.groovy index 9b56faf..0a2c3a6 100644 --- a/scripts/toy/imagery.groovy +++ b/scripts/toy/imagery.groovy @@ -133,6 +133,7 @@ save("toy.owner.outfit", outfit.set); save("toy.owner.outfitTime", getTime()); loadDomme(OWNER, outfit.set); + executeTrigger("ownerOutfitChange", outfit.set); return outfit.set; }; return null; diff --git a/scripts/toy/orgasmControl.groovy b/scripts/toy/orgasmControl.groovy index 0f017bd..e9c36df 100644 --- a/scripts/toy/orgasmControl.groovy +++ b/scripts/toy/orgasmControl.groovy @@ -4,13 +4,16 @@ final taken = showButtonG("Sorry, ${dommeTitle()}, I'm cumming $reason", "cumming", time); if (taken < time) { playBackgroundSound(null); + executeTrigger("toyCum"); if (lenient && taken < 2) { + executeTrigger("toyCumClose"); present(null, [ ["Awww.", "Damn."], ["That was close;", "I'll let you have that one;"], ["And I was looking forward to punishing you.", "No punishment this time."]]); } else { + executeTrigger("toyCumBad"); present(null, [ ["Bah!", "Pfft. I'm very disappointed in you."], ["Ruin it.", "Don't touch it."]]); @@ -52,6 +55,8 @@ return cumChanceDenied(); } } + executeTrigger("toyCum"); + executeTrigger("toyCumGood"); present([TITS], [ ["Cum, cum", "Cum for me"], ["you little slut.", "my lucky toy.", "you dirty boy."]]); @@ -84,6 +89,8 @@ return mightCum(15, true, "too late"); } } + executeTrigger("toyCum"); + executeTrigger("toyCumGood"); pause(10); showButtonG("Thank you, ${dommeTitle()}.", "ok"); return true; @@ -105,6 +112,8 @@ present([TEASE], [ ["Hands off!", "Leave it."], ["Let it all ooze out.", "You're not getting a proper release."]]); + executeTrigger("toyCum"); + executeTrigger("toyCumGood"); pause(10); showButtonG("Thank you, ${dommeTitle()}.", "ok"); return true; diff --git a/scripts/toy/play.groovy b/scripts/toy/play.groovy index 2078d0b..f30f19c 100644 --- a/scripts/toy/play.groovy +++ b/scripts/toy/play.groovy @@ -221,8 +221,10 @@ if (first.asBoolean()) { playWait(); } + executeTrigger("playStarted"); sessionPlay(); sessionRelease(sessionAborted == null); + executeTrigger("playEnded", sessionAborted); } else { adjustPunish(25); diff --git a/scripts/toy/sleep.groovy b/scripts/toy/sleep.groovy index da17157..6497ee0 100644 --- a/scripts/toy/sleep.groovy +++ b/scripts/toy/sleep.groovy @@ -18,6 +18,10 @@ showButtonG("Good night, ${dommeTitle()}", "night"); addEvent(BEDTIMECHECK, getTime() + 300 + getRandom(600), BEDTIMECHECK); showLounge(); + executeTrigger("bedtime", true); + } + else { + executeTrigger("bedtime", false); } // Assume toy will return dressed tomorrow removeEvent(REDRESS); @@ -53,6 +57,7 @@ setAway(null); playSchedule(); sleepSchedule(); + executeTrigger("wakeup"); }; toy.addNamedEvent(WAKEUP, { name, arg, schedTime, rt -> toy.wakeup(rt) }); diff --git a/scripts/toy/social.groovy b/scripts/toy/social.groovy index 0a6c179..1de4ec3 100644 --- a/scripts/toy/social.groovy +++ b/scripts/toy/social.groovy @@ -7,8 +7,10 @@ final timeWindow = { float min, float max -> (int)((min * HOUR) - localTimeOffset() + getRandom((int)((max - min) * HOUR))) }; final friendName = FRIENDS[getRandom(FRIENDS.size())]; final day = getDay() + ((getRandom(3) + (localTime() > startmin ? 1 : 0)) * DAY); - addEventIfMissing(plan, day + timeWindow(startmin, startmax), BEGINPLAN, - [friendName: friendName, returnTime: day + timeWindow(endmin, endmax)]); + if (addEventIfMissing(plan, day + timeWindow(startmin, startmax), BEGINPLAN, + [friendName: friendName, returnTime: day + timeWindow(endmin, endmax)])) { + executeTrigger("ownerSocialPlanned", plan); + } } toy.metaClass.setupPlans { @@ -51,9 +53,10 @@ setAway(plan); removeEvent(PLAY); showLounge(); + executeTrigger("ownerSocialBegin", plan); }; - toy.metaClass.endPlan { rt -> + toy.metaClass.endPlan { rt, plan -> save("toy.owner.outfitTime", getTime()); setAway(null); if (rt && sessionSummon([DRESSED])) { @@ -63,6 +66,7 @@ } readNote(); playSchedule(); + executeTrigger("ownerSocialEnd", plan); setupPlans(); }; @@ -81,7 +85,7 @@ }; toy.addNamedEvent(BEGINPLAN, { name, arg, schedTime, rt -> toy.beginPlan(rt, name, arg) }); - toy.addNamedEvent(ENDPLAN, { name, arg, schedTime, rt -> toy.endPlan(rt) }); + toy.addNamedEvent(ENDPLAN, { name, arg, schedTime, rt -> toy.endPlan(rt, name) }); toy.addRequestable("calendar", "Calendar", { toy.showCalendar() }); toy.setupPlans(); return null; diff --git a/scripts/toy/tease.groovy b/scripts/toy/tease.groovy index 74e3fbe..c14b809 100644 --- a/scripts/toy/tease.groovy +++ b/scripts/toy/tease.groovy @@ -73,6 +73,7 @@ ["Hands off!", "Stop!"]]); if (mightCum(getRandom(5) + 5)) return; allowedTime /= 2; + executeTrigger("toyEdged"); }; }; -- cgit v1.2.3