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

[Request] Passworded Program

Started by HellsGuard, 22 April 2012 - 12:52 AM
HellsGuard #1
Posted 22 April 2012 - 02:52 AM
Hello CC world,

I'm quite new to CC and the entire coding scene in general.
I've tried to find a program already close to mine, or something similar that I might be able to edit, but I… am a noob…

What I am requesting I believe to be simple, yet difficult for me to figure out, I am requesting a simple program that will activate a redstone current having it password locked, and deactivated using that same password.

What I am fully trying to accomplish is having the program activate redstone, which activates a wireless transmitter, which activates my oil pumping station recievers, I will be doing the same for my Water Pump Station.

So to give a decent breakdown of my request as I understand it….
Password Protected program that activates redstone until I decide I want to shut it off.

If this is possible, can someone help me out?

Thanks in advance.


Edit:

I believe I have accomplished this… somewhat…


write ("Oil Pump Station Control")
sleep(3)
local oldPull = os.pullEvent;
os.pullEvent = os.pullEventRaw;
term.clear()
term.setCursorPos(1,)
correctpass = "mypasshere"
write ("Activation Code: ")
pass = read("*")
if pass == (correctpass) then
write ("Pump Activated Press ESC")
redstone.setOutput("back", true )
end

Now, what I have done is it will activate it, then when I press ESC, it will close the terminal and keep the redstone current running until I reopen the terminal and type "exit"

Any suggestions or modifications are welcome, As I said i would like to be able to enter the "Activation Code" to be able to turn it on AND off, cause right now anyone can really turn it off… lol
libraryaddict #2
Posted 22 April 2012 - 12:36 PM

while true do -- While true is true repeat this
  shell.run("clear")
  print("Oil Pump Station Control")
  if rs.getOutput("back") then
	PumpStatus = "Running"
  else
	PumpStatus = "Stopped"
  end
  print("Pump status: "..PumpStatus)
  write("Password: ")
  Ignore,ReadPassword = pcall(read) -- pcall() stops error codes, Which is what a terminate event is.
  if ReadPassword == "mypasshere" then
	rs.setOutput("back", not rs.getOutput("back"))
  end
end
HellsGuard #3
Posted 22 April 2012 - 09:39 PM

while true do -- While true is true repeat this
  shell.run("clear")
  print("Oil Pump Station Control")
  if rs.getOutput("back") then
	PumpStatus = "Running"
  else
	PumpStatus = "Stopped"
  end
  print("Pump status: "..PumpStatus)
  write("Password: ")
  Ignore,ReadPassword = pcall(read) -- pcall() stops error codes, Which is what a terminate event is.
  if ReadPassword == "mypasshere" then
	rs.setOutput("back", not rs.getOutput("back"))
  end
end

Just tested this, and this is exactly what I was looking for, thanks a TON , its gonna help me big time.