Page 1 of 1

on_item_request_removed

Posted: Thu Oct 18, 2018 10:51 pm
by DaveMcW
I would like to know when an item-request-proxy is cancelled or completed. I don't care about items (because apparently that is hard). I just want to know when my item-request-proxy is removed and which entity (if it still exists) was the target.

Re: on_item_request_removed

Posted: Sat Feb 09, 2019 8:26 pm
by Arcitos
+1

Dear devs,
please make completion and cancellation of entity-type "item-request-proxy" detectable. Currently there is no efficient way to get information about this, because the "death" of item request proxies is also not covered by event.on_entity_died().

Regards,
Arcitos

Re: on_item_request_removed

Posted: Sat Feb 09, 2019 8:36 pm
by quyxkh
I think the problem with this might be that mods can fulfill those requests themselves, there's no way to know what's going to happen when a mod reads an entity's `item_requests` or sets it nil.

Re: on_item_request_removed

Posted: Sat Feb 09, 2019 9:14 pm
by Arcitos
quyxkh wrote:
Sat Feb 09, 2019 8:36 pm
[...] there's no way to know what's going to happen when a mod reads an entity's `item_requests` or sets it nil.
If the "item_requests"-value of a item-request-proxy is set to nil, the item-request-proxy is fulfilled and subsequently removed (i tested this a few minutes ago). It doesn't matter if this is done by drones or by setting it to nil via script. I just want to know that an item-request-proxy has been fulfilled/removed.

Re: on_item_request_removed

Posted: Sat Apr 18, 2020 7:38 pm
by moon69
This would be handy.

Re: on_item_request_removed

Posted: Sat Apr 18, 2020 10:40 pm
by Rseding91
Why?

Re: on_item_request_removed

Posted: Sun Apr 19, 2020 5:08 am
by DaveMcW
The general use case is to make complicated buildings that require multiple items to build. Instead of a ghost, you build a chest with an item-request-proxy, then check every tick if it has the complete set of items to build it. This event would remove the requirement to check every tick.

My specific use case was for Blueprintable Trains, which is no long needed now that they are in the base game.

Re: on_item_request_removed

Posted: Sun Apr 19, 2020 5:23 pm
by moon69
Similar to Dave really - I want to avoid plopping complete things down, but rather build them in stages.

I'm also working on a construction bot based ammo/fuel filling station.

Is it an expensive thing to implement or make performant? I assumed the game already knows when the request is complete as it removes the proxy?

Re: on_item_request_removed

Posted: Sun Apr 19, 2020 6:10 pm
by eradicator
+1
For progressively building structures like in traditional RTS games. I.e. if something needs 100 wood planks then every plank delivered builds 1% of the structure.

If the proxy entity knew which bots are heading towards itself (i.e. something like LuaEntity.bots_ordered_to_build_this (table or nil)?) then it would at least be possibly to make a cheaper polling solution in script by estimating the bots arrival time based on max_speed. Ofc an event would be much cleaner so that's just my usual "maybe that's easier to implement" compromise.

Re: on_item_request_removed

Posted: Sun Apr 19, 2020 6:32 pm
by Rseding91
eradicator wrote:
Sun Apr 19, 2020 6:10 pm
+1
For progressively building structures like in traditional RTS games. I.e. if something needs 100 wood planks then every plank delivered builds 1% of the structure.

If the proxy entity knew which bots are heading towards itself (i.e. something like LuaEntity.bots_ordered_to_build_this (table or nil)?) then it would at least be possibly to make a cheaper polling solution in script by estimating the bots arrival time based on max_speed. Ofc an event would be much cleaner so that's just my usual "maybe that's easier to implement" compromise.
That's a completely different request: on-item-delivered - and it's not going to happen.

The original request for an event when the proxy is being deleted because it was fulfilled might happen.

Re: on_item_request_removed

Posted: Sun Apr 19, 2020 7:41 pm
by Oktokolo
Rseding91 wrote:
Sun Apr 19, 2020 6:32 pm
That's a completely different request: on-item-delivered - and it's not going to happen.
The original request for an event when the proxy is being deleted because it was fulfilled might happen.
If on-item-request-proxy-complete gets implemented, someone could use it for incremental building by creating one proxy per build stage.
That would certainly not be as UPS-friendly as on-item-delivered. But it might (or might not - would have to be benchmarked) still be better than checking the current state each 6th tick (100ms response time).

Re: on_item_request_removed

Posted: Sun Apr 19, 2020 7:42 pm
by Rseding91
Oktokolo wrote:
Sun Apr 19, 2020 7:41 pm
Rseding91 wrote:
Sun Apr 19, 2020 6:32 pm
That's a completely different request: on-item-delivered - and it's not going to happen.
The original request for an event when the proxy is being deleted because it was fulfilled might happen.
If on-item-request-proxy-complete gets implemented, someone could use it for incremental building by creating one proxy per build stage.
That would certainly not be as UPS-friendly as on-item-delivered. But it might (or might not - would have to be benchmarked) still be better than checking the current state each 6th tick (100ms response time).
That would end up taking more CPU time overall because 5 robots would have to get sent out vs 1 with all the items.

Re: on_item_request_removed

Posted: Mon Apr 20, 2020 7:46 pm
by eradicator
Rseding91 wrote:
Sun Apr 19, 2020 6:32 pm
That's a completely different request: on-item-delivered - and it's not going to happen.

The original request for an event when the proxy is being deleted because it was fulfilled might happen.
I think you completely misunderstood my post, there was no request in that post. But if on_item_request_removed happens it doesn't really matter.

Re: on_item_request_removed

Posted: Mon Apr 20, 2020 10:02 pm
by Oktokolo
Rseding91 wrote:
Sun Apr 19, 2020 7:42 pm
Oktokolo wrote:
Sun Apr 19, 2020 7:41 pm
If on-item-request-proxy-complete gets implemented, someone could use it for incremental building by creating one proxy per build stage.
That would certainly not be as UPS-friendly as on-item-delivered. But it might (or might not - would have to be benchmarked) still be better than checking the current state each 6th tick (100ms response time).
That would end up taking more CPU time overall because 5 robots would have to get sent out vs 1 with all the items.
Yes, that probably kills cosmetic build stages.

Re: on_item_request_removed

Posted: Tue Mar 09, 2021 12:53 pm
by DaveMcW
I found another use case, I would like to know when a newly built locomotive is refueled.

Re: on_item_request_removed

Posted: Wed Mar 10, 2021 2:02 am
by PFQNiet
Does "register_on_entity_destroyed" not work for item request proxies? Because that might be a helpful first step. You'd have to determine if it was caused by the requesting entity being destroyed, or the player cancelling the request, or it being fulfilled, but it could be wrangled.

Alternatively, keeping a table of item request proxy entities and looping over that every tick... It might sound bad but I have to wonder how many of them you expect to have at any given time. Unless you expect there to be hundreds of thousands of them, I wouldn't worry so much about UPS - especially if most of the time the number is more like zero because everything is fulfilled. "Iterating" over an empty table takes a mere nanoseconds.

Re: on_item_request_removed

Posted: Wed Mar 10, 2021 3:37 am
by DaveMcW
PFQNiet wrote:
Wed Mar 10, 2021 2:02 am
Does "register_on_entity_destroyed" not work for item request proxies?
Sadly it does not. But that would also work for me if it was implemented!

Re: on_item_request_removed

Posted: Sat May 15, 2021 2:48 pm
by ickputzdirwech
DaveMcW wrote:
Wed Mar 10, 2021 3:37 am
PFQNiet wrote:
Wed Mar 10, 2021 2:02 am
Does "register_on_entity_destroyed" not work for item request proxies?
Sadly it does not. But that would also work for me if it was implemented!
It does work for me. Did they implement it only very recently?

Re: on_item_request_removed

Posted: Sat May 15, 2021 4:53 pm
by DaveMcW
It seems they did, this can be moved to Implemented mod requests!