Files
factorio-scenario-ExpCluster/exp_scenario/module/commands/jail.lua
T
bbassie 2e53e4668d Move jail into exp_scenario
With the role system finished the jail module has nothing legacy left in
it, so it moves to exp_scenario/module/control/jail.lua and the copy in
exp_legacy is removed. The module takes LuaPlayer only, requires a reason,
returns false rather than nil when there is nothing to do, and exposes its
event ids as Jail.on_player_jailed and Jail.on_player_unjailed in the same
shape as exp_util's selection events.
2026-09-05 19:18:04 +00:00

44 lines
1.9 KiB
Lua

--[[-- Commands - Jail
Adds a commands that allow admins to jail and unjail
]]
local Commands = require("modules/exp_commands")
local format_player_name = Commands.format_player_name_locale
local Jail = require("modules/exp_scenario/control/jail")
--- Puts a player into jail and removes all other roles.
Commands.new("jail", { "exp-commands_jail.description" })
:argument("player", { "exp-commands_jail.arg-player" }, Commands.types.lower_role_player)
:optional("reason", { "exp-commands_jail.arg-reason" }, Commands.types.string)
:enable_auto_concatenation()
:register(function(player, other_player, reason)
--- @cast other_player LuaPlayer
--- @cast reason string?
if not reason then
reason = "None Given."
end
local player_name = format_player_name(player)
local other_player_name = format_player_name(other_player)
if Jail.jail_player(other_player, player.name, reason) then
game.print{ "exp-commands_jail.jailed", other_player_name, player_name, reason }
else
return Commands.status.error{ "exp-commands_jail.already-jailed", other_player_name }
end
end)
--- Removes a player from jail and restores their old roles.
Commands.new("unjail", { "exp-commands_unjail.description" })
:argument("player", { "exp-commands_unjail.arg-player" }, Commands.types.lower_role_player)
:register(function(player, other_player)
--- @cast other_player LuaPlayer
local player_name = format_player_name(player)
local other_player_name = format_player_name(other_player)
if Jail.unjail_player(other_player, player.name) then
game.print{ "exp-commands_unjail.unjailed", other_player_name, player_name }
else
return Commands.status.error{ "exp-commands_unjail.not-jailed", other_player_name }
end
end)