I would like to know the precise positions of items held by a transport belt's lane.
I couldn't find any appropriate method in LuaTransportLine, except can_insert_at(), which is a very indirect way of finding where the items might be placed. It also doesn't say what items there are.
Using the LuaTransportLine's operator[] does tell me what items there are on the lane, but I can't figure out a way to get the LuaItemStacks' positions.
I also tried find_entities() on the nauvis LuaSurface, but that only seems to find the transport belt itself, not items lying on it.
Are items lying on the belt also LuaEntities? Can I find them somehow?
How to get item positions on a transport-belt?
- eradicator
- Smart Inserter
- Posts: 5207
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: How to get item positions on a transport-belt?
No. Historically they once were, but belts have been heavily performance-optimized.
I don't think there's a way to get the pixel-perfect stack position. The index of a stack in a LuaTransportLine - as you already know - covers a range of positions on the belt.
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.
Re: How to get item positions on a transport-belt?
I also needed to find the items on a single transport-belt, and I found a workaround.
If you mark a transport-belt for deconstruction, this breaks its connections. Then get_transport_line() returns a LuaTransportLine containing exactly the items on that belt.
If you mark a transport-belt for deconstruction, this breaks its connections. Then get_transport_line() returns a LuaTransportLine containing exactly the items on that belt.
- eradicator
- Smart Inserter
- Posts: 5207
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: How to get item positions on a transport-belt?
LuaEntity.get_transport_line() always returns a transport line for just that one belt.DaveMcW wrote: ↑Fri Nov 06, 2020 5:18 am I also needed to find the items on a single transport-belt, and I found a workaround.
If you mark a transport-belt for deconstruction, this breaks its connections. Then get_transport_line() returns a LuaTransportLine containing exactly the items on that belt.
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.