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 write_str(m,s,slow) local W,H = m.getSize() for i = 1,#s do m.write(s:sub(i,i)) if slow then os.sleep(0.1) end if (m.getCursorPos()) == W then m.scroll(1) m.setCursorPos(1,H) end end end local function f_write(mon, tab, slow) for _,val in ipairs(tab) do if type(val) == "string" then write_str(mon, val, slow) elseif type(val) == "number" then mon.setTextColor(val) else f_write(mon, val, slow) end end end local norm_color = colors.gray local urgent = { "URGENT", "WARNING", "ALERT", "CRITICAL", "BREAKING" } local orgs = {"Council", "Committee", "Board", "Division", "Bureau", "Team", "Task Force", "Secretariat" } local orgtype = { "Executive", "Leadership", "Management", "Control", "Command", "Planning" } local function pretitle() local out = "" while math.random() < 0.5 do out = choice{"Acting","Acting","Provisional","Provisional","Provisional","Strategic"} .. " " .. out end return out end local function beecount() if math.random() < 0.4 then return {colors.yellow, "all bees ", norm_color} end local n = ("%4d"):format(math.random(9999)) return {colors.yellow, 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() local council = {choice{colors.red, colors.blue, colors.green}, pretitle(), choice(orgtype), " ", choice(orgs), norm_color} return { colors.red, choice(urgent), norm_color, ": ", choice { -- the council has condemned all bees for [being/having been] boiled [illegally/without a permit/behind schedule] { "The ", council, " has 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 { "The ", council, " has 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 { "The ", council, " has scheduled ", beecount(), "to be ", colors.brown, choice(verbs), norm_color, " by ", timeframe() }, -- 9998 bees were exploded [mistakenly/in error/by accident/by our enemies]. the council has [ordered/decreed/decided] that 1234 bees will be boiled [instead/as compensation/as well] { beecount(), "were ", colors.magenta, choice(verbs), norm_color, " ", choice{"mistakenly","in error","by accident","by our enemies"}, ". The ", council, " has ", choice{"ordered","decreed","decided"}, " that ", beecount(), "will be ", colors.pink, choice(verbs), norm_color, " ", choice{"instead","as compensation","as well","or else"}}, }, norm_color, "." } end local function regular_item() 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 local function some_item() if math.random()<0.05 then return news_item() else return regular_item() end end for _ = 1,H do m.scroll(1) m.setCursorPos(1,H) f_write(m,some_item(), false) end while true do m.scroll(1) m.setCursorPos(1,H) f_write(m, some_item(), true) os.sleep(math.random(5,100)/10) end