diff --git a/LandfillPainting/changelog.txt b/LandfillPainting/changelog.txt index 91c380b..e29bb12 100644 --- a/LandfillPainting/changelog.txt +++ b/LandfillPainting/changelog.txt @@ -1,4 +1,10 @@ --------------------------------------------------------------------------------------------------- +Version: 0.6.0 +Date: 23.11.2024 + Changes: + - Update for Factorio 2.0 + - Allowed landfill to be placed over any existing tile (including other landfill types and concrete) +--------------------------------------------------------------------------------------------------- Version: 0.5.3 Date: 02.12.2023 Bugfixes: diff --git a/LandfillPainting/data-updates.lua b/LandfillPainting/data-updates.lua index 224eaae..6e668ae 100644 --- a/LandfillPainting/data-updates.lua +++ b/LandfillPainting/data-updates.lua @@ -1,20 +1,3 @@ -for _,v in pairs(data.raw.tile) do - if v.minable then - local found = false - for _,c in pairs(v.collision_mask or {}) do - if c == LANDFILL_PAINTING_LAYER then - found = true - end - end - if not found then - if not v.collision_mask then - v.collision_mask = {} - end - table.insert(v.collision_mask, LANDFILL_PAINTING_LAYER) - end - end -end - local technology = data.raw.technology['water-washing-2'] if technology and technology.effects then diff --git a/LandfillPainting/data.lua b/LandfillPainting/data.lua index 94f05f1..ae47002 100644 --- a/LandfillPainting/data.lua +++ b/LandfillPainting/data.lua @@ -1,16 +1,12 @@ require "util" -local collision_mask_util = require("collision-mask-util") -LANDFILL_PAINTING_LAYER = collision_mask_util.get_first_unused_layer() - -local function findname(t, name) - for i,v in ipairs(t) do - if v.name == name then - return v - end - end -end +-- Collision masks have been replaced with CollisionMaskConnector prototypes in 2.0, which contains a property "layers" +-- Settings layers to empty means that the tile can be placed on top of anything +LANDFILL_COLLISION_MASK_CONNECTOR = { + layers = {} +} +-- Define the names of each terrain type we're adding local terrains = { "dry-dirt", "dirt-4", @@ -18,14 +14,17 @@ local terrains = { "red-desert-1", "sand-3" } + +-- Define the localised names of each terrain type we're adding, additional localised names can be added in lanfillpainting/locale local names = { - ["dry-dirt"] = "tile-name.dry-dirt", - ["dirt-4"] = "autoplace-control-names.dirt", - ["grass-1"] = "autoplace-control-names.grass", - ["red-desert-1"] = "autoplace-control-names.desert", - ["sand-3"] = "autoplace-control-names.sand" + ["dry-dirt"] ="tile-name.dry-dirt", + ["dirt-4"] = "tile-name.dirt", + ["grass-1"] = "tile-name.grass", + ["red-desert-1"] = "tile-name.desert", + ["sand-3"] = "tile-name.sand" } +-- Get the vanilla landfill recipe and technology prototypes local baserecipe = data.raw.recipe['landfill'] local technology = data.raw.technology['landfill'] @@ -52,11 +51,12 @@ else baserecipe.subgroup = "terrain-landfill" end -for _,v in ipairs(terrains) do +-- Add new items and recipes for each terrain type +for i,v in ipairs(terrains) do local item = { type = "item", name = "landfill-" .. v, - localised_name = {names[v]}, + localised_name = {v .. '-name.name'}, localised_description = {"item-description.landfill"}, icon = "__LandfillPainting__/graphics/icons/landfill-" .. v .. ".png", icon_size = 64, icon_mipmaps = 4, @@ -67,8 +67,8 @@ for _,v in ipairs(terrains) do { result = v, condition_size = 1, - condition = {LANDFILL_PAINTING_LAYER} - } + condition = LANDFILL_COLLISION_MASK_CONNECTOR + }, } local recipe = util.table.deepcopy(baserecipe) recipe.name = "landfill-" .. v @@ -83,8 +83,10 @@ for _,v in ipairs(terrains) do table.insert(technology.effects, { type = "unlock-recipe", recipe = "landfill-" .. v }) end + + data.raw.item['landfill'].icon = "__LandfillPainting__/graphics/icons/landfill-landfill.png" -data.raw.item['landfill'].place_as_tile.condition = {LANDFILL_PAINTING_LAYER} +data.raw.item['landfill'].place_as_tile.condition = LANDFILL_COLLISION_MASK_CONNECTOR -- dry-dirt -> dirt-1 -> dirt-2 ->dirt-3 -- dirt-4 -> dirt-5 -> dirt-6 -> dirt-7 @@ -144,4 +146,11 @@ local allterrain = { } for _,v in pairs(allterrain) do data.raw.tile[v].can_be_part_of_blueprint = nil + + -- Enable vanilla landfill to be replace all types of terrain that LandfillPainter allows the player to create + if data.raw.item['landfill'].place_as_tile.tile_condition then + table.insert(data.raw.item['landfill'].place_as_tile.tile_condition, v) + else + data.raw.item['landfill'].place_as_tile.tile_condition = {v} + end end diff --git a/LandfillPainting/info.json b/LandfillPainting/info.json index 7de28df..3dc598d 100644 --- a/LandfillPainting/info.json +++ b/LandfillPainting/info.json @@ -1,7 +1,7 @@ { "name": "LandfillPainting", - "version": "0.5.3", - "factorio_version": "1.1", + "version": "0.6.0", + "factorio_version": "2.0", "title": "Landfill Painting", "author": "Trainwreck", "description": "Adds some different types of terrain landfill, allows landfill to overwrite existing terrain", diff --git a/LandfillPainting/locale/en/LandfillPainting.cfg b/LandfillPainting/locale/en/LandfillPainting.cfg index d1f7cf0..f3510f5 100644 --- a/LandfillPainting/locale/en/LandfillPainting.cfg +++ b/LandfillPainting/locale/en/LandfillPainting.cfg @@ -1,6 +1,21 @@ [item-description] landfillR=Press __CONTROL__rotate__ with item in hand to cycle terrain variations +[dry-dirt-name] +name=Dry dirt + +[dirt-4-name] +name=Dirt + +[grass-1-name] +name=Grass + +[red-desert-1-name] +name=Red desert + +[sand-3-name] +name=Sand + [mod-setting-name] landfillpainting-use-rotation=Rotate to select landfill variation diff --git a/LandfillPainting/migrations/LandfillPainting_0.1.3.lua b/LandfillPainting/migrations/LandfillPainting_0.1.3.lua index d66750e..60dfebb 100644 --- a/LandfillPainting/migrations/LandfillPainting_0.1.3.lua +++ b/LandfillPainting/migrations/LandfillPainting_0.1.3.lua @@ -1,16 +1,27 @@ +-- Define the names of each terrain type we're adding +local terrains = { + "dry-dirt", + "dirt-4", + "grass-1", + "red-desert-1", + "sand-3" +} + for _, force in pairs(game.forces) do force.reset_technologies() force.reset_recipes() + + -- Get appropriate technology local tech = force.technologies['landfill'] - if force.technologies['water-washing'] and force.technologies['water-washing'].enabled then + if force.technologies['water-washing'] and + force.technologies['water-washing'].enabled then tech = force.technologies['water-washing'] end - if tech.researched then - for _,v in ipairs(tech.effects) do - if v.type == 'unlock-recipe' then - force.recipes[v.recipe].enabled = true - end + + -- Enable recipes if technology is researched + if tech and tech.researched then + for i,v in ipairs(terrains) do + force.recipes['landfill-' .. v].enabled = true end end -end - +end \ No newline at end of file