Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local file="print(\"Booting Svizel pritula's door password program...\")\nsleep(0.1)\n\nlocal h = fs.open(\"properties\", \"r\")\nlocal password=h.readLine()\nlocal wm=h.readLine()\nlocal wo=h.readLine()\nlocal s=h.readLine()\nlocal goodT=h.readLine()*1\nlocal wrongT=h.readLine()*1\nlocal resetT=h.readLine()*1\nlocal invert=h.readLine()==\"true\"\nlocal wrong=h.readLine()\nlocal hide=h.readLine()==\"true\"\n\nh.close()\nlocal monitor = peripheral.wrap(wm)\nlocal event = \"event\"\nlocal side = \"side\"\nlocal x = 0\nlocal y = 0\nlocal key = 0\nlocal code = \"\"\nlocal passOkTimer = \"nothing\"\nlocal passWrongTimer = \"nothing\"\nlocal passTermTimer = \"nothing\"\nlocal passResetTimer = \"nothing\"\nlocal passQuessState=0\nlocal editing = 0\nlocal editingType = 0\nlocal editingValue = \"\"\nlocal editingMaxLenght = 2\nrs.setOutput(s,invert)\n\nfunction saveValue(value, spot)\nlocal save = fs.open(\"properties\", \"w\")\n\nif editing==1 then\nsave.writeLine(value)\nelse\nsave.writeLine(password)\nend\nif editing==3 then\nsave.writeLine(value)\nelse\nsave.writeLine(wm)\nend\nif editing==4 then\nsave.writeLine(value)\nelse\nsave.writeLine(wo)\nend\nif editing==5 then\nsave.writeLine(value)\nelse\nsave.writeLine(s)\nend\nif editing==6 then\nsave.writeLine(value)\nelse\nsave.writeLine(goodT)\nend\nif editing==7 then\nsave.writeLine(value)\nelse\nsave.writeLine(wrongT)\nend\nif editing==8 then\nsave.writeLine(value)\nelse\nsave.writeLine(resetT)\nend\nif editing==2 then\nsave.writeLine(value)\nelse\nsave.writeLine(invert)\nend\nif editing==9 then\nsave.writeLine(value)\nelse\nsave.writeLine(wrong)\nend\nif editing==10 then\nsave.writeLine(value)\nelse\nsave.writeLine(hide)\nend\n\nsave.close()\nos.reboot()\nend\n\nfunction draw()\nmonitor.setBackgroundColor(colors.black)\nmonitor.clear()\nif editingType<4 then\nmonitor.setBackgroundColor(colors.black)\nmonitor.clear()\nmonitor.setTextScale(1)\nmonitor.setBackgroundColor(colors.yellow)\nmonitor.setCursorPos(3,2)\nmonitor.write(\"123\")\nmonitor.setCursorPos(3,3)\nmonitor.write(\"456\")\nmonitor.setCursorPos(3,4)\nmonitor.write(\"789\")\nmonitor.setCursorPos(3,5)\nmonitor.write(\"0\")\nmonitor.setBackgroundColor(colors.red)\nmonitor.setCursorPos(4,5)\nmonitor.write(\"<\")\nmonitor.setBackgroundColor(colors.green)\nmonitor.setCursorPos(5,5)\nmonitor.write(\" \")\n\nif passQuessState==0 then\nmonitor.setBackgroundColor(colors.gray)\nelseif passQuessState==1 then\nmonitor.setBackgroundColor(colors.green)\nelseif passQuessState==2 then\nmonitor.setBackgroundColor(colors.red)\nelseif passQuessState==3 then\nmonitor.setBackgroundColor(colors.blue)\nend\n\nmonitor.setCursorPos(2,1)\nmonitor.write(\" \")\nmonitor.setCursorPos(2,1)\nif hide then\nmonitor.write(string.rep(\"*\",string.len(code)))\nelse\nmonitor.write(code)\nend\nend\n\nterm.setBackgroundColor(colors.yellow)\nterm.clear()\n\nterm.setBackgroundColor(colors.orange)\nterm.setCursorPos(2,2)\nterm.setTextColor(colors.black)\nterm.write(\"Svizel pritula's door password program\")\n\nif editingType==0 then\n\nterm.setBackgroundColor(colors.yellow)\nterm.setCursorPos(2,4)\nterm.write(\"Actualy entered code: \")\nterm.setTextColor(colors.gray)\nif string.len(code)==0 then\nterm.write(\"none\")\nelse\nterm.write(code)\nend\n\nterm.setTextColor(colors.black)\nterm.setCursorPos(30,4)\nterm.write(\"Password: \")\nterm.setTextColor(colors.gray)\nif string.len(password)==0 then\nterm.write(\"none\")\nelse\nterm.write(password)\nend\nterm.setCursorPos(46,4)\nterm.setBackgroundColor(colors.green)\nterm.setTextColor(colors.black)\nterm.write(\"edit\")\n\nterm.setBackgroundColor(colors.yellow)\nterm.setTextColor(colors.black)\nterm.setCursorPos(2,6)\nterm.write(\"Output: \")\nterm.setTextColor(colors.gray)\nif rs.getOutput(s) then\nterm.write(\"Yes\")\nelse\nterm.write(\"No\")\nend\n\n\nterm.setTextColor(colors.black)\nterm.setCursorPos(14,6)\nterm.write(\"Inverted: \")\nterm.setTextColor(colors.gray)\nif invert then\nterm.write(\"Yes\")\nelse\nterm.write(\"No\")\nend\nterm.setCursorPos(28,6)\nterm.setBackgroundColor(colors.green)\nterm.setTextColor(colors.black)\nterm.write(\"edit\")\n\n\nterm.setBackgroundColor(colors.yellow)\nterm.setTextColor(colors.black)\nterm.setCursorPos(2,8)\nterm.write(\"Monitor: \")\nterm.setTextColor(colors.gray)\nterm.write(wm)\nterm.setCursorPos(22,8)\nterm.setBackgroundColor(colors.green)\nterm.setTextColor(colors.black)\nterm.write(\"edit\")\n\nterm.setBackgroundColor(colors.yellow)\nterm.setTextColor(colors.black)\nterm.setCursorPos(27,8)\nterm.write(\"Activation: \")\nterm.setTextColor(colors.gray)\nterm.write(wo)\nterm.setCursorPos(46,8)\nterm.setBackgroundColor(colors.green)\nterm.setTextColor(colors.black)\nterm.write(\"edit\")\n\nterm.setBackgroundColor(colors.yellow)\nterm.setTextColor(colors.black)\nterm.setCursorPos(2,10)\nterm.write(\"Door: \")\nterm.setTextColor(colors.gray)\nterm.write(s)\nterm.setCursorPos(15,10)\nterm.setBackgroundColor(colors.green)\nterm.setTextColor(colors.black)\nterm.write(\"edit\")\n\nterm.setBackgroundColor(colors.yellow)\nterm.setTextColor(colors.black)\nterm.setCursorPos(20,10)\nterm.write(\"Door open time: \")\nterm.setTextColor(colors.gray)\nterm.write(goodT)\nterm.setCursorPos(39,10)\nterm.setBackgroundColor(colors.green)\nterm.setTextColor(colors.black)\nterm.write(\"edit\")\n\nterm.setBackgroundColor(colors.yellow)\nterm.setTextColor(colors.black)\nterm.setCursorPos(2,12)\nterm.write(\"Wrong password wait time: \")\nterm.setTextColor(colors.gray)\nterm.write(wrongT)\nterm.setCursorPos(31,12)\nterm.setBackgroundColor(colors.green)\nterm.setTextColor(colors.black)\nterm.write(\"edit\")\n\nterm.setBackgroundColor(colors.yellow)\nterm.setTextColor(colors.black)\nterm.setCursorPos(2,14)\nterm.write(\"Password reset time: \")\nterm.setTextColor(colors.gray)\nterm.write(resetT)\nterm.setCursorPos(26,14)\nterm.setBackgroundColor(colors.green)\nterm.setTextColor(colors.black)\nterm.write(\"edit\")\n\nterm.setBackgroundColor(colors.yellow)\nterm.setTextColor(colors.black)\nterm.setCursorPos(31,14)\nterm.write(\"Hide pass: \")\nterm.setTextColor(colors.gray)\nif hide then\nterm.write(\"Yes\")\nelse\nterm.write(\"No\")\nend\nterm.setCursorPos(46,14)\nterm.setBackgroundColor(colors.green)\nterm.setTextColor(colors.black)\nterm.write(\"edit\")\n\nterm.setBackgroundColor(colors.yellow)\nterm.setTextColor(colors.black)\nterm.setCursorPos(2,16)\nterm.write(\"Wrong password output: \")\nterm.setTextColor(colors.gray)\nterm.write(wrong)\nterm.setCursorPos(32,16)\nterm.setBackgroundColor(colors.green)\nterm.setTextColor(colors.black)\nterm.write(\"edit\")\n\nterm.setBackgroundColor(colors.yellow)\nterm.setCursorPos(2,18)\nif passQuessState==0 then\nterm.setTextColor(colors.black)\nterm.write(\"Waiting for password\")\nelseif passQuessState==1 then\nterm.setTextColor(colors.green)\nterm.write(\"Right password!\")\nelseif passQuessState==2 then\nterm.setTextColor(colors.red)\nterm.write(\"Wrong password!\")\nelseif passQuessState==3 then\nterm.setTextColor(colors.blue)\nterm.write(\"Opening redstone activated!\")\nend\n\nelseif editingType==1 then\n\nterm.setBackgroundColor(colors.yellow)\nterm.setCursorPos(2,4)\nterm.write(\"Enter value: \")\nterm.setTextColor(colors.gray)\nif string.len(editingValue)==0 then\nterm.write(\"none\")\nelse\nterm.write(editingValue)\nend\nelseif editingType==2 then\n\nterm.setBackgroundColor(colors.yellow)\nterm.setCursorPos(2,4)\nterm.write(\"Click on the right option: \")\nterm.setTextColor(colors.gray)\nterm.setCursorPos(2,6)\nterm.write(\"Yes\")\nterm.setCursorPos(2,7)\nterm.write(\"No\")\n\nelseif editingType==3 then\n\nterm.setBackgroundColor(colors.yellow)\nterm.setCursorPos(2,4)\nterm.write(\"Click on the right option: \")\nterm.setTextColor(colors.gray)\nterm.setCursorPos(2,6)\nterm.write(\"Left\")\nterm.setCursorPos(2,7)\nterm.write(\"Right\")\nterm.setCursorPos(2,8)\nterm.write(\"Top\")\nterm.setCursorPos(2,9)\nterm.write(\"Bottom\")\nterm.setCursorPos(2,10)\nterm.write(\"Front\")\nterm.setCursorPos(2,11)\nterm.write(\"Back\")\nif editingMaxLenght==1 then\nterm.setCursorPos(2,12)\nterm.write(\"None\")\nend\n\nelseif editingType==4 then\n\nterm.setBackgroundColor(colors.yellow)\nterm.setCursorPos(2,4)\nterm.write(\"Click on the monitor you want to use\")\n\nend\n\nend\n\nwhile true do\ndraw()\nevent, side, x, y = os.pullEvent()\n\nif event==\"redstone\" then\nif not (wo==\"none\") then\nif rs.getInput(wo)==true then\nrs.setOutput(s,not invert)\npassTermTimer = os.startTimer(goodT)\npassQuessState=3\nend\nend\nend\n\nif event==\"timer\" then\nif side==passOkTimer then\ncode=\"\"\npassQuessState=0\nrs.setOutput(s,invert)\nend\nif side==passWrongTimer then\ncode=\"\"\npassQuessState=0\nrs.setOutput(wrong,false)\nend\nif side==passTermTimer then\ncode=\"\"\npassQuessState=0\nrs.setOutput(s,invert)\nend\nif side==passResetTimer and passQuessState==0 then\ncode=\"\"\nend\nend\n\nif event==\"mouse_click\" then\nif editingType==0 then\nif (y==4 and x>45 and x<50) then\nediting = 1\neditingType = 1\neditingMaxLenght = 5\neditingValue = password\nelseif (y==6 and x>27 and x<32) then\nediting = 2\neditingType = 2\nelseif (y==8 and x>21 and x<26) then\nediting = 3\neditingType = 4\nelseif (y==8 and x>45 and x<50) then\nediting = 4\neditingType = 3\neditingMaxLenght=1\nelseif (y==10 and x>14 and x<19) then\nediting = 5\neditingType = 3\neditingMaxLenght=0\nelseif (y==10 and x>38 and x<43) then\nediting = 6\neditingType = 1\neditingMaxLenght = 2\neditingValue = goodT\nelseif (y==12 and x>30 and x<35) then\nediting = 7\neditingType = 1\neditingMaxLenght = 3\neditingValue = wrongT\nelseif (y==14 and x>25 and x<30) then\nediting = 8\neditingType = 1\neditingMaxLenght = 3\neditingValue = resetT\nelseif (y==16 and x>31 and x<36) then\nediting = 9\neditingType = 3\neditingMaxLenght = 1\nelseif (y==14 and x>45 and x<50) then\nediting = 10\neditingType = 2\nend\n\nelseif editingType==2 and (y>5 and y<8) then\nsaveValue(y==6, editing)\n\nelseif editingType==3 and (y>5 and (y<12 or (y<13 and editingMaxLenght==1))) then\nif y==6 then\nsaveValue(\"left\", editing)\nelseif y==7 then\nsaveValue(\"right\", editing)\nelseif y==8 then\nsaveValue(\"top\", editing)\nelseif y==9 then\nsaveValue(\"bottom\", editing)\nelseif y==10 then\nsaveValue(\"front\", editing)\nelseif y==11 then\nsaveValue(\"back\", editing)\nelseif y==12 then\nsaveValue(\"none\", editing)\nend\n\nend\nend\n\nif event==\"key\" then\nif editingType==1 then\nif (side>1 and side<11 and string.len(editingValue)<editingMaxLenght) then\neditingValue=editingValue..side-1\nelseif (side==11 and string.len(editingValue)<editingMaxLenght) then\neditingValue=editingValue..0\nelseif side==14 then\neditingValue=string.sub(editingValue, 0, string.len(editingValue)-1)\nelseif side==28 and (string.len(editingValue)>0 and not (editingValue*1==0)) then\nsaveValue(editingValue, editing)\nend\nend\nend\n\nif event==\"monitor_touch\" then\nif editingType<4 then\nif side==wm then\npassResetTimer=os.startTimer(resetT)\nend\nif (x<6 and x>2 and y<6 and y>1 and side==wm and passQuessState==0) then\nkey = (x-2)+(y-2)*3\nif string.len(code)<5 then\nif key<10 then\ncode = code..key\nend\nif key==10 then\ncode = code..0\nend\nend\nif key==11 then\ncode=string.sub(code, 0, string.len(code)-1)\nend\nif key==12 then\nif code==password then\nrs.setOutput(s,not invert)\npassOkTimer = os.startTimer(goodT)\npassQuessState=1\nelse\nrs.setOutput(wrong,true)\npassWrongTimer = os.startTimer(wrongT)\npassQuessState=2\nend\nend\nend\nelse\nsaveValue(side, editing)\nend\nend\n\nend"
- local startup = fs.open("startup", "w")
- local prop = fs.open("properties", "w")
- local run=true
- local value=""
- local event=""
- local x=0
- local y=0
- function direction(a,b,c,e,d)
- run=true
- while run do
- logo()
- term.setCursorPos(2,4)
- term.write(a)
- term.setTextColor(colors.gray)
- term.setCursorPos(2,6)
- term.write("Left")
- term.setCursorPos(2,7)
- term.write("Right")
- term.setCursorPos(2,8)
- term.write("Top")
- term.setCursorPos(2,9)
- term.write("Bottom")
- term.setCursorPos(2,10)
- term.write("Front")
- term.setCursorPos(2,11)
- term.write("Back")
- if d then
- term.setCursorPos(2,12)
- term.write("None")
- end
- term.setTextColor(colors.black)
- term.setCursorPos(2,14)
- term.write(b)
- term.setCursorPos(2,15)
- term.write(c)
- term.setCursorPos(2,16)
- term.write(e)
- event, value, x, y=os.pullEvent("mouse_click")
- if value==1 and (y>5 and ((y<13 and d)or(y<12 and not d))) then
- run=false
- if y==6 then
- prop.writeLine("left")
- elseif y==7 then
- prop.writeLine("right")
- elseif y==8 then
- prop.writeLine("top")
- elseif y==9 then
- prop.writeLine("bottom")
- elseif y==10 then
- prop.writeLine("front")
- elseif y==11 then
- prop.writeLine("back")
- elseif y==12 then
- prop.writeLine("none")
- end
- end
- end
- end
- function number(a,b,c,d,e)
- value=d
- run=true
- while run do
- logo()
- term.setCursorPos(2,4)
- term.write(a)
- term.setTextColor(colors.gray)
- term.write(value)
- term.setTextColor(colors.black)
- term.setCursorPos(2,5)
- term.write(b)
- term.setCursorPos(2,6)
- term.write(e)
- event,key=os.pullEvent("key")
- if string.len(value)<c then
- if key>1 and key<11 then
- value=value..key-1
- end
- if key==11 then
- value=value..0
- end
- end
- if key==14 then
- value=string.sub(value, 0, string.len(value)-1)
- end
- if key==28 and (string.len(value)>0 and not (value*1==0)) then
- prop.writeLine(value)
- run=false
- end
- end
- end
- function logo()
- term.setBackgroundColor(colors.yellow)
- term.setTextColor(colors.black)
- term.clear()
- term.setCursorPos(2,2)
- term.setBackgroundColor(colors.orange)
- term.write("Svizel pritula's door password program")
- term.setBackgroundColor(colors.yellow)
- end
- logo()
- term.setCursorPos(2,4)
- term.write("Welcome to Svizel pritula's door password program!")
- term.setCursorPos(2,5)
- term.write("This is an instalation wizard.")
- term.setCursorPos(2,6)
- term.write("All the values entered can be changed later.")
- term.setCursorPos(2,8)
- term.write("Click to continue")
- os.pullEvent("mouse_click")
- number("Enter your password: ","Your password can have 1-5 digits",5,"","")
- logo()
- term.setCursorPos(2,4)
- term.write("Click on the monitor you want to use")
- event, value=os.pullEvent("monitor_touch")
- prop.writeLine(value)
- direction("Activation redstone: (Click) ","When you send a redstone signal to this side,","the door will open","",true)
- direction("Door output: ","When you enter the right password, you will","get a redstone signal on this side","Connect this to your door",false)
- number("Enter output lenght: ","When you enter the good password",2,"5","the output will be on for this many seconds")
- number("Enter block time: ","When you enter the wrong password",3,"20","the keypad will be locked for this many seconds")
- number("Enter password reset time: ","The entered password will be deleted when you",3,"10","don't touch the screen for this many seconds")
- run=true
- while run do
- logo()
- term.setCursorPos(2,4)
- term.write("Output inverted:")
- term.setTextColor(colors.gray)
- term.setCursorPos(2,6)
- term.write("Yes")
- term.setCursorPos(2,7)
- term.write("No")
- term.setTextColor(colors.black)
- term.setCursorPos(2,9)
- term.write("This will make the redstone to be on by default,")
- term.setCursorPos(2,10)
- term.write("and turn off when you enter the correct password")
- event, value, x, y=os.pullEvent("mouse_click")
- if value==1 and (y>5 and y<8) then
- run=false
- prop.writeLine(y==6)
- end
- end
- direction("Wrong password output: ","If you enter a wrong password, you will","get a redstone signal on this side","",true)
- run=true
- while run do
- logo()
- term.setCursorPos(2,4)
- term.write("Hide password:")
- term.setTextColor(colors.gray)
- term.setCursorPos(2,6)
- term.write("Yes")
- term.setCursorPos(2,7)
- term.write("No")
- term.setTextColor(colors.black)
- term.setCursorPos(2,9)
- term.write("If you put this on, you won't see the password on")
- term.setCursorPos(2,10)
- term.write("the monitor")
- event, value, x, y=os.pullEvent("mouse_click")
- if value==1 and (y>5 and y<8) then
- run=false
- prop.writeLine(y==6)
- end
- end
- prop.close()
- startup.write(file)
- startup.close()
- logo()
- term.setCursorPos(2,4)
- term.write("The instalation is complete!")
- term.setCursorPos(2,5)
- term.write("Make sure no one can get to this computer")
- term.setCursorPos(2,6)
- term.write("The program will be started when you")
- term.setCursorPos(2,7)
- term.write("reboot this computer")
- term.setCursorPos(2,9)
- term.write("Click to reboot")
- os.pullEvent("mouse_click")
- os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement