This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
nynoray's profile picture

Password Protected Computer | Nynoray

Started by nynoray, 12 July 2012 - 10:38 PM
nynoray #1
Posted 13 July 2012 - 12:38 AM
Hey guy, this is my program that makes your computer password protected.
I'm new with lua so the coding isn't very complex, even though you don't need complex coding to do this.

First off let's learn about this. (This is basics for the program, most people will be able to skip through most of this and still use the program fully)

[indent=1]The code:[/indent]

[indent=1]

os.pullEvent = os.pullEventRaw
term.clear()
term.setCursorPos(1,1)
print("Borta Computer Security 1.1")
print("UserName: Nynoray")
write("Password: ")
function pass()
t = io.read()
if t == "rhino" then
print ("Access Granted.")
sleep(2)
term.clear()
term.setCursorPos(1,1)
else
print ("Incorrect Login Details.")
sleep(1)
term.clear()
term.setCursorPos(1,1)
print("Borta Computer Security 1.1")
print("UserName: Nynoray")
write("Password: ")
pass()
end
end
pass()
[/indent]


[indent=1]Have this code as the startup program on your computer. (If this code doesn't work let me know because it is a copying error I would have made.)[/indent]
[indent=1]You can change the prints to customize the interface, but, if that print/write occurs later in the coding the two should match. (You could just change the whole interface if you want more tricky though.)[/indent]

[indent=1]Here is the main interface, it shows after the computer boots and after you enter an incorrect password.[/indent]

[indent=1][/indent]

[indent=1]This is the interface that shows up when you enter an incorrect password, it reverts to the main interface after two seconds.[/indent]

[indent=1][/indent]

[indent=1]This is the interface that shows up when you enter the correct password, after one second it clears the screen and you have access to the computer.[/indent]

[indent=1][/indent]

[indent=1]There are ways to get past this lock lock like almost every one I know about. If you boot it from a floppy you can get past the password, A way to prevent this is if you make it so only one side of the computer is open and the other sides can't be opened by an intruder. This would be done by surrounding the surface in blocks that only you (and friends maybe) can destroy. You would need access to bedrock or be able to protect blocks with a plugin on the server. That way if they put the disk drive on the computer, they can not click the computer (if they have more person they may be able to do this though). The computer never reboots before you get the password correct, so you can't do something like get the wrong pass then put the disk drive to load the floppy.[/indent]

[indent=1]That's all i think, if there is any info you want on it, ask and I can add it.[/indent]
glopso #2
Posted 13 July 2012 - 12:53 AM
If the server is lagging enough you could probably shift-right click and then right-click again before the block appears, bypassing the security.
Lyqyd #3
Posted 13 July 2012 - 01:27 AM
This is a somewhat improved version. It is always a bad idea to try to create an infinite loop through recursion; you'll eventually overflow your stack, except in very limited circumstances. You also should be using a read("*") call for passwords, not io.read().


oldPull = os.pullEvent
os.pullEvent = os.pullEventRaw
while true do
	term.clear()
	term.setCursorPos(1,1)
	print("Borta Computer Security 1.1")
	print("UserName: Nynoray")
	write("Password: ")
	if read("*") == "rhino" then
		print("Access Granted.")
		sleep(2)
		term.clear()
		term.setCursorPos(1,1)
		break
	else
		print ("Incorrect Login Details.")
		sleep(1)
	end
end
os.pullEvent = oldPull
nynoray #4
Posted 13 July 2012 - 02:20 AM
If the server is lagging enough you could probably shift-right click and then right-click again before the block appears, bypassing the security.

Possibly, but you would also need to insert the floppy into the disk drive and that might not be possible if the disk drive hasn't showed up.
nynoray #5
Posted 13 July 2012 - 02:44 AM
This is a somewhat improved version. It is always a bad idea to try to create an infinite loop through recursion; you'll eventually overflow your stack, except in very limited circumstances. You also should be using a read("*") call for passwords, not io.read().

Yea I didn't know another way to make it not stop the startup if the password was wrong. I am trying to learn the lua used for cc but I'll be pretty bad at it for a bit :)/>/>.
Lyqyd #6
Posted 13 July 2012 - 05:53 AM
This is a somewhat improved version. It is always a bad idea to try to create an infinite loop through recursion; you'll eventually overflow your stack, except in very limited circumstances. You also should be using a read("*") call for passwords, not io.read().

Yea I didn't know another way to make it not stop the startup if the password was wrong. I am trying to learn the lua used for cc but I'll be pretty bad at it for a bit :)/>/>.

Well, the way you were doing it would work, it would just cause problems if someone kept trying wrong passwords. The version I posted above keeps them in the loop ("while true do" is the start of the loop) until the correct password is put in, then the "break" instruction exits the loop.
nynoray #7
Posted 13 July 2012 - 06:27 AM
This is a somewhat improved version. It is always a bad idea to try to create an infinite loop through recursion; you'll eventually overflow your stack, except in very limited circumstances. You also should be using a read("*") call for passwords, not io.read().

Yea I didn't know another way to make it not stop the startup if the password was wrong. I am trying to learn the lua used for cc but I'll be pretty bad at it for a bit :)/>/>.

Well, the way you were doing it would work, it would just cause problems if someone kept trying wrong passwords. The version I posted above keeps them in the loop ("while true do" is the start of the loop) until the correct password is put in, then the "break" instruction exits the loop.

Yea, but could you have the 'while true do' when there is multiple options other then else.

I'll give an example here but the coding might fail because I'm just writing this up now without testing, but the main point: would doing 'while true do' for each option (or something like that) work also. or is this code just fine.


print("diamond:1, iron:2")
function item()
t = io.read()
if t == "1" then
	  rs.setOutput("right", true)
	  sleep(1)
	  rs.setOutput("right", false)
	  os.reboot()
	  end
if t == "2" then
	  rs.setOutput("left", true)
	  sleep(1)
	  rs.setOutput("left", false).
	  os.reboot()
	  end
else
				-- dont remember this part exactly so its going to be shit
item()
end
end
item()
			  --probably made an infinite loop if they dont put 1 or 2 but you should know thats not an option

i had a comp running this (the script that works, this is just an example that prob doesn't work) connected to dispensers and worked.
tried making it use 'while true do' and it didnt work. (probably my errors)

was doing this on phone so there will be a lot of grammar errors, sorry
glopso #8
Posted 13 July 2012 - 06:28 AM
If the server is lagging enough you could probably shift-right click and then right-click again before the block appears, bypassing the security.

Possibly, but you would also need to insert the floppy into the disk drive and that might not be possible if the disk drive hasn't showed up.
Oh yeah. My bad
nynoray #9
Posted 13 July 2012 - 06:30 AM
If the server is lagging enough you could probably shift-right click and then right-click again before the block appears, bypassing the security.

Possibly, but you would also need to insert the floppy into the disk drive and that might not be possible if the disk drive hasn't showed up.
Oh yeah. My bad


yea but if you had 2 people one could right click the comp, the other add disk drive and floppy and the 1st will still be in comp,(atleast i think)
then just ctrl+r
Disy #10
Posted 15 July 2012 - 04:04 AM
I have a question, I decided to mix Lyqyd, and your codes together, and I got a great design. The only problem
being that if you get the password correct the computer screen will now exit out of the program. How would I go
about creating it so that it will just reboot after getting the password correct?
nynoray #11
Posted 06 September 2012 - 10:08 PM
I have a question, I decided to mix Lyqyd, and your codes together, and I got a great design. The only problem
being that if you get the password correct the computer screen will now exit out of the program. How would I go
about creating it so that it will just reboot after getting the password correct?
Sorry for taking like 3 months to respond but I haven't been playing tekkit a lot getting back into it now… anyways, It's probably answered already but i'll try anyways :D/>/>. I couldn't be sure without seeing your coding for it, but since his coding was a slightly more efficient version so mixing the two might end up with some parts missing. You could try using only one of them or I could maybe find out if I could see your code.
yungskittlez #12
Posted 15 February 2013 - 07:53 PM
i have the while looped code and when i enter the correct password i am still stuck in a loop help?
Cranium #13
Posted 16 February 2013 - 04:08 AM
*sigh*
Don't raise threads that are months old from the dead. If you need help with code, there is a section in the Ask A Pro area for that. Locked.