forked from VoxeLibre/VoxeLibre
Merge pull request 'Lightning command: Strike player by name' (#2326) from MrRar/MineClone2:lightning into master
Reviewed-on: MineClone2/MineClone2#2326 Reviewed-by: PrairieWind <prairie.astronomer1@gmail.com> Reviewed-by: cora <cora@noreply.git.minetest.land>
This commit is contained in:
commit
87bf3fdc0d
|
@ -238,8 +238,8 @@ after(5, function(dtime)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
minetest.register_chatcommand("lightning", {
|
minetest.register_chatcommand("lightning", {
|
||||||
params = "[<X> <Y> <Z>]",
|
params = "[<X> <Y> <Z> | <player name>]",
|
||||||
description = S("Let lightning strike at the specified position or yourself"),
|
description = S("Let lightning strike at the specified position or player. No parameter will strike yourself."),
|
||||||
privs = { maphack = true },
|
privs = { maphack = true },
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
local pos = {}
|
local pos = {}
|
||||||
|
@ -247,21 +247,21 @@ minetest.register_chatcommand("lightning", {
|
||||||
pos.x = tonumber(pos.x)
|
pos.x = tonumber(pos.x)
|
||||||
pos.y = tonumber(pos.y)
|
pos.y = tonumber(pos.y)
|
||||||
pos.z = tonumber(pos.z)
|
pos.z = tonumber(pos.z)
|
||||||
|
local player_to_strike
|
||||||
if not (pos.x and pos.y and pos.z) then
|
if not (pos.x and pos.y and pos.z) then
|
||||||
pos = nil
|
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
|
end
|
||||||
if name == "" and pos == nil then
|
if not player_to_strike and pos == nil then
|
||||||
return false, "No position specified and unknown player"
|
return false, "No position specified and unknown player"
|
||||||
end
|
end
|
||||||
if pos then
|
if pos then
|
||||||
lightning.strike(pos)
|
lightning.strike(pos)
|
||||||
else
|
elseif player_to_strike then
|
||||||
local player = minetest.get_player_by_name(name)
|
lightning.strike(player_to_strike:get_pos())
|
||||||
if player then
|
|
||||||
lightning.strike(player:get_pos())
|
|
||||||
else
|
|
||||||
return false, S("No position specified and unknown player")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end,
|
end,
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# textdomain: lightning
|
# textdomain: lightning
|
||||||
@1 was struck by lightning.=
|
Let lightning strike at the specified position or player. No parameter will strike yourself.=
|
||||||
Let lightning strike at the specified position or yourself=
|
|
||||||
No position specified and unknown player=
|
No position specified and unknown player=
|
||||||
|
|
Loading…
Reference in New Issue