I don't see anything wrong with this, doesn't work though.
6 replies, posted
So i have this table and a function. This is a example what im doing.
[lua]
Table = {
1 = 1,
2 = 1,
3 = 0,
4 = 0,
5 = 1
}
[/lua]
[lua]
function ThisExist( a )
return Table[ a ] == 1
end
[/lua]
So how come that doesn't return true when i check ThisExist( 1 ) and it should be true.
[highlight](User was banned for this post ("Undescriptive thread title" - mahalis))[/highlight]
[QUOTE=ChewGum;16276157]So i have this table and a function. This is a example what im doing.
[lua]
Table = {
1 = 1,
2 = 1,
3 = 0,
4 = 0,
5 = 1
}
[/lua]
[lua]
function ThisExist( a )
return Table[ a ] == 1
end
[/lua]
So how come that doesn't return true when i check ThisExist( 1 ) and it should be true.[/QUOTE]
I think you can just do your table like
Table = {1, 1, 0, 0, 1}
and Table[1] will be 1, Table [3] will be 0, etc.
Maybe that will fix it.
I want to see if the table[num] is 1 and then it returns true, thats what the functions does, but it doesn't seem to do that if I do ThisExist( 1 ).
That code should be throwing an error.
Non-string keys require being wrapped in [ ] for a constant.
So it should be
Table = {
[ 1 ] = 1,
...
}
Well, I missed that in my example.
Though the thing I do is I create a empty table then I do, EmptyTable = NewTable.
Then I do that check function and it doesn't return true even if the value in the table is 1.
If I do PrintTable on the table it says the value is 1, but the function doesn't seem to detect that, maybe its slow?
[QUOTE=ChewGum;16276546]I want to see if the table[num] is 1 and then it returns true, thats what the functions does, but it doesn't seem to do that if I do ThisExist( 1 ).[/QUOTE]
So, it's a boolean table? Why not just use true/false? Would make it a lot easier in the long run. So instead of doing:
[code]return table[num] == 1[/code]
You could just do:
[code]return table[num][/code]
Sorry, you need to Log In to post a reply to this thread.