Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local redstoneSide="bottom"
- local buttons=peripheral.wrap("monitor_2")
- local display=peripheral.wrap("monitor_3")
- if buttons==nil then
- buttons=peripheral.wrap("monitor_5")
- display=peripheral.wrap("monitor_4")
- end
- local password="666"
- local code={}
- os.loadAPI("button")
- function drawInput()
- display.clear()
- local screenx,screeny=display.getSize()
- local numberCount=#code
- for i=1,numberCount do
- display.setCursorPos(screenx/2-1,screeny/(numberCount+1)*i)
- display.write("*")
- end
- end
- function addNumber(buttonName)
- if buttonName=="X" then
- code={}
- drawInput()
- elseif buttonName==">" then
- local input=""
- for id,number in ipairs(code) do
- input=input..number
- end
- if tostring(input)==password then
- code={}
- drawInput()
- redstone.setOutput(redstoneSide,true)
- sleep(5)
- redstone.setOutput(redstoneSide,false)
- else
- code={}
- drawInput()
- end
- else
- code[#code+1]=buttonName
- drawInput()
- end
- end
- function setup()
- button.setMonitor(buttons)
- button.addButton(1,1,6,3,"1",addNumber,false,false,128,128)
- button.addButton(7,1,6,3,"2",addNumber,false,false,128,128)
- button.addButton(13,1,6,3,"3",addNumber,false,false,128,128)
- button.addButton(1,4,6,3,"4",addNumber,false,false,128,128)
- button.addButton(7,4,6,3,"5",addNumber,false,false,128,128)
- button.addButton(13,4,6,3,"6",addNumber,false,false,128,128)
- button.addButton(1,7,6,3,"7",addNumber,false,false,128,128)
- button.addButton(7,7,6,3,"8",addNumber,false,false,128,128)
- button.addButton(13,7,6,3,"9",addNumber,false,false,128,128)
- button.addButton(1,10,6,3,"X",addNumber,false,false,16384,16384)
- button.addButton(7,10,6,3,"0",addNumber,false,false,128,128)
- button.addButton(13,10,6,3,">",addNumber,false,false,8192,8192)
- end
- setup()
- while true do
- button.run()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement