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

Double expected, got nil error.

Started by Chrisn1995, 19 June 2012 - 11:18 PM
Chrisn1995 #1
Posted 20 June 2012 - 01:18 AM
term.clear()
term.setCursorPos(1, 1)
debug = "debug"
password = "justice"
guest = "guest"
sp = textutils.slowPrint
write("Name: ")
name = read()
sp ("Welcome tot Justice "..name.."!")
sp("Please enter your autherization ID.")
sp("If you are new, please type guest.")
write("Auth. ID: ")
input = ("*")

term.clear()
term.setCursorPos(1, 1)
if input == password then
sp("Authenticating. . .")
sp("Welcome back! Please proceed in.")
rs.setOutput("right", true)
sleep(4)
rs.setOutput("right", false)
sleep(4)
rs.setOutput("back", true)
sleep(3)
os.shutdown()

elseif input == guest then
sp("Welcome.")
rs.setOutput("right", true)
sleep(4)
rs.setOutput("right", false)
os.shutdown()

elseif input == theworld then
rs.setOutput("right", true)
sleep(4)
rs.setOutput("right", false)
exit()

else
sp("Nope.")
os.shutdown()
end


I get bios:25: bad argument: double expected, got nil
tfoote #2
Posted 20 June 2012 - 01:43 AM
it looks like it might be a os.shutdown() problem… try shell.run("shutdown") also you may want to use the os.reboot() function… I don't know why os.shutdown would be having problems… Let me know if this fix works
Chrisn1995 #3
Posted 20 June 2012 - 01:46 AM
No luck, it works fine if I type justice, but all the other pass's give me this error.
tfoote #4
Posted 20 June 2012 - 01:49 AM
Use a while true do:


while true do
term.clear()
term.setCursorPos(1, 1)
debug = "debug"
password = "justice"
guest = "guest"
sp = textutils.slowPrint
write("Name: ")
name = read()
sp ("Welcome tot Justice "..name.."!")
sp("Please enter your autherization ID.")
sp("If you are new, please type guest.")
write("Auth. ID: ")
input = ("*")
term.clear()
term.setCursorPos(1, 1)
if input == password then
sp("Authenticating. . .")
sp("Welcome back! Please proceed in.")
rs.setOutput("right", true)
sleep(4)
rs.setOutput("right", false)
sleep(4)
rs.setOutput("back", true)
sleep(3)
elseif input == guest then
sp("Welcome.")
rs.setOutput("right", true)
sleep(4)
rs.setOutput("right", false)
elseif input == theworld then
rs.setOutput("right", true)
sleep(4)
rs.setOutput("right", false)
else
sp("Nope.")
end
end -- This will eliminate any problems... once the door or whatever is off it will wait for the next person to come and enter a password.
MysticT #5
Posted 20 June 2012 - 01:49 AM
There's some errors:


term.clear()
term.setCursorPos(1, 1)
debug = "debug"
password = "justice"
guest = "guest"
sp = textutils.slowPrint
write("Name: ")
name = read()
sp("Welcome tot Justice "..name.."!")
sp("Please enter your autherization ID.")
sp("If you are new, please type guest.")
write("Auth. ID: ")
input = ("*") -- should be read("*")

term.clear()
term.setCursorPos(1, 1)
if input == password then
  sp("Authenticating. . .")
  sp("Welcome back! Please proceed in.")
  rs.setOutput("right", true)
  sleep(4)
  rs.setOutput("right", false)
  sleep(4)
  rs.setOutput("back", true)
  sleep(3)
  os.shutdown()
elseif input == guest then
  sp("Welcome.")
  rs.setOutput("right", true)
  sleep(4)
  rs.setOutput("right", false)
  os.shutdown()
elseif input == theworld then -- theworld is not defined
  rs.setOutput("right", true)
  sleep(4)
  rs.setOutput("right", false)
  exit() -- should be os.shutdown()
else
  sp("Nope.")
  os.shutdown()
end
but none of them should cause the one you get. It looks like a sleep with no arguments.
I suppose you typed the code here (instead of copying it), so you might have a sleep with no arguments in your code.
Chrisn1995 #6
Posted 20 June 2012 - 02:21 AM
All fixed, thank you all.