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

attempt to index ? (a nil value), while doing for

Started by ichim, 13 January 2013 - 01:03 PM
ichim #1
Posted 13 January 2013 - 02:03 PM
Hi, its me again.

If you need the full code please tell me. For now im writing the part i think is interessting:

The Error apperas when im doing:

			if tonumber(Maus[1]) > tonumber(tempArry[1]) and tonumber(Maus[2]) > tonumber(tempArray[2]) then

If im now putting this code in front of it it works:


			local temp0
			local temp1
			local temp2
			local temp3
			temp0 = tonumber(Maus[1])
			temp1 = tonumber(Maus[2])
			temp2 = tonumber(tempArray[1])
			temp3 = tonumber(tempArray[2])

I dont see how this would affect the other code.

To see if i dont have any nil, i used this Codeand it gave me the right Numbers:

			print(tostring(Maus[1])..":"..tostring(Maus[2]))
			print(tostring(tempArray[1])..":"..tostring(tempArray[2]))

When im putting only the numbers (same as the code above gives back) into the first code it works.


Edit: Please dont hit me .. was sitting hours over this, and now when i posted it i saw something … tempArry ~= tempArray

Sorry
RunasSudo-AWOLindefinitely #2
Posted 13 January 2013 - 02:08 PM
tempArry?
Sure that's not a spelling error?
TheOddByte #3
Posted 14 January 2013 - 01:24 AM
tempArry?
Sure that's not a spelling error?


Yeah I've gotten that error when misspelling and the program tries to call
a nil function and then get that error.
So try to change that and It will probably work. ;)/>