Advertisement
Wyvern67

EnderChestFreq properly formatted

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