Page 1 of 1

Logistic Network Identifier

Posted: Wed Feb 09, 2022 11:59 am
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

Re: Logistic Network Identifier

Posted: Thu Feb 10, 2022 1:04 am
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

Re: Logistic Network Identifier

Posted: Wed Mar 09, 2022 12:08 pm
by ILLISIS
I thought I might give this a bump.

Re: Logistic Network Identifier

Posted: Wed Mar 09, 2022 1:52 pm
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