diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2019-01-06 12:44:07 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2019-01-06 12:44:07 +0000 |
commit | 5efe8fddc7b4db3033e72dbdf577b77a856a0937 (patch) | |
tree | 8f3a30e333d597a7bbe6d6247dcaf7bb56a58a06 /scripts | |
parent | Ensure no sound escapes between activities (diff) | |
download | toy-5efe8fddc7b4db3033e72dbdf577b77a856a0937.zip |
Split out sentence composer
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/toy.groovy | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/scripts/toy.groovy b/scripts/toy.groovy index e927151..049ee56 100644 --- a/scripts/toy.groovy +++ b/scripts/toy.groovy @@ -238,11 +238,15 @@ def gagText = { t, p -> def showButtonG = { s, p, t = null -> return t != null ? showButton(gagText(s, p), t) : showButton(gagText(s, p)); }; +def compose = { texts -> + if (!texts || texts.isEmpty()) return null; + return texts.collect { + t -> t[getRandom(t.size())] + }.join(" ").capitalize(); +}; def present = { imageSpec, texts -> if (texts) { - show(texts.collect { - t -> t[getRandom(t.size())] - }.join(" ").capitalize()); + show(compose(texts)); } if (imageSpec) { return showImage(imageSpec); |