guitarplayer616

SecretProject

Jun 23rd, 2016
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.36 KB | None | 0 0
  1. local blit = false
  2. local timers = {}
  3. clickCount = 0
  4.  
  5. function switchColors()
  6.   local alphabet = {"a","b","c","d","e","f"}
  7.  
  8.   for i,v in pairs(colors) do
  9.     if tonumber(v) then
  10.         --print(v)
  11.       res = math.log(v)/math.log(2)
  12.       if res > 9 then
  13.         res = alphabet[res-9]
  14.       end
  15.       colors[i] = tostring(res)
  16.     end
  17.   end
  18. end
  19.  
  20. function checkEvents()
  21.   for i,v in pairs(events) do
  22.     print(i," ",v)
  23.   end
  24. end
  25.  
  26. function draw(str,xPos,yPos,txtcol,bakcol)
  27.   local str = tostring(str) or ""
  28.   local txtcol = txtcol or colors.white
  29.   local bakcol = bakcol or colors.black
  30.   --local xPos,yPos = xPos,yPos or term.getCursorPos()
  31.   term.setCursorPos(xPos, yPos)
  32.   if blit then
  33.     term.blit(str,string.rep(txtcol,#str),string.rep(bakcol,#str))
  34.   else
  35.     term.setBackgroundColor(bakcol)
  36.     term.setTextColor(txtcol)
  37.     term.write(str)
  38.   end
  39. end
  40.  
  41. timers.gametick = os.startTimer(0)
  42. if blit then
  43.   switchColors()
  44. else
  45.   colors = colours --temporary solution
  46. end
  47.  
  48. term.clear()
  49. term.setCursorPos(1,1)
  50.  
  51. while true do
  52.     local events = {coroutine.yield()}
  53.     if events[1] == "timer" then
  54.         if events[2] == timers.gametick then
  55.             draw(clickCount,1,1,colors.yellow)
  56.             timers.gametick = os.startTimer(0)
  57.         end
  58.     elseif events[1] == "mouse_click" then
  59.         clickCount = clickCount + 1
  60.     elseif events[1] == "key" then
  61.         break
  62.     end
  63. end
Add Comment
Please, Sign In to add comment