From 6c20a8daf94307b87a0861c9e143c74cc4aca711 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 6 Jul 2019 14:59:29 +0100 Subject: Make the activityList of objects --- scripts/toy.groovy | 4 +++- scripts/toy/debug.groovy | 2 +- scripts/toy/play.groovy | 10 +++++----- 3 files changed, 9 insertions(+), 7 deletions(-) (limited to 'scripts') 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); }; -- cgit v1.2.3