mirror of
https://github.com/minetest/minetest_game.git
synced 2024-12-22 06:02:25 +01:00
Fix some placer nil checks
This commit is contained in:
parent
a3b171e317
commit
70cf7a26fd
@ -40,7 +40,7 @@ for i in ipairs (butter_list) do
|
||||
},
|
||||
floodable = true,
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
local player_name = placer:get_player_name()
|
||||
local player_name = placer and placer:get_player_name() or ""
|
||||
local pos = pointed_thing.above
|
||||
|
||||
if not minetest.is_protected(pos, player_name) and
|
||||
@ -73,7 +73,7 @@ for i in ipairs (butter_list) do
|
||||
groups = {not_in_creative_inventory = 1},
|
||||
floodable = true,
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
local player_name = placer:get_player_name()
|
||||
local player_name = placer and placer:get_player_name() or ""
|
||||
local pos = pointed_thing.above
|
||||
|
||||
if not minetest.is_protected(pos, player_name) and
|
||||
|
@ -413,7 +413,8 @@ minetest.register_craftitem("carts:cart", {
|
||||
minetest.sound_play({name = "default_place_node_metal", gain = 0.5},
|
||||
{pos = pointed_thing.above}, true)
|
||||
|
||||
if not minetest.is_creative_enabled(placer:get_player_name()) then
|
||||
local player_name = placer and placer:get_player_name() or ""
|
||||
if not minetest.is_creative_enabled(player_name) then
|
||||
itemstack:take_item()
|
||||
end
|
||||
return itemstack
|
||||
|
@ -1985,8 +1985,8 @@ minetest.register_node("default:sand_with_kelp", {
|
||||
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
-- Call on_rightclick if the pointed node defines it
|
||||
if pointed_thing.type == "node" and placer and
|
||||
not placer:get_player_control().sneak then
|
||||
if pointed_thing.type == "node" and not (placer and placer:is_player()
|
||||
and placer:get_player_control().sneak) then
|
||||
local node_ptu = minetest.get_node(pointed_thing.under)
|
||||
local def_ptu = minetest.registered_nodes[node_ptu.name]
|
||||
if def_ptu and def_ptu.on_rightclick then
|
||||
@ -2035,19 +2035,20 @@ minetest.register_node("default:sand_with_kelp", {
|
||||
--
|
||||
|
||||
local function coral_on_place(itemstack, placer, pointed_thing)
|
||||
if pointed_thing.type ~= "node" or not placer then
|
||||
if pointed_thing.type ~= "node" then
|
||||
return itemstack
|
||||
end
|
||||
|
||||
local player_name = placer:get_player_name()
|
||||
local player_name = placer and placer:get_player_name()
|
||||
local pos_under = pointed_thing.under
|
||||
local pos_above = pointed_thing.above
|
||||
local node_under = minetest.get_node(pos_under)
|
||||
local def_under = minetest.registered_nodes[node_under.name]
|
||||
|
||||
if def_under and def_under.on_rightclick and not placer:get_player_control().sneak then
|
||||
if def_under and def_under.on_rightclick and not (
|
||||
placer and placer:is_player() and placer:get_player_control().sneak) then
|
||||
return def_under.on_rightclick(pos_under, node_under,
|
||||
placer, itemstack, pointed_thing) or itemstack
|
||||
placer, itemstack, pointed_thing)
|
||||
end
|
||||
|
||||
if node_under.name ~= "default:coral_skeleton" or
|
||||
@ -2057,9 +2058,6 @@ local function coral_on_place(itemstack, placer, pointed_thing)
|
||||
|
||||
if minetest.is_protected(pos_under, player_name) or
|
||||
minetest.is_protected(pos_above, player_name) then
|
||||
default.log_player_action(placer,
|
||||
"tried to place", itemstack:get_name(),
|
||||
"at protected position", pos_under)
|
||||
minetest.record_protection_violation(pos_under, player_name)
|
||||
return itemstack
|
||||
end
|
||||
|
@ -488,16 +488,15 @@ function default.sapling_on_place(itemstack, placer, pointed_thing,
|
||||
interval) then
|
||||
minetest.record_protection_violation(pos, player_name)
|
||||
-- Print extra information to explain
|
||||
-- minetest.chat_send_player(player_name,
|
||||
-- itemstack:get_definition().description .. " will intersect protection " ..
|
||||
-- "on growth")
|
||||
minetest.chat_send_player(player_name,
|
||||
S("@1 will intersect protection on growth.",
|
||||
itemstack:get_definition().description))
|
||||
return itemstack
|
||||
end
|
||||
|
||||
if placer then
|
||||
default.log_player_action(placer, "places node", sapling_name, "at", pos)
|
||||
end
|
||||
|
||||
local take_item = not minetest.is_creative_enabled(player_name)
|
||||
local newnode = {name = sapling_name}
|
||||
|
@ -178,7 +178,9 @@ farming.place_seed = function(itemstack, placer, pointed_thing, plantname)
|
||||
end
|
||||
|
||||
-- add the node and remove 1 item from the itemstack
|
||||
if placer then
|
||||
default.log_player_action(placer, "places node", plantname, "at", pt.above)
|
||||
end
|
||||
minetest.add_node(pt.above, {name = plantname, param2 = 1})
|
||||
tick(pt.above)
|
||||
if not minetest.is_creative_enabled(player_name) then
|
||||
|
@ -625,7 +625,7 @@ function tnt.register_tnt(def)
|
||||
groups = {dig_immediate = 2, mesecon = 2, tnt = 1, flammable = 5},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
after_place_node = function(pos, placer)
|
||||
if placer:is_player() then
|
||||
if placer and placer:is_player() then
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("owner", placer:get_player_name())
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user