Files
factorio-scenario-ExpCluster/exp_commands/module/commands/sudo.lua
T
bbassieandClaude Opus 5 c233a9ab06 Defer need-check-nil and clean up stale suppressions
emmylua deserialises an unknown diagnostic code to a catch all that
matches no checker, so every `invisible`, `nil-check` and
`global-element` suppression was silently doing nothing. Renamed to the
emmylua codes. `name-style-check` has no equivalent and is dropped, it
was already disabled under luals.

The `get_tile` suppressions referenced an api typedef bug from 2024
which no longer reproduces.

need-check-nil is deferred rather than disabled on merit: a third of the
407 findings come from MapPosition and BoundingBox being aliased as
`struct|[double, double]`, so every `entity.position.x` reads as
possibly nil. The rest need per site knowledge of runtime invariants.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-07 15:31:18 +00:00

30 lines
1.1 KiB
Lua

--[[-- Commands - Sudo
System command to execute a command as another player using their permissions (except for permissions group actions)
--- Run the example command as another player
-- As Cooldude2606: /repeat 5
/_system-sudo Cooldude2606 repeat 5
]]
local Commands = require("modules/exp_commands")
Commands.new("_sudo", { "exp-commands_sudo.description" })
:argument("player", { "exp-commands_sudo.arg-player" }, Commands.types.player)
:argument("command", { "exp-commands_sudo.arg-command" }, Commands.types.key_of(Commands.registered_commands))
:optional("arguments", { "exp-commands_sudo.arg-arguments" }, Commands.types.string)
:enable_auto_concatenation()
:add_flags{ "system_only" }
:register(function(_player, player, command, parameter)
--- @cast player LuaPlayer
--- @cast command ExpCommand
--- @cast parameter string
--- @diagnostic disable-next-line: access-invisible
return Commands._event_handler{
name = command.name,
tick = game.tick,
player_index = player.index,
parameter = parameter,
}
end)