From 5b451f160a853a5d8a8e3c77b47f6149782d6ada Mon Sep 17 00:00:00 2001 From: Cooldude2606 <25043174+Cooldude2606@users.noreply.github.com> Date: Sun, 27 Sep 2026 01:08:38 +0100 Subject: [PATCH] Remove graftorio --- exp_legacy/module/config/_file_loader.lua | 1 - .../module/modules/graftorio/forcestats.lua | 196 ------------------ .../module/modules/graftorio/general.lua | 63 ------ .../module/modules/graftorio/require.lua | 28 --- .../module/modules/graftorio/statics.lua | 36 ---- 5 files changed, 324 deletions(-) delete mode 100644 exp_legacy/module/modules/graftorio/forcestats.lua delete mode 100644 exp_legacy/module/modules/graftorio/general.lua delete mode 100644 exp_legacy/module/modules/graftorio/require.lua delete mode 100644 exp_legacy/module/modules/graftorio/statics.lua diff --git a/exp_legacy/module/config/_file_loader.lua b/exp_legacy/module/config/_file_loader.lua index d9eb6ad4..8d642629 100644 --- a/exp_legacy/module/config/_file_loader.lua +++ b/exp_legacy/module/config/_file_loader.lua @@ -14,5 +14,4 @@ return { "modules.data.alt-view", "modules.data.tag", "modules.data.language", - "modules.graftorio.require", -- graftorio } diff --git a/exp_legacy/module/modules/graftorio/forcestats.lua b/exp_legacy/module/modules/graftorio/forcestats.lua deleted file mode 100644 index 195f2e4c..00000000 --- a/exp_legacy/module/modules/graftorio/forcestats.lua +++ /dev/null @@ -1,196 +0,0 @@ -local Event = require("modules/exp_legacy/utils/event") -local general = require("modules.exp_legacy.modules.graftorio.general") -local config = require("modules.exp_legacy.config.graftorio") - -local lib = {} - -lib.collect_production = function() - for _, force in pairs(game.forces) do - general.data.output[force.name].production = {} - for _, surface in pairs(game.surfaces) do - --- @class ItemStats - --- @field count number - - --- @class ProductionStatistics - --- @field item_input table - --- @field item_output table - --- @field fluid_input table - --- @field fluid_output table - --- @field kill_input table - --- @field kill_output table - --- @field build_input table - --- @field build_output table - local stats = { - item_input = {}, - item_output = {}, - fluid_input = {}, - fluid_output = {}, - kill_input = {}, - kill_output = {}, - build_input = {}, - build_output = {}, - } - - for name, count in pairs(force.get_item_production_statistics(surface).input_counts) do - local itemstats = stats.item_input[name] or {} - itemstats.count = count - stats.item_input[name] = itemstats - end - - for name, count in pairs(force.get_item_production_statistics(surface).output_counts) do - local itemstats = stats.item_output[name] or {} - itemstats.count = count - stats.item_output[name] = itemstats - end - - for name, count in pairs(force.get_fluid_production_statistics(surface).input_counts) do - local fluidstats = stats.fluid_input[name] or {} - fluidstats.count = count - stats.fluid_input[name] = fluidstats - end - - for name, count in pairs(force.get_fluid_production_statistics(surface).output_counts) do - local fluidstats = stats.fluid_output[name] or {} - fluidstats.count = count - stats.fluid_output[name] = fluidstats - end - - for name, count in pairs(force.get_kill_count_statistics(surface).input_counts) do - local killstats = stats.kill_input[name] or {} - killstats.count = count - stats.kill_input[name] = killstats - end - - for name, count in pairs(force.get_kill_count_statistics(surface).output_counts) do - local killstats = stats.kill_output[name] or {} - killstats.count = count - stats.kill_output[name] = killstats - end - - for name, count in pairs(force.get_entity_build_count_statistics(surface).input_counts) do - local buildstats = stats.build_input[name] or {} - buildstats.count = count - stats.build_input[name] = buildstats - end - - for name, count in pairs(force.get_entity_build_count_statistics(surface).output_counts) do - local buildstats = stats.build_output[name] or {} - buildstats.count = count - stats.build_output[name] = buildstats - end - - general.data.output[force.name].production[surface.name] = stats - end - end -end - -lib.collect_loginet = function() - for _, force in pairs(game.forces) do - --- @class RobotStatistics - --- @field all_construction_robots uint - --- @field available_construction_robot uint - --- @field all_logistic_robots uint - --- @field available_logistic_robots uint - --- @field charging_robot_count uint - --- @field to_charge_robot_count uint - --- @field items table - --- @field pickups table - --- @field deliveries table - local stats = { - all_construction_robots = 0, - available_construction_robots = 0, - - all_logistic_robots = 0, - available_logistic_robots = 0, - - charging_robot_count = 0, - to_charge_robot_count = 0, - - items = {}, - pickups = {}, - deliveries = {}, - } - for _, networks in pairs(force.logistic_networks) do - for _, network in pairs(networks) do - stats.available_construction_robots = network.available_construction_robots - stats.all_construction_robots = network.all_construction_robots - - stats.available_logistic_robots = network.available_logistic_robots - stats.all_logistic_robots = network.all_logistic_robots - - stats.charging_robot_count = 0 - stats.to_charge_robot_count = 0 - for _, cell in pairs(network.cells) do - stats.charging_robot_count = (stats.charging_robot_count) + cell.charging_robot_count - stats.to_charge_robot_count = (stats.to_charge_robot_count) + cell.to_charge_robot_count - end - - if config.modules.logistorage then - for _, item in pairs(network.get_contents()) do - stats.items[item.name] = (stats.items[item.name] or 0) + item.count - end - - -- pickups and deliveries of items - for _, point_list in pairs{ network.provider_points, network.requester_points, network.storage_points } do - for _, point in pairs(point_list) do - for _, item in pairs(point.targeted_items_pickup) do - stats.pickups[item.name] = (stats.pickups[item.name] or 0) + item.count - end - - for _, item in pairs(point.targeted_items_deliver) do - stats.deliveries[item.name] = (stats.deliveries[item.name] or 0) + item.count - end - end - end - end - end - end - - general.data.output[force.name].robots = stats - end -end - ---- @class Research ---- @field name string ---- @field level uint ---- @field progress double - -Event.add(defines.events.on_research_finished, function(evt) - local research = evt.research - if not general.data.output[research.force.name] then general.data.output[research.force.name] = {} end - if not general.data.output[research.force.name].research then general.data.output[research.force.name].research = {} end - - local force_research = general.data.output[research.force.name].research or {} - table.remove(force_research, 1) - general.data.output[research.force.name].research = force_research -end) - -Event.add(defines.events.on_research_started, function(evt) - -- move queue up - local research = evt.research - if not general.data.output[research.force.name].research then general.data.output[research.force.name].research = {} end - - local force_research = general.data.output[research.force.name].research or {} - table.remove(force_research, 1) - general.data.output[research.force.name].research = force_research -end) - -Event.on_nth_tick(60, function() - for _, force in pairs(game.forces) do - if not general.data.output[force.name].research then general.data.output[force.name].research = {} end - - local force_research = {} - -- this works even if the queue is disabled, but it will always be just 1 long in that case - for _, research in pairs(force.research_queue) do - table.insert(force_research, { - name = research.name, - level = research.level, - progress = force.technologies[research.name].saved_progress - }) - end - - general.data.output[force.name].research = force_research - end -end) - -return lib diff --git a/exp_legacy/module/modules/graftorio/general.lua b/exp_legacy/module/modules/graftorio/general.lua deleted file mode 100644 index 440cedc0..00000000 --- a/exp_legacy/module/modules/graftorio/general.lua +++ /dev/null @@ -1,63 +0,0 @@ -local Event = require("modules/exp_legacy/utils/event") -local Storage = require("modules/exp_util/storage") - -local lib = {} - -lib.data = { - output = {}, -} - -Storage.register(lib.data, function(tbl) - lib.data = tbl -end) - ---- @class Statistics ---- @field production ProductionStatistics? ---- @field robots RobotStatistics? ---- @field other OtherStatistics? ---- @field research Research[]? - -Event.on_init(function() - --- @type table - lib.data.output = {} - for _, force in pairs(game.forces) do - lib.data.output[force.name] = {} - end -end) - ---- @class OtherStatistics ---- @field tick uint ---- @field evolution EvolutionStatistics - ---- @class EvolutionStatistics ---- @field evolution_factor double ---- @field evolution_factor_by_pollution double ---- @field evolution_factor_by_time double ---- @field evolution_factor_by_killing_spawners double - -lib.collect_other = function() - for _, force in pairs(game.forces) do - --- @type OtherStatistics - local other = lib.data.output[force.name].other or {} - - other.evolution = { - evolution_factor = force.get_evolution_factor(game.surfaces[1]), - evolution_factor_by_pollution = force.get_evolution_factor_by_pollution(game.surfaces[1]), - evolution_factor_by_time = force.get_evolution_factor_by_time(game.surfaces[1]), - evolution_factor_by_killing_spawners = force.get_evolution_factor_by_killing_spawners(game.surfaces[1]), - } - for k, v in pairs(other) do - lib.data.output[force.name].other[k] = v - end - end -end - -Event.add(defines.events.on_force_created, function(evt) - lib.data.output[evt.force.name] = {} -end) - -Event.add(defines.events.on_forces_merged, function(evt) - lib.data.output[evt.source_name] = nil -end) - -return lib diff --git a/exp_legacy/module/modules/graftorio/require.lua b/exp_legacy/module/modules/graftorio/require.lua deleted file mode 100644 index aa584e54..00000000 --- a/exp_legacy/module/modules/graftorio/require.lua +++ /dev/null @@ -1,28 +0,0 @@ -local Commands = require("modules/exp_commands") -local config = require("modules.exp_legacy.config.graftorio") -local statics = require("modules.exp_legacy.modules.graftorio.statics") -local general = require("modules.exp_legacy.modules.graftorio.general") -local forcestats = nil - -local table_to_json = helpers.table_to_json - -if config.modules.forcestats then - forcestats = require("modules.exp_legacy.modules.graftorio.forcestats") -end - -Commands.new("collectdata", "Collect data for RCON usage") - :optional("location", "", Commands.types.string) -- Not sure what this is for, i didn't write this - :register(function() - -- this must be first as it overwrites the stats - -- also makes the .other table for all forces - statics.collect_statics() - if config.modules.other then - general.collect_other() - end - if config.modules.forcestats then - --- @cast forcestats -nil - forcestats.collect_production() - forcestats.collect_loginet() - end - return Commands.status.success(table_to_json(general.data.output)) - end) diff --git a/exp_legacy/module/modules/graftorio/statics.lua b/exp_legacy/module/modules/graftorio/statics.lua deleted file mode 100644 index 82bda26d..00000000 --- a/exp_legacy/module/modules/graftorio/statics.lua +++ /dev/null @@ -1,36 +0,0 @@ -local general = require("modules.exp_legacy.modules.graftorio.general") - -local lib = {} - ---- @class StaticStatistics ---- @field tick uint ---- @field online_players string[] ---- @field mods table ---- @field seed table - -lib.collect_statics = function() - local stats = {} - stats.tick = game.tick - - stats.online_players = {} - for _, player in pairs(game.connected_players) do - table.insert(stats.online_players, player.name) - end - - stats.mods = {} - for name, version in pairs(script.active_mods) do - stats.mods[name] = version - end - - -- reason behind this is that the map gen settings can be changed during runtime so just get them fresh - stats.seed = {} - for _, surface in pairs(game.surfaces) do - stats.seed[surface.name] = surface.map_gen_settings.seed - end - - for _, force in pairs(game.forces) do - general.data.output[force.name].other = stats - end -end - -return lib