From 1273d59995bca09aecc2dd0674ccb4a24642ae80 Mon Sep 17 00:00:00 2001 From: Johannes Fritz Date: Tue, 29 Mar 2022 12:16:06 -0500 Subject: [PATCH 1/3] Lightning command: Strike player by name --- mods/ENVIRONMENT/lightning/init.lua | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/mods/ENVIRONMENT/lightning/init.lua b/mods/ENVIRONMENT/lightning/init.lua index 3579316e8..59e494858 100644 --- a/mods/ENVIRONMENT/lightning/init.lua +++ b/mods/ENVIRONMENT/lightning/init.lua @@ -238,8 +238,8 @@ after(5, function(dtime) end) minetest.register_chatcommand("lightning", { - params = "[ ]", - description = S("Let lightning strike at the specified position or yourself"), + params = "[ ] | | ", + description = S("Let lightning strike at the specified position or player. No parameter will strike yourself."), privs = { maphack = true }, func = function(name, param) local pos = {} @@ -247,21 +247,21 @@ minetest.register_chatcommand("lightning", { pos.x = tonumber(pos.x) pos.y = tonumber(pos.y) pos.z = tonumber(pos.z) + local player_to_strike if not (pos.x and pos.y and pos.z) then pos = nil + player_to_strike = minetest.get_player_by_name(param) + if not player_to_strike and param == "" then + player_to_strike = minetest.get_player_by_name(name) + end end - if name == "" and pos == nil then + if not player_to_strike and pos == nil then return false, "No position specified and unknown player" end if pos then lightning.strike(pos) - else - local player = minetest.get_player_by_name(name) - if player then - lightning.strike(player:get_pos()) - else - return false, S("No position specified and unknown player") - end + elseif player_to_strike then + lightning.strike(player_to_strike:get_pos()) end return true end, From ddaa96589e1eca84f8385d3987e04d6e8aa89026 Mon Sep 17 00:00:00 2001 From: Johannes Fritz Date: Fri, 1 Apr 2022 07:58:26 -0500 Subject: [PATCH 2/3] Make params description sensable --- mods/ENVIRONMENT/lightning/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ENVIRONMENT/lightning/init.lua b/mods/ENVIRONMENT/lightning/init.lua index 59e494858..14d8f5176 100644 --- a/mods/ENVIRONMENT/lightning/init.lua +++ b/mods/ENVIRONMENT/lightning/init.lua @@ -238,7 +238,7 @@ after(5, function(dtime) end) minetest.register_chatcommand("lightning", { - params = "[ ] | | ", + params = "[ | ]", description = S("Let lightning strike at the specified position or player. No parameter will strike yourself."), privs = { maphack = true }, func = function(name, param) From d424aaa5bcaeecf5275c4c8ae0d7f2b34ee00b83 Mon Sep 17 00:00:00 2001 From: Johannes Fritz Date: Mon, 4 Apr 2022 07:48:05 -0500 Subject: [PATCH 3/3] Lightning mod: fix localization template --- mods/ENVIRONMENT/lightning/locale/template.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ENVIRONMENT/lightning/locale/template.txt b/mods/ENVIRONMENT/lightning/locale/template.txt index 2c07393f6..897f295eb 100644 --- a/mods/ENVIRONMENT/lightning/locale/template.txt +++ b/mods/ENVIRONMENT/lightning/locale/template.txt @@ -1,4 +1,4 @@ # textdomain: lightning @1 was struck by lightning.= -Let lightning strike at the specified position or yourself= +Let lightning strike at the specified position or player. No parameter will strike yourself.= No position specified and unknown player=