Jump to content


Macapple's Content

There have been 6 items by Macapple (Search limited from 06-June 19)


By content type

See this member's

Sort by                Order  

#251758 Check for Keycard, and if it's not there, ask a password

Posted by Macapple on 21 May 2016 - 01:10 PM in Ask a Pro

Solved, a guy in the server helped.

Can rm thistopic



#251756 Check for Keycard, and if it's not there, ask a password

Posted by Macapple on 21 May 2016 - 01:00 PM in Ask a Pro

Hi everyone! I'm trying to make a security lock, but I can't get it to work as I intend to.

My code is [PASTEBIN LINK]
local pass = "Temp"
local dPas = "Debug"
local timer = 5
local delay = 1
local side = "left"
local dside = "bottom"
--//This code runs first on computer startup, checking for a valid keycard in the bottom disk
while true do
		if disk.isPresent(dside) then
		if fs.exists("disk/security/key") then
		shell.run("disk/security/key")
		if key == "Code" then
		disk.eject(dside)
		rs.setOutput(side,false)
		sleep(timer)
		rs.setOutput(side,true)
	  
else
disk.eject(dside)
end
else
disk.eject(dside)
end
end

else
--// This code must run only if user has turned on the computer without a keycard in the bottom disk driver, or if the keycard is invalid
print("Door is Locked")
sleep(delay)
print("Insert Password:   ")
sleep(delay)
local input = read("x")
if input == pass then --If the password is correct do
rs.setOutput(side,false)
sleep(timer)
rs.setOutput(side,true)
sleep(delay)
os.shutdown()
else --If the password is incorrect do
print ("Incorrect password)
sleep(delay)
os.shutdown()
end
end
end

Is there something wrong in the code?



#229776 Advanced Password Door

Posted by Macapple on 11 August 2015 - 06:27 PM in Ask a Pro

I went through the problem of the shutdown by totally revamping the Code.
local side = "back"
local DoorVar = false
local DoorStat = "Closed"
local PAX = "Matrix"

if DoorVar == false then

  print(" Node Emboldener Matrix MK II ")
  sleep(1)
  print("Door Status: "..DoorStat)
  sleep(1)
  textutils.slowPrint("Password Required")
  sleep(0.5)
  textutils.slowWrite("Enter Password: ")
  sleep(0.5)

  input = read("x")
  if input == PAX then
  print(" Password Accepted. Opening Door ")
  rs.setOutput(side, true)
  DoorVar = true
  DoorStat = "Open"
  sleep(1)
  while true do
    print("Press R to Reboot and Close the Door")
  
    local event, key = os.pullEvent("key")
	  if key == keys.r then
	   print(" Rebooting... ")
	   sleep(2)
	   os.reboot()
	   break
	   end
	   end
	  
  elseif input ~= PAX then
  print(" Access Denied. Bad Password. ")
  sleep(3)
  os.reboot()


  else
  print(" Closing Door ")
  rs.setOutput(side, false)
  DoorVar = false

  end
end

As you can see I added a loop at the end of the opening function, so that once finished, one can simply access the Terminal and Press R to Reboot the Terminal and Close the Door.

Thanks everybody for their help!



#229761 Advanced Password Door

Posted by Macapple on 11 August 2015 - 04:52 PM in Ask a Pro

The problem is when i come to use rs.getOutput(side)
Since rebooting shuts the redstone down, it closes the door and asks me the password again.
One thing I could certainly do is latching the output to a Piston Vanilla Toggle Mechanism, and edit the program with a Boolean.



#229747 Advanced Password Door

Posted by Macapple on 11 August 2015 - 04:29 PM in Ask a Pro

View PostKingofGamesYami, on 11 August 2015 - 02:46 PM, said:

If you have code you've written already, please post it. It helps to know what your program looks like, so we can give you solutions specific to your code.
<Omitted>
Here's the code I made on your advice:
local side = "back"
local PASSWORD = "MATRIX"

print(" Aura Node Emboldener MK I ")
print(" Password Required: ")
sleep(1)
if rs.getOutput(side) == true then
print("Door State: Open")
else
print("Door State: Locked")

end
if rs.getOutput(side) == false then
write("Password: ")


  input = read("x")
  if input == PASSWORD then
  print(" Accepted ")
  rs.setOutput(side, true)
  sleep(1)

  elseif input ~= PASSWORD then
  print(" Access Denied " )
  sleep(1)
  end

elseif rs.getOutput(side) == true then
print(" Closing Door ")
sleep(5)
rs.setOutput(side, false)
end

Problems:
1) I want the Computer to Shut Down once it opens the door, but to KEEP giving redstone signal from the Back ('side' variable)
2) I want it not to ask me the password when I want to lock the door, and shutdown afterwards.



#229721 Advanced Password Door

Posted by Macapple on 11 August 2015 - 02:22 PM in Ask a Pro

Hi Everyone! I'm new to coding, and I can't make a program work as I want to.

Long story short: The program should show a Door State (Open or Locked) i tried doing so with variables, but the program forgets I opened the door, so even if it's opened, it shows it's "Locked"

THE PROGRAM SHOULD

1) Show if a Piston Door is Open/Closed (I figure I'll need a Boolean (?))
2) Ask for Password
3) Open the Door if it's Closed, Close the Door if it's Open
4) Shutdown
5) Must not f&%k up when rebooted

OR

1) Show if Piston Door is Open/Closed
2) Ask Password ONLY when Door is Closed and I want to Open it, and Open It when password is correct.

3) Shutdown
4) Must not f&%k up when rebooted
2.1] If Door is Open, without asking the password, Close the Door, Shutdown.