Browse Source

[nalc_flowers] Corrige callback on_place du lily_pad

master
sys4 2 months ago
parent
commit
61176e5bf0
1 changed files with 17 additions and 17 deletions
  1. +17
    -17
      nalc_flowers/init.lua

+ 17
- 17
nalc_flowers/init.lua View File

@@ -4,24 +4,24 @@ lilypad_def.tiles = {"flowers_lily_pad.png"}
lilypad_def.inventory_image = "flowers_lily_pad.png"
lilypad_def.wield_image = "flowers_lily_pad.png"
lilypad_def.on_place = function(itemstack, placer, pointed_thing)
local pos = pointed_thing.above
local node = minetest.get_node(pointed_thing.under)
local def = minetest.registered_nodes[node.name]

if def and def.on_rightclick then
return def.on_rightclick(pointed_thing.under, node, placer, itemstack,
pointed_thing)
end

if def and def.liquidtype == "source" and
local pos = pointed_thing.above
local node = minetest.get_node(pointed_thing.under)
local def = minetest.registered_nodes[node.name]
if def then
if def.on_rightclick then
def.on_rightclick(pointed_thing.under, node, placer, itemstack, pointed_thing)
elseif def.liquidtype == "source" and
minetest.get_item_group(node.name, "water") > 0 then
local player_name = placer and placer:get_player_name() or ""
if not minetest.is_protected(pos, player_name) then
minetest.set_node(pos, {name = "nalc_flowers:lily_pad" ..
(def.waving == 3 and "_waving" or ""),
param2 = math.random(0, 3)})
if not (creative and creative.is_enabled_for
and creative.is_enabled_for(player_name)) then
minetest.set_node(
pos, {
name = "nalc_flowers:lily_pad" ..(def.waving == 3 and "_waving" or ""),
param2 = math.random(0, 3)
})
if not (creative and creative.is_enabled_for and
creative.is_enabled_for(player_name)) then
itemstack:take_item()
end
else
@@ -29,8 +29,8 @@ lilypad_def.on_place = function(itemstack, placer, pointed_thing)
minetest.record_protection_violation(pos, player_name)
end
end
return itemstack
end
return itemstack
end

local lilypad_waving_def = table.copy(lilypad_def)


Loading…
Cancel
Save