Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local mon = peripheral.wrap("monitor_59")
- local eChestSide = "right"
- function sleepASec()
- sleep(1)
- end
- function touchPull()
- event, side, x, y = os.pullEvent("monitor_touch")
- print(x, ",", y)
- if (not (math.fmod(x-1,6) > 4)) then
- if (not (y > 16)) then
- slot = (x-math.fmod(x,6))/6
- print("Slot ", slot)
- if (not (chest == nil)) then
- a,b,c = chest.getColors()
- if (slot == 0) then a = math.pow(2, y-1) end
- if (slot == 1) then b = math.pow(2, y-1) end
- if (slot == 2) then c = math.pow(2, y-1) end
- chest.setColors(a,b,c)
- end
- end
- end
- end
- function drawColor(x, y, color)
- mon.setBackgroundColor(color)
- mon.setTextColor(color)
- mon.setCursorPos(x,y)
- mon.write(" ")
- mon.setBackgroundColor(colors.black)
- mon.setTextColor(colors.white)
- end
- while (true) do
- mon.clear()
- mon.setCursorPos(1,1)
- chest = peripheral.wrap(eChestSide)
- if (chest == nil) then
- mon.write("Place the chest")
- mon.setCursorPos(1,2)
- mon.write("on the " .. eChestSide)
- mon.setCursorPos(1,3)
- mon.write("of the computer")
- sleep(1)
- else
- if (chest.getColors == nil) then
- mon.write("That's not an")
- mon.setCursorPos(1,2)
- mon.write("ender chest!")
- sleep(1)
- else
- for x = 1,3,1 do
- for y = 1,16,1 do
- drawColor(x*7-6, y, math.pow(2, y-1))
- drawColor(x*7-5, y, math.pow(2, y-1))
- drawColor(x*7-4, y, math.pow(2, y-1))
- drawColor(x*7-3, y, math.pow(2, y-1))
- end
- end
- if (parallel.waitForAny(sleepASec, touchPull) == 2) then
- print("Touch!")
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement