Jump to content




Password Programm [Can set the PW while running the programm]

utility help

  • You cannot reply to this topic
4 replies to this topic

#1 c0rvin

  • New Members
  • 2 posts

Posted 27 February 2014 - 04:29 PM

First of:My friend created this. He is a beginner but he is actually pretty proud of it. ( He told me to link it here)

This programm will save the passwords you type in, when first run on your Computer.
The rest is self explaining.
This is copied from our PasteBin upload:
http://pastebin.com/bagM6FhK



  • local pullEvent = os.pullEvent


  • os.pullEvent = os.pullEventRaw


  • function clear()


  • term.setCursorPos(1,1)


  • term.clear()


  • end


  • clear()


  • local setpass --for setting the password


  • local adminpass -- for setting the admin password


  • local opentime -- for setting how long the door will stay open


  • local rootpass -- for setting the rootpass


  • local redstoneOutputSide


  • local args = {...}


  • if fs.exists("doorlock-settings") and args[1] ~= "reset" then


  • local f = fs.open("doorlock-settings", "r")


  • setpass = f.readLine()


  • adminpass = f.readLine()


  • rootpass = f.readLine()


  • opentime = tonumber(f.readLine())


  • redstoneOutputSide = f.readLine()


  • f.close()


  • else


  • print("Please define the password to gain access to the door:")


  • setpass = read("*")


  • clear()


  • print("Please define the password to gain root access to the computer(to edit files):")


  • rootpass = read("*")


  • clear()


  • print("Please define the admin password. This password will keep the door open when entered")


  • adminpass = read("*")


  • clear()


  • print("Please define the amount of time the redstone pulse will be on:")


  • opentime = tonumber(read())


  • clear()


  • local vside = false


  • while true do


  • print("Which side is the door on?")


  • redstoneOutputSide = read()


  • for k,v in pairs(rs.getSides()) do


  • if v == redstoneOutputSide then


  • vside = true


  • break


  • end


  • end


  • if vside then break end


  • print("Invalid side!")


  • sleep(0.5)


  • clear()


  • end


  • local f = fs.open("doorlock-settings", "w")


  • f.writeLine(setpass)


  • f.writeLine(adminpass)


  • f.writeLine(rootpass)


  • f.writeLine(tostring(opentime))


  • f.writeLine(redstoneOutputSide)


  • f.close()


  • end


  • while true do


  • clear()


  • print ("Loading...")


  • print ("Done Loading!")


  • sleep(1)


  • term.clear()


  • term.setCursorPos(1,1)


  • write "Passcode: "


  • input = read("*")


  • if input == setpass then


  • print ("Access Granted for " .. tostring(opentime) .. " seconds, better hurry!")


  • rs.setOutput(redstoneOutputSide, true)


  • sleep(opentime)


  • rs.setOutput(redstoneOutputSide, false)


  • os.shutdown()


  • elseif input == adminpass then


  • print ("Door will remain open, remember to close!")


  • rs.setOutput(redstoneOutputSide, true)


  • while true do


  • term.clear()


  • write "Passcode: "


  • input2 = read("*")


  • if input2 == adminpass then


  • rs.setOutput(redstoneOutputSide, false)


  • os.shutdown()


  • break


  • end


  • end


  • elseif input == rootpass then


  • textutils.slowPrint ("Welcome, you may now edit the programs/files on this computer!")


  • term.clear()


  • os.pullEvent = pullEvent


  • print ("Root permissions enabled")


  • return


  • else


  • print ("Uhhm... Wrong password..")


  • sleep(2)


  • os.shutdown()


  • end


  • end


#2 SeaLife

  • Members
  • 23 posts

Posted 27 February 2014 - 07:04 PM

First: You must use an <spoiler> tag on your code, thanks :D

Edit it please...


~To the Program:
Its an easy program, and its nice to start with programming in LUA :D (I Dont need this program, but nice work)

Have fun in coding for the next time, and cu :)

Code from Pastebin:
Spoiler

Code to put in Spoiler :D:
[spoiler]
--Here the Code :D/>
[/spoiler]

Edited by SeaLife, 27 February 2014 - 07:07 PM.


#3 willwac

  • Members
  • 182 posts

Posted 27 February 2014 - 11:47 PM

View PostSeaLife, on 27 February 2014 - 07:04 PM, said:

--snip--
Its an easy program, and its nice to start with programming in LUA :D (I Dont need this program, but nice work)
--snip--
Correction: Lua, not "LUA!"

Anyway, this is a good program, but like he said, there's not much use for it.

Edited by willwac (NewCoolPC), 27 February 2014 - 11:48 PM.


#4 c0rvin

  • New Members
  • 2 posts

Posted 28 February 2014 - 02:07 PM

Thanks for your feedback.
I know that it is not useful. But we just started coding in LUA.
We thought, we might share our first steps

#5 overfritz

  • Members
  • 65 posts

Posted 01 March 2014 - 02:03 AM

It's "Lua", not LUA. Why? Because "Lua" is Portuguese for Moon.

Looks nice, but again somewhat useless. It will be cool to see where you guys go with this!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users