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

Making a password program that allows access into the pc without infinite loop?

Started by hamsterben5, 02 October 2014 - 07:50 PM
hamsterben5 #1
Posted 02 October 2014 - 09:50 PM
So, I have a program originally from this youtube video (https://www.youtube.com/watch?v=3UVXMasB0i8)
That program loops endlessly. What if I want to save my file on a floppy because my multiplayer server wipes every program on reboot? I remade the program, testing it out and fixing stuff, so hopefully it won't loop endlessly after the redstone opens the door. Here is my program: http://imgur.com/hJx34NW
http://imgur.com/PBrJMkL

Can someone rewrite the program to open the redstone door for 3 seconds, close, then gain acess to the computer, and then when the user types "Lock it" the computer says "Alrighty then, locking it." and starts the startup program? I would love you so much (no homo xD)
-Sorry for the foul language in the video and screenshot, it was ment to be funny for adults and shiz. Just a joke.
Cranium #2
Posted 03 October 2014 - 01:18 AM
So wait… your server computers are wiped on every reboot?

WHY?!

Also, do you have any code of your own? We generally don't do program requests unless we're bored, but people here are more than happy to help you write your own code.
Anavrins #3
Posted 03 October 2014 - 03:40 AM
This is pretty basic code…

local oldPullEvent = os.pullEvent
os.pullEvent = os.pullEventRaw
local redstoneSide = "back"	--// Valid sides are {"front","back","top","bottom","left","right"} case sensitive
local password = "yourpassword" --// Your own password, case sensitive
local delay = 3				--// Delay in second
while true do
  term.clear()
  term.setCursorPos(1,1)
  print("Enter password: ")
  local input = read("*")
  if input == password then
	print("Correct")
	rs.setOutput(redstoneSide, true)
	os.sleep(delay)
	rs.setOutput(redstoneSide, false)
        os.pullEvent = oldPullEvent --// Restore the termination functionality
	break			--// Break out of the infinite loop
  else
	print("Incorrect")
	os.sleep(delay)
  end
end
Edited on 03 October 2014 - 05:58 AM
Dragon53535 #4
Posted 03 October 2014 - 03:42 AM
This is pretty basic code…
–snip–
Where's the redstone? :P/>
Anavrins #5
Posted 03 October 2014 - 03:48 AM
Forgot it, it's added now.
Dragon53535 #6
Posted 03 October 2014 - 04:18 AM
And if you want it when someone types lock it to run startup have this and name the program, lock

local tArgs = {...}
if tArgs[1] == "it" then
  shell.run("startup")
end
Anavrins #7
Posted 03 October 2014 - 07:48 AM
Or run the built-in program "reboot"
hamsterben5 #8
Posted 05 October 2014 - 04:11 PM
Alrighty, I got my program set up. But, now I need to get it the disk to copy itself onto the computer and then have the computer run the program infinitely until the server resets, which will restart the program if this works. I had a shop on Tekkit Classic that autoran and copied itself on the computer, but the server went down and I forgot the code. Here is my code so far:




This program works fine, and I know how to get it to autorun, but I just don't know how to get the program to autorun from the disk without having me to type cd disk and then startup, I need it to automatically copy from the disk onto the pc, then autorun it until the server resets and the cycle starts all over again.
TheOddByte #9
Posted 05 October 2014 - 04:30 PM
Wouldn't it work to just save the file as

disk/startup
then reboot it

But if that doesn't work in your case then I'd suggest you added this to the program you have on the disk

local program = shell.getRunningProgram()
fs.copy( program, "startup" )
Edited on 05 October 2014 - 02:31 PM