Landfill plus | Breakable landfill, recipe changer and more


Allows the player to break landfill and enable various other landfill related tweaks.

Utilities
2 years ago
1.0 - 1.1
21.8K

g Fix for grass tile bug

4 years ago
(updated 4 years ago)

Hi, if you add this to your control.lua, it fixes the bug with grass tiles from old unmodded landfill. (Tested it in my save) Would be cool if you include it.

-- Replaces grass with water when mining landfill
local function on_mined_tile(event)
    local surface = game.get_surface(event.surface_index)

    if surface and surface.valid then
        local newTiles = {}

        for _,tile in pairs(event.tiles) do
            local oldTile = tile.old_tile

            if oldTile.name == "landfill" then
                local newTile = surface.get_tile(tile.position.x, tile.position.y)

                if newTile and newTile.valid and newTile.name == "grass-1" then
                    newTiles[#newTiles + 1] = {
                        name = "water",
                        position = tile.position
                    }
                end
            end
        end

        if #newTiles > 0 then
            surface.set_tiles(newTiles)
        end
    end
end

script.on_event(defines.events.on_player_mined_tile, on_mined_tile)
script.on_event(defines.events.on_robot_mined_tile, on_mined_tile)
4 years ago

Hello,
thank you so much for a fix for this problem. I don't really know how scripting in factorio works so I couldn't fix it on my own.
This change will be implemented in version 1.0.3 of the mod.
Have a great day!

4 years ago

Great, thanks for implementing it!

New response