Flowers: small fix and update

This commit is contained in:
MoNTE48 2020-04-28 21:30:46 +02:00
parent 451b899704
commit be9b23c718
4 changed files with 24 additions and 16 deletions

View File

@ -59,20 +59,28 @@ local function flowerpot_on_rightclick(pos, _, clicker, itemstack)
end end
local function get_tile(def) local function get_tile(def)
local tile = def.tiles[1]
if type(tile) == "table" then
tile = tile.name
end
local tiles = {"flowerpot.png"} local tiles = {"flowerpot.png"}
if def.drawtype == "plantlike" then local drawtype = def.drawtype
tiles[2] = tile
if drawtype == "mesh" then
tiles[2] = "[combine:64x64:0,10=" .. def.inventory_image
tiles[3] = "blank.png" tiles[3] = "blank.png"
else else
tiles[2] = "blank.png" local tile = def.tiles[1]
tiles[3] = tile if type(tile) == "table" then
tile = tile.name
end
if drawtype == "plantlike" then
tiles[2] = tile
tiles[3] = "blank.png"
else
tiles[2] = "blank.png"
tiles[3] = tile
end
end end
return tiles return tiles
end end
@ -149,7 +157,7 @@ inv.on_place = function(itemstack, placer, pointed_thing)
if result and not (creative and creative.is_enabled_for and if result and not (creative and creative.is_enabled_for and
creative.is_enabled_for(placer)) then creative.is_enabled_for(placer)) then
itemstack:take_item() itemstack:take_item()
minetest.sound_play({name = "default_place_node_hard", gain = 1}, minetest.sound_play({name = "default_place_node_hard"},
{pos = pointed_thing.above}) {pos = pointed_thing.above})
end end
end end
@ -171,6 +179,6 @@ minetest.register_craft({
local register_pot = flowerpot.register_node local register_pot = flowerpot.register_node
for node, def in pairs(minetest.registered_nodes) do for node, def in pairs(minetest.registered_nodes) do
if def.groups.flora or def.groups.sapling then if def.groups.flora or def.groups.sapling then
flowerpot.register_node(node) register_pot(node)
end end
end end

View File

@ -228,8 +228,8 @@ minetest.register_node("flowers:mushroom_brown", {
function flowers.mushroom_spread(pos, node) function flowers.mushroom_spread(pos, node)
if minetest.get_node_light(pos, 0.5) > 3 then if minetest.get_node_light(pos, 0.5) > 3 then
if minetest.get_node_light(pos, nil) == 15 then if minetest.get_node_light(pos, nil) == 15 then
minetest.remove_node(pos) minetest.remove_node(pos)
end end
return return
end end
@ -250,8 +250,8 @@ end
minetest.register_abm({ minetest.register_abm({
label = "Mushroom spread", label = "Mushroom spread",
nodenames = {"flowers:mushroom_brown", "flowers:mushroom_red"}, nodenames = {"flowers:mushroom_brown", "flowers:mushroom_red"},
interval = 20, interval = 15,
chance = 100, chance = 150,
action = function(...) action = function(...)
flowers.mushroom_spread(...) flowers.mushroom_spread(...)
end end
@ -300,7 +300,6 @@ minetest.register_node("flowers:waterlily", {
local pos = pointed_thing.above local pos = pointed_thing.above
local node = minetest.get_node(pointed_thing.under) local node = minetest.get_node(pointed_thing.under)
local def = minetest.registered_nodes[node.name] local def = minetest.registered_nodes[node.name]
local player_name = placer and placer:get_player_name() or ""
if def and def.on_rightclick then if def and def.on_rightclick then
return def.on_rightclick(pointed_thing.under, node, placer, itemstack, return def.on_rightclick(pointed_thing.under, node, placer, itemstack,
@ -309,6 +308,7 @@ minetest.register_node("flowers:waterlily", {
if def and def.liquidtype == "source" and 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 if not minetest.is_protected(pos, player_name) then
minetest.set_node(pos, {name = "flowers:waterlily", minetest.set_node(pos, {name = "flowers:waterlily",
param2 = math.random(0, 3)}) param2 = math.random(0, 3)})

Binary file not shown.

Before

Width:  |  Height:  |  Size: 217 B

After

Width:  |  Height:  |  Size: 215 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 246 B

After

Width:  |  Height:  |  Size: 243 B