Page 1 of 1

copying belt contents

Posted: Fri Dec 13, 2024 3:04 am
by hgschmie
So I have two belt entities, that are identical, except one has items on it and the other one has not. I want to copy the contents of one belt to the other.

I tried this:

Code: Select all

for line_index = 1, entity.get_max_transport_line_index() do
    local source = entity.get_transport_line(line_index)
    local dest = target.get_transport_line(line_index)
    for item_index = 1, #source do
        dest.insert_at_back(source[item_index])
    end
    source.clear()
end
The source belt holds a handful of entities:
Screenshot 2024-12-12 at 18.59.40.png
Screenshot 2024-12-12 at 18.59.40.png (85.08 KiB) Viewed 63 times
and the destination belt reports true for dest.can_insert_at_back() before the first entity. The first entity copies over ok but now "can_insert_at_back" is false. So it only ever copies one (the first) entity.

For both, source and destination, the line length is shown as "1" in the debugger, which is weird as the source line clearly has five entities. What am I doing wrong?
Screenshot 2024-12-12 at 19.02.46.png
Screenshot 2024-12-12 at 19.02.46.png (142.41 KiB) Viewed 63 times