Make: foreach take any pair data
This commit is contained in:
parent
9aaba0eca6
commit
6096d5601a
|
@ -27,7 +27,7 @@ end, function() minetest.log("Callback") end)
|
|||
5. run throught each element in a table.
|
||||
```lua
|
||||
local array = {"start", "text2", "text3", "text4", "text5", "end"}
|
||||
async.foreach(array, function(k, v)
|
||||
async.foreach(pairs(array), function(k, v)
|
||||
minetest.log(v)
|
||||
end, function() minetest.log("Callback") end)
|
||||
```
|
||||
|
|
|
@ -68,11 +68,11 @@ function async.Async()
|
|||
return
|
||||
end)
|
||||
end
|
||||
self.foreach = function(array, func, callback)
|
||||
self.foreach = function(_pairs, func, callback)
|
||||
self.create_worker(function()
|
||||
local last_time = minetest.get_us_time() / 1000
|
||||
local maxtime = self.maxtime
|
||||
for k,v in ipairs(array) do
|
||||
for k, v in _pairs do
|
||||
local b = func(k, v)
|
||||
if b ~= nil and b == false then
|
||||
break
|
||||
|
|
Loading…
Reference in New Issue
Block a user