Advertisement
Ginga2221

testInterfaceOpti

Dec 3rd, 2022
735
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.86 KB | None | 0 0
  1. local xinit, yinit, deltax, deltay, gap = 1, 1, 29, 2, 2
  2. local Texts = {"C","1","2","3","4"}
  3.  
  4. local color_init = colors.gray
  5. local color_change = colors.green
  6.  
  7. function traceBoite(n, color)
  8.     paintutils.drawFilledBox(xinit, yinit + (n-1)*(deltay  + gap), xinit+deltax, yinit + (n-1)*(deltay  + gap) + deltay, color)
  9.     term.setCursorPos(16,yinit + (n-1)*(deltay  + gap) + 1)
  10.     term.write(Texts[n])
  11. end
  12.  
  13.  
  14. function init()
  15. c = color_init
  16.  
  17. for i=1,5 do
  18.     traceBoite(i, c)
  19. end
  20.  
  21. end
  22.  
  23.  
  24. term.clear()
  25. init()
  26.  
  27.  
  28. while true do
  29.  
  30. local event, button, x, y =  os.pullEvent("mouse_click")
  31.  
  32. if (x >= xinit) and (x <= xinit+deltax) then
  33.     for i=1,5 do
  34.         if (y >= yinit + (i-1)*(deltay  + gap) ) and ( y <= yinit + (i-1)*(deltay  + gap) + deltay ) then
  35.             traceBoite(i,color_change)
  36.             target_stage = i
  37.             os.sleep(1)
  38.             traceBoite(i,color_init)
  39.         end
  40.     end
  41. end
  42.  
  43. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement