Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local blit = false
- local timers = {}
- clickCount = 0
- function switchColors()
- local alphabet = {"a","b","c","d","e","f"}
- for i,v in pairs(colors) do
- if tonumber(v) then
- --print(v)
- res = math.log(v)/math.log(2)
- if res > 9 then
- res = alphabet[res-9]
- end
- colors[i] = tostring(res)
- end
- end
- end
- function checkEvents()
- for i,v in pairs(events) do
- print(i," ",v)
- end
- end
- function draw(str,xPos,yPos,txtcol,bakcol)
- local str = tostring(str) or ""
- local txtcol = txtcol or colors.white
- local bakcol = bakcol or colors.black
- --local xPos,yPos = xPos,yPos or term.getCursorPos()
- term.setCursorPos(xPos, yPos)
- if blit then
- term.blit(str,string.rep(txtcol,#str),string.rep(bakcol,#str))
- else
- term.setBackgroundColor(bakcol)
- term.setTextColor(txtcol)
- term.write(str)
- end
- end
- timers.gametick = os.startTimer(0)
- if blit then
- switchColors()
- else
- colors = colours --temporary solution
- end
- term.clear()
- term.setCursorPos(1,1)
- while true do
- local events = {coroutine.yield()}
- if events[1] == "timer" then
- if events[2] == timers.gametick then
- draw(clickCount,1,1,colors.yellow)
- timers.gametick = os.startTimer(0)
- end
- elseif events[1] == "mouse_click" then
- clickCount = clickCount + 1
- elseif events[1] == "key" then
- break
- end
- end
Add Comment
Please, Sign In to add comment