local m = peripheral.find"monitor" m.setTextScale(0.5) local W,H = m.getSize() local function read_lines(fname) local out = {} local fp = assert(fs.open(fname,"r")) repeat local line = fp.readLine() table.insert(out, line) until not line fp.close() return out end local cities = read_lines("/cities.txt") 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 m.write(s:sub(i,i)) os.sleep(0.1) end end 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 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}, string.format("%5d",math.random(0,99999)), norm_color, " bees ", choice{"have been ","were "}, choice{colors.lime, colors.lightBlue, colors.pink}, choice(verbs), norm_color, " in ", choice{colors.orange, colors.yellow, colors.purple}, choice(cities), norm_color, "."} end for _ = 1,H do m.scroll(1) m.setCursorPos(1,H) f_write_fast(m,make_entry()) end while true do m.scroll(1) m.setCursorPos(1,H) f_write_slow(m, news_item()) os.sleep(math.random(5,100)/10) end