table.find finds the first occurrence of the value, I want to find the index of the exact value I am using.
local t = {1, 1, 4, 4, 1, 3}
for i, v in pairs(t) do
print(table.find(t, v)
end
Expected output
1, 2, 3, 4, 5, 6
Reality
1, 1, 3, 3, 1, 6
Sorry if I said or got something wrong.
msix29
(msix29)
#2
Try this instead.
print(table.find(t, v, i) --i is the starting Index to look from
1 Like
Forummer
(Forummer)
#3
local t = {1, 1, 4, 4, 1, 3}
for i, v in ipairs(t) do
print(table.find(t, v, i)) --1, 2, 3, 4, 5, 6
end
Just ‘i’ not ‘i + 1’.
1 Like
msix29
(msix29)
#4
I actually had it as i in the start but decided to add a 1, wasn’t sure, thanks for telling me tho!
This all works really well, thanks.
1 Like