Files
factorio-scenario-ExpCluster/modules/commands/kill.lua
Cooldude2606 0499ad35ab Dependenices
2019-07-22 17:38:56 +01:00

26 lines
1.0 KiB
Lua

local Commands = require 'expcore.commands' --- @dep expcore.commands
local Roles = require 'expcore.roles' --- @dep expcore.roles
require 'config.expcore-commands.parse_general'
require 'config.expcore-commands.parse_roles'
Commands.new_command('kill','Kills yourself or another player.')
:add_param('player',true,'player-role-alive') -- the player to kill, must be alive to be valid
:set_defaults{player=function(player)
-- default is the player unless they are dead
if player.character and player.character.health > 0 then
return player
end
end}
:register(function(player,action_player,raw)
if not action_player then
-- can only be nil if no player given and the user is dead
return Commands.error{'expcom-kill.already-dead'}
end
if player == action_player then
action_player.character.die()
elseif Roles.player_allowed(player,'command/kill/always') then
action_player.character.die()
else
return Commands.error{'expcore-commands.unauthorized'}
end
end)