Page 1 of 1

Get item position on belt

Posted: Mon Feb 29, 2016 11:26 am
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.

Re: Get item position on belt

Posted: Mon Feb 29, 2016 12:04 pm
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.

Re: Get item position on belt

Posted: Mon Feb 29, 2016 12:38 pm
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.

Re: Get item position on belt

Posted: Mon Feb 29, 2016 12:59 pm
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.

Re: Get item position on belt

Posted: Wed Mar 02, 2016 7:32 am
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.

Re: Get item position on belt

Posted: Fri Mar 04, 2016 1:02 pm
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

Re: Get item position on belt

Posted: Fri Mar 04, 2016 5:42 pm
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.

Re: Get item position on belt

Posted: Sat Mar 05, 2016 5:45 pm
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.