mirror of
https://github.com/minetest-mods/mesecons.git
synced 2025-07-06 09:30:23 +02:00
add fallback implementation for fifo_queue.add_list() in case table.move() is missing
This commit is contained in:
@ -20,10 +20,19 @@ function fifo_queue.add(self, v)
|
|||||||
self.buf_in[n] = v
|
self.buf_in[n] = v
|
||||||
end
|
end
|
||||||
|
|
||||||
-- add several elements to the queue
|
-- table.move is not available in some lua versions, provide a fallback implementaion
|
||||||
function fifo_queue.add_list(self, v)
|
if table.move ~= nil then
|
||||||
|
-- add several elements to the queue
|
||||||
|
function fifo_queue.add_list(self, v)
|
||||||
table.move(v, 1, #v, self.n_in + 1, self.buf_in)
|
table.move(v, 1, #v, self.n_in + 1, self.buf_in)
|
||||||
self.n_in = self.n_in + #v
|
self.n_in = self.n_in + #v
|
||||||
|
end
|
||||||
|
else
|
||||||
|
function fifo_queue.add_list(self, v)
|
||||||
|
for _, elem in ipairs(v) do
|
||||||
|
self:add(elem)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
-- removes and returns the next element, or nil of empty
|
-- removes and returns the next element, or nil of empty
|
||||||
function fifo_queue.take(self)
|
function fifo_queue.take(self)
|
||||||
|
Reference in New Issue
Block a user