From 253100380c5b40ead80286f13037f0d11cc6377e Mon Sep 17 00:00:00 2001 From: Nils Dagsson Moskopp Date: Wed, 10 Nov 2021 19:42:16 +0100 Subject: [PATCH] Add debug command to burn a player --- mods/ENTITIES/mcl_burning/api.lua | 45 +++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/mods/ENTITIES/mcl_burning/api.lua b/mods/ENTITIES/mcl_burning/api.lua index a217d294..bf721414 100644 --- a/mods/ENTITIES/mcl_burning/api.lua +++ b/mods/ENTITIES/mcl_burning/api.lua @@ -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(" "), + 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, +})