I'm trying to emulate execution of certain functions from scripts of other app. That app have Lua library which contains function list(), it returns table where key is string UUID and value just string, like local tbl = { "0000..-0000-..." = "someString", etc... }. That table can be iterated in for loop, like
local lib = require("someLibrary.lua");
for key, value in lib.list() do
-- do something with keys and values, like print
end
-- or it can be used like this
local tbl = lib.list();
for key, value in tbl do -- tbl works as pairs(tbl) and works exactly how code on top
-- do something with keys and values, like print
end
So the question, how do I implement __call metamethod to work as pairs() or next() etc.?
Thanks
Yes! I've managed to find answer to my question. I've found source code of library that I trying to replicate. It actually uses local variables to iterate through table
Here is a code how I made
lib.list()andlstwork