forked from Mineclonia/Mineclonia
Merge pull request 'ENTITIES/mcl_burning: Add debug command to burn a player' (#164) from add-burn-command-2 into master
Reviewed-on: Mineclonia/Mineclonia#164 Reviewed-by: cora <cora@noreply.git.minetest.land>
This commit is contained in:
commit
bfbc953b92
|
@ -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 New Issue