summaryrefslogtreecommitdiff
path: root/scripts/toy.groovy
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/toy.groovy')
-rw-r--r--scripts/toy.groovy25
1 files changed, 18 insertions, 7 deletions
diff --git a/scripts/toy.groovy b/scripts/toy.groovy
index 509fb74..05c817e 100644
--- a/scripts/toy.groovy
+++ b/scripts/toy.groovy
@@ -70,16 +70,27 @@ def selectImage = { domme, set, spec ->
});
};
def matches = IMAGEDATA
- .find({ d -> d.domme == domme })
- .sets.find({ s -> s.set == set })
+ .find({ d -> d.domme == domme });
+ if (!matches) return null;
+ matches = matches
+ .sets.find({ s -> s.set == set });
+ if (!matches) return null;
+ matches = matches
.images.findAll({ i -> meets(i) });
+ if (matches.isEmpty()) return null;
return matches[getRandom(matches.size())];
};
def showImage = { spec ->
def outfit = loadString("toy.owner.outfit");
def image = selectImage(OWNER, outfit, spec);
- setImage("toy/$OWNER/$outfit/${image.image}.jpg");
- return image.tags;
+ if (image) {
+ setImage("toy/$OWNER/$outfit/${image.image}.jpg");
+ return image.tags;
+ }
+ else {
+ setImage(null);
+ return null;
+ }
};
def selectImageSet = { domme, specs ->
def matches = IMAGEDATA
@@ -94,7 +105,7 @@ def dress = { specs ->
def prev = IMAGEDATA
.find({ d -> d.domme == OWNER })
.sets.find({ s -> s.set == outfit });
- if (specs.every({ spec -> selectImage(OWNER, prev.set, spec)})) {
+ if (prev && specs.every({ spec -> selectImage(OWNER, prev.set, spec)})) {
return outfit;
}
}
@@ -131,7 +142,7 @@ def can = {i -> loadBoolean("toy.permission.$i") == true};
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"); };
+def getPunish = { loadInteger("toy.punishment") ?: 0; };
def adjustPunish = { p -> save("toy.punishment", Math.max(getPunish() + (int)p, 0)); };
def sessionAborted = null;
def gagText = { t, p ->
@@ -401,7 +412,7 @@ def strokes = { amount, imageSpec ->
save("toy.strokeTeaseOffset", sto);
}
def clampPulls = { amount ->
- getRandom(amount).times {
+ getRandom(1 + amount).times {
present([DRESSED], [
["Pull them tight.", "Pull them!"]]);
wait(getRandom(10) + 5);