From 8f048a1acf35505c33560dcdacdbdf332600e920 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 23 Jun 2019 21:09:55 +0100 Subject: Extract release requests into play module --- scripts/toy.groovy | 3 --- scripts/toy/play.groovy | 5 +++++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/toy.groovy b/scripts/toy.groovy index 8ad391b..93d231b 100644 --- a/scripts/toy.groovy +++ b/scripts/toy.groovy @@ -392,9 +392,6 @@ return new Object() { def opts = requestables.values().toList().findAll { it -> !it.cond || it.cond() }; - TOYTOYS.findAll { stateIs(it) }.each { - opts.push([ lbl: "May I be un-$it".toString(), act: { requestRelease() }, arg: it ]); - }; opts.push([ lbl: "Back", act: null ]); def opt = getSelectedValue(stateIs("DEBUG") ? DOMME : "Yes, toy?", opts.collect { it.lbl }); def act = opts[opt].act; diff --git a/scripts/toy/play.groovy b/scripts/toy/play.groovy index a383bef..bc0c954 100644 --- a/scripts/toy/play.groovy +++ b/scripts/toy/play.groovy @@ -318,5 +318,10 @@ toy.addNamedEvent(PLAY, { name, arg, schedTime, rt -> toy.playEvent(rt, arg) }); toy.addNamedEvent(RELEASEFROM, { name, arg, schedTime, rt -> toy.releaseFrom(rt, arg, name) }); toy.addNamedEvent(REDRESS, { name, arg, schedTime, rt -> toy.redress(rt) }); + toy.TOYTOYS.each { toyState -> + toy.addRequestable("un$toyState".toString(), "May I be un-$toyState".toString(), + { toy.requestRelease(toyState) }, + { toy.stateIs(toyState) }) + }; toy.playSchedule(); } -- cgit v1.2.3