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

Need Help With This Code

Started by Emen8asuer, 01 September 2012 - 09:35 PM
Emen8asuer #1
Posted 01 September 2012 - 11:35 PM
Having Problem with my Computer Password code.
Here's the code:

local side = "right"

print"==========================="
print"Crule.Co Mainframe Terminal"
print"==========================="
textutils.slowPrint"Please Type Clearance Code"
textutils.slowWrite"Code: "
correctpassword = "1212"
local input = read("*")
if input == "1212" then
term.clear()
term.setCursorPos(1,1)
textutils.slowPrint"Welcome Emen8asuer"
textutils.slowPrint"Rememeber to type reboot to log off"

else
repeat
term.clear()
term.setCursorPos(1,1)
textutils.slowPrint"Unauthorized Access, Fail Safe Activated"
rs.setOutput(side,true)
textutils.slowWrite"Fail safe Password: "
local input = read("*")
if input == "Enderman" then
textutils.slowPrint"Fail Safe Deactivated"
rs.setOutput(side,false)
end
until end sleep(2) os.reboot()
else textutils.slowPrint"Access Denied"
textutils.slowPrint"Seek Admin for help.
until i==3
Matrixmage #2
Posted 01 September 2012 - 11:38 PM
whats the error?
Emen8asuer #3
Posted 01 September 2012 - 11:41 PM
Its on the sleep(2) os.reboot() line, it wants me to have until and end on it but tehy wont work together
Matrixmage #4
Posted 01 September 2012 - 11:42 PM
line 28 is

until end sleep(2) os.reboot()
I don't think this is proper code, I dont even know what you want it to do…

Edit: sorry copying didn't work right, but I fixed it
Emen8asuer #5
Posted 01 September 2012 - 11:44 PM
Its a Password system, u eneter wrong code and it turns on a failsafe hooked to a industrial alarm. i want it to continue if tehy dont put in right password for failsafe
Matrixmage #6
Posted 01 September 2012 - 11:48 PM
I think your looking for "else"… if not, what do you want line 28 to do?
Emen8asuer #7
Posted 01 September 2012 - 11:49 PM
It was ment to reboot if they got the password right but it said to but end and until in it but i dunno how
Matrixmage #8
Posted 01 September 2012 - 11:51 PM
on lines 21 and 26 you put rs.setOutput(side,true), it has to be rs.setOutput("side you want", true)
Matrixmage #9
Posted 01 September 2012 - 11:52 PM
so when they enter the password "enderman" you want it to restart after 2 seconds?
Emen8asuer #10
Posted 01 September 2012 - 11:53 PM
Still doesent solve teh problem
Emen8asuer #11
Posted 01 September 2012 - 11:54 PM
Yes and if tehy dont get it correct it will make the password message come up again
Matrixmage #12
Posted 01 September 2012 - 11:54 PM
I don't think that the repeat command is in the current version of CC, but i'm not positive, are you using 1.4 or tekkit (1.3)?
Emen8asuer #13
Posted 01 September 2012 - 11:55 PM
Tekkit 1.3.2
Matrixmage #14
Posted 02 September 2012 - 12:03 AM
here I fixed the code:


local side = "right"

print"==========================="
print"Crule.Co Mainframe Terminal"
print"==========================="
function password()
textutils.slowPrint"Please Type Clearance Code"
textutils.slowWrite"Code: "
correctpassword = "1212"
local input = read("*")
if input == "1212" then
term.clear()
term.setCursorPos(1,1)
textutils.slowPrint"Welcome Emen8asuer"
textutils.slowPrint"Rememeber to type reboot to log off"

else
while true do
term.clear()
term.setCursorPos(1,1)
textutils.slowPrint"Unauthorized Access, Fail Safe Activated"
rs.setOutput(side,true)
textutils.slowWrite"Fail safe Password: "
local input = read("*")
if input == "Enderman" then
textutils.slowPrint"Fail Safe Deactivated"
rs.setOutput(side,false)
sleep(2)
os.restart()

else
textutils.slowPrint"Access Denied"
textutils.slowPrint"Seek Admin for help."
break
password()
end
end
password()
It should work, untested though
Emen8asuer #15
Posted 02 September 2012 - 12:05 AM
Thank you
Matrixmage #16
Posted 02 September 2012 - 12:06 AM
Your welcome!
Tiin57 #17
Posted 02 September 2012 - 12:06 AM
You mean Tekkit 3.1.2, so CC 1.33. Tekkit doesn't have support for 1.3.2 yet.
Edit: Damn, I've been ninja'd.