Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- monSide="back"
- m=peripheral.wrap(monSide)
- redstoneSide="right"
- code="12345"
- inputs={}
- function drawNumpad()
- m.clear()
- clearInput()
- m.setBackgroundColor(128)
- m.setCursorPos(2,1)
- m.write(" ")
- m.setBackgroundColor(256)
- m.setCursorPos(1,1)
- m.write(" ")
- m.setCursorPos(7,1)
- m.write(" ")
- m.setCursorPos(1,2)
- m.write(" ")
- m.setBackgroundColor(32768)
- m.setCursorPos(2,2)
- m.write("1 2 3")
- m.setCursorPos(2,3)
- m.write("4 5 6")
- m.setCursorPos(2,4)
- m.write("7 8 9")
- m.setCursorPos(2,5)
- m.write(" 0 ")
- m.setBackgroundColor(256)
- m.setCursorPos(1,3)
- m.write(" ")
- m.setCursorPos(1,4)
- m.write(" ")
- m.setCursorPos(1,5)
- m.write(" ")
- m.setCursorPos(7,3)
- m.write(" ")
- m.setCursorPos(7,4)
- m.write(" ")
- m.setCursorPos(7,5)
- m.write(" ")
- m.setBackgroundColor(32)
- m.setCursorPos(6,5)
- m.write("Ok")
- m.setBackgroundColor(16384)
- m.setCursorPos(1,5)
- m.write("C ")
- end
- function inputNumber()
- event,side,x,y=os.pullEvent("monitor_touch")
- if x==2 and y==2 then
- digit=1
- elseif x==4 and y==2 then
- digit=2
- elseif x==6 and y==2 then
- digit=3
- elseif x==2 and y==3 then
- digit=4
- elseif x==4 and y==3 then
- digit=5
- elseif x==6 and y==3 then
- digit=6
- elseif x==2 and y==4 then
- digit=7
- elseif x==4 and y==4 then
- digit=8
- elseif x==6 and y==4 then
- digit=9
- elseif x==4 and y==5 then
- digit=0
- elseif x>=2 and y==5 then
- digit="ok"
- elseif x<=6 and y==5 then
- digit="clear"
- end
- if digit=="ok" then
- checkNumber()
- elseif digit=="clear" then
- clearInput()
- else
- if #inputs<5 then
- inputs[#inputs+1]=digit
- m.setBackgroundColor(128)
- m.setCursorPos(#inputs+2,1)
- m.write("*")
- end
- end
- end
- function checkNumber()
- input=""
- for id,number in pairs(inputs) do
- input=input..number
- end
- if input==code then
- redstone.setOutput(redstoneSide,true)
- sleep(5)
- redstone.setOutput(redstoneSide,false)
- clearInput()
- else
- clearInput()
- end
- end
- function clearInput()
- inputs={}
- m.setCursorPos(2,1)
- m.setBackgroundColor(128)
- m.write(" ")
- end
- drawNumpad()
- while true do
- inputNumber()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement