2013-05-18 16:05:16 +02:00
|
|
|
-- Minetest 0.4 mod: default
|
|
|
|
-- See README.txt for licensing and other information.
|
|
|
|
|
2015-08-07 18:41:44 +02:00
|
|
|
|
2015-06-04 20:08:54 +02:00
|
|
|
-- Namespace for functions
|
2015-08-07 18:41:44 +02:00
|
|
|
|
2015-06-04 20:08:54 +02:00
|
|
|
flowers = {}
|
|
|
|
|
2015-08-01 03:13:14 +02:00
|
|
|
|
2013-05-18 16:05:16 +02:00
|
|
|
-- Map Generation
|
2015-08-07 18:41:44 +02:00
|
|
|
|
2015-08-01 03:13:14 +02:00
|
|
|
dofile(minetest.get_modpath("flowers") .. "/mapgen.lua")
|
|
|
|
|
2013-05-18 16:05:16 +02:00
|
|
|
|
2015-08-07 18:41:44 +02:00
|
|
|
--
|
|
|
|
-- Flowers
|
|
|
|
--
|
|
|
|
|
2013-05-18 16:05:16 +02:00
|
|
|
-- Aliases for original flowers mod
|
2015-08-07 18:41:44 +02:00
|
|
|
|
2013-05-18 16:05:16 +02:00
|
|
|
minetest.register_alias("flowers:flower_rose", "flowers:rose")
|
|
|
|
minetest.register_alias("flowers:flower_tulip", "flowers:tulip")
|
2015-08-07 18:41:44 +02:00
|
|
|
minetest.register_alias("flowers:flower_dandelion_yellow", "flowers:dandelion_yellow")
|
|
|
|
minetest.register_alias("flowers:flower_geranium", "flowers:geranium")
|
2013-05-18 16:05:16 +02:00
|
|
|
minetest.register_alias("flowers:flower_viola", "flowers:viola")
|
2015-08-07 18:41:44 +02:00
|
|
|
minetest.register_alias("flowers:flower_dandelion_white", "flowers:dandelion_white")
|
2013-05-18 16:05:16 +02:00
|
|
|
|
2015-08-01 03:13:14 +02:00
|
|
|
|
|
|
|
-- Flower registration
|
|
|
|
|
2015-06-04 20:08:54 +02:00
|
|
|
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-08-01 03:13:14 +02:00
|
|
|
minetest.register_node("flowers:" .. name, {
|
2015-04-18 16:48:43 +02:00
|
|
|
description = desc,
|
|
|
|
drawtype = "plantlike",
|
2015-09-06 07:03:08 +02:00
|
|
|
waving = 1,
|
2015-08-01 03:13:14 +02:00
|
|
|
tiles = {"flowers_" .. name .. ".png"},
|
2015-06-04 20:08:54 +02:00
|
|
|
inventory_image = "flowers_" .. name .. ".png",
|
|
|
|
wield_image = "flowers_" .. name .. ".png",
|
2015-04-18 16:48:43 +02:00
|
|
|
sunlight_propagates = true,
|
|
|
|
paramtype = "light",
|
|
|
|
walkable = false,
|
|
|
|
stack_max = 99,
|
|
|
|
groups = f_groups,
|
|
|
|
sounds = default.node_sound_leaves_defaults(),
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
2015-06-04 20:08:54 +02:00
|
|
|
fixed = box
|
|
|
|
}
|
2015-04-18 16:48:43 +02:00
|
|
|
})
|
|
|
|
end
|
|
|
|
|
2015-06-04 20:08:54 +02:00
|
|
|
flowers.datas = {
|
2015-08-01 03:13:14 +02:00
|
|
|
{"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_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}},
|
|
|
|
{"viola", "Viola", {-0.5, -0.5, -0.5, 0.5, -0.2, 0.5}, {color_violet = 1}},
|
|
|
|
{"dandelion_white", "White dandelion", {-0.5, -0.5, -0.5, 0.5, -0.2, 0.5}, {color_white = 1}}
|
2015-06-04 20:08:54 +02:00
|
|
|
}
|
2013-05-18 16:05:16 +02:00
|
|
|
|
2015-06-04 20:08:54 +02:00
|
|
|
for _,item in pairs(flowers.datas) do
|
|
|
|
add_simple_flower(unpack(item))
|
|
|
|
end
|
2013-05-18 16:05:16 +02:00
|
|
|
|
2015-08-01 03:13:14 +02:00
|
|
|
|
2015-08-07 18:41:44 +02:00
|
|
|
-- Flower spread
|
|
|
|
|
|
|
|
minetest.register_abm({
|
|
|
|
nodenames = {"group:flora"},
|
|
|
|
neighbors = {"default:dirt_with_grass", "default:desert_sand"},
|
|
|
|
interval = 50,
|
|
|
|
chance = 25,
|
|
|
|
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"})
|
|
|
|
elseif under.name ~= "default:dirt_with_grass" then
|
|
|
|
return
|
|
|
|
end
|
2015-08-10 01:03:15 +02:00
|
|
|
|
2015-08-07 18:41:44 +02:00
|
|
|
local light = minetest.get_node_light(pos)
|
|
|
|
if not light or light < 13 then
|
|
|
|
return
|
|
|
|
end
|
2015-08-10 01:03:15 +02:00
|
|
|
|
2015-08-07 18:41:44 +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-08-10 01:03:15 +02:00
|
|
|
|
2015-08-07 18:41:44 +02:00
|
|
|
local flowers = minetest.find_nodes_in_area(pos0, pos1, "group:flora")
|
|
|
|
if #flowers > 3 then
|
|
|
|
return
|
|
|
|
end
|
2015-08-10 01:03:15 +02:00
|
|
|
|
2015-08-07 18:41:44 +02: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,
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
--
|
2015-08-01 03:13:14 +02:00
|
|
|
-- Mushrooms
|
2015-08-07 18:41:44 +02:00
|
|
|
--
|
2015-08-01 03:13:14 +02:00
|
|
|
|
2015-07-12 12:47:04 +02:00
|
|
|
local mushrooms_datas = {
|
2015-08-01 03:13:14 +02:00
|
|
|
{"brown", 2},
|
|
|
|
{"red", -6}
|
2015-07-12 12:47:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
for _, m in pairs(mushrooms_datas) do
|
|
|
|
local name, nut = m[1], m[2]
|
2015-08-01 03:13:14 +02:00
|
|
|
|
2015-08-10 12:57:27 +02:00
|
|
|
-- Register fertile mushrooms
|
2015-08-01 03:13:14 +02:00
|
|
|
|
2015-08-10 12:57:27 +02:00
|
|
|
-- These are placed by mapgen and the growing ABM.
|
|
|
|
-- These drop an infertile mushroom, and 0 to 3 spore
|
|
|
|
-- nodes with an average of 1.25 per mushroom, for
|
|
|
|
-- a slow multiplication of mushrooms when farming.
|
|
|
|
|
|
|
|
minetest.register_node("flowers:mushroom_fertile_" .. name, {
|
2015-08-01 03:13:14 +02:00
|
|
|
description = string.sub(string.upper(name), 0, 1) ..
|
2015-08-10 12:57:27 +02:00
|
|
|
string.sub(name, 2) .. " Fertile Mushroom",
|
2015-08-01 03:13:14 +02:00
|
|
|
tiles = {"flowers_mushroom_" .. name .. ".png"},
|
|
|
|
inventory_image = "flowers_mushroom_" .. name .. ".png",
|
|
|
|
wield_image = "flowers_mushroom_" .. name .. ".png",
|
2015-07-12 12:47:04 +02:00
|
|
|
drawtype = "plantlike",
|
|
|
|
paramtype = "light",
|
|
|
|
sunlight_propagates = true,
|
|
|
|
walkable = false,
|
|
|
|
buildable_to = true,
|
2015-08-10 12:57:27 +02:00
|
|
|
groups = {snappy = 3, flammable = 3, attached_node = 1,
|
|
|
|
not_in_creative_inventory = 1},
|
2015-08-01 03:13:14 +02:00
|
|
|
drop = {
|
|
|
|
items = {
|
2015-08-10 12:57:27 +02:00
|
|
|
{items = {"flowers:mushroom_" .. name}},
|
|
|
|
{items = {"flowers:mushroom_spores_" .. name}, rarity = 4},
|
|
|
|
{items = {"flowers:mushroom_spores_" .. name}, rarity = 2},
|
|
|
|
{items = {"flowers:mushroom_spores_" .. name}, rarity = 2}
|
|
|
|
}
|
2015-08-01 03:13:14 +02:00
|
|
|
},
|
2015-07-12 12:47:04 +02:00
|
|
|
sounds = default.node_sound_leaves_defaults(),
|
|
|
|
on_use = minetest.item_eat(nut),
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {-0.3, -0.5, -0.3, 0.3, 0, 0.3}
|
|
|
|
}
|
|
|
|
})
|
2015-08-01 03:13:14 +02:00
|
|
|
|
2015-08-10 12:57:27 +02:00
|
|
|
-- Register infertile mushrooms
|
|
|
|
|
|
|
|
-- These do not drop spores, to avoid the use of repeated digging
|
|
|
|
-- and placing of a single mushroom to generate unlimited spores.
|
|
|
|
|
|
|
|
minetest.register_node("flowers:mushroom_" .. name, {
|
|
|
|
description = string.sub(string.upper(name), 0, 1) ..
|
|
|
|
string.sub(name, 2) .. " Mushroom",
|
|
|
|
tiles = {"flowers_mushroom_" .. name .. ".png"},
|
|
|
|
inventory_image = "flowers_mushroom_" .. name .. ".png",
|
|
|
|
wield_image = "flowers_mushroom_" .. name .. ".png",
|
|
|
|
drawtype = "plantlike",
|
|
|
|
paramtype = "light",
|
|
|
|
sunlight_propagates = true,
|
|
|
|
walkable = false,
|
|
|
|
buildable_to = true,
|
|
|
|
groups = {snappy = 3, flammable = 3, attached_node = 1},
|
|
|
|
sounds = default.node_sound_leaves_defaults(),
|
|
|
|
on_use = minetest.item_eat(nut),
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {-0.3, -0.5, -0.3, 0.3, 0, 0.3}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2015-08-07 18:41:44 +02:00
|
|
|
-- Register mushroom spores
|
2015-08-01 03:13:14 +02:00
|
|
|
|
2015-08-07 18:41:44 +02:00
|
|
|
minetest.register_node("flowers:mushroom_spores_" .. name, {
|
2015-08-01 03:13:14 +02:00
|
|
|
description = string.sub(string.upper(name), 0, 1) ..
|
|
|
|
string.sub(name, 2) .. " Mushroom Spores",
|
|
|
|
drawtype = "signlike",
|
2015-08-07 18:41:44 +02:00
|
|
|
tiles = {"flowers_mushroom_spores_" .. name .. ".png"},
|
|
|
|
inventory_image = "flowers_mushroom_spores_" .. name .. ".png",
|
|
|
|
wield_image = "flowers_mushroom_spores_" .. name .. ".png",
|
2015-08-01 03:13:14 +02:00
|
|
|
paramtype = "light",
|
|
|
|
paramtype2 = "wallmounted",
|
|
|
|
sunlight_propagates = true,
|
|
|
|
walkable = false,
|
|
|
|
buildable_to = true,
|
|
|
|
selection_box = {
|
|
|
|
type = "wallmounted",
|
|
|
|
},
|
|
|
|
groups = {dig_immediate = 3, attached_node = 1},
|
|
|
|
})
|
2015-07-12 12:47:04 +02:00
|
|
|
end
|
|
|
|
|
2015-08-01 03:13:14 +02:00
|
|
|
|
2015-08-07 18:41:44 +02:00
|
|
|
-- Register growing ABM
|
2015-08-01 03:13:14 +02:00
|
|
|
|
2013-05-18 16:05:16 +02:00
|
|
|
minetest.register_abm({
|
2015-08-07 18:41:44 +02:00
|
|
|
nodenames = {"flowers:mushroom_spores_brown", "flowers:mushroom_spores_red"},
|
|
|
|
interval = 11,
|
|
|
|
chance = 50,
|
2013-05-18 16:05:16 +02:00
|
|
|
action = function(pos, node)
|
2015-08-07 18:41:44 +02:00
|
|
|
local node_under = minetest.get_node_or_nil({x = pos.x,
|
|
|
|
y = pos.y - 1, z = pos.z})
|
|
|
|
if not node_under then
|
2013-05-18 16:05:16 +02:00
|
|
|
return
|
|
|
|
end
|
2015-08-07 18:41:44 +02:00
|
|
|
if minetest.get_item_group(node_under.name, "soil") ~= 0 and
|
|
|
|
minetest.get_node_light(pos, nil) <= 13 then
|
|
|
|
if node.name == "flowers:mushroom_spores_brown" then
|
2015-08-10 12:57:27 +02:00
|
|
|
minetest.set_node(pos, {name = "flowers:mushroom_fertile_brown"})
|
|
|
|
elseif node.name == "flowers:mushroom_spores_red" then
|
|
|
|
minetest.set_node(pos, {name = "flowers:mushroom_fertile_red"})
|
2013-05-18 16:05:16 +02:00
|
|
|
end
|
|
|
|
end
|
2015-08-07 18:41:44 +02:00
|
|
|
end
|
2013-05-18 16:05:16 +02:00
|
|
|
})
|