Hi,
I have got table formated that i store it by rown, and into them, i store columns, but i need to count how many nil values are in 1st column and in 2nd column. Ik, that i can do this by for, but is there way to do it with less script?
Do you have a set amount of rows and cells per column?
its 6x2 (6 rows * 2 columns)ā¦
I believe this should work unless I misunderstood you.
local NilCounter = 0
for i,v in ipairs(YourRowTableHere) do
for i = 1, 2 do
if YourRowTableHere[i] == nil then
NilCounter = NilCounter + 1
end
end
end
print(NilCounter)
Ok so for is only way (or easiest)?
As far as Iām aware that is the only way to do it.
And also i need to do it separatly for column 1 and 2, but for that i need only to set up 2 nil counters and replace the second for by 2 if
Do you have your table set up in a fashion similar to the following?
local Table = {{1,2,3,4,5,6}, {1,2,3,4,5,6}}
no, i have columns in rows (as in html, i define table for each row and put columns into it)
Currently there is no method that can count a value in a table.
If you have to do it multiple times, I suggest you using a function, so you will have that long code once at top, and can search a value in a table with only one line of code.