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
3 months ago
0.17 - 1.1
3.20K
Logistic network

g Copy/blueprint with channel settings

a month ago
(updated a month 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)?

a month ago
(updated a month 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.

New response