I have x/y coordinates in the world. The tile they point at is a belt or splitter. I want to get the number of the transport line my coordinates point at, and the "position" on that transport line. Possibly only if there's an exact match, possibly the nearest match.
Also the reverse, from transportline+position to Position
I would use this functionality in Belt Overflow and other items-on-belts manipulating mods.
convert Position to LuaTransportLine and position
Re: convert Position to LuaTransportLine and position
Now that we have info on which transportlines connect to which others, this would be even more useful to figure out where items leaving one will appear on the other.
-
- Inserter
- Posts: 24
- Joined: Mon Feb 11, 2019 12:37 pm
- Contact:
Re: convert Position to LuaTransportLine and position
Support on this.
I'd like a that returns the index of the transport line, or nil if position is outside the TransportBeltConnectable (the index so we can easily call get_transport_line(index) and do some math with the index). Would be nice if it would return that position as well as a second return value.
Or have LuaEntity.drop_target also store the LuaTransportLine or its index as a second value if the target is a TransportBeltConnectable.
But if we have the .get_transport_line_index(position) then we get that behaviour with
I wrote my own function for this to try to figure out at which transportline an inserter is inserting items to.
Which works fine. All vanilla inserters insert at the top right corner of a belt.
Except for that one exception where you're inserting on a corner piece
Which is literally the only exception. A south facing inserter inserting to a north facing belt that has only a east facing belt feeding into it from the west. (And similarly for all its 90 degree rotation variations)
Accounting for that exception is the majority of the code of that method (can probably be optimized a bit) and it probably breaks when using modded inserters.
I'd like a
Code: Select all
LuaEntity.get_transport_line_index(position)
Or have LuaEntity.drop_target also store the LuaTransportLine or its index as a second value if the target is a TransportBeltConnectable.
But if we have the .get_transport_line_index(position) then we get that behaviour with
Code: Select all
local belt = inserter.drop_target
local transport_line = belt.get_transport_line(belt.get_transport_line_index(inserter.drop_position)
I wrote my own function for this to try to figure out at which transportline an inserter is inserting items to.
Which works fine. All vanilla inserters insert at the top right corner of a belt.
Except for that one exception where you're inserting on a corner piece

Which is literally the only exception. A south facing inserter inserting to a north facing belt that has only a east facing belt feeding into it from the west. (And similarly for all its 90 degree rotation variations)
Accounting for that exception is the majority of the code of that method (can probably be optimized a bit) and it probably breaks when using modded inserters.