From 9d9fa892e8a1b0bd6fb089dc0acc2efb3b8fbeac Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Wed, 26 Jun 2019 19:27:58 +0100 Subject: Execute postLoad right before main loop as moduleSetup --- scripts/toy.groovy | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/scripts/toy.groovy b/scripts/toy.groovy index 1d8aa03..d1bd099 100644 --- a/scripts/toy.groovy +++ b/scripts/toy.groovy @@ -60,26 +60,12 @@ return new Object() { .sum() }; def loadModules = { toy -> - final postLoad = [:]; new File("$DATAFOLDER/scripts/toy") .listFiles() - .each({s -> - if (stateIs("DEBUG")) { - show("Loading ${s.name}..."); - } - postLoad[s.name] = Eval.me(s.text)(toy); - }); - postLoad - .findAll { s, p -> p } - .each { s, p -> - if (stateIs("DEBUG")) { - show("Post load $s..."); - } - p(); - }; - if (stateIs("DEBUG")) { - show("All modules loaded"); + .collect { s -> + Eval.me(s.text)(toy); } + .findAll { }; }; // Utils @@ -340,7 +326,7 @@ return new Object() { setDefault("toy.owner", "ancilla"); OWNER = loadString("toy.owner"); loadDomme(OWNER); - loadModules(this); + def moduleSetup = loadModules(this); def getDayNum = { Math.floorDiv(getTime() - localTimeOffset() - 14400, 86400) }; def getAvail = { dayNum -> loadInteger("toy.availability.$dayNum") ?: 0 }; def addAvail = { amount -> @@ -362,6 +348,7 @@ return new Object() { setDefault("toy.punishment", 0); execEvents(false); tidyAvail(); + moduleSetup.each { p -> p() }; final cycleTime = 60; showLounge(); -- cgit v1.2.3