Advertisement
guitarplayer616

EventViewer

Jun 23rd, 2016
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.01 KB | None | 0 0
  1. function switchColors()
  2.   local alphabet = {"a","b","c","d","e","f"}
  3.   for i,v in pairs(colors) do
  4.     if tonumber(v) then
  5.       res = math.log(v)/math.log(2)
  6.       if res > 9 then
  7.         res = alphabet[res-9]
  8.       end
  9.       colors[i] = tostring(res)
  10.     end
  11.   end
  12. end
  13.  
  14. function draw(str,xPos,yPos,txtcol,bakcol)
  15.   local str = tostring(str) or ""
  16.   local txtcol = txtcol or colors.white
  17.   local bakcol = bakcol or colors.black
  18.   if xPos and yPos then
  19.     term.setCursorPos(xPos, yPos)
  20.   end
  21.   if term.blit then
  22.     term.blit(str,string.rep(txtcol,#str),string.rep(bakcol,#str))
  23.   else
  24.     term.setBackgroundColor(bakcol)
  25.     term.setTextColor(txtcol)
  26.     term.write(str)
  27.   end
  28. end
  29.  
  30. if term.blit then
  31.     switchColors()
  32. else
  33.     os.loadAPI(shell.resolve("rom/apis/colors"))
  34. end
  35.  
  36. while true do
  37.     local events = {coroutine.yield()}
  38.     term.clear()
  39.     draw("EVENTS",1,1,colors.green)
  40.     for i = 1,#events do
  41.       draw(tostring(i).."."..tostring(events[i]),1,i+1,colors.yellow)
  42.     end
  43. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement