From 4ee328a3f4a3734dd05b1f97876972ae64dbaf35 Mon Sep 17 00:00:00 2001 From: Joey De Pauw Date: Sat, 12 Oct 2019 11:53:07 +0200 Subject: [PATCH] reduce fluid capacity of air filters --- README.md | 6 ++- better-air-filtering/changelog.txt | 14 +++++-- better-air-filtering/control.lua | 4 +- better-air-filtering/info.json | 5 ++- better-air-filtering/migrations/0.1.2.lua | 38 +++++++++++++++++- better-air-filtering/prototypes/entity.lua | 46 +++++++++++----------- 6 files changed, 79 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 1ee56c9..3a29d58 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Better Air Filtering #### A mod for Factorio that provides complex air filtering steps to remove pollution. - +Based on the [air filtering mod](https://mods.factorio.com/mod/air-filtering) by [Schorty](https://mods.factorio.com/user/Schorty) ## Overview ![overview](https://github.com/JoeyDP/Factorio-Better-Air-Filtering/blob/master/res/overview.png?raw=true) @@ -26,6 +26,8 @@ There are currently two types of filters: __expendable filters__ and __recyclabl ## Technical Details Some things to keep in mind when using this mod: + + - Pollution updates are very UPS efficient. The suction of pollution is implemented per chunk, rather than per machine and updates are spread evenly over an interval of 20 ticks. - The [evolution](https://wiki.factorio.com/Enemies#Evolution) factor of enemies is based on the total amount of produced pollution. Cleaning it back up does not reverse this effect. This means that biters will still get stronger, no matter how proficient you are at cleaning pollution. You can prevent attacks caused by pollution reaching the biter nests however. - Pollution from other chunks is sucked toward air filters at an exponentially decreasing rate depending on the distance. The formula is `suction = base_suction * (1/4)^distance`. This means that filters only pull in approximately as much pollution as they can filter. - When an air filter machine or any other entity containing pollution is destroyed or mined, the pollution inside is dispersed back into the atmosphere. @@ -37,7 +39,7 @@ Refer to the Factorio mod page for the complete [changelog](https://mods.factori ## Future Features - A third and more efficient air filtering production chain based on first "dissolving" pollution in water and then treating it in chemical plants. - + - Support for signals, and a potential integration with https://mods.factorio.com/mod/pollution-detector. ## Bugs / Crashes / Suggestions > Important! This mod is in it's early stages of development and has not yet been extensively tested and balanced. diff --git a/better-air-filtering/changelog.txt b/better-air-filtering/changelog.txt index 359949d..7051a70 100644 --- a/better-air-filtering/changelog.txt +++ b/better-air-filtering/changelog.txt @@ -1,4 +1,12 @@ --------------------------------------------------------------------------------------------------- +Version: 0.1.2 +Date: 2019.10.12 + Features: + - Air filters tier 2 and 3 now behave like furnaces. They accept expendable air filters as well as reusable ones. + - Fluid capacity of air filter machines reduced to more reasonable amounts. + Locale: + - EN for reusable air filter tech. +--------------------------------------------------------------------------------------------------- Version: 0.1.1 Date: 2019.10.09 Features: @@ -10,9 +18,9 @@ Date: 2019.10.09 Version: 0.1.0 Date: 2019.10.08 Info: - - Initial release + - Initial release. Locale: - - Only English + - English. License: - - Using MIT License. + - MIT License. diff --git a/better-air-filtering/control.lua b/better-air-filtering/control.lua index b9eaa50..d2e0fdd 100644 --- a/better-air-filtering/control.lua +++ b/better-air-filtering/control.lua @@ -158,8 +158,8 @@ function absorbChunk(chunk) local totalAbsorptionRate = chunk:getTotalAbsorptionRate() - -- game.print("totalAbsorptionRate: " .. totalAbsorptionRate) - -- game.print("filter count: " .. #chunk.filters) + --game.print("totalAbsorptionRate: " .. totalAbsorptionRate) + --game.print("filter count: " .. #chunk.filters) if totalAbsorptionRate == 0 then return diff --git a/better-air-filtering/info.json b/better-air-filtering/info.json index 64c0008..da3cc77 100644 --- a/better-air-filtering/info.json +++ b/better-air-filtering/info.json @@ -8,7 +8,8 @@ "factorio_version": "0.17", "dependencies": [ "base >= 0.17", - "!air-filtering" + "!air-filtering", + "!NauvisDay" ], - "description": "An overhaul of the air filtering mod by Schorty." + "description": "An overhaul of the air filtering mod by Schorty. Includes complex air filtering steps to remove pollution." } diff --git a/better-air-filtering/migrations/0.1.2.lua b/better-air-filtering/migrations/0.1.2.lua index 1e60c44..71a542a 100644 --- a/better-air-filtering/migrations/0.1.2.lua +++ b/better-air-filtering/migrations/0.1.2.lua @@ -1,6 +1,40 @@ -for index, force in pairs(game.forces) do +-- Unlock new recipe +for _, force in pairs(game.forces) do local technologies = force.technologies local recipes = force.recipes recipes["filter-air-expendable"].enabled = technologies["air-filtering-2"].researched -end \ No newline at end of file +end + + +-- Doesn't work because migration script is loaded too late + +--local function capAtCapacity(entity, capacity) +-- local pollutionFluid = entity.fluidbox[1] +-- local pollution = 0 +-- if pollutionFluid then +-- pollution = pollutionFluid.amount +-- end +-- if pollution > capacity then +-- local toRemove = pollution - capacity +-- entity.surface.pollute(entity.position, toRemove) +-- entity.insert_fluid({ name = "pollution", amount = -toRemove }) +-- game.print("Removing " .. toRemove .. " pollution") +-- end +--end +-- +---- Disperse pollution (fluidbox made smaller) +--for _, surface in pairs(game.surfaces) do +-- local filters1 = surface.find_entities_filtered { +-- name = { "air-filter-machine-1" } +-- } +-- for _, filter in pairs(filters1) do +-- capAtCapacity(filter, 4) +-- end +-- local filters23 = surface.find_entities_filtered { +-- name = { "air-filter-machine-2", "air-filter-machine-3" } +-- } +-- for _, filter in pairs(filters23) do +-- capAtCapacity(filter, 40) +-- end +--end \ No newline at end of file diff --git a/better-air-filtering/prototypes/entity.lua b/better-air-filtering/prototypes/entity.lua index fa80b1c..e641384 100644 --- a/better-air-filtering/prototypes/entity.lua +++ b/better-air-filtering/prototypes/entity.lua @@ -49,7 +49,7 @@ data:extend({ fluid_boxes = { { production_type = "input", - base_area = 2, + base_area = 0.2, base_level = -1, pipe_connections = {}, }, @@ -124,7 +124,7 @@ data:extend({ fluid_boxes = { { production_type = "input", - base_area = 2, + base_area = 0.4, base_level = -1, pipe_connections = {} }, @@ -164,7 +164,7 @@ data:extend({ return_ingredients_on_change = true, }, { - type = "assembling-machine", + type = "furnace", name = "air-filter-machine-3", icon = "__better-air-filtering__/graphics/icons/air-filter-machine-3.png", icon_size = 32, @@ -210,27 +210,27 @@ data:extend({ fluid_boxes = { { production_type = "input", - base_area = 2, + base_area = 0.4, base_level = -1, pipe_connections = {} }, - { - production_type = "input", - pipe_picture = assembler3pipepictures(), - pipe_covers = pipecoverspictures(), - base_area = 2, - base_level = -1, - pipe_connections = { { type = "input", position = { 0, -2 } } } - }, - { - production_type = "output", - pipe_picture = assembler3pipepictures(), - pipe_covers = pipecoverspictures(), - base_area = 2, - base_level = 1, - pipe_connections = { { type = "output", position = { 0, 2 } } }, - secondary_draw_orders = { north = -1 } - }, + --{ + -- production_type = "input", + -- pipe_picture = assembler3pipepictures(), + -- pipe_covers = pipecoverspictures(), + -- base_area = 2, + -- base_level = -1, + -- pipe_connections = { { type = "input", position = { 0, -2 } } } + --}, + --{ + -- production_type = "output", + -- pipe_picture = assembler3pipepictures(), + -- pipe_covers = pipecoverspictures(), + -- base_area = 2, + -- base_level = 1, + -- pipe_connections = { { type = "output", position = { 0, 2 } } }, + -- secondary_draw_orders = { north = -1 } + --}, off_when_no_fluid_recipe = true }, crafting_categories = { "air-filtering-advanced" }, @@ -242,12 +242,12 @@ data:extend({ }, energy_usage = "100kW", fixed_recipe = "filter-air2", - ingredient_count = 2, + result_inventory_size = 1, + source_inventory_size = 1, module_specification = { module_slots = 3 }, allowed_effects = { "consumption", "speed" }, return_ingredients_on_change = true, - module_slots = 0, } })