I'd like to clone both ends of an underground belt, and in addition copy over all the items on the LuaTransportLines underground.
This is for a softmod, so API only.
Is that possible?
Cloning underground belts - clone their transport line too?
-
- Inserter
- Posts: 24
- Joined: Wed Apr 29, 2020 9:53 pm
- Contact:
Re: Cloning underground belts - clone their transport line too?
Should be far as I know - LuaEntity has a member neighbours that for underground belts includes it's matching pair. It also has get_max_transport_line_index() and get_max_transport_line_index(index) which should let you grab the items that are on them. Not sure if you can get the exact positions of items on the underground portion, but you can insert things.
Also not sure, but LuaSurface.clone_entities MIGHT include the items? Haven't tried that and documentation doesn't say at all what aspects are copied, if any.
Also not sure, but LuaSurface.clone_entities MIGHT include the items? Haven't tried that and documentation doesn't say at all what aspects are copied, if any.
-
- Inserter
- Posts: 24
- Joined: Wed Apr 29, 2020 9:53 pm
- Contact:
Re: Cloning underground belts - clone their transport line too?
Seems like that might work.
As somebody who hasn't used LuaTransportLine much before, can you give any pointers as to how I'd use get_max_transport_line_index() here?
Currently, when I clone a bunch of belts and undergrounds, the items on the belt clone across along with the belts but any items underground are lost.
(I haven't tried clone_entities() yet, but I should try that soon.)
As somebody who hasn't used LuaTransportLine much before, can you give any pointers as to how I'd use get_max_transport_line_index() here?
Currently, when I clone a bunch of belts and undergrounds, the items on the belt clone across along with the belts but any items underground are lost.
(I haven't tried clone_entities() yet, but I should try that soon.)
Re: Cloning underground belts - clone their transport line too?
Honestly only reason I knew it existed was to help someone delete a modded item off all their belts/inserters once, but the max index bit is just so you know how many lines it has, so you can loop over them. AFAIK, it's always 2 for belts/undergrounds, but modded stuff might allow a different number.
Odd that items on undergrounds aren't included if belt items are. It might be worth putting in a modding interface request that cloning include items on underground belts if both sides of the belt are being cloned.
Odd that items on undergrounds aren't included if belt items are. It might be worth putting in a modding interface request that cloning include items on underground belts if both sides of the belt are being cloned.
- eradicator
- Smart Inserter
- Posts: 5206
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: Cloning underground belts - clone their transport line too?
You can not get the pixel perfect location, only the line index, which has a variance of 32/4 = 8 pixels.
TransportLine is not moddable. Belts and loaders have 2, underground 4 and splitters 8 lines it seems.
I agree that native "clone()" type functions should include underground items (if they actually don't - I didn't test that).
I can see the underground items on the output line of the input underground belts first pair of lines...
Code: Select all
/c game.print(serpent.line(game.player.selected.get_transport_line(2).output_lines[1].get_contents()))
Code: Select all
/c game.print(game.player.selected.get_transport_line(2).output_lines[1] == game.player.selected.get_transport_line(4))
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.