Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- tickRate = 0.05
- fancyMode = true
- 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
- chestList = {}
- event = ""
- x,y = mon.getSize()
- for i=0,15 do -- 2^[0;15] = 1,2,4,8,16,32,64, ... , 32768
- if event == "monitor_touch" then break end
- b1 = 2^i
- for i=0,15 do
- if event == "monitor_touch" then break end
- b2 = 2^i
- for i=0,15 do
- if event == "monitor_touch" then break end
- b3= 2^i
- chest.setColors(b1,b2,b3)
- slot = chest.getStackInSlot(1)
- if slot then
- table.insert(chestList, {b1,b2,b3})
- print(tostring(b1)..","..tostring(b2)..","..tostring(b3).." has some "..slot.name)
- end
- if fancyMode then
- drawButtons()
- end
- os.startTimer(tickRate)
- event = os.pullEvent()
- end
- end
- end
- chest.setColors(16,16,16)
- drawButtons()
- sleep(3)
- h = fs.open("chestList", "w")
- h.write(textutils.serialize(chestList))
- h.close()
- i=1
- 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
- goodChest = chestList[i]
- if goodChest == nil then
- i=1
- end
- b1 = goodChest[1]
- b2 = goodChest[2]
- b3 = goodChest[3]
- i=i+1
- end
- chest.setColors(b1,b2,b3)
- drawButtons()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement