From a7b550488c30a7d4f88c3623fc9d8a005816da2a Mon Sep 17 00:00:00 2001 From: sys4 Date: Sun, 10 May 2020 00:49:39 +0200 Subject: [PATCH] [nalc_flowers] Ajoute le lily_pad ondulant --- nalc_flowers/init.lua | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/nalc_flowers/init.lua b/nalc_flowers/init.lua index 5fe468e..f154fff 100644 --- a/nalc_flowers/init.lua +++ b/nalc_flowers/init.lua @@ -1,4 +1,4 @@ -minetest.register_node("nalc_flowers:lily_pad", { +local lilypad_def = { description = "Lily Pad", drawtype = "nodebox", tiles = { "flowers_lily_pad.png" }, @@ -12,7 +12,7 @@ minetest.register_node("nalc_flowers:lily_pad", { walkable = false, buildable_to = true, floodable = true, - groups = {snappy = 3, flammable = 2, flower = 1}, + groups = {snappy = 3, flammable = 1, flower = 1}, sounds = default.node_sound_leaves_defaults(), node_placement_prediction = "", node_box = { @@ -27,7 +27,6 @@ minetest.register_node("nalc_flowers:lily_pad", { local pos = pointed_thing.above local node = minetest.get_node(pointed_thing.under) local def = minetest.registered_nodes[node.name] - local player_name = placer and placer:get_player_name() or "" if def and def.on_rightclick then return def.on_rightclick(pointed_thing.under, node, placer, itemstack, @@ -35,10 +34,12 @@ minetest.register_node("nalc_flowers:lily_pad", { end if def and def.liquidtype == "source" and - minetest.get_item_group(node.name, "water") > 0 then + 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", - param2 = math.random(0, 3)}) + 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() @@ -51,25 +52,36 @@ minetest.register_node("nalc_flowers:lily_pad", { return itemstack end -}) +} + +local lilypad_waving_def = table.copy(lilypad_def) +lilypad_waving_def.waving = 3 +lilypad_waving_def.drop = "nalc_flowers:lily_pad" +lilypad_waving_def.groups.not_in_creative_inventory = 1 + +minetest.register_node("nalc_flowers:lily_pad", lilypad_def) +minetest.register_node("nalc_flowers:lily_pad_waving", lilypad_waving_def) minetest.register_decoration({ - deco_type = "schematic", + name = "nalc_flowers:lily_pad", + deco_type = "simple", place_on = {"default:dirt"}, sidelen = 16, noise_params = { offset = -0.12, - scale = 0.31, + scale = 0.3, spread = {x=200, y=200, z=200}, - seed = 33, + seed = 34, octaves = 3, persist = 0.7 }, biomes = {"rainforest_swamp", "savanna_shore", "deciduous_forest_shore"}, y_min = 0, y_max = 0, - schematic = minetest.get_modpath("nalc_flowers").."/schematics/lilypad.mts", - rotation = "random", + decoration = "nalc_flowers:lily_pad_waving", + param2 = 0, + param2_max = 3, + place_offset_y = 1, }) minetest.register_alias("flowers:lily_pad", "nalc_flowers:lily_pad")