theeboris

painttools

Dec 30th, 2013
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.85 KB | None | 0 0
  1. --Checks the screensize
  2. screenx, screeny = term.getSize()
  3.  
  4. function getVersion()
  5.     return "0.4"
  6. end
  7.  
  8. function fill(x, x2, y, y2, colour)
  9.     filling = true
  10.     y2 = y2+1
  11.     count = 1+y2-y
  12.     while filling do
  13.         paintutils.drawLine(x,y,x2,y,colour)
  14.         y2 = y2 -1
  15.         y = y2
  16.         count = count-1
  17.         if count == 0 then
  18.             filling = false
  19.         end
  20.     end
  21. end
  22.  
  23. function menu(x, x2, y, y2, colour, colour2)
  24.     x3 = x + 1
  25.     x4 = x2 - 1
  26.     y3 = y + 1
  27.     y4 = y2 - 1
  28.     paintutils.drawLine(x, y, x2, y, colour)
  29.     paintutils.drawLine(x, y2, x2, y2, colour)
  30.     paintutils.drawLine(x, y, x, y2, colour)
  31.     paintutils.drawLine(x2, y, x2, y2, colour)
  32.     fill(x3, x4, y3, y4, colour2)
  33. end
  34.  
  35. function colourpick(x, y, failcol)
  36.     ymax = screeny - 6
  37.     xmax = screenx - 6
  38.     if y >= ymax then
  39.         y = ymax
  40.     end
  41.     if x >= screenx then
  42.         x = xmax
  43.     end
  44.     if x < 1 then
  45.         x = 1
  46.     end
  47.     if y < 1 then
  48.         y = 1
  49.     end
  50.     paintutils.drawImage(paintutils.loadImage("img/colourpick"), x, y)
  51.     event, button, XS, YS = os.pullEvent("mouse_click")
  52.     XSYS = XS..","..YS
  53.     if YS == y+1 and XS == x+1 then
  54.         return 32768
  55.     elseif YS == y+1 and XS == x+2 then
  56.         return 16384
  57.     elseif YS == y+1 and XS == x+3 then
  58.         return 8192
  59.     elseif YS == y+1 and XS == x+4 then
  60.         return 4096
  61.     elseif YS == y+2 and XS == x+1 then
  62.         return 2048
  63.     elseif YS == y+2 and XS == x+2 then
  64.         return 1024
  65.     elseif YS == y+2 and XS == x+3 then
  66.         return 512
  67.     elseif YS == y+2 and XS == x+4 then
  68.         return 256
  69.     elseif YS == y+3 and XS == x+1 then
  70.         return 128
  71.     elseif YS == y+3 and XS == x+2 then
  72.         return 64
  73.     elseif YS == y+3 and XS == x+3 then
  74.         return 32
  75.     elseif YS == y+3 and XS == x+4 then
  76.         return 16
  77.     elseif YS == y+4 and XS == x+1 then
  78.         return 8
  79.     elseif YS == y+4 and XS == x+2 then
  80.         return 4
  81.     elseif YS == y+4 and XS == x+3 then
  82.         return 2
  83.     elseif YS == y+4 and XS == x+4 then
  84.         return 1
  85.     else
  86.         return failcol
  87.     end
  88. end
Advertisement
Add Comment
Please, Sign In to add comment