Advertisement
guitarplayer616

ReturnCoords

Jun 29th, 2015
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.76 KB | None | 0 0
  1. shell.run("clear")
  2. term.setBackgroundColor(colors.orange)
  3. local h = fs.open("coords",'w')
  4. local lastx, lasty
  5.  
  6.  
  7. while true do
  8.   local e = {os.pullEvent()}
  9.   if e[1] == "mouse_click" then
  10.     if e[2] == 1 then
  11.       paintutils.drawPixel(e[3],e[4])
  12.       h.writeLine("paintutils.drawPixel("..tostring(e[3])..', '..tostring(e[4])..")")
  13.       h.flush()
  14.     elseif e[2] == 2 then
  15.       if lastx and lasty then
  16.         paintutils.drawFilledBox(lastx,lasty,e[3],e[4])
  17.         h.writeLine("paintutils.drawFilledBox("..tostring(lastx)..', '..tostring(lasty)..', '..tostring(e[3])..', '..tostring(e[4])..")")
  18.         h.flush()
  19.         lastx,lasty = nil,nil
  20.       else
  21.         lastx,lasty = e[3],e[4]
  22.         paintutils.drawPixel(e[3],e[4])
  23.       end
  24.     end
  25.   end
  26. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement