mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-27 11:35:22 +09:00
Use new linter (#294)
* Use new linter * Luacheck and Sumneko Lua fixes * Bump CI action versions * Fix excludes for ldoc
This commit is contained in:
@@ -6,15 +6,18 @@ local lib = {}
|
||||
|
||||
lib.collect_production = function()
|
||||
for _, force in pairs(game.forces) do
|
||||
---@class ItemStats
|
||||
---@field count number
|
||||
|
||||
---@class ProductionStatistics
|
||||
---@field item_input table<string, double|uint64>
|
||||
---@field item_output table<string, double|uint64>
|
||||
---@field fluid_input table<string, double|uint64>
|
||||
---@field fluid_output table<string, double|uint64>
|
||||
---@field kill_input table<string, double|uint64>
|
||||
---@field kill_output table<string, double|uint64>
|
||||
---@field build_input table<string, double|uint64>
|
||||
---@field build_output table<string, double|uint64>
|
||||
---@field item_input table<string, ItemStats>
|
||||
---@field item_output table<string, ItemStats>
|
||||
---@field fluid_input table<string, ItemStats>
|
||||
---@field fluid_output table<string, ItemStats>
|
||||
---@field kill_input table<string, ItemStats>
|
||||
---@field kill_output table<string, ItemStats>
|
||||
---@field build_input table<string, ItemStats>
|
||||
---@field build_output table<string, ItemStats>
|
||||
local stats = {
|
||||
item_input = {},
|
||||
item_output = {},
|
||||
@@ -138,17 +141,11 @@ lib.collect_loginet = function()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
---@class ResearchStatistics
|
||||
---@field current Research
|
||||
---@field queue Research[]
|
||||
|
||||
---@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
|
||||
|
||||
@@ -12,11 +12,10 @@ Global.register(lib.data, function(tbl)
|
||||
end)
|
||||
|
||||
---@class Statistics
|
||||
---@field trains TrainStatistics
|
||||
---@field power PowerStatistics
|
||||
---@field production ProductionStatistics
|
||||
---@field robots RobotStatistics
|
||||
---@field other OtherStatistics
|
||||
---@field production ProductionStatistics?
|
||||
---@field robots RobotStatistics?
|
||||
---@field other OtherStatistics?
|
||||
---@field research Research[]?
|
||||
|
||||
Event.on_init(function()
|
||||
---@type table<string, Statistics>
|
||||
@@ -29,7 +28,6 @@ end)
|
||||
---@class OtherStatistics
|
||||
---@field tick uint
|
||||
---@field evolution EvolutionStatistics
|
||||
---@field research ResearchStatistics
|
||||
|
||||
---@class EvolutionStatistics
|
||||
---@field evolution_factor double
|
||||
|
||||
@@ -1,26 +1,27 @@
|
||||
local Commands = require("expcore.commands")
|
||||
local config = require("config.graftorio")
|
||||
local statics = require("modules.graftorio.statics")
|
||||
local general = require("modules.graftorio.general")
|
||||
local forcestats = nil
|
||||
local general = nil
|
||||
|
||||
if config.modules.forcestats then
|
||||
forcestats = require("modules.graftorio.forcestats")
|
||||
end
|
||||
if config.modules.general then
|
||||
general = require("modules.graftorio.general")
|
||||
end
|
||||
|
||||
Commands.new_command("collectdata", "Collect data for RCON usage")
|
||||
:add_param("location", true)
|
||||
: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.general then general.collect_other() end
|
||||
if config.modules.forcestats then
|
||||
forcestats.collect_production()
|
||||
forcestats.collect_loginet()
|
||||
end
|
||||
rcon.print(game.table_to_json(general.data.output))
|
||||
return Commands.success()
|
||||
end)
|
||||
:add_param("location", true)
|
||||
: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
|
||||
rcon.print(game.table_to_json(general.data.output))
|
||||
return Commands.success()
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user