LewdLamb

Untitled

Jul 6th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.09 KB | None | 0 0
  1. function putColors()
  2.   if type == "ender_chest" then
  3.      chest.setColors(b1,b2,b3)
  4.   elseif type == "ender_tank" then
  5.      chest.setColors(b3,b2,b1)
  6.   end
  7. end
  8.  
  9. function takeColors()
  10.   if type == "ender_chest" then
  11.     b1,b2,b3 = chest.getColors()
  12.   elseif type == "ender_tank" then
  13.     b3,b2,b1 = chest.getColors()
  14.   end
  15. end
  16.  
  17. function monClear()
  18.   mon.clear()
  19.   mon.setCursorPos(1,1)
  20. end
  21.  
  22. function drawButtons()
  23. for i= 1, y do
  24.   for k=1,x/3+1 do
  25.     mon.setCursorPos(k,i)
  26.     mon.setBackgroundColor(b1)
  27.     mon.write(" ")
  28.   end
  29. end
  30. for i=1, y do
  31.   for k=x/3+1,x/3*2+2 do
  32.     mon.setCursorPos(k,i)
  33.     mon.setBackgroundColor(b2)
  34.     mon.write(" ")
  35.   end
  36. end
  37. for i=1, y do
  38.   for k=x/3*2+2, x+2 do
  39.     mon.setCursorPos(k,i)
  40.     mon.setBackgroundColor(b3)
  41.     mon.write(" ")
  42.   end
  43. end
  44. for i=1, y do
  45.   mon.setBackgroundColor(colors.black)
  46.   mon.setCursorPos(x/3+1,i)
  47.   mon.write(" ")
  48. end
  49. for i=1, y do
  50.   mon.setBackgroundColor(colors.black)
  51.   mon.setCursorPos(x/3*2+1,i)
  52.   mon.write(" ")
  53. end
  54. end
  55.  
  56. mon = peripheral.wrap("top")
  57. x,y = mon.getSize()
  58. for a,b in pairs(rs.getSides()) do
  59.   if peripheral.getType(b) == "ender_chest" or peripheral.getType(b) == "ender_tank" then
  60.    type = peripheral.getType(b)
  61.    chest = peripheral.wrap(b)
  62.    takeColors()
  63.    drawButtons()
  64.    break
  65.   end
  66. end
  67.  
  68. while true do
  69.   event, param1, param2, param3 = os.pullEvent()
  70.   if peripheral.getType(param1) == "ender_chest" then
  71.     chest = peripheral.wrap(param1)
  72.     type = peripheral.getType(param1)
  73.     takeColors()
  74.     mon.setBackgroundColor(colors.black)
  75.     monClear()
  76.     drawButtons()
  77.   elseif event == "peripheral_detach" then
  78.   monClear()
  79.   elseif event == "monitor_touch" then
  80.     if param2 < x/3 then
  81.       if b1 == 32768 then
  82.         b1=1
  83.       else
  84.         b1 = b1*2
  85.       end
  86.     elseif param2 > x/3 and param2 < x/3*2 then
  87.       if b2 == 32768 then
  88.         b2=1
  89.       else
  90.         b2 = b2*2
  91.       end
  92.     elseif param2 >x/3*2 then
  93.       if b3 == 32768 then
  94.         b3=1
  95.       else
  96.         b3 = b3*2
  97.       end
  98.     end
  99.   putColors()
  100.   drawButtons()
  101.   end
  102. end
Add Comment
Please, Sign In to add comment