Skip to content

Commit

Permalink
Add custom Better Victory Screen statistics (#323)
Browse files Browse the repository at this point in the history
* Add mineral sludge consumed to better victory screen

* Add PR number

* Add amount of landfil placed (approx)

* Formatting etc

---------

Co-authored-by: KiwiHawk <[email protected]>
  • Loading branch information
heinwessels and KiwiHawk authored Jun 8, 2024
1 parent 1552b0b commit 05438db
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 2 deletions.
7 changes: 6 additions & 1 deletion SeaBlock/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
---------------------------------------------------------------------------------------------------
Version: 0.5.17
Date: ??.??.??
Changes:
- Added custom Better Victory Screen statistics #323
---------------------------------------------------------------------------------------------------
Version: 0.5.16
Date: 27.02.2024
Changes:
Expand Down Expand Up @@ -577,4 +582,4 @@ Date: 8. 1. 2018
- Disable bobplates cheaper steel
- Reduce number of beacon module slots. Two modules per beacon regardless of level.
- Undo boblogistics changes to logistic-system technology. High tech and production science packs restored.
- Add setting for changing ScienceCostTweaker multiplier when SpaceMod is present.
- Add setting for changing ScienceCostTweaker multiplier when SpaceMod is present.
2 changes: 1 addition & 1 deletion SeaBlock/info.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "SeaBlock",
"version": "0.5.16",
"version": "0.5.17",
"factorio_version": "1.1",
"title": "Sea Block",
"author": "Trainwreck",
Expand Down
7 changes: 7 additions & 0 deletions SeaBlock/locale/en/SeaBlock.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,10 @@ sb-default-landfill-landfill-grass-1=[img=item/landfill-grass-1]Grass
sb-default-landfill-landfill=[img=item/landfill]Landfill
sb-default-landfill-landfill-red-desert-1=[img=item/landfill-red-desert-1]Red desert
sb-default-landfill-landfill-sand-3=[img=item/landfill-sand-3]Sand

[bvs-stats]
mineral-sludge-consumed=Mineral sludge consumed
landfill-count=Landfill placed

[bvs-stat-tooltip]
landfill-count=The amount of non-water tiles that currently exists. Includes generated islands.
26 changes: 26 additions & 0 deletions SeaBlock/remote.lua
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,31 @@ local function get_jetpack_fuels()
return { ["enriched-fuel"] = 0.7 }
end

---@param winning_force LuaForce
---@param forces LuaForce[] list of forces that GUI will be show to
local function better_victory_screen_statistics(winning_force, forces)

-- Landfil is common to all forces. To prevent having to check which
-- tiles can be used for landfil, and handle paving, etc, we will only
-- count non-water tiles according to the collision masks.
local landfill_count = game.surfaces.nauvis.count_tiles_filtered{collision_mask="water-tile", invert=true}

local stats_by_force = { }
for _, force in pairs(forces) do
local get_output_fluid_count = force.fluid_production_statistics.get_output_count
stats_by_force[force.name] = {
["production"] = { stats = {
["mineral-sludge-consumed"] = { value = get_output_fluid_count("mineral-sludge"), order="b" },
["ores-produced"] = { ignore = true }, -- Cannot mine ores
}},
["infrastructure"] = { stats = {
["landfill-count"] = {value = landfill_count , order = "i", has_tooltip=true}
}}
}
end
return { by_force = stats_by_force }
end

remote.add_interface("SeaBlock", {
get_unlocks = get_unlocks,
set_unlock = set_unlock,
Expand All @@ -229,4 +254,5 @@ remote.add_interface("SeaBlock", {
set_starting_items = set_starting_items,
milestones_presets = milestones_presets,
jetpack_fuels = get_jetpack_fuels,
["better-victory-screen-statistics"] = better_victory_screen_statistics,
})

0 comments on commit 05438db

Please sign in to comment.