I don't see anything wrong with this, doesn't work though.

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.


(User was banned for this post ("Undescriptive thread title" - mahalis))

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?

[lua]Table = {}
Table[1] = 1
Table[2] = 1
Table[3] = 0
Table[4] = 0
Table[5] = 1
[/lua]

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:


return table[num] == 1

You could just do:


return table[num]