fix crash when place waterlily

This commit is contained in:
crabman77 2016-06-09 21:43:23 +02:00
parent caa7a6ac8e
commit 074b8e327f
1 changed files with 18 additions and 9 deletions

View File

@ -253,19 +253,28 @@ minetest.register_node("flowers:waterlily", {
fixed = {-0.5, -0.5, -0.5, 0.5, -0.4375, 0.5}
},
on_place = function(_, _, pointed_thing)
on_place = function(itemstack, placer, pointed_thing)
local pos = pointed_thing.above
local node = minetest.get_node(pointed_thing.under).name
local def = minetest.registered_nodes[node]
local player_name = placer:get_player_name()
if def and def.liquidtype == "source" and minetest.get_item_group(node, "water") > 0 then
minetest.set_node(pos, {name = "flowers:waterlily", param2 = math.random(0, 3)})
elseif #find_river_water ~= 0 then
minetest.set_node(pos, {name = "default:river_water_source"})
pos.y = pos.y + 1
minetest.set_node(pos, {name = "flowers:waterlily", param2 = math.random(0, 3)})
else
minetest.remove_node(pos)
return true
if not minetest.is_protected(pos, player_name) then
minetest.set_node(pos, {name = "flowers:waterlily", param2 = math.random(0, 3)})
if not minetest.setting_getbool("creative_mode") then
itemstack:take_item()
end
else
minetest.chat_send_player(player_name, "This area is protected")
end
end
return itemstack
end
})