SHARE
TWEET
elevator
a guest
Jan 29th, 2018
67
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- local types = peripheral.getNames()
- local mons = { }
- for _,m in pairs(types) do
- if peripheral.getType(m) == 'monitor' then
- table.insert(mons, peripheral.wrap(m))
- end
- end
- local floors = {
- { name = 'Ndiniz ', ri = 7 },
- { name = 'Bedroom', ri = 8 },
- { name = 'Storage', ri = 9 },
- { name = 'Ground ', ri = 6 },
- { name = 'Smeltery', ri = 5 },
- }
- local function clear(bg)
- for _, monitor in pairs(mons) do
- monitor.setBackgroundColor(bg)
- monitor.setTextScale(.5)
- monitor.clear()
- end
- end
- local function write(x, y, text, fg, bg)
- for _, monitor in pairs(mons) do
- monitor.setTextColor(fg)
- monitor.setBackgroundColor(bg)
- monitor.setCursorPos(x, y)
- monitor.write(text)
- end
- end
- local function drawMenu()
- for i, floor in ipairs(floors) do
- write(5, i*2, floor.name, colors.white, colors.gray)
- end
- end
- clear(colors.gray)
- drawMenu()
- while true do
- local event,button,X,Y = os.pullEvent()
- if event == "monitor_touch" then
- drawMenu()
- local floorNo = math.floor(Y / 2)
- local floor = floors[floorNo]
- if floor then
- write(5, floorNo * 2, floor.name, colors.white, colors.lime)
- local ri = 'redstone_integrator_' .. floor.ri
- peripheral.call(ri, "setOutput", 'south', true)
- os.sleep(.5)
- peripheral.call(ri, "setOutput", 'south', false)
- end
- end
- end
RAW Paste Data

