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

Attempt to index(a nil value?) Can't find it.

Started by MastInvincible, 31 March 2015 - 01:19 PM
MastInvincible #1
Posted 31 March 2015 - 03:19 PM
I just made a program designed to monitor the temperatures of a nuclear reactor and it coming up with the error in the title and apparently it's on line 8 however, I can't see what's wrong. I know what the error code means but I can't find it. Help!

The code goes like this (I may have made errors while typing it up so I recommend you use the screen shot instead):

term.clear()
print("Reactor heat monitor and control.")
sleep(3)
term.clear()
password = read()
while true do
if rs.testBundledInput("back", colour.red) then
print("Reactor temperature is at 500C.")
sleep(5)
os.reboot()
else
os.reboot()
end

There is more code obviously but this is the bit where the error is coming up.
Thanks for the help!
Here's a screenshot of the exact code.
[attachment=2180:Screenshot (12).png]
Edited on 31 March 2015 - 01:20 PM
KingofGamesYami #2
Posted 31 March 2015 - 03:20 PM
Change colour to colours on line 7. Alternatively, the US spelling is 'colors'.

Edit: Also, you are missing an end to your while loop.
Edited on 31 March 2015 - 01:22 PM
Lupus590 #3
Posted 31 March 2015 - 03:21 PM
indent your code, it helps find problems like this
edit: just noticed that you said that this is a snippet


term.clear()
print("Reactor heat monitor and control.")
sleep(3)
term.clear()
password = read()
while true do
   if rs.testBundledInput("back", colours.red) then --#this was colour.red
	  print("Reactor temperature is at 500C.")
	  sleep(5)
	  os.reboot()
   else
	  os.reboot()
   end
--#you are missing an end here, this may be because of the snippet thing
Edited on 31 March 2015 - 01:23 PM
MastInvincible #4
Posted 31 March 2015 - 03:23 PM
I'll try it.

indent your code, it helps find problems like this
edit: just noticed that you said that this is a snippet


term.clear()
print("Reactor heat monitor and control.")
sleep(3)
term.clear()
password = read()
while true do
   if rs.testBundledInput("back", colour[u]s[/u].red) then
	  print("Reactor temperature is at 500C.")
	  sleep(5)
	  os.reboot()
   else
	  os.reboot()
   end
--#you are missing an end here

That's not all the code there's a lot more after it so i put the end in just further down.
Edited on 31 March 2015 - 01:29 PM
MastInvincible #5
Posted 31 March 2015 - 03:28 PM
Change colour to colours on line 7. Alternatively, the US spelling is 'colors'.

Edit: Also, you are missing an end to your while loop.

Thanks this fixed it!
DannySMc #6
Posted 31 March 2015 - 04:14 PM
indent your code, it helps find problems like this
edit: just noticed that you said that this is a snippet


term.clear()
print("Reactor heat monitor and control.")
sleep(3)
term.clear()
password = read()
while true do
   if rs.testBundledInput("back", colours.red) then --#this was colour.red
	  print("Reactor temperature is at 500C.")
	  sleep(5)
	  os.reboot()
   else
	  os.reboot()
   end
--#you are missing an end here, this may be because of the snippet thing

Even if they indent code for some reason if you are using sublime it doesn't always indent the code…on these forums…
MKlegoman357 #7
Posted 31 March 2015 - 04:42 PM
The editor on these forums is really buggy. But, there is a 'Toggle Edit Mode' button on the top-left corner of the editor which turns off all the fancy edit parts, so, although you have to type every tag manually, it is way easier to write the post in that mode. It doesn't mess with any pasted-code indentation or any other formatting, that's why I use it all the time.
DannySMc #8
Posted 31 March 2015 - 04:56 PM
The editor on these forums is really buggy. But, there is a 'Toggle Edit Mode' button on the top-left corner of the editor which turns off all the fancy edit parts, so, although you have to type every tag manually, it is way easier to write the post in that mode. It doesn't mess with any pasted-code indentation or any other formatting, that's why I use it all the time.

Didn't know that!!