Posted 13 March 2014 - 05:26 PM
local tArgs = { ... }
local number = tArgs[1]
print(number)
print(number == 5)
I'm having a lot of trouble understanding tables, I have looked at a lot of tutorials but there's something about them that goes right over my head. The code above is a test program a made after my main program wasn't working properly and I'm really confused at the results. I run the program by typing "test 5" which I thought would set "tArgs[1]" to 5 and that assumption seems to be correct because the "print(number) line returns 5, but then the "print(number == 5)" line returns false, meaning it isn't 5.
I first come across this problem while trying to make a simple block placer program. I set up these variables at the start of the program:
local tArgs = { ... }
local totalX = tArgs[1]
local totalY = tArgs[2]
local currentX = 0
local currentY = 0
And then the plan was to have the turtle place a block, move forward and then +1 to the currentX value until currentX == totalX but I found that totalX doesn't actually show up as a number when you compare them so they were never equalling each other and the turtle was going forward forever.I'm really sorry if this is a stupid/obvious question, I have looked all over for information on tables but even though I picked up the other basics of LUA quite quickly tables are giving me so much trouble, I think I must be looking at them the wrong way.