diff options
author | ubq323 <ubq323@ubq323.website> | 2024-04-02 04:10:38 +0100 |
---|---|---|
committer | ubq323 <ubq323@ubq323.website> | 2024-04-02 04:10:38 +0100 |
commit | 537fbf9dbddfe913b1089848a9e88d8b703e4dcf (patch) | |
tree | 1793a622e5954ae88aaab40b5ebdcba35c64734a | |
parent | d8f475917f054adfcfc064b31e261516367c2d9b (diff) |
launch beescroll
-rw-r--r-- | beescroll.lua | 79 | ||||
-rw-r--r-- | verbs.txt | 1 |
2 files changed, 63 insertions, 17 deletions
diff --git a/beescroll.lua b/beescroll.lua index 0732400..0481c01 100644 --- a/beescroll.lua +++ b/beescroll.lua @@ -20,6 +20,14 @@ local verbs = read_lines("/verbs.txt") local function choice(list) return list[math.random(#list)] end +local function maybe(list, prob) + prob = prob or 0.5 + if math.random() < prob then + return choice(list) .. " " + else + return "" + end +end local function slow_write(m,s) for i = 1,#s do @@ -28,28 +36,67 @@ local function slow_write(m,s) end end -local function slow_write_f(m, t) - for _,val in ipairs(t) do - if type(val) == "string" then - slow_write(m,val) - else - m.setTextColor(val) +local function f_write(mon, tab, fn) + for _,val in ipairs(tab) do + if type(val) == "string" then fn(mon, val) + elseif type(val) == "number" then mon.setTextColor(val) + else f_write(mon, val, fn) end end end -local function write_f(m,t) - for _,val in ipairs(t) do - if type(val) == "string" then - m.write(val) - else - m.setTextColor(val) - end - end +local function f_write_fast(mon, tab) + f_write(mon, tab, function(mon, str) mon.write(str) end) +end +local function f_write_slow(mon, tab) + f_write(mon, tab, function(mon, str) slow_write(mon, str) end) end local norm_color = colors.gray + +local urgent = { "URGENT", "WARNING", "ALERT", "CRITICAL", "BREAKING" } +local orgs = {"Council", "Committee", "Board" } +local orgtype = { "Executive", "Leadership", "Management" } +local function pretitle() + local out = "" + while math.random() < 0.25 do out = choice{"Acting","Provisional","Provisional"} .. " " .. out end + return out +end + +local function beecount() + if math.random() < 0.4 then return {"all bees ", norm_color} end + local n = ("%4d"):format(math.random(9999)) + return {n, " bees ", norm_color} +end + +local function timeframe() + return choice { + "the end of the day", + ("%02d:00 tomorrow"):format(math.random(23)), + "next "..choice{"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"}, + } +end + +local function news_item() + return { + " ", colors.red, choice(urgent), norm_color, ": ", + "The ", choice{colors.red, colors.blue, colors.green}, pretitle(), choice(orgtype), " ", choice(orgs), + norm_color, " has ", choice { + -- the council has condemned all bees for [being/having been] boiled [illegally/without a permit/behind schedule] + { "condemned ", beecount(), "for ", choice{"being","having been"}, " ", colors.blue, choice(verbs), + norm_color, choice{"illegally","without a permit","behind schedule"} }, + -- the council has decreed that 1234 bees shall be skewed by next tuesday + { "decreed that ", beecount(), "shall be ", colors.orange, choice(verbs), + norm_color, " by ", timeframe() }, + -- the council has scheduled 9998 bees to be translated by next thursday + { "scheduled ", beecount(), "to be ", colors.brown, choice(verbs), + norm_color, " by ", timeframe() }, + }, norm_color, "." } + end + + + local function make_entry() return { choice{colors.yellow, colors.red, colors.cyan}, @@ -65,12 +112,12 @@ end for _ = 1,H do m.scroll(1) m.setCursorPos(1,H) - write_f(m,make_entry()) + f_write_fast(m,make_entry()) end while true do m.scroll(1) m.setCursorPos(1,H) - slow_write_f(m, make_entry()) + f_write_slow(m, news_item()) os.sleep(math.random(5,100)/10) end @@ -132,4 +132,3 @@ enumerated rounded composited primed - |