diff --git a/LandfillPainting/data-updates.lua b/LandfillPainting/data-updates.lua index 224eaae..de6d080 100644 --- a/LandfillPainting/data-updates.lua +++ b/LandfillPainting/data-updates.lua @@ -1,8 +1,10 @@ -for _,v in pairs(data.raw.tile) do +local tile_collision_masks = require("__base__/prototypes/tile/tile-collision-masks") + +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 + for _, c in pairs(v.collision_mask or {}) do + if c == tile_collision_masks.ground() then found = true end end @@ -10,22 +12,22 @@ for _,v in pairs(data.raw.tile) do if not v.collision_mask then v.collision_mask = {} end - table.insert(v.collision_mask, LANDFILL_PAINTING_LAYER) + table.insert(v.collision_mask, tile_collision_masks.ground()) end end end -local technology = data.raw.technology['water-washing-2'] +local technology = data.raw.technology["angels-water-washing-2"] if technology and technology.effects then for i, effect in pairs(technology.effects) do - if effect.type == 'unlock-recipe' and effect.recipe == 'solid-mud-landfill' then + if effect.type == "unlock-recipe" and effect.recipe == "angels-solid-mud-landfill" then table.remove(technology.effects, i) end end end -technology = data.raw.technology['water-washing-1'] +technology = data.raw.technology["angels-water-washing-1"] if technology then - table.insert(technology.effects, {type = 'unlock-recipe', recipe = 'solid-mud-landfill'}) + table.insert(technology.effects, { type = "unlock-recipe", recipe = "angels-solid-mud-landfill" }) end diff --git a/LandfillPainting/data.lua b/LandfillPainting/data.lua index 94f05f1..f1411d6 100644 --- a/LandfillPainting/data.lua +++ b/LandfillPainting/data.lua @@ -1,147 +1,147 @@ -require "util" -local collision_mask_util = require("collision-mask-util") +require("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 +local tile_collision_masks = require("__base__/prototypes/tile/tile-collision-masks") local terrains = { "dry-dirt", "dirt-4", "grass-1", "red-desert-1", - "sand-3" -} -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" + "sand-3", } -local baserecipe = data.raw.recipe['landfill'] -local technology = data.raw.technology['landfill'] - -if mods['angelssmelting'] and data.raw.technology['water-washing-1'] and - (data.raw.technology['water-washing-1'].enabled == nil or data.raw.technology['water-washing-1'].enabled) and - data.raw.recipe['solid-mud-landfill'] then - baserecipe = data.raw.recipe['solid-mud-landfill'] - technology = data.raw.technology['water-washing-1'] - data:extend({{ - type = "item-subgroup", - name = "water-landfill", - group = "water-treatment", - order = "eb" - }}) +local baserecipe = data.raw.recipe["landfill"] +local technology = data.raw.technology["landfill"] + +if + mods["angelssmelting"] + and data.raw.technology["angels-water-washing-1"] + and (data.raw.technology["angels-water-washing-1"].enabled == nil or data.raw.technology["angels-water-washing-1"].enabled) + and data.raw.recipe["angels-solid-mud-landfill"] +then + baserecipe = data.raw.recipe["angels-solid-mud-landfill"] + technology = data.raw.technology["angels-water-washing-1"] + data:extend({ + { + type = "item-subgroup", + name = "water-landfill", + group = "angels-water-treatment", + order = "eb", + }, + }) baserecipe.subgroup = "water-landfill" baserecipe.order = nil else - data:extend({{ - type = "item-subgroup", - name = "terrain-landfill", - group = "logistics", - order = "hb" - }}) + data:extend({ + { + type = "item-subgroup", + name = "terrain-landfill", + group = "logistics", + order = "hb", + }, + }) baserecipe.subgroup = "terrain-landfill" end -for _,v in ipairs(terrains) do +for _, v in ipairs(terrains) do local item = { type = "item", name = "landfill-" .. v, - localised_name = {names[v]}, - localised_description = {"item-description.landfill"}, + localised_name = { "tile-name." .. v }, + localised_description = { "item-description.landfill" }, icon = "__LandfillPainting__/graphics/icons/landfill-" .. v .. ".png", - icon_size = 64, icon_mipmaps = 4, + icon_size = 64, + icon_mipmaps = 4, subgroup = "terrain", order = "c[landfill]-a[" .. v .. "]", stack_size = 100, - place_as_tile = - { + place_as_tile = { result = v, condition_size = 1, - condition = {LANDFILL_PAINTING_LAYER} - } + condition = tile_collision_masks.ground(), + }, } + local recipe = util.table.deepcopy(baserecipe) recipe.name = "landfill-" .. v + recipe.localised_name = { "tile-name." .. v } + if recipe.results then recipe.results[1].name = "landfill-" .. v else - recipe.result = "landfill-" .. v + recipe.results = { item } end - data:extend({item}) - data:extend({recipe}) + data.raw.tile[v].minable = { + mining_time = data.raw.tile["landfill"].minable.mining_time, + result = item.name, + } + + data:extend({ item }) + data:extend({ recipe }) 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"].icon = "__LandfillPainting__/graphics/icons/landfill-landfill.png" +data.raw.item["landfill"].place_as_tile.condition = tile_collision_masks.ground() -- dry-dirt -> dirt-1 -> dirt-2 ->dirt-3 -- dirt-4 -> dirt-5 -> dirt-6 -> dirt-7 -- grass-1 -> grass-3 -> grass-2 -> grass-4 -- red-desert-1 -> red-desert-2 -> red-desert-3 -> red-desert-4 -- sand-3 -> sand-1 -> sand-2 -if settings.startup['landfillpainting-use-rotation'].value then - for _,v in ipairs(terrains) do - data.raw.item['landfill-' .. v].localised_description = {'item-description.landfillR'} +if settings.startup["landfillpainting-use-rotation"].value then + for _, v in ipairs(terrains) do + data.raw.item["landfill-" .. v].localised_description = { "item-description.landfillR" } end - data.raw.tile['dry-dirt'].next_direction = 'dirt-1' - data.raw.tile['dirt-1'].next_direction = 'dirt-2' - data.raw.tile['dirt-2'].next_direction = 'dirt-3' - data.raw.tile['dirt-3'].next_direction = 'dry-dirt' - - data.raw.tile['dirt-4'].next_direction = 'dirt-5' - data.raw.tile['dirt-5'].next_direction = 'dirt-6' - data.raw.tile['dirt-6'].next_direction = 'dirt-7' - data.raw.tile['dirt-7'].next_direction = 'dirt-4' - - data.raw.tile['grass-1'].next_direction = 'grass-3' - data.raw.tile['grass-3'].next_direction = 'grass-2' - data.raw.tile['grass-2'].next_direction = 'grass-4' - data.raw.tile['grass-4'].next_direction = 'grass-1' - - data.raw.tile['red-desert-0'].next_direction = 'red-desert-1' - data.raw.tile['red-desert-1'].next_direction = 'red-desert-2' - data.raw.tile['red-desert-2'].next_direction = 'red-desert-3' - data.raw.tile['red-desert-3'].next_direction = 'red-desert-0' - - data.raw.tile['sand-3'].next_direction = 'sand-1' - data.raw.tile['sand-1'].next_direction = 'sand-2' - data.raw.tile['sand-2'].next_direction = 'sand-3' + data.raw.tile["dry-dirt"].next_direction = "dirt-1" + data.raw.tile["dirt-1"].next_direction = "dirt-2" + data.raw.tile["dirt-2"].next_direction = "dirt-3" + data.raw.tile["dirt-3"].next_direction = "dry-dirt" + + data.raw.tile["dirt-4"].next_direction = "dirt-5" + data.raw.tile["dirt-5"].next_direction = "dirt-6" + data.raw.tile["dirt-6"].next_direction = "dirt-7" + data.raw.tile["dirt-7"].next_direction = "dirt-4" + + data.raw.tile["grass-1"].next_direction = "grass-3" + data.raw.tile["grass-3"].next_direction = "grass-2" + data.raw.tile["grass-2"].next_direction = "grass-4" + data.raw.tile["grass-4"].next_direction = "grass-1" + + data.raw.tile["red-desert-0"].next_direction = "red-desert-1" + data.raw.tile["red-desert-1"].next_direction = "red-desert-2" + data.raw.tile["red-desert-2"].next_direction = "red-desert-3" + data.raw.tile["red-desert-3"].next_direction = "red-desert-0" + + data.raw.tile["sand-3"].next_direction = "sand-1" + data.raw.tile["sand-1"].next_direction = "sand-2" + data.raw.tile["sand-2"].next_direction = "sand-3" end local allterrain = { - 'dry-dirt', - 'dirt-1', - 'dirt-2', - 'dirt-3', - 'dirt-4', - 'dirt-5', - 'dirt-6', - 'dirt-7', - 'grass-1', - 'grass-2', - 'grass-3', - 'grass-4', - 'red-desert-0', - 'red-desert-1', - 'red-desert-2', - 'red-desert-3', - 'sand-1', - 'sand-2', - 'sand-3' + "dry-dirt", + "dirt-1", + "dirt-2", + "dirt-3", + "dirt-4", + "dirt-5", + "dirt-6", + "dirt-7", + "grass-1", + "grass-2", + "grass-3", + "grass-4", + "red-desert-0", + "red-desert-1", + "red-desert-2", + "red-desert-3", + "sand-1", + "sand-2", + "sand-3", } -for _,v in pairs(allterrain) do + +for _, v in pairs(allterrain) do data.raw.tile[v].can_be_part_of_blueprint = nil 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/stylua.toml b/stylua.toml new file mode 100644 index 0000000..90af126 --- /dev/null +++ b/stylua.toml @@ -0,0 +1,2 @@ +indent_type = "Spaces" +indent_width = 2 \ No newline at end of file