mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-27 03:25:23 +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:
2
.github/workflows/docs-deploy.yml
vendored
2
.github/workflows/docs-deploy.yml
vendored
@@ -29,7 +29,7 @@ jobs:
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install Lua
|
||||
uses: leafo/gh-actions-lua@v8.0.0
|
||||
uses: leafo/gh-actions-lua@v10
|
||||
|
||||
- name: Install LuaRocks
|
||||
uses: leafo/gh-actions-luarocks@v4
|
||||
|
||||
17
.github/workflows/pr-checker.yml
vendored
17
.github/workflows/pr-checker.yml
vendored
@@ -7,28 +7,21 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Extract branch name
|
||||
shell: bash
|
||||
run: echo "##[set-output name=branch;]$(echo ${GITHUB_BASE_REF#refs/heads/})"
|
||||
id: extract_branch
|
||||
|
||||
- name: Lint
|
||||
uses: Roang-zero1/factorio-mod-luacheck@master
|
||||
with:
|
||||
luacheckrc_url: https://raw.githubusercontent.com/explosivegaming/scenario/${{ steps.extract_branch.outputs.branch }}/.luacheckrc
|
||||
- name: Luacheck linter
|
||||
uses: lunarmodules/luacheck@v1
|
||||
|
||||
docs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Install Lua
|
||||
uses: leafo/gh-actions-lua@v8.0.0
|
||||
uses: leafo/gh-actions-lua@v10
|
||||
|
||||
- name: Install LuaRocks
|
||||
uses: leafo/gh-actions-luarocks@v4
|
||||
|
||||
5
.luarc.json
Normal file
5
.luarc.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"Lua.diagnostics.disable": [
|
||||
"luadoc-miss-type-name"
|
||||
]
|
||||
}
|
||||
@@ -30,7 +30,7 @@ return {
|
||||
['roundabout'] = {'chat-bot.loops'},
|
||||
['roundabouts'] = {'chat-bot.loops'},
|
||||
['redmew'] = {'info.redmew'},
|
||||
['afk'] = function(player)
|
||||
['afk'] = function(player, _is_command)
|
||||
local max = player
|
||||
for _, next_player in pairs(game.connected_players) do
|
||||
if max.afk_time < next_player.afk_time then
|
||||
@@ -39,13 +39,13 @@ return {
|
||||
end
|
||||
return {'chat-bot.afk', max.name, format_time(max.afk_time, {minutes = true, seconds = true, long = true})}
|
||||
end,
|
||||
['players'] = function()
|
||||
['players'] = function(_player, _is_command)
|
||||
return {'chat-bot.players', #game.players}
|
||||
end,
|
||||
['online'] = function()
|
||||
['online'] = function(_player, _is_command)
|
||||
return {'chat-bot.players-online', #game.connected_players}
|
||||
end,
|
||||
['r!verify'] = function(player)
|
||||
['r!verify'] = function(player, _is_command)
|
||||
return {'chat-bot.verify', player.name}
|
||||
end,
|
||||
},
|
||||
@@ -54,7 +54,7 @@ return {
|
||||
command_prefix = '!', --- @setting command_prefix prefix used for commands below and to print to all players (if enabled above)
|
||||
commands = { --- @setting commands will trigger only when command prefix is given
|
||||
['dev'] = {'chat-bot.not-real-dev'},
|
||||
['blame'] = function(player)
|
||||
['blame'] = function(player, _is_command)
|
||||
local names = {'Cooldude2606', 'arty714', 'badgamernl', 'mark9064', 'aldldl', 'Drahc_pro', player.name}
|
||||
for _, next_player in pairs(game.connected_players) do
|
||||
names[#names + 1] = next_player.name
|
||||
@@ -65,52 +65,52 @@ return {
|
||||
['aids'] = {'chat-bot.aids'},
|
||||
['riot'] = {'chat-bot.riot'},
|
||||
['lenny'] = {'chat-bot.lenny'},
|
||||
['hodor'] = function()
|
||||
['hodor'] = function(_player, _is_command)
|
||||
local options = {'?', '.', '!', '!!!'}
|
||||
return {'chat-bot.hodor', table.get_random_dictionary_entry(options)}
|
||||
end,
|
||||
['evolution'] = function()
|
||||
['evolution'] = function(_player, _is_command)
|
||||
return {'chat-bot.current-evolution', string.format('%.2f', game.forces['enemy'].evolution_factor)}
|
||||
end,
|
||||
['makepopcorn'] = function(player)
|
||||
['makepopcorn'] = function(player, _is_command)
|
||||
local timeout = math.floor(180*(math.random()+0.5))
|
||||
Async(async_message, true, {'chat-bot.reply', {'chat-bot.get-popcorn-1'}})
|
||||
Async.wait(timeout, async_message, true, {'chat-bot.reply', {'chat-bot.get-popcorn-2', player.name}})
|
||||
end,
|
||||
['passsomesnaps'] = function(player)
|
||||
['passsomesnaps'] = function(player, _is_command)
|
||||
local timeout = math.floor(180*(math.random()+0.5))
|
||||
Async(async_message, player, {'chat-bot.reply', {'chat-bot.get-snaps-1'}})
|
||||
Async.wait(timeout, async_message, true, {'chat-bot.reply', {'chat-bot.get-snaps-2', player.name}})
|
||||
Async.wait(timeout*(math.random()+0.5), async_message, true, {'chat-bot.reply', {'chat-bot.get-snaps-3', player.name}})
|
||||
end,
|
||||
['makecocktail'] = function(player)
|
||||
['makecocktail'] = function(player, _is_command)
|
||||
local timeout = math.floor(180*(math.random()+0.5))
|
||||
Async(async_message, true, {'chat-bot.reply', {'chat-bot.get-cocktail-1'}})
|
||||
Async.wait(timeout, async_message, true, {'chat-bot.reply', {'chat-bot.get-cocktail-2', player.name}})
|
||||
Async.wait(timeout*(math.random()+0.5), async_message, true, {'chat-bot.reply', {'chat-bot.get-cocktail-3', player.name}})
|
||||
end,
|
||||
['makecoffee'] = function(player)
|
||||
['makecoffee'] = function(player, _is_command)
|
||||
local timeout = math.floor(180*(math.random()+0.5))
|
||||
Async(async_message, true, {'chat-bot.reply', {'chat-bot.make-coffee-1'}})
|
||||
Async.wait(timeout, async_message, true, {'chat-bot.reply', {'chat-bot.make-coffee-2', player.name}})
|
||||
end,
|
||||
['orderpizza'] = function(player)
|
||||
['orderpizza'] = function(player, _is_command)
|
||||
local timeout = math.floor(180*(math.random()+0.5))
|
||||
Async(async_message, true, {'chat-bot.reply', {'chat-bot.order-pizza-1'}})
|
||||
Async.wait(timeout, async_message, true, {'chat-bot.reply', {'chat-bot.order-pizza-2', player.name}})
|
||||
Async.wait(timeout*(math.random()+0.5), async_message, true, {'chat-bot.reply', {'chat-bot.order-pizza-3', player.name}})
|
||||
end,
|
||||
['maketea'] = function(player)
|
||||
['maketea'] = function(player, _is_command)
|
||||
local timeout = math.floor(180*(math.random()+0.5))
|
||||
Async(async_message, true, {'chat-bot.reply', {'chat-bot.make-tea-1'}})
|
||||
Async.wait(timeout, async_message, true, {'chat-bot.reply', {'chat-bot.make-tea-2', player.name}})
|
||||
end,
|
||||
['meadplease'] = function(player)
|
||||
['meadplease'] = function(player, _is_command)
|
||||
local timeout = math.floor(180*(math.random()+0.5))
|
||||
Async(async_message, true, {'chat-bot.reply', {'chat-bot.get-mead-1'}})
|
||||
Async.wait(timeout, async_message, true, {'chat-bot.reply', {'chat-bot.get-mead-2', player.name}})
|
||||
end,
|
||||
['passabeer'] = function(player)
|
||||
['passabeer'] = function(player, _is_command)
|
||||
local timeout = math.floor(180*(math.random()+0.5))
|
||||
Async(async_message, true, {'chat-bot.reply', {'chat-bot.get-beer-1'}})
|
||||
Async.wait(timeout, async_message, true, {'chat-bot.reply', {'chat-bot.get-beer-2', player.name}})
|
||||
|
||||
@@ -2,6 +2,6 @@ return {
|
||||
modules = {
|
||||
["forcestats"] = true,
|
||||
["logistorage"] = false,
|
||||
["general"] = true,
|
||||
["other"] = true,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@ global.version = require 'overrides.version' -- The current version for exp gami
|
||||
inspect = require 'overrides.inspect' -- Used to covert any value into human readable string
|
||||
Debug = require 'overrides.debug' -- Global Debug module
|
||||
_C = require 'expcore.common' -- _C is used to store lots of common functions expected to be used
|
||||
_CHEATS = false
|
||||
_DEBUG = false
|
||||
|
||||
-- Please go to config/file_loader.lua to edit the files that are loaded
|
||||
log('[INFO] Reading loader config')
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
file = { '../', exclude = { '../.install', '../.lua', '../.luarocks' } }
|
||||
file = { '../', exclude = { '../.lua', '../.luarocks' } }
|
||||
dir = '../docs'
|
||||
project = 'ExpGaming Scenario'
|
||||
title = 'ExpGaming Scenario'
|
||||
|
||||
@@ -36,7 +36,7 @@ local Async = {}
|
||||
local internal_run =
|
||||
Token.register(function(params)
|
||||
local func = Token.get(params.token)
|
||||
return func(unpack(params.params))
|
||||
return func(table.unpack(params.params))
|
||||
end)
|
||||
|
||||
--[[-- Register a new async function, must called when the file is loaded
|
||||
|
||||
@@ -692,7 +692,7 @@ nb: use error(error_message) within your callback to trigger do not trigger dire
|
||||
@treturn boolean The opposite of success so true means to cancel execution, used internally
|
||||
|
||||
@usage-- Used in the command system to log handler errors
|
||||
local success, err = pcall(command_data.callback, player, unpack(params))
|
||||
local success, err = pcall(command_data.callback, player, table.unpack(params))
|
||||
if Commands.internal_error(success, command_data.name, err) then
|
||||
return command_log(player, command_data, 'Internal Error: Command Callback Fail', raw_params, command_event.parameter, err)
|
||||
end
|
||||
@@ -806,7 +806,7 @@ function Commands.run_command(command_event)
|
||||
end
|
||||
|
||||
-- If its not a function throw and error
|
||||
if not type(parse_callback) == 'function' then
|
||||
if type(parse_callback) ~= 'function' then
|
||||
Commands.internal_error(false, command_data.name, 'Invalid param parse '..tostring(param_data.parse))
|
||||
command_log(player, command_data, 'Internal Error: Invalid Param Parse', params, raw_input, tostring(param_data.parse))
|
||||
return
|
||||
@@ -820,7 +820,7 @@ function Commands.run_command(command_event)
|
||||
end
|
||||
|
||||
-- input: string, player: LuaPlayer, reject: function, ... extra args
|
||||
local success, param_parsed = pcall(parse_callback, raw_params[index], player, reject, unpack(param_data.parse_args))
|
||||
local success, param_parsed = pcall(parse_callback, raw_params[index], player, reject, table.unpack(param_data.parse_args))
|
||||
if Commands.internal_error(success, command_data.name, param_parsed) then
|
||||
return command_log(player, command_data, 'Internal Error: Param Parse Fail', params, raw_input, param_parsed)
|
||||
end
|
||||
@@ -837,7 +837,7 @@ function Commands.run_command(command_event)
|
||||
|
||||
elseif param_parsed == nil or param_parsed == Commands.defines.error or param_parsed == reject then
|
||||
-- No value was returned or error was returned, if nil then give generic error
|
||||
if not param_parsed == Commands.defines.error then
|
||||
if param_parsed ~= Commands.defines.error then
|
||||
command_log(player, command_data, 'Invalid Param Given', raw_params, raw_input, param_name)
|
||||
Commands.error{'expcore-commands.command-error-param-format', param_name, 'please make sure it is the correct type'}
|
||||
end
|
||||
@@ -853,7 +853,7 @@ function Commands.run_command(command_event)
|
||||
-- Run the command
|
||||
-- player: LuaPlayer, ... command params, raw: string
|
||||
params[command_data.max_param_count+1] = raw_input
|
||||
local success, rtn = pcall(command_data.callback, player, unpack(params))
|
||||
local success, rtn = pcall(command_data.callback, player, table.unpack(params))
|
||||
if Commands.internal_error(success, command_data.name, rtn) then
|
||||
return command_log(player, command_data, 'Internal Error: Command Callback Fail', raw_params, command_event.parameter, rtn)
|
||||
end
|
||||
|
||||
@@ -90,7 +90,7 @@ function Gui.inject_left_flow_order(provider)
|
||||
Gui.get_left_flow_order = provider
|
||||
local debug_info = debug.getinfo(2, "Sn")
|
||||
local file_name = debug_info.source:match('^.+/currently%-playing/(.+)$'):sub(1, -5)
|
||||
local func_name = debug_info.name or "<anonymous:"..debug_info.linedefined..">"
|
||||
local func_name = debug_info.name or ("<anonymous:"..debug_info.linedefined..">")
|
||||
Gui._left_flow_order_src = file_name..":"..func_name
|
||||
end
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ end
|
||||
local function get_defined_at(level)
|
||||
local debug_info = debug.getinfo(level, "Sn")
|
||||
local file_name = debug_info.source:match('^.+/currently%-playing/(.+)$'):sub(1, -5)
|
||||
local func_name = debug_info.name or "<anonymous:"..debug_info.linedefined..">"
|
||||
local func_name = debug_info.name or ("<anonymous:"..debug_info.linedefined..">")
|
||||
return file_name..":"..func_name
|
||||
end
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ Gui.toolbar_button_style(button, false)
|
||||
|
||||
]]
|
||||
function Gui.toolbar_button_style(button, state, size)
|
||||
---@cast button LuaGuiElement
|
||||
if state then
|
||||
button.style = Gui.top_flow_button_toggled_style
|
||||
else
|
||||
@@ -107,7 +108,7 @@ function Gui.inject_top_flow_order(provider)
|
||||
Gui.get_top_flow_order = provider
|
||||
local debug_info = debug.getinfo(2, "Sn")
|
||||
local file_name = debug_info.source:match('^.+/currently%-playing/(.+)$'):sub(1, -5)
|
||||
local func_name = debug_info.name or "<anonymous:"..debug_info.linedefined..">"
|
||||
local func_name = debug_info.name or ("<anonymous:"..debug_info.linedefined..">")
|
||||
Gui._top_flow_order_src = file_name..":"..func_name
|
||||
end
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -127,7 +127,7 @@ function Debug.object_type(object)
|
||||
end
|
||||
|
||||
---Shows the given message if debug is on.
|
||||
---@param position Position
|
||||
---@param position MapPosition
|
||||
---@param message string
|
||||
function Debug.print_position(position, message)
|
||||
Debug.print(format('%s %s', serialize(position), message))
|
||||
|
||||
@@ -161,7 +161,7 @@ function table.extract_keys(tbl, ...)
|
||||
for _, key in pairs({...}) do
|
||||
table.insert(values, tbl[key])
|
||||
end
|
||||
return unpack(values)
|
||||
return table.unpack(values)
|
||||
end
|
||||
|
||||
--- Adds an element into a specific index position while shuffling the rest down
|
||||
|
||||
@@ -51,10 +51,13 @@ function Game.player_print(str, color)
|
||||
end
|
||||
|
||||
--[[
|
||||
@param Position String to display at
|
||||
Creates a floating text entity at a location with the specified color.
|
||||
Example: "+10 iron" or "-10 coins"
|
||||
|
||||
@param surface LuaSurface
|
||||
@param position String to display at
|
||||
@param text String to display
|
||||
@param color table in {r = 0~1, g = 0~1, b = 0~1}, defaults to white.
|
||||
@param surface LuaSurface
|
||||
|
||||
@return the created entity
|
||||
]]
|
||||
|
||||
@@ -25,7 +25,7 @@ global.tpt = global.task_queue_speed
|
||||
local function get_task_per_tick()
|
||||
if game.tick % 300 == 0 then
|
||||
local size = global.total_task_weight
|
||||
global.tpt = math.floor(math.log10(size + 1)) * global.task_queue_speed
|
||||
global.tpt = math.floor(math.log(size + 1, 10)) * global.task_queue_speed
|
||||
if global.tpt < 1 then
|
||||
global.tpt = 1
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user