how to detect if at least one item_request_proxy is being constructed

Place to get help with not working mods / modding interface.
User avatar
Stargateur
Filter Inserter
Filter Inserter
Posts: 346
Joined: Sat Oct 05, 2019 6:17 am
Contact:

how to detect if at least one item_request_proxy is being constructed

Post by Stargateur »

So, I dig "item-request-proxy" and wow that hard.

So to create a request I discover one must do create_entity using "item-request-proxy" entity name then I saw that item_request_proxy return the "The first found item request proxy targeting this entity." so that mean we should be able to create more than one "item-request-proxy" for the same entity. I tested and yes, that work.

So far so good, I use all of this to try to upgrade modules quality, and then I have a problem because I want to be able to cancel an upgrade, or even downgrade a module request, and I want to do that only if there is not this module quality in storage and it's still not being done, I did some test and is_registered_for_construction() look to work as expected but the problem is that is_registered_for_construction only return false if ALL request item are being not registered for construction (or at least according to my small testing). I wish to be able to know this for individual request. (could is_registered_for_construction return false if at least one request items is being constructed ? or could I ask for such feature with another api function like all_is_registered_for_construction )

Then back to start, I could do that by creating one item-request-proxy by module I want to upgrade. This way I could know with is_registered_for_construction that it's being done, but then the problem is how to retrieve all "item-request-proxy" for one entity. Cause item_request_proxy only return the first one. I guess I could do find_entities filter for "item-request-proxy" (and maybe position) then check for proxy_target. But this mean I need O(n) for one entity. Does item_request_proxy property already do an O(n) search anyway ? could we have a item_request_proxies[] property ?

Linked to Ability to put module ghost into module inventory

What are my other options ? did I miss the obvious ? What would you do ?

My brain right now (even if the simple fact it's possible to do all that is already amazing that very hard to understand :lol: )
Image
Rseding91
Factorio Staff
Factorio Staff
Posts: 16387
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: how to detect if at least one item_request_proxy is being constructed

Post by Rseding91 »

item request proxy will have a logistic point that's requesting the items it needs. You can check that to see which items are on-the-way to know which modules will be delivered.

https://lua-api.factorio.com/stable/cla ... ms_deliver
If you want to get ahold of me I'm almost always on Discord.
User avatar
Stargateur
Filter Inserter
Filter Inserter
Posts: 346
Joined: Sat Oct 05, 2019 6:17 am
Contact:

Re: how to detect if at least one item_request_proxy is being constructed

Post by Stargateur »

Look it doesn't return his logistic point, both get_logistic_point() from entity and proxy return empty. damm I feel I spamming you with questions :lol: thx for the help BTW I don't answer thx everytime to not spam

Code: Select all

9557.655 Script log(serpent.block(game.player.selected.item_request_proxy.insert_plan)):1: {
  {
    id = {
      name = "speed-module-3",
      quality = "legendary"
    },
    items = {
      in_inventory = {
        {
          inventory = 4,
          stack = 0
        },
        {
          inventory = 4,
          stack = 1
        },
        {
          inventory = 4,
          stack = 2
        },
        {
          inventory = 4,
          stack = 3
        }
      }
    }
  },
  {
    id = {
      name = "engine-unit"
    },
    items = {
      in_inventory = {
        {
          count = 50,
          inventory = 2,
          stack = 2
        }
      }
    }
  }
}
9564.571 Script log(serpent.block(game.player.selected.item_request_proxy.get_logistic_point())):1: {}
Rseding91
Factorio Staff
Factorio Staff
Posts: 16387
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: how to detect if at least one item_request_proxy is being constructed

Post by Rseding91 »

Ah my mistake. It looks like that value isn't actually exposed - although the proxy knows about it.
If you want to get ahold of me I'm almost always on Discord.
User avatar
Stargateur
Filter Inserter
Filter Inserter
Posts: 346
Joined: Sat Oct 05, 2019 6:17 am
Contact:

Re: how to detect if at least one item_request_proxy is being constructed

Post by Stargateur »

I think I will only upgrade module one by one, if there is a proxy existing with multiple module I will split it into several one module proxy, and if it's a proxy that contains other than just module I will just wait. Maybe this logistic point can be exposed in 2.1. Also one final comment, it's anoying that https://lua-api.factorio.com/latest/def ... .inventory have lab_modules mining_drill_modules crafter_modules beacon_modules that would be way more simpler to just have modules. Thus I don't know if that limit what we could do so maybe not. But that mean I will need to check entity type and that add to my code complexity
although the proxy knows about it.
Image
Post Reply

Return to “Modding help”