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

Door lock with User login *!HELP!*

Started by JiRB0T, 18 June 2012 - 03:22 PM
JiRB0T #1
Posted 18 June 2012 - 05:22 PM
My door login was working on SSP now it does not in SMP this is my code:

os.pullEvent = os.pullEventRaw
term.clear()
term.setCursorPos(5,5)
print(" !!test!!") – can remove
write(" Please Enter Your Name:")
name = io.read()
if name == "JiRBOT" then
term.clear()
print(" Good Day "..name)
sleep(3)
elseif name == "Demise" then
term.clear()
print(" Good Day "..name)
sleep(3)
else
term.clear()
print(" Can't let you do that")
sleep(2)
os.reboot()
end
term.clear()
term.setCursorPos(5,5)
print(" Hello " ..name.." please enter the password")
write(" ")
password = read("*")
if password == "1001" then
term.clear()
print(" Thanks "..name..". Enter.")
rs.setOutput("back", true)
sleep(3)
os.reboot()
rs.setOutput("back", false)
term.clear()
term.setCursorPos(5,5)
else
term.clear()
print(" WRONG!")
sleep(2)
os.reboot()
end
it gives me a
"filename":21:attempt to call nil
error
it half works i can input user it says hello msg then give me error above
BigSHinyToys #2
Posted 18 June 2012 - 06:23 PM
CC sometimes errors for unknown reasons. I have tested your code and it works perfectly on my system.

try logging off the sever restarting minecraft and log back in again then try the door again.It should work and has for me in the past
JiRB0T #3
Posted 18 June 2012 - 06:39 PM
didn't work same error :21: attempt to call nil
BigSHinyToys #4
Posted 18 June 2012 - 06:59 PM
You fouled up os.pullevent() by accidentally doing something like os.pullEvent = os.pullEventRaw() possible


delete " os.pullEvent = os.pullEventRaw "
use this as the first line in your code

os.pullEvent = coroutine.yield

it will still be secure and Ctrl + T will not work as before
Cloudy #5
Posted 18 June 2012 - 07:31 PM
You do realise that os.pullEventRaw just calls coroutine.yield and as such this is a bit pointless, right?
BigSHinyToys #6
Posted 18 June 2012 - 07:35 PM
You do realise that os.pullEventRaw just calls coroutine.yield and as such this is a bit pointless, right?

yes i do the problem how ever is a function that = nil being called now the os.pullEvent function is being over written so that is where i think something has gone wrong making it = nil and causing a 21 error (I could be wrong but non of the other called functions look like they are being tampered with.) so the solution i proposed is fool prof and should by pass any damage that os.pullEvent or os.pullEventraw have uncured due to miss use.
JiRB0T #7
Posted 18 June 2012 - 07:37 PM
totally worked thanks!!! I'm a N00b to lua btw, so much appreciated