Fix crash in 5.6 gm-creative digging

This commit is contained in:
cora 2022-10-08 22:32:03 +02:00
parent 24c03c2d32
commit a1919b572a
1 changed files with 6 additions and 2 deletions

View File

@ -208,8 +208,8 @@ end
--Insta "digging" nodes in gamemode-creative --Insta "digging" nodes in gamemode-creative
minetest.register_on_punchnode(function(pos, node, puncher, pointed_thing) minetest.register_on_punchnode(function(pos, node, puncher, pointed_thing)
if not puncher or not puncher:is_player() then return end if not puncher or not puncher:is_player() then return end
if minetest.is_creative_enabled() then return end
local name = puncher:get_player_name() local name = puncher:get_player_name()
if minetest.is_creative_enabled(name) then return end
if not minetest.is_creative_enabled(name) then return end if not minetest.is_creative_enabled(name) then return end
if pointed_thing.type ~= "node" then return end if pointed_thing.type ~= "node" then return end
local def = minetest.registered_nodes[node.name] local def = minetest.registered_nodes[node.name]
@ -255,10 +255,13 @@ minetest.register_chatcommand("gamemode",{
privs = { server = true }, privs = { server = true },
func = function(n,param) func = function(n,param)
-- Full input validation ( just for @erlehmann <3 ) -- Full input validation ( just for @erlehmann <3 )
local p = minetest.get_player_by_name(n) local p
local args = param:split(" ") local args = param:split(" ")
if args[2] ~= nil then if args[2] ~= nil then
p = minetest.get_player_by_name(args[2]) p = minetest.get_player_by_name(args[2])
n = args[2]
else
p = minetest.get_player_by_name(n)
end end
if not p then if not p then
return false, S("Player not online") return false, S("Player not online")
@ -268,6 +271,7 @@ minetest.register_chatcommand("gamemode",{
elseif args[1] ~= nil then elseif args[1] ~= nil then
mcl_inventory.player_set_gamemode(p,args[1]) mcl_inventory.player_set_gamemode(p,args[1])
end end
--Result message - show effective game mode --Result message - show effective game mode
local gm = p:get_meta():get_string("gamemode") local gm = p:get_meta():get_string("gamemode")
if gm == "" then gm = gamemodes[1] end if gm == "" then gm = gamemodes[1] end