function putColors()
if type == "ender_chest" then
chest.setColors(b1,b2,b3)
elseif type == "ender_tank" then
chest.setColors(b3,b2,b1)
end
end
function takeColors()
if type == "ender_chest" then
b1,b2,b3 = chest.getColors()
elseif type == "ender_tank" then
b3,b2,b1 = chest.getColors()
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
mon = peripheral.wrap("top")
x,y = mon.getSize()
for a,b in pairs(rs.getSides()) do
if peripheral.getType(b) == "ender_chest" or peripheral.getType(b) == "ender_tank" then
type = peripheral.getType(b)
chest = peripheral.wrap(b)
takeColors()
drawButtons()
break
end
end
while true do
event, param1, param2, param3 = os.pullEvent()
if event == "peripheral" and (peripheral.getType(param1) == "ender_chest" or peripheral.getType(param1) == "ender_tank") then
chest = peripheral.wrap(param1)
type = peripheral.getType(param1)
takeColors()
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
putColors()
drawButtons()
end
end
Comments