summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scripts/toy.groovy15
1 files changed, 13 insertions, 2 deletions
diff --git a/scripts/toy.groovy b/scripts/toy.groovy
index 5828903..68d7114 100644
--- a/scripts/toy.groovy
+++ b/scripts/toy.groovy
@@ -153,12 +153,23 @@ def localTime = {
return wallclock;
};
def getDay = { (int)(getTime() / DAY) * DAY };
+def getProp = {i, f, d = null ->
+ final v = f("toy.$i".toString());
+ if (v == null) return d;
+ return v;
+};
+def loadB = { p -> loadBoolean(p)};
+def loadI = { p -> loadInteger(p)};
+def loadS = { p -> loadString(p)};
+def setProp = {i, v -> save("toy.$i".toString(), v)};
def has = {i -> loadBoolean("toys.$i") == true};
def likes = {i -> loadBoolean("fetish.$i") == true};
def can = {i -> loadBoolean("toy.permission.$i") == true};
def perm = can;
-def givePermission = {i -> save("toy.permission.$i", true)};
-def revokePermission = {i -> save("toy.permission.$i", false)};
+def getPermission = {i -> getProp("permission.$i", loadB)};
+def setPermission = {i, v -> setProp("permission.$i", v)};
+def givePermission = {i -> setPermission(i, true)};
+def revokePermission = {i -> setPermission(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 };