2014-10-28 18:01:32 +01:00
|
|
|
-- Minetest 0.4 mod: default
|
|
|
|
-- See README.txt for licensing and other information.
|
|
|
|
|
2015-06-06 15:38:01 +02:00
|
|
|
-- Namespace for functions
|
|
|
|
flowers = {}
|
|
|
|
|
2014-10-28 18:01:32 +01:00
|
|
|
-- Map Generation
|
|
|
|
dofile(minetest.get_modpath("flowers").."/mapgen.lua")
|
|
|
|
|
|
|
|
-- Aliases for original flowers mod
|
|
|
|
minetest.register_alias("flowers:flower_dandelion_white", "flowers:dandelion_white")
|
|
|
|
minetest.register_alias("flowers:flower_dandelion_yellow", "flowers:dandelion_yellow")
|
|
|
|
minetest.register_alias("flowers:flower_geranium", "flowers:geranium")
|
|
|
|
minetest.register_alias("flowers:flower_rose", "flowers:rose")
|
|
|
|
minetest.register_alias("flowers:flower_tulip", "flowers:tulip")
|
|
|
|
minetest.register_alias("flowers:flower_viola", "flowers:viola")
|
|
|
|
|
2015-06-06 15:38:01 +02:00
|
|
|
-- Flower registration function
|
|
|
|
local function add_simple_flower(name, desc, box, f_groups)
|
|
|
|
-- Common flowers' groups
|
|
|
|
f_groups.snappy = 3
|
|
|
|
f_groups.flammable = 2
|
|
|
|
f_groups.flower = 1
|
|
|
|
f_groups.flora = 1
|
|
|
|
f_groups.attached_node = 1
|
2015-03-12 05:06:37 +01:00
|
|
|
|
|
|
|
minetest.register_node("flowers:"..name.."", {
|
|
|
|
description = desc,
|
|
|
|
drawtype = "plantlike",
|
2015-06-06 15:38:01 +02:00
|
|
|
tiles = { "flowers_" .. name .. ".png" },
|
|
|
|
inventory_image = "flowers_" .. name .. ".png",
|
|
|
|
wield_image = "flowers_" .. name .. ".png",
|
2015-03-12 05:06:37 +01:00
|
|
|
sunlight_propagates = true,
|
|
|
|
paramtype = "light",
|
|
|
|
walkable = false,
|
2015-03-24 17:21:32 +01:00
|
|
|
stack_max = 99,
|
2015-03-24 19:16:13 +01:00
|
|
|
groups = f_groups,
|
2015-03-12 05:06:37 +01:00
|
|
|
sounds = default.node_sound_leaves_defaults(),
|
2015-06-06 15:38:01 +02:00
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = box
|
|
|
|
}
|
2015-03-12 05:06:37 +01:00
|
|
|
})
|
|
|
|
end
|
|
|
|
|
2015-06-06 15:38:01 +02:00
|
|
|
-- Registrations using the function above
|
|
|
|
flowers.datas = {
|
|
|
|
{"dandelion_yellow", "Yellow Dandelion", { -0.15, -0.5, -0.15, 0.15, 0.2, 0.15 }, {color_yellow=1}},
|
|
|
|
{"geranium", "Blue Geranium", { -0.15, -0.5, -0.15, 0.15, 0.2, 0.15 }, {color_blue=1}},
|
|
|
|
{"rose", "Rose", { -0.15, -0.5, -0.15, 0.15, 0.3, 0.15 }, {color_red=1}},
|
|
|
|
{"tulip", "Orange Tulip", { -0.15, -0.5, -0.15, 0.15, 0.2, 0.15 }, {color_orange=1}},
|
|
|
|
{"dandelion_white", "White dandelion", { -0.5, -0.5, -0.5, 0.5, -0.2, 0.5 }, {color_white=1}},
|
|
|
|
{"viola", "Viola", { -0.5, -0.5, -0.5, 0.5, -0.2, 0.5 }, {color_violet=1}}
|
2015-05-31 20:29:28 +02:00
|
|
|
}
|
|
|
|
|
2015-06-06 15:38:01 +02:00
|
|
|
for _,item in pairs(flowers.datas) do
|
|
|
|
add_simple_flower(unpack(item))
|
|
|
|
end
|
2014-10-28 18:01:32 +01:00
|
|
|
|
2015-06-09 17:59:08 +02:00
|
|
|
minetest.register_node("flowers:lily_pad", {
|
|
|
|
description = "Lily Pad",
|
|
|
|
drawtype = "nodebox",
|
|
|
|
tiles = { "flowers_lily_pad.png" },
|
|
|
|
inventory_image = "flowers_lily_pad.png",
|
|
|
|
wield_image = "flowers_lily_pad.png",
|
|
|
|
wield_scale = {x = 1, y = 1, z = 0.001},
|
|
|
|
is_ground_content = true,
|
|
|
|
sunlight_propagates = true,
|
|
|
|
paramtype = "light",
|
|
|
|
walkable = false,
|
|
|
|
buildable_to = true,
|
|
|
|
groups = {snappy = 3, flammable = 2, flower = 1, flora = 1},
|
|
|
|
sounds = default.node_sound_leaves_defaults(),
|
|
|
|
node_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {-0.5, -0.45, -0.5, 0.5, -0.4375, 0.5},
|
|
|
|
},
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {-0.5, -0.5, -0.5, 0.5, -0.4375, 0.5},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
2014-10-28 18:01:32 +01:00
|
|
|
minetest.register_abm({
|
|
|
|
nodenames = {"group:flora"},
|
|
|
|
neighbors = {"default:dirt_with_grass", "default:desert_sand"},
|
2014-12-11 18:53:00 +01:00
|
|
|
interval = 2,
|
|
|
|
chance = 500,
|
2014-10-28 18:01:32 +01:00
|
|
|
action = function(pos, node)
|
|
|
|
pos.y = pos.y - 1
|
|
|
|
local under = minetest.get_node(pos)
|
|
|
|
pos.y = pos.y + 1
|
|
|
|
if under.name == "default:desert_sand" then
|
|
|
|
minetest.set_node(pos, {name="default:dry_shrub"})
|
2015-06-06 15:38:01 +02:00
|
|
|
elseif under.name ~= "default:dirt_with_grass" then
|
|
|
|
return
|
|
|
|
end
|
2015-06-10 19:12:48 +02:00
|
|
|
|
2014-10-28 18:01:32 +01:00
|
|
|
local light = minetest.get_node_light(pos)
|
2015-06-06 15:38:01 +02:00
|
|
|
if not light or light < 13 then
|
|
|
|
return
|
|
|
|
end
|
2015-06-10 19:12:48 +02:00
|
|
|
|
2015-06-06 15:38:01 +02:00
|
|
|
local pos0 = {x=pos.x-4,y=pos.y-4,z=pos.z-4}
|
|
|
|
local pos1 = {x=pos.x+4,y=pos.y+4,z=pos.z+4}
|
|
|
|
if #minetest.find_nodes_in_area(pos0, pos1, "group:flora_block") > 0 then
|
|
|
|
return
|
|
|
|
end
|
2015-06-10 19:12:48 +02:00
|
|
|
|
2014-10-28 18:01:32 +01:00
|
|
|
local flowers = minetest.find_nodes_in_area(pos0, pos1, "group:flora")
|
2015-06-06 15:38:01 +02:00
|
|
|
if #flowers > 3 then
|
|
|
|
return
|
|
|
|
end
|
2015-06-10 19:12:48 +02:00
|
|
|
|
2014-10-28 18:01:32 +01:00
|
|
|
local seedling = minetest.find_nodes_in_area(pos0, pos1, "default:dirt_with_grass")
|
|
|
|
if #seedling > 0 then
|
|
|
|
seedling = seedling[math.random(#seedling)]
|
|
|
|
seedling.y = seedling.y + 1
|
|
|
|
light = minetest.get_node_light(seedling)
|
|
|
|
if not light or light < 13 then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
if minetest.get_node(seedling).name == "air" then
|
|
|
|
minetest.set_node(seedling, {name=node.name})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
})
|