Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --NanoTech Industries ©
- --Edit the below part for customization
- --Possible sides: front,right,back,left,top,bottom
- monSide="back" -- The side on which the monitor is
- redstoneSide="bottom" -- The side of which you want the redstone signal to output
- code="12345" -- The code can be 1 to 5 numbers
- -- Do NOT change anything below this point.
- inputs={}
- m=peripheral.wrap(monSide)
- 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("< ")
- 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
- backspaceInput()
- else
- if #inputs<5 then
- inputs[#inputs+1]=digit
- m.setBackgroundColor(128)
- m.setCursorPos(#inputs+1,1)
- m.write(tostring(digit))
- 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)
- clearInput()
- sleep(5)
- redstone.setOutput(redstoneSide,false)
- else
- clearInput()
- end
- end
- function backspaceInput()
- inputs[#inputs]=nil
- m.setCursorPos(2,1)
- m.write(" ")
- m.setCursorPos(2,1)
- m.setBackgroundColor(128)
- for i,number in pairs(inputs) do
- m.write(tostring(number))
- 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