Pipe Plus

by yokmp

Adds some additional underground pipe-stuff.

Content
4 months ago
1.1 - 2.0
6.87K
Logistics Fluids

i Factoriopedia simulations

4 months ago

Hello, I've been working on adding color coded variants of your pipes to my mod (nice work on the sprites btw, they look great!). As I was updating the factoriopedia simulations on my mod, I noticed that the pipes in this mod use the default pipe-to-ground simulation. I hope I'm not overstepping, but I figured I'd share the little code I wrote in case you want it. I use this for my color-coded pipes, but it should work for yours as well :)

---@param old_entity_name string
---@param new_entity_name string
---@param simulation data.SimulationDefinition
local function update_factoriopedia_simulation(old_entity_name, new_entity_name, simulation)
    simulation.init = simulation.init or ""
    simulation.init = simulation.init .. [[
        for _, surface in pairs(game.surfaces) do
            local original_entities = surface.find_entities_filtered { name = "]] .. old_entity_name .. [[" }
            for _, original_entity in pairs(original_entities) do
                surface.create_entity {
                    name = "]] .. new_entity_name .. [[",
                    position = original_entity.position,
                    force = original_entity.force,
                    direction = original_entity.direction,
                    fluidbox = original_entity.fluidbox,
                    fast_replace = true,
                    spill = false
                }
            end
        end
    ]]
end
local pipe_plus_pipes = {
    { type = "pipe-to-ground", name = "pipe-to-ground-2" },
    { type = "pipe-to-ground", name = "pipe-to-ground-3" },
}
for _, pipe in pairs(pipe_plus_pipes) do
    local entity = data.raw[pipe.type][pipe.name]
    if entity then
        local simulation = entity.factoriopedia_simulation
        if simulation then
            update_factoriopedia_simulation(pipe.type, pipe.name, simulation)
        end
    end
end
4 months ago

Thanks! Included in next release.

New response