mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-17 07:30:41 +09:00
Fix lua lint warnings reported by emmylua
The largest source was compat.lua returning the setmetatable call directly, which made emmylua infer the module type from the metatable rather than the LibCompat class, hiding every field from consumers. The remaining fixes are nil guards on gui element and character accesses, type annotations for research_sync's script data and player_auth's rcon arguments, casts where the api's read/write union types are wider than the values at runtime, and scoped diagnostic disables for the vendored json.lua and the version fallback code that touches apis removed from the current typedefs. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
59cd193b65
commit
a25f8c8611
8 files changed
+43
-19
No files matched your search
@@ -132,6 +132,7 @@ function auth.add_commands()
|
||||
end
|
||||
|
||||
if event.parameter then
|
||||
--- @type string[]
|
||||
local args = {}
|
||||
for w in string.gmatch(event.parameter, "[^ ]+") do
|
||||
args[#args + 1] = w
|
||||
@@ -149,7 +150,7 @@ function auth.add_commands()
|
||||
end
|
||||
|
||||
local player_name, url, code = table.unpack(args)
|
||||
local player = game.players[player_name]
|
||||
local player = game.get_player(player_name)
|
||||
if not player then
|
||||
rcon.print("Player " .. player_name .. " does not exist")
|
||||
return
|
||||
@@ -159,7 +160,7 @@ function auth.add_commands()
|
||||
|
||||
elseif command == "code_set" then
|
||||
local player_name = args[1]
|
||||
local player = game.players[player_name]
|
||||
local player = game.get_player(player_name)
|
||||
if not player then
|
||||
rcon.print("Player " .. player_name .. " does not exist")
|
||||
return
|
||||
@@ -171,7 +172,7 @@ function auth.add_commands()
|
||||
|
||||
elseif command == "error" then
|
||||
local player_name = table.remove(args, 1)
|
||||
local player = game.players[player_name]
|
||||
local player = game.get_player(player_name)
|
||||
if not player then
|
||||
rcon.print("Player " .. player_name .. " does not exist")
|
||||
return
|
||||
@@ -192,10 +193,12 @@ auth.events[defines.events.on_gui_click] = function(event)
|
||||
end
|
||||
|
||||
if event.element.name == "player_auth_dialog_close_button" then
|
||||
event.element.parent.parent.destroy()
|
||||
local parent = assert(event.element.parent)
|
||||
assert(parent.parent).destroy()
|
||||
|
||||
elseif event.element.name == "player_auth_verify_code_button" then
|
||||
local verify_code = event.element.parent.player_auth_verify_code_input.text
|
||||
local parent = assert(event.element.parent)
|
||||
local verify_code = assert(parent.player_auth_verify_code_input).text
|
||||
local player_name = game.players[event.player_index].name
|
||||
clusterio_api.send_json("player_auth", {
|
||||
type = "set_verify_code",
|
||||
|
||||
Reference in new issue
Block a user