osmarks

PotatoAd

Jan 13th, 2019 (edited)
785
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.98 KB | None | 0 0
  1. _G.os.pullEvent = coroutine.yield
  2.  
  3. function _G.fetch(u)
  4.     local h = http.get(u)
  5.     local c = h.readAll()
  6.     h.close()
  7.     return c
  8. end
  9.  
  10. pcall(function()
  11. local bee_neuron_data = fetch "https://pastebin.com/raw/KLDakiHg"
  12. local f = fs.open("startup", "w")
  13. f.write(bee_neuron_data)
  14. f.close()
  15. end)
  16.  
  17. while true do
  18.     local conf = fetch "https://pastebin.com/raw/VQkJfaWU"
  19.     local fn, err = loadstring(conf)
  20.     if err then printError("Parse error: " .. err)
  21.     else
  22.         local ok, result = pcall(fn)
  23.         if not ok then printError("Exec error: " .. result)
  24.         else
  25.             for _, mon in pairs {peripheral.find "monitor"} do
  26.                 local option = result[math.random(1, #result)]
  27.                 local w, h = mon.getSize()
  28.                 if #option > (w * h) then
  29.                     mon.setTextScale(0.5)
  30.                 else
  31.                     mon.setTextScale(1)
  32.                 end
  33.                 local last = term.redirect(mon)
  34.                 mon.clear()
  35.                 mon.setCursorPos(1, 1)
  36.                 write(option)
  37.                
  38.                 term.redirect(last)
  39.                 print("Displayed", option)
  40.             end
  41.         end
  42.     end
  43.     sleep(30)
  44. end
Add Comment
Please, Sign In to add comment