Page 1 of 1

How to get item positions on a transport-belt?

Posted: Sun Aug 23, 2020 9:53 pm
by uukgoblin
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?

Re: How to get item positions on a transport-belt?

Posted: Tue Aug 25, 2020 3:12 pm
by eradicator
uukgoblin wrote: Sun Aug 23, 2020 9:53 pm Are items lying on the belt also LuaEntities?
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.

Re: How to get item positions on a transport-belt?

Posted: Fri Nov 06, 2020 5:18 am
by DaveMcW
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.

Re: How to get item positions on a transport-belt?

Posted: Mon Nov 16, 2020 10:30 am
by eradicator
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.
LuaEntity.get_transport_line() always returns a transport line for just that one belt.