Logistic Network Channels


Adds communication channels to logistic networks. Logistic entities can be assigned to different channels, and will only form a network with other entities on the same channel. This allows for creating separate logistic networks in areas where they would normally overlap and be merged by the game into one network.

Tweaks
14 days ago
0.17 - 2.0
3.85K
Logistic network

g Copy/blueprint with channel settings

7 months ago
(updated 7 months ago)

Hi, so copy-paste/blueprinting works out-of-the-box now, but doesn't copy channel settings which makes building out e.g. a large transport network on a separate channel difficult. Anything that can be done (or another mod that helps with this)?

7 months ago
(updated 7 months ago)

i noticed the same thing. adding

local function save_blueprint_data(blueprint, mapping)
    for i, entity in pairs(mapping) do
        if entity.valid then
            local channel = get_channel(entity)
            if channel > 0  then
                blueprint.set_blueprint_entity_tag(i, 'channel', channel)
            end
        end
    end
end

-- saving to copy-paste tool & cut-paste tool
script.on_event(defines.events.on_player_setup_blueprint, function(event)
    local player = game.players[event.player_index]

    local cursor = player.cursor_stack
    if cursor and cursor.valid_for_read and cursor.type == 'blueprint' then
        save_blueprint_data(cursor, event.mapping.get())
    else
        global.blueprint_mappings[player.index] = event.mapping.get()
    end
end)

-- saving to regular blueprint
script.on_event(defines.events.on_player_configured_blueprint, function(event)
    local player = game.players[event.player_index]
    if (global.blueprint_mappings == nil) then
      return --invalid
    end
    local mapping = global.blueprint_mappings[player.index]
    local cursor = player.cursor_stack

    if cursor and cursor.valid_for_read and cursor.type == 'blueprint' and mapping and #mapping == cursor.get_blueprint_entity_count() then
        save_blueprint_data(cursor, mapping)
    end
    global.blueprint_mappings[player.index] = nil
end)

local function on_built(event)
    local tags = event.tags
    local channel = tags and tags.channel or 0
    if channel > 0  then
        set_channel(event.created_entity, channel)
    end
end

script.on_event(defines.events.on_built_entity, on_built)
script.on_event(defines.events.on_robot_built_entity, on_built)

at the end of control.lua will fix that.

6 months ago
(updated 6 months ago)

i noticed the same thing. adding

at the end of control.lua will fix that.

It works! But... game crashes, when trying to blueprint anything with 'create blueprint' tool (pick tool, then select anything with it). Error message:

The mod Logistic Network Channels (1.1.2) caused a non-recoverable error.
Please report this error to the mod author.

Error while running event LogiNetChannels::on_player_setup_blueprint (ID 70)
LogiNetChannels/control.lua:593: attempt to index field 'blueprint_mappings' (a nil value)
stack traceback:
LogiNetChannels/control.lua:593: in function <LogiNetChannels/control.lua:586>

Where line 593 is:

global.blueprint_mappings[player.index] = event.mapping.get()

in this script:
-- saving to copy-paste tool & cut-paste tool
script.on_event(defines.events.on_player_setup_blueprint, function(event)
local player = game.players[event.player_index]

    local cursor = player.cursor_stack
    if cursor and cursor.valid_for_read and cursor.type == 'blueprint' then
        save_blueprint_data(cursor, event.mapping.get())
    else
        global.blueprint_mappings[player.index] = event.mapping.get()
    end
end)
5 months ago

just lacking a nil check then (altho it does mean that the create blueprint tool probably woulndt work with it and would just be default behavior.

New response