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:
@@ -37,10 +37,10 @@ Event.add(defines.events.on_console_chat, function(event)
|
||||
for key_word, reply in pairs(config.commands) do
|
||||
if message:find(prefix..key_word) then
|
||||
if type(reply) == 'function' then
|
||||
reply = reply(player, true)
|
||||
local msg = reply(player, true)
|
||||
|
||||
if reply then
|
||||
game.print{'chat-bot.reply', reply}
|
||||
game.print{'chat-bot.reply', msg}
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
@@ -67,7 +67,7 @@ Commands.new_command('clear-warnings', 'Clears all warnings (and script warnings
|
||||
:add_param('player', false, 'player')
|
||||
:register(function(player, action_player)
|
||||
Warnings.clear_warnings(action_player, player.name)
|
||||
Warnings.clear_script_warnings(action_player, player.name)
|
||||
Warnings.clear_script_warnings(action_player)
|
||||
local action_player_name_color = format_chat_player_name(action_player)
|
||||
local by_player_name_color = format_chat_player_name(player)
|
||||
game.print{'expcom-warnings.cleared', action_player_name_color, by_player_name_color}
|
||||
|
||||
@@ -83,12 +83,12 @@ function Jail.jail_player(player, by_player_name, reason)
|
||||
if has_role(player, 'Jail') then return end
|
||||
local roles = get_roles(player)
|
||||
|
||||
player.walking_state = { walking = false }
|
||||
player.walking_state = { walking = false, direction = player.walking_state.direction }
|
||||
player.riding_state = { acceleration = defines.riding.acceleration.nothing, direction = player.riding_state.direction }
|
||||
player.mining_state = { mining = false }
|
||||
player.shooting_state = { state = defines.shooting.not_shooting }
|
||||
player.shooting_state = { state = defines.shooting.not_shooting, position = player.shooting_state.position }
|
||||
player.picking_state = false
|
||||
player.repair_state = { repairing = false }
|
||||
player.repair_state = { repairing = false, position = player.repair_state.position }
|
||||
|
||||
unassign_roles(player, roles, by_player_name, nil, true)
|
||||
assign_roles(player, 'Jail', by_player_name, nil, true)
|
||||
|
||||
@@ -129,7 +129,7 @@ function Selection.on_selection(selection_name, handler)
|
||||
Event.add(defines.events.on_player_selected_area, function(event)
|
||||
local selection = selections[event.player_index]
|
||||
if not selection or selection.name ~= selection_name then return end
|
||||
handler(event, unpack(selection.arguments))
|
||||
handler(event, table.unpack(selection.arguments))
|
||||
end)
|
||||
end
|
||||
|
||||
@@ -140,13 +140,13 @@ function Selection.on_alt_selection(selection_name, handler)
|
||||
Event.add(defines.events.on_player_alt_selected_area, function(event)
|
||||
local selection = selections[event.player_index]
|
||||
if not selection or selection.name ~= selection_name then return end
|
||||
handler(event, unpack(selection.arguments))
|
||||
handler(event, table.unpack(selection.arguments))
|
||||
end)
|
||||
end
|
||||
|
||||
--- Stop selection if the selection tool is removed from the cursor
|
||||
Event.add(defines.events.on_player_cursor_stack_changed, function(event)
|
||||
local player = game.get_player(event.player_index)
|
||||
local player = game.get_player(event.player_index) ---@cast player -nil
|
||||
if player.cursor_stack.is_selection_tool then return end
|
||||
Selection.stop(player)
|
||||
end)
|
||||
|
||||
@@ -33,6 +33,7 @@ local Warps = {}
|
||||
|
||||
-- Global lookup table for force name to task ids
|
||||
local force_warps = {_uid=1}
|
||||
---@cast force_warps table<string, { spawn: string, [number]: string }>
|
||||
Global.register(force_warps, function(tbl)
|
||||
force_warps = tbl
|
||||
end)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -6,7 +6,7 @@ local type = type
|
||||
local concat = table.concat
|
||||
local inspect = table.inspect
|
||||
local pcall = pcall
|
||||
local loadstring = loadstring
|
||||
local loadstring = loadstring ---@diagnostic disable-line
|
||||
local rawset = rawset
|
||||
|
||||
local Public = {}
|
||||
|
||||
@@ -32,7 +32,8 @@ local function format_energy(amount, unit)
|
||||
end
|
||||
end
|
||||
|
||||
local formatted, k = amount
|
||||
local k
|
||||
local formatted = amount
|
||||
|
||||
while true do
|
||||
formatted, k = string.gsub(formatted, '^(-?%d+)(%d%d%d)', '%1,%2')
|
||||
|
||||
@@ -806,6 +806,7 @@ Event.on_nth_tick(math.floor(60/config.update_smoothing), function()
|
||||
if was_in_range and not in_range then
|
||||
PlayerInRange:set(player, nil)
|
||||
elseif not was_in_range and in_range then
|
||||
---@cast closest_warp -nil
|
||||
PlayerInRange:set(player, closest_warp.warp_id)
|
||||
end
|
||||
|
||||
@@ -819,6 +820,7 @@ Event.on_nth_tick(math.floor(60/config.update_smoothing), function()
|
||||
add_warp_element.enabled = true
|
||||
add_warp_element.tooltip = {'warp-list.add-tooltip'}
|
||||
elseif not can_make_warp and was_able_to_make_warp or closest_warp and (old_closest_warp_name ~= closest_warp.name) then
|
||||
---@cast closest_warp -nil
|
||||
add_warp_element.enabled = false
|
||||
add_warp_element.tooltip = {'warp-list.too-close', closest_warp.name}
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user