summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2019-07-06 14:59:29 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2019-07-06 14:59:29 +0100
commit6c20a8daf94307b87a0861c9e143c74cc4aca711 (patch)
tree1ae2ab401d313288d3c551d8a6d90ea6a6da5f80
parentNo writes to parent vars from metaClass methods (diff)
downloadtoy-6c20a8daf94307b87a0861c9e143c74cc4aca711.zip
Make the activityList of objects
-rw-r--r--scripts/toy.groovy4
-rw-r--r--scripts/toy/debug.groovy2
-rw-r--r--scripts/toy/play.groovy10
3 files changed, 9 insertions, 7 deletions
diff --git a/scripts/toy.groovy b/scripts/toy.groovy
index 295e500..8d193fb 100644
--- a/scripts/toy.groovy
+++ b/scripts/toy.groovy
@@ -304,7 +304,9 @@ return new Object() {
final activityList = [:];
final addActivity = { String name, func ->
- activityList[name] = func;
+ activityList[name] = [
+ func: func
+ ];
}
final namedEvents = [:];
diff --git a/scripts/toy/debug.groovy b/scripts/toy/debug.groovy
index 7f5f715..4bd3a64 100644
--- a/scripts/toy/debug.groovy
+++ b/scripts/toy/debug.groovy
@@ -29,7 +29,7 @@
toy.metaClass.playActivity {
final keys = new ArrayList<?>(activityList.keySet());
final act = getSelectedValue("Choose activity", keys);
- activityList[keys[act]]();
+ activityList[keys[act]].func();
};
toy.addRequestable("status", "Status", { toy.setupShowState() });
diff --git a/scripts/toy/play.groovy b/scripts/toy/play.groovy
index c7f00b3..da0bff2 100644
--- a/scripts/toy/play.groovy
+++ b/scripts/toy/play.groovy
@@ -14,7 +14,7 @@
];
def apply = { activitity, use = null ->
if (!activitity) return;
- def val = activitity();
+ def val = activitity.func();
playBackgroundSound(null);
if (use && val instanceof Number) {
use(val);
@@ -62,10 +62,10 @@
final eval = { expr -> Eval.me('toy', playScope, expr.toString()) };
if (stateIs("DEBUG")) {
// Check everything in DOMME evaluates and resolves
- final checkIsFunc = { group, name ->
+ final checkIsFunc = { group, name, s = { f -> f } ->
if (!name) return;
show("checking $group:$name is a function");
- if (!(funcMap[group][name] instanceof Closure)) {
+ if (!(s(funcMap[group][name]) instanceof Closure)) {
showPopup("$group:$name is not a function");
}
}
@@ -81,10 +81,10 @@
checkIsFunc("select", phase.select);
checkEval(phase.number ?: 1);
phase.activities.forEach { a ->
- checkIsFunc("activities", a);
+ checkIsFunc("activities", a, { f -> f.func });
}
(phase.intervals ?: []).forEach { i ->
- checkIsFunc("activities", i);
+ checkIsFunc("activities", i, { f -> f.func });
}
checkIsFunc("use", phase.use);
};