Advertisement
TriiNoxYs

[ComputerCraft] Paint (Advenced Computer)

Jul 6th, 2014
421
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.63 KB | None | 0 0
  1. -- Ce programme [cree pas TriiNoxYs] est libre de droits ;)
  2. -- Si vous le modifier/publiez/presentez/etc, SVP pensez a citer son auteur.
  3. -- Consultez tout les autres scripts de TriiNoxys sur le lien pastein.com/benjfn71
  4. -- Ou sur la page de TriiNoxYs: pastebin.com/u/TriiNoxYs
  5.  
  6. -- COMMANDES:
  7. -- Molette de souris: Selectionner la couleur
  8. -- Clic Gauche: Colorier
  9. -- Clic Droit: Copier une couleur
  10. -- C: Tout effacer
  11. -- V: Colorier de la couleur selectionner
  12. -- T: Fermer
  13.  
  14. function colorScreen(color)
  15.   for a = 0,59 do
  16.      for b = 0,19 do
  17.          paintutils.drawPixel(a,b,color)
  18.     end
  19.   end
  20. end
  21. function setScreen(color)
  22.   local s = {}
  23.   for i =1,51 do
  24.     s[i] = {}
  25.     for j =1,19 do
  26.       s[i][j] = color
  27.     end
  28.   end
  29.   return s
  30. end
  31. shell.run("clear")
  32. local screen = setScreen(16)
  33. local color = {1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768}
  34. local i = 1
  35. while true do
  36.   paintutils.drawPixel(1,1,color[i])
  37.   event,value,x,y = os.pullEvent()
  38.   if event == "mouse_click" or event == "mouse_drag" then
  39.     if value == 1 then
  40.       screen[x][y] = i
  41.       paintutils.drawPixel(x,y,color[i])
  42.     elseif value == 2 then
  43.       i = screen[x][y]
  44.     end
  45.   elseif event == "mouse_scroll" then
  46.     i = i + value
  47.     if i < 1 then i = 1
  48.     elseif i > 16 then i = 16 end
  49.   elseif event == "key" then
  50.     if value == 46 then -- Lettre C
  51.         colorScreen(32768)
  52.         screen = setScreen(16)
  53.     elseif value == 47 then -- Lettre V
  54.         colorScreen(color[i])
  55.         screen = setScreen(i)
  56.     elseif value == 20 then --Lettre T
  57.       break
  58.     end
  59.   end
  60. end
  61. colorScreen(32768)
  62. shell.run("clear")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement