This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
attempt to call nil
Started by Artmaster, 01 January 2013 - 09:41 AMPosted 01 January 2013 - 10:41 AM
im trying to make a program to turn my ic2 reactor on but it keeps getting the attempt to call nil can anyone help
Posted 01 January 2013 - 11:02 AM
That is extreamly generic error. You'll need to post the code for us to help.
Posted 01 January 2013 - 11:02 AM
Sure, but first you will probably need to post the entire error message and the code you're having problems with. We're not that good….
Posted 01 January 2013 - 11:13 AM
Generally, it means that, on the line number specified by the error message, you have misspelled a function name when trying to call it, or you have called it before it is in scope and assigned properly.
We would need to see the entire code so as to determine which problem your having, and how to fix it. If it's just a misspelling, you can probably fix it on your own. If it's a simple scope or assignment problem, then just declaring the function before you attempt to call it should work. So, you might well be able to fix that on your own. Give it a shot, and if it doesn't work, then post the entire code (in those nifty [CODE][/CODE] tags) and the entire error message.
We would need to see the entire code so as to determine which problem your having, and how to fix it. If it's just a misspelling, you can probably fix it on your own. If it's a simple scope or assignment problem, then just declaring the function before you attempt to call it should work. So, you might well be able to fix that on your own. Give it a shot, and if it doesn't work, then post the entire code (in those nifty [CODE][/CODE] tags) and the entire error message.
Posted 01 January 2013 - 11:20 AM
sorry i thought i attached the code
while true do
term.clear()
term.setCursor(1, 1)
print("Enter Startup Code ")
input = read("*")
if input == "beast" then
redstone.setOutput("back", true)
sleep(2)
end
end
while true do
term.clear()
term.setCursor(1, 1)
print("Enter Startup Code ")
input = read("*")
if input == "beast" then
redstone.setOutput("back", true)
sleep(2)
end
end
Posted 01 January 2013 - 11:23 AM
term.setCursor(1, 1)
--should actually be
term.setCursorPos(1,1)
Posted 01 January 2013 - 11:26 AM
thanks
could you help me get the program to exit automatically after the password it inputed
could you help me get the program to exit automatically after the password it inputed
Posted 01 January 2013 - 11:27 AM
while true do
term.clear()
term.setCursorPos(1, 1)
print("Enter Startup Code ")
input = read("*")
if input == "beast" then
redstone.setOutput("back", true)
sleep(2)
break
end
end
Posted 01 January 2013 - 11:28 AM
Sure thing, you will want to break out of the while loop
while true do
term.clear()
term.setCursorPos(1, 1)
print("Enter Startup Code ")
input = read("*")
if input == "beast" then
redstone.setOutput("back", true)
sleep(2)
redstone.setOutput("back", false) --to turn off the redstone, not sure if you want that or not added in case, remove if you want
break -- will exit the for loop and should kick you back to the shell since there is nothing else to run after this
end
end
Posted 01 January 2013 - 11:30 AM
could i break the loop with out having to set the output back to false i want to keep it going
Posted 01 January 2013 - 11:31 AM
If you want the redstone signal left on yes just dont put that line in. I was thinking that this might be for a password locked door or something like that.
EDIT: and as mibac demonstrated below, you probably don't need the sleep
EDIT: and as mibac demonstrated below, you probably don't need the sleep
Posted 01 January 2013 - 11:31 AM
then delete redstone.setOutput("back", false)
(
(
while true do
term.clear()
term.setCursorPos(1, 1)
print("Enter Startup Code ")
input = read("*")
if input == "beast" then
redstone.setOutput("back", true)
break -- will exit the for loop and should kick you back to the shell since there is nothing else to run after this
end
end
)Posted 01 January 2013 - 11:32 AM
no its just a nuclear reactor from industrial craft and i want different passwords for turning on and off
Posted 01 January 2013 - 11:39 AM
You can put them both in 1 program, you don't need to exit this one. Here's an example.
while true do
term.clear()
term.setCursorPos(1, 1)
print("Enter Startup Code ")
input = read("*")
if input == "beast" then
redstone.setOutput("back", true)
elseif input == "turnItOff" then --just change turnItOff to your "off" password.
redstone.setOutput("back", true)
end
end
Posted 01 January 2013 - 11:47 AM
now im having trouble with my kill program
the error says bios:338: {string "off"]:8: ')' expected (to close '(' at line 7)
(
while true do
term.clear()
term.setCursorPos(1,1)
print("Enter Reactor Kill Code: ")
input = read("*")
if input == "kill" then
redstone.setOutput("back", false
break()
end
end
)
the error says bios:338: {string "off"]:8: ')' expected (to close '(' at line 7)
(
while true do
term.clear()
term.setCursorPos(1,1)
print("Enter Reactor Kill Code: ")
input = read("*")
if input == "kill" then
redstone.setOutput("back", false
break()
end
end
)
Posted 01 January 2013 - 11:49 AM
You missing the 2nd parentheses for the redstone.setOutput("back",false), and the break don't need any parentheses.
Try this
Try this
while true do
term.clear()
term.setCursorPos(1, 1)
if rs.getOutput("back") then
print("Enter Reactor Kill Code: ")
else
print("Enter Startup Code ")
end
input = read("*")
if input == "beast" then
redstone.setOutput("back", true)
elseif input == "kill" then
redstone.setOutput("back", true)
end
end
Edited on 01 January 2013 - 10:53 AM
Posted 01 January 2013 - 11:52 AM
thanks alot i dont think i would have found that
your code worked perfectly thanks
your code worked perfectly thanks
Posted 01 January 2013 - 01:15 PM
You missing the 2nd parentheses for the redstone.setOutput("back",false), and the break don't need any parentheses.
Try thiswhile true do term.clear() term.setCursorPos(1, 1) if rs.getOutput("back") then print("Enter Reactor Kill Code: ") else print("Enter Startup Code ") end input = read("*") if input == "beast" then redstone.setOutput("back", true) elseif input == "kill" then redstone.setOutput("back", true) end end
You may want to set the boolean to false for the kill command :P/>
Posted 01 January 2013 - 04:33 PM
i did