mirror of
https://git.minetest.land/Mineclonia/Mineclonia.git
synced 2024-11-05 09:15:05 +00:00
Add debug command to burn a player
This commit is contained in:
parent
df98db1d8c
commit
253100380c
1 changed files with 45 additions and 0 deletions
|
@ -296,3 +296,48 @@ function mcl_burning.fire_entity_step(self, dtime)
|
|||
end
|
||||
self.animation_timer = animation_timer
|
||||
end
|
||||
|
||||
minetest.register_chatcommand("burn", {
|
||||
params = S("<playername> <duration> <reason>"),
|
||||
description = S("Sets a player on fire for the given amount of seconds with the given reason."),
|
||||
privs = { debug = true },
|
||||
func = function(name, params)
|
||||
local playername, duration, reason = params:match("^(.+) (.+) (.+)$")
|
||||
if not (playername and duration and reason) then
|
||||
return false, S("Error: Parameter missing.")
|
||||
end
|
||||
local player = minetest.get_player_by_name(playername)
|
||||
if not player then
|
||||
return false, S(
|
||||
"Error: Player “@1” not found.",
|
||||
playername
|
||||
)
|
||||
end
|
||||
local duration_number = tonumber(duration)
|
||||
-- Lua numbers are truthy
|
||||
-- NaN is not equal to NaN
|
||||
if not duration_number or (duration_number ~= duration_number) then
|
||||
return false, S(
|
||||
"Error: Duration “@1” is not a number.",
|
||||
duration
|
||||
)
|
||||
end
|
||||
if duration_number < 0 then
|
||||
return false, S(
|
||||
"Error: Duration “@1” is negative.",
|
||||
duration
|
||||
)
|
||||
end
|
||||
mcl_burning.set_on_fire(
|
||||
player,
|
||||
duration_number,
|
||||
reason
|
||||
)
|
||||
return true, S(
|
||||
"Set @1 on fire for @2s for the following reason: @3",
|
||||
playername,
|
||||
duration,
|
||||
reason
|
||||
)
|
||||
end,
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue