Page 1 of 1

ItemEntity from TransportLine

Posted: Tue Oct 18, 2016 9:13 am
by Neel
Currently TransportLine only gives item name and counts, I need to access the health too. Trying to find entities also skip the items on transport lines. So I can't get this info in any way, however the health exists, and is available if an inserter or player picks up the item from the belt.

Re: ItemEntity from TransportLine

Posted: Tue Oct 18, 2016 2:53 pm
by Afforess
Neel wrote:Currently TransportLine only gives item name and counts, I need to access the health too. Trying to find entities also skip the items on transport lines. So I can't get this info in any way, however the health exists, and is available if an inserter or player picks up the item from the belt.
TransportLines don't carry ItemEntities (or they haven't since 0.11), as I understand it's an emulated facsimile that is not really an entity. It sounds like the health field does need to be exposed somehow though.

Re: ItemEntity from TransportLine

Posted: Tue Oct 18, 2016 4:45 pm
by Rseding91
Ah yes, there was a bug fix in one of the recent versions of 0.14 that means I can now make a wrapper around LuaItemStack that will point at a item on belt. Or, at least I think I can :)

So, perhaps for 0.15 that will be added in.

Re: ItemEntity from TransportLine

Posted: Tue Oct 18, 2016 8:59 pm
by Neel
Rseding91 wrote:So, perhaps for 0.15 that will be added in.
Looking forward to it! <3

Re: ItemEntity from TransportLine

Posted: Fri Oct 21, 2016 12:27 am
by Neel
Any possibility this might come out in a 14.x version soon? I wanted to try some experimental ideas with stacks on belt.

The nice thing about health is that it's a double, so, can be used as an additional kind of type, or ID, or all kinds of crazy things. :)

Re: ItemEntity from TransportLine

Posted: Fri Oct 21, 2016 12:38 am
by Rseding91
Neel wrote:Any possibility this might come out in a 14.x version soon? I wanted to try some experimental ideas with stacks on belt.

The nice thing about health is that it's a double, so, can be used as an additional kind of type, or ID, or all kinds of crazy things. :)
No, also health isn't unique to an item. If 2 items have the same health the game will stack them. Also health is not a double: it's a float.

Re: ItemEntity from TransportLine

Posted: Fri Oct 21, 2016 2:06 am
by Neel
Sorry didn't phrase that right. I am aware that items with same health stack, and that's fine for my use case. Factorissimo uses it as id in a creative way, and I want to do something similar. Thanks for the correction on float vs double. 32 bits good enough for me. :)

Re: ItemEntity from TransportLine

Posted: Fri Oct 21, 2016 3:03 am
by aubergine18
There are plans to change the way it works in 0.15 according to the recent #FF: viewtopic.php?f=38&t=34319

It would be better to use some alternate approach, for example...

When the entity is mind, use the pre_mined events to swap it with a different entity (not sure if this is feasible if a robot is mining, although there's prototype flag to prevent robots mining a specific kind of entity)... Anyway, maybe a blueprint or something, that you can give a custom name or value to. I've not tried, but it should be possible to create custom blueprint prototype in your data.lua, so you can give it proper icon, name and description - the user will not be aware that it's a blueprint if done properly.