Get item position on belt

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
Hexicube
Fast Inserter
Fast Inserter
Posts: 200
Joined: Wed Feb 24, 2016 9:50 pm
Contact:

Get item position on belt

Post by Hexicube »

Currently there's no way to check how far along a belt piece any given item is, which would be useful for determining if an item is at the end of that belt. I'd like to either be able to check how far along the belt lane a given item is (with a way to check the lane length too), or get the item currently at the end of the belt.

As it stands, if I want to remove a given item from a belt I have no way of doing it in a smooth manner. I either have to wait some specific unit of time calculated using the belt speed and configuration of surrounding belts (and hope that the configuration isn't changed during that time), or remove it immediately. My current use case (which is moving items to other nearby belts) results in teleporting items, since the item doesn't travel the length of the belt it was previously on.

Koub
Global Moderator
Global Moderator
Posts: 6550
Joined: Fri May 30, 2014 8:54 am
Contact:

Re: Get item position on belt

Post by Koub »

Well you can know an item is at the end of a belt if an inserter can pick it up and put it in a chest. Wouldn't it be enough to fulfill your needs ?
I ask because what you ask for seems somehow weird to implement. Each belt would need new attributes as total length, recalculated real time every time you remove or add a belt, ... A true nightmare.
Koub - Please consider English is not my native language.

Hexicube
Fast Inserter
Fast Inserter
Posts: 200
Joined: Wed Feb 24, 2016 9:50 pm
Contact:

Re: Get item position on belt

Post by Hexicube »

I'm adding an entity that splits each belt channel off to a different side, to fill in the gap of belt-based splitters that's only filled by the underground belt trick (which I view as mechanical exploitation and also suspect may be removed at any time). It currently functions fine, but items basically teleport a full tile forward.

I could probably solve the problem with some raw values, what kind of things would be easily exposed? Even something as simple as the tile state (left bend, right bend, or straight) and the position in the path would suffice. I don't explicitly need to know how far along the item is, just if it's at the end.

Hexicube
Fast Inserter
Fast Inserter
Posts: 200
Joined: Wed Feb 24, 2016 9:50 pm
Contact:

Re: Get item position on belt

Post by Hexicube »

Just realised I was a little unclear. When I was referring to the lane length, I meant the length in the single tile the item is on, not the entire path.

Rseding91
Factorio Staff
Factorio Staff
Posts: 11928
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Get item position on belt

Post by Rseding91 »

Hexicube wrote:... (which I view as mechanical exploitation and also suspect may be removed at any time)...
It isn't and It won't.
If you want to get ahold of me I'm almost always on Discord.

ShadowTheAge
Inserter
Inserter
Posts: 29
Joined: Fri Mar 04, 2016 12:58 pm
Contact:

Re: Get item position on belt

Post by ShadowTheAge »

This would be useful. I have also had this problem when you can't even check any additional parameters (for example damage or durability value) for entities on a belt. LuaTransportLine should have a method to get an ItemStack reference somehow.

For example, if you are making a belt teleporter. You should be able to get the first item on a belt and insert it into another belt. Players shouldn't be able to repair or refill items that comes through

Rseding91
Factorio Staff
Factorio Staff
Posts: 11928
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Get item position on belt

Post by Rseding91 »

ShadowTheAge wrote:This would be useful. I have also had this problem when you can't even check any additional parameters (for example damage or durability value) for entities on a belt. LuaTransportLine should have a method to get an ItemStack reference somehow.

For example, if you are making a belt teleporter. You should be able to get the first item on a belt and insert it into another belt. Players shouldn't be able to repair or refill items that comes through
The main problem with that is: the reference would only be valid so long as the contents of the belt didn't change and belts change contents *all* the time. If it wasn't for that I would have already added the ability to get ItemStack references from transport lines.
If you want to get ahold of me I'm almost always on Discord.

ratchetfreak
Filter Inserter
Filter Inserter
Posts: 950
Joined: Sat May 23, 2015 12:10 pm
Contact:

Re: Get item position on belt

Post by ratchetfreak »

Rseding91 wrote:
ShadowTheAge wrote:This would be useful. I have also had this problem when you can't even check any additional parameters (for example damage or durability value) for entities on a belt. LuaTransportLine should have a method to get an ItemStack reference somehow.

For example, if you are making a belt teleporter. You should be able to get the first item on a belt and insert it into another belt. Players shouldn't be able to repair or refill items that comes through
The main problem with that is: the reference would only be valid so long as the contents of the belt didn't change and belts change contents *all* the time. If it wasn't for that I would have already added the ability to get ItemStack references from transport lines.
But if it is enough for the processing in one tick then it's fine.

Post Reply

Return to “Modding interface requests”