From 487813b6de6d17649cce562d6a0b007afdc07427 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 23 Jun 2019 20:52:20 +0100 Subject: Conditional requestables and move clothing request --- scripts/toy.groovy | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'scripts/toy.groovy') diff --git a/scripts/toy.groovy b/scripts/toy.groovy index 5c3ab02..16df507 100644 --- a/scripts/toy.groovy +++ b/scripts/toy.groovy @@ -341,8 +341,8 @@ return new Object() { def requestables = [ faq: [ lbl: "FAQ (webpage)", act: showFaq ], ]; - final addRequestable = { String name, String label, func -> - requestables[name] = [lbl: label, act: func]; + final addRequestable = { String name, String label, func, cond = null -> + requestables[name] = [lbl: label, act: func, cond: cond]; }; final removeRequestable = { String name -> requestables.remove(name); @@ -417,15 +417,14 @@ return new Object() { final waitTime = Math.min(cycleTime, e.event.time - getTime()); final clickTime = showButton("Please, ${dommeTitle()}?", waitTime); if (clickTime < waitTime) { - def opts = requestables.values().toList(); + def opts = requestables.values().toList().findAll { + it -> !it.cond || it.cond() + }; if (stateIs("DEBUG")) { opts.push([ lbl: "Status", act: setupShowState ]); opts.push([ lbl: "Play", act: { playEvent() }, arg: true ]); opts.push([ lbl: "Activity", act: playActivity ]); } - if (stateIs(NAKED)) { - opts.push([ lbl: "May I wear clothes", act: { requestClothes() } ]); - } TOYTOYS.findAll { stateIs(it) }.each { opts.push([ lbl: "May I be un-$it".toString(), act: { requestRelease() }, arg: it ]); }; -- cgit v1.2.3