diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2019-06-26 19:27:58 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2019-06-26 19:27:58 +0100 |
commit | 9d9fa892e8a1b0bd6fb089dc0acc2efb3b8fbeac (patch) | |
tree | 13d0456cc2e65edc2465f30d5f768ef277e76346 /scripts | |
parent | Support post load module callback for late setup (diff) | |
download | toy-9d9fa892e8a1b0bd6fb089dc0acc2efb3b8fbeac.zip |
Execute postLoad right before main loop as moduleSetup
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/toy.groovy | 23 |
1 files 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(); |