SHARE
TWEET
test
a guest
Jan 29th, 2018
51
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- local types = peripheral.getNames()
- local iPass = "6420"
- --ocal iPass = ""
- 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
- local function drawKeypad()
- write(5,1," ",colors.white,colors.gray)
- write(5,2," ",colors.white,colors.gray)
- ----------------------------------
- write(6,2,"1",colors.white,colors.lightGray)
- write(8,2,"2",colors.white,colors.lightGray)
- write(10,2,"3",colors.white,colors.lightGray)
- ----------------------------------
- write(5,3," ",colors.white,colors.gray)
- write(5,4," ",colors.white,colors.gray)
- ----------------------------------
- write(6,4,"4",colors.white,colors.lightGray)
- write(8,4,"5",colors.white,colors.lightGray)
- write(10,4,"6",colors.white,colors.lightGray)
- ----------------------------------
- write(5,5," ",colors.white,colors.gray)
- write(5,6," ",colors.white,colors.gray)
- ----------------------------------
- write(6,6,"7",colors.white,colors.lightGray)
- write(8,6,"8",colors.white,colors.lightGray)
- write(10,6,"9",colors.white,colors.lightGray)
- ----------------------------------
- write(5,7," ",colors.white,colors.gray)
- write(5,8," ",colors.white,colors.gray)
- ----------------------------------
- write(6,8,"C",colors.white,colors.lightGray)
- write(8,8,"0",colors.white,colors.lightGray)
- write(10,8,"E",colors.white,colors.lightGray)
- ----------------------------------
- write(5 ,9," ",colors.white,colors.gray)
- write(5 ,10," ",colors.white,colors.gray)
- end
- clear(colors.gray)
- drawMenu()
- local aa, ab, ac, ad = "", "", "", ""
- local pass = ''
- local setPEnter = 0
- local setP = 0
- while true do
- local event,button,X,Y = os.pullEvent()
- if event == "monitor_touch" then
- drawMenu()
- drawKeypad()
- -- you set setP to 0 here
- -- setP = 0
- -- local setPEnter = 0
- -----------------------------------
- -- so it can only be 0 here
- if setP == 0 then
- if X == 6 and Y == 2 then --1
- pass = pass .. '1'
- elseif X == 8 and Y == 2 then -- 2
- pass = pass .. '2'
- elseif X == 10 and Y == 2 then -- 3
- pass = pass .. '3'
- elseif X == 6 and Y == 4 then -- 4
- pass = pass .. '4'
- elseif X == 8 and Y == 4 then -- 5
- pass = pass .. '5'
- elseif X == 10 and Y == 4 then -- 6
- pass = pass .. '6'
- elseif X == 6 and Y == 6 then -- 7
- pass = pass .. '7'
- elseif X == 8 and Y == 6 then -- 8
- pass = pass .. '8'
- elseif X == 10 and Y == 6 then -- 9
- pass = pass .. '9'
- elseif X == 6 and Y == 8 then -- Clear
- pass = ''
- elseif X == 8 and Y == 8 then -- 0
- pass = pass .. '0'
- elseif X == 10 and Y == 8 then -- Enter
- print(pass)
- print(setP)
- if iPass == pass then
- setP = 1
- drawMenu()
- else
- clear(colors.red)
- os.sleep(.5)
- clear(colors.gray)
- drawKeypad()
- end
- pass = ''
- end
- else
- print('set p = 1')
- print('going to floor')
- setP = 0
- -----------------------------------
- local floorNo = math.floor(Y / 2)
- local floor = floors[floorNo]
- if floor then
- drawMenu()
- write(5, floorNo * 2, floor.name, colors.lime, colors.gray)
- local ri = 'redstone_integrator_' .. floor.ri
- peripheral.call(ri, "setOutput", 'south', true)
- os.sleep(.5)
- peripheral.call(ri, "setOutput", 'south', false)
- end
- -----------------------------------
- --end
- end
- end
- print(pass)
- end
RAW Paste Data

