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

Code Error: Attempting to call nil startup:26

Started by andrew28, 04 April 2014 - 09:19 PM
andrew28 #1
Posted 04 April 2014 - 11:19 PM
Ive been having problems with my login system code. Out of my knowledge, I think this should work.

term.clear()
term.setCursorPos(1, 1)
username = {"andrew28", "nhutnguyen1234"}
password ={"nga64AT@", "dragon29"}
write("Username: ")
user = read()
write("Password: ")
pass = read ('*')
for i=1, #username do
  if user == username[i] and pass == password[1] then
	access = true
  end
end
if access == true then
print("Logging in...")
sleep(1)
print("Welcome "..user)
else
print("Incorrect Credits")
sleep(2)
os.reboot()
end
It only happens when I enter incorrect credits.
Edited on 04 April 2014 - 09:20 PM
Dreossk #2
Posted 04 April 2014 - 11:32 PM
I'm unable to test at this moment so sorry if I'm wrong but shouldn't password[1] be password[i] in the first if? If not, what is the problem exactly?
Edited on 04 April 2014 - 09:33 PM
CometWolf #3
Posted 04 April 2014 - 11:46 PM
I'm unable to test at this moment so sorry if I'm wrong but shouldn't password[1] be password[i] in the first if? If not, what is the problem exactly?
This is probably correct, however it wouldn't cause the aformentioned error.

Your error points to line 26, the code you posted is 22 lines. Please post the full code.
Dreossk #4
Posted 04 April 2014 - 11:53 PM
Oops yeah, the title eluded me.
RoD #5
Posted 05 April 2014 - 02:20 PM
I think that the problem isnt in your code but maybe in the default startup code.. did you changed anything in there?
andrew28 #6
Posted 05 April 2014 - 02:39 PM
I didn't do anything to it. I don't know what happened here
Bomb Bloke #7
Posted 05 April 2014 - 03:34 PM
Presumably this IS your startup code y/n?

What happens if you just trying running os.reboot() via the Lua prompt?
andrew28 #8
Posted 06 April 2014 - 04:41 PM
It doesn't work, shutdown works though. Im gonna use shell.exit
RoD #9
Posted 06 April 2014 - 05:02 PM
my cc has be going wierd just like that… it prints out errors in a perfect code (when i try do call a function) and the problem may be in you cc not in the code. Try reinstalling cc.
CometWolf #10
Posted 06 April 2014 - 05:45 PM
Ugh this went off the rails so fast…
Your error points to line 26, the code you posted is 22 lines. Please post the full code.
TheOddByte #11
Posted 06 April 2014 - 07:04 PM
Uhmm.. Try to declare the variable access like this above all of your code and see if that solves anything

local access = false
If this isn't all of your code then please do as CometWolf above me said and post the full code.
RoD #12
Posted 06 April 2014 - 08:01 PM
I had the chance, to try out this code, and it works perfectly. You may have a conflict with other codes(so as everyone said, paste here your full code) or you may have a bug in your minecraft/computercraft/forge (try reinstalling them)