Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mon = peripheral.wrap("top")
- for a,b in pairs(rs.getSides()) do
- if peripheral.getType(b) == "ender_chest" then
- chest = peripheral.wrap(b)
- b1,b2,b3 = chest.getColors()
- break
- end
- end
- function monClear()
- mon.clear()
- mon.setCursorPos(1,1)
- end
- function drawButtons()
- for i= 1, y do
- for k=1,x/3+1 do
- mon.setCursorPos(k,i)
- mon.setBackgroundColor(b1)
- mon.write(" ")
- end
- end
- for i=1, y do
- for k=x/3+1,x/3*2+2 do
- mon.setCursorPos(k,i)
- mon.setBackgroundColor(b2)
- mon.write(" ")
- end
- end
- for i=1, y do
- for k=x/3*2+2, x+2 do
- mon.setCursorPos(k,i)
- mon.setBackgroundColor(b3)
- mon.write(" ")
- end
- end
- for i=1, y do
- mon.setBackgroundColor(colors.black)
- mon.setCursorPos(x/3+1,i)
- mon.write(" ")
- end
- for i=1, y do
- mon.setBackgroundColor(colors.black)
- mon.setCursorPos(x/3*2+1,i)
- mon.write(" ")
- end
- end
- while true do
- x,y = mon.getSize()
- event, param1, param2, param3 = os.pullEvent()
- if event == "peripheral" and peripheral.getType(param1) == "ender_chest" then
- chest = peripheral.wrap(param1)
- b1,b2,b3 = chest.getColors()
- mon.setBackgroundColor(colors.black)
- monClear()
- drawButtons()
- elseif event == "peripheral_detach" then
- monClear()
- elseif event == "monitor_touch" then
- if param2 < x/3 then
- if b1 == 32768 then
- b1=1
- else
- b1 = b1*2
- end
- elseif param2 > x/3 and param2 < x/3*2 then
- if b2 == 32768 then
- b2=1
- else
- b2 = b2*2
- end
- elseif param2 >x/3*2 then
- if b3 == 32768 then
- b3=1
- else
- b3 = b3*2
- end
- end
- chest.setColors(b1,b2,b3)
- drawButtons()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement