summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scripts/toy.groovy71
1 files changed, 71 insertions, 0 deletions
diff --git a/scripts/toy.groovy b/scripts/toy.groovy
index 05c817e..b2d3283 100644
--- a/scripts/toy.groovy
+++ b/scripts/toy.groovy
@@ -139,11 +139,72 @@ def getDay = { (int)(getTime() / DAY) * DAY };
def has = {i -> loadBoolean("toys.$i") == true};
def likes = {i -> loadBoolean("fetish.$i") == true};
def can = {i -> loadBoolean("toy.permission.$i") == true};
+def givePermission = {i -> save("toy.permission.$i", true)};
+def revokePermission = {i -> save("toy.permission.$i", false)};
def is = {i -> loadBoolean("toy.state.$i") == true};
def set = {i, s -> save("toy.state.$i", s)};
def positioned = { i -> loadString("toy.position") == i };
def getPunish = { loadInteger("toy.punishment") ?: 0; };
def adjustPunish = { p -> save("toy.punishment", Math.max(getPunish() + (int)p, 0)); };
+def namedEvents;
+def loadEvents = {
+ return (loadMap("toy.events") ?: [:]);
+}
+def saveEvents = { events ->
+ save("toy.events", events);
+}
+def nextEvent = { events ->
+ def first = null;
+ events.each{ k, v ->
+ if (!first || first.event.time > v.time) {
+ first = [ name: k, event: v ];
+ }
+ };
+ return first;
+};
+def setEvent = { events, name, time, func, arg = null ->
+ if (namedEvents.containsKey(name)) {
+ events[name] = [
+ time: time,
+ func: func,
+ arg: arg
+ ];
+ return true;
+ saveEvents(events);
+ }
+ else {
+ showPopup("No such event $name");
+ return false;
+ }
+};
+def addEvent = { name, time, func, arg = null ->
+ def events = loadEvents();
+ return setEvent(events, name, time, func, arg);
+}
+def addEventIfMissing = { name, time, func, arg = null ->
+ def events = loadEvents();
+ if (!events.containsKey(name)) {
+ return setEvent(events, name, time, func, arg);
+ }
+};
+def removeEvent = { name ->
+ def events = loadEvents();
+ events.remove(name);
+ saveEvents(events);
+};
+def execEvents = { rt ->
+ def events = loadEvents();
+ events
+ .findAll({ e -> e.value.time <= getTime() })
+ .each({ e ->
+ def f = namedEvents[e.value.func];
+ events.remove(e.key);
+ saveEvents(events);
+ if (f) {
+ f(e.value.arg, e.value.time, rt);
+ }
+ })
+};
def sessionAborted = null;
def gagText = { t, p ->
if (!is(GAGGED)) return t;
@@ -876,6 +937,9 @@ def sessionPlay = {
playRepeat(1 + getRandom(3), [preRelease, preEdge, preGag, preClamps, preCollar, preStrip]);
playRepeat(1 + getRandom(3), [playStrokes, playEdges]);
playTake(getRandom(3), [postCum, postChastity]);
+ if (!sessionAborted) {
+ addEventIfMissing(CUM, getTime() + (DAY * 2) + getRandom(DAY * 2), "givePermission", CUM); // 2 - 4 days from now
+ }
}
};
def sessionRelease = { goodToy ->
@@ -918,6 +982,7 @@ def sessionRelease = { goodToy ->
else {
present([DRESSED], [
["Get out of my sight.", "Go!"]]);
+ removeEvent(CUM);
}
wait(10);
setImage(null);
@@ -1088,6 +1153,10 @@ def beginPlan = { plan ->
exit();
};
// Initial - basic checks and defaults
+namedEvents = [
+ // name: func(arg, schedTime rt)
+ "givePermission": { arg, schedTime, rt -> givePermission(arg) }
+];
def setupInitial = {
if (loadInteger("toy.version") == null) {
// Welcome
@@ -1139,6 +1208,7 @@ def setupInitial = {
setDefault("toy.strokeTeaseOffset", 0);
setDefault("toy.punishment", 0);
setupPlans();
+ execEvents(false);
};
def setupShowState = {
show(
@@ -1250,6 +1320,7 @@ while (true) {
else if (getRandom(1000) == 0) {
playtime();
}
+ execEvents(true);
addAvail(cycleTime);
}