Logistic Network Identifier

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
ILLISIS
Inserter
Inserter
Posts: 25
Joined: Wed Feb 09, 2022 10:49 am
Contact:

Logistic Network Identifier

Post by ILLISIS »

Hi

I have a need in Constructron-Continued to be able to identify a logistic network and not just individual roboports and/or it's neighbors. v1.0.7 will walk between service stations(effectively roboports) based on a game.tick time out and walk to the next closest station with no regard for if it is in the same logistic network or not.

Essentially what I briefly would like to do is identify the logistic networks and their contents in storage then do some logic on what items can be fulfilled in each.

This probably could be achieved with a lot more code but this is a simple and clean way of doing it.

Thanks
meifray
Long Handed Inserter
Long Handed Inserter
Posts: 61
Joined: Sat May 29, 2021 6:12 pm
Contact:

Re: Logistic Network Identifier

Post by meifray »

I think it is already possible in both way:

From top down,you can use LuaForce.logistic_networks[surface_name][index] to get LuaLogisticNetwork
https://lua-api.factorio.com/latest/Lua ... c_networks
https://lua-api.factorio.com/latest/Lua ... twork.html

which will have the property you need.

From bottom up,you can LuaEntity.logistic_network to get it.
https://lua-api.factorio.com/latest/Lua ... ic_network

nah,Id system for logistic network is really something needed
ILLISIS
Inserter
Inserter
Posts: 25
Joined: Wed Feb 09, 2022 10:49 am
Contact:

Re: Logistic Network Identifier

Post by ILLISIS »

I thought I might give this a bump.
User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3724
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Logistic Network Identifier

Post by DaveMcW »

Here is a function you can use to get a unique identifier for a logistic network.

Code: Select all

function get_logistic_network_id(logistic_network)
  if not global.logistic_networks then global.logistic_networks = {} end
  for id, n in pairs(global.logistic_networks) do 
    if n == logistic_network then
      return id
    end
  end
  if not global.last_id then global.last_id = 0 end
  global.last_id = global.last_id + 1
  global.logistic_networks[global.last_id] = logistic_network
  return global.last_id
end
Post Reply

Return to “Modding interface requests”