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

Troubleshooting: Attempt to index? (a nil value)?

Started by MastInvincible, 11 January 2015 - 10:27 AM
MastInvincible #1
Posted 11 January 2015 - 11:27 AM
Helloooooo. Can someone help me? I just got Minecraft yesterday and I started programming (to no success of course). I've encountered this error. Can someone help me fix it? Error code: Quarry:5: attempt to index ? (A nil value). Here's the code:
Write("input password")
Password = read()
If password == "Start" then
Write("Yay! It worked!")
Set.redstoneOutput("back", true)
Sleep(5)
Else
Write("Wrong!")
Sleep(2)
End

Someone help?
(Expect typos, I am using a tablet with auto correct).
wieselkatze #2
Posted 11 January 2015 - 07:03 PM
The error is Set.redstoneOutput("back", true) - it is actually rs.setOutput("back", true). I think you did realize the case sensitivity - hence the auto correct thingy.
For the next time put your code in code tags to simplify reading, like so:


[ CODE ]


the fixed code would look like this:


write( "Input password" )
password = read() --# You might also use read( "*" ) for obfuscating the text

if password == "Start" then
  write( "Yay! It worked" )
  rs.setOutput( "back", true )
  sleep( 5 )
else
  write( "Wrong!" )
  sleep( 2 )
end
Edited on 11 January 2015 - 06:04 PM
MastInvincible #3
Posted 11 January 2015 - 09:06 PM
Thank you!