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

Attempt to index ? (A boolean value)

Started by Inumel, 04 June 2013 - 06:04 PM
Inumel #1
Posted 04 June 2013 - 08:04 PM
Hi! Me againsorry I am trying to do the following


x = rs.getInput("top")


But I am getting the error attempt to index ? (a boolean value)

I am not sure what I am doing wrong.. I could have sworn I have used this very code before :s

Any help, of course is appreciated, sorry for being such a dumb :P/>
GopherAtl #2
Posted 04 June 2013 - 08:16 PM
seeing your whole program would make it easier to identify the problem and help, but "attempt to index ?" means you tried to treat something that isn't a table (in this case, a boolean value) as a table, either with [] or "." If the error is indeed on that line, and not the previous line (which can and does happen sometimes), then somewhere you've overwritten "rs" with a boolean value.
Bomb Bloke #3
Posted 04 June 2013 - 08:16 PM
Seems to me you're misinterpreting the number of the line that's triggering the error. That code is fine, but the code around it may not be - bear in mind that statements can exceed one line in length.
Lyqyd #4
Posted 04 June 2013 - 08:21 PM
Please post the whole code.
Inumel #5
Posted 04 June 2013 - 08:25 PM
I am using a very slightly modified version of this program here, bottom most post
http://www.computercraft.info/forums2/index.php?/topic/9996-melee-turtle-programs/
And this is the program as it is on my computer
http://pastebin.com/fyn09SuJ

But when I run lua and try to just do x = rs.getInput("top"), I still get the error, even when no other code is entered
GopherAtl #6
Posted 04 June 2013 - 08:30 PM
But when I run lua and try to just do x = rs.getInput("top"), I still get the error, even when no other code is entered

reboot the computer and then try that in lua, should work then. Overwriting globals like rs has effects beyond the program running, it's not like just blocking access to rs with a local variable. It may be an earlier version of the program, or even a completely different program, causing the error.

And if the program still errors after a reboot, give us the exact error message, including the context (filename and line number).
Inumel #7
Posted 04 June 2013 - 08:31 PM
But when I run lua and try to just do x = rs.getInput("top"), I still get the error, even when no other code is entered

reboot the computer and then try that in lua, should work then. Overwriting globals like rs has effects beyond the program running, it's not like just blocking access to rs with a local variable. It may be an earlier version of the program, or even a completely different program, causing the error.

And if the program still errors after a reboot, give us the exact error message, including the context (filename and line number).

This worked wonders, I should have tried that first.. thank you