Version MFF.
36
mods/flowers/README.txt
Normal file → Executable file
@ -1,16 +1,26 @@
|
||||
Minetest 0.4 mod: flowers
|
||||
=========================
|
||||
Minetest Game mod: flowers
|
||||
==========================
|
||||
See license.txt for license information.
|
||||
|
||||
License of source code:
|
||||
-----------------------
|
||||
Copyright (C) 2012-2013 Ironzorg, VanessaE
|
||||
Authors of source code
|
||||
----------------------
|
||||
Originally by Ironzorg (MIT) and VanessaE (MIT)
|
||||
Various Minetest developers and contributors (MIT)
|
||||
|
||||
This program is free software. It comes without any warranty, to
|
||||
the extent permitted by applicable law. You can redistribute it
|
||||
and/or modify it under the terms of the Do What The Fuck You Want
|
||||
To Public License, Version 2, as published by Sam Hocevar. See
|
||||
http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
Authors of media (textures)
|
||||
---------------------------
|
||||
RHRhino (CC BY-SA 3.0):
|
||||
flowers_dandelion_white.png
|
||||
flowers_dandelion_yellow.png
|
||||
flowers_geranium.png
|
||||
flowers_rose.png
|
||||
flowers_tulip.png
|
||||
flowers_viola.png
|
||||
|
||||
License of media (textures and sounds)
|
||||
--------------------------------------
|
||||
WTFPL
|
||||
Gambit (CC BY-SA 3.0):
|
||||
flowers_mushroom_brown.png
|
||||
flowers_mushroom_red.png
|
||||
flowers_waterlily.png
|
||||
|
||||
yyt16384 (CC BY-SA 3.0):
|
||||
flowers_waterlily_bottom.png, derived from Gambit's texture
|
||||
|
0
mods/flowers/depends.txt
Normal file → Executable file
430
mods/flowers/init.lua
Normal file → Executable file
@ -1,167 +1,321 @@
|
||||
-- Minetest 0.4 mod: default
|
||||
-- See README.txt for licensing and other information.
|
||||
|
||||
|
||||
-- Namespace for functions
|
||||
|
||||
flowers = {}
|
||||
|
||||
|
||||
-- Map Generation
|
||||
dofile(minetest.get_modpath("flowers").."/mapgen.lua")
|
||||
|
||||
dofile(minetest.get_modpath("flowers") .. "/mapgen.lua")
|
||||
|
||||
|
||||
--
|
||||
-- Flowers
|
||||
--
|
||||
|
||||
-- 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_dandelion_yellow", "flowers:dandelion_yellow")
|
||||
minetest.register_alias("flowers:flower_geranium", "flowers:geranium")
|
||||
minetest.register_alias("flowers:flower_viola", "flowers:viola")
|
||||
minetest.register_alias("flowers:flower_dandelion_white", "flowers:dandelion_white")
|
||||
|
||||
minetest.register_node("flowers:dandelion_white", {
|
||||
description = "White Dandelion",
|
||||
drawtype = "plantlike",
|
||||
tiles = { "flowers_dandelion_white.png" },
|
||||
inventory_image = "flowers_dandelion_white.png",
|
||||
wield_image = "flowers_dandelion_white.png",
|
||||
|
||||
-- Flower registration
|
||||
|
||||
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
|
||||
|
||||
minetest.register_node("flowers:" .. name, {
|
||||
description = desc,
|
||||
drawtype = "plantlike",
|
||||
waving = 1,
|
||||
tiles = {"flowers_" .. name .. ".png"},
|
||||
inventory_image = "flowers_" .. name .. ".png",
|
||||
wield_image = "flowers_" .. name .. ".png",
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
stack_max = 99,
|
||||
groups = f_groups,
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = box
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
flowers.datas = {
|
||||
{
|
||||
"rose",
|
||||
"Rose",
|
||||
{-2 / 16, -0.5, -2 / 16, 2 / 16, 5 / 16, 2 / 16},
|
||||
{color_red = 1, flammable = 1}
|
||||
},
|
||||
{
|
||||
"tulip",
|
||||
"Orange Tulip",
|
||||
{-2 / 16, -0.5, -2 / 16, 2 / 16, 3 / 16, 2 / 16},
|
||||
{color_orange = 1, flammable = 1}
|
||||
},
|
||||
{
|
||||
"dandelion_yellow",
|
||||
"Yellow Dandelion",
|
||||
{-2 / 16, -0.5, -2 / 16, 2 / 16, 4 / 16, 2 / 16},
|
||||
{color_yellow = 1, flammable = 1}
|
||||
},
|
||||
{
|
||||
"geranium",
|
||||
"Blue Geranium",
|
||||
{-2 / 16, -0.5, -2 / 16, 2 / 16, 2 / 16, 2 / 16},
|
||||
{color_blue = 1, flammable = 1}
|
||||
},
|
||||
{
|
||||
"viola",
|
||||
"Viola",
|
||||
{-5 / 16, -0.5, -5 / 16, 5 / 16, -1 / 16, 5 / 16},
|
||||
{color_violet = 1, flammable = 1}
|
||||
},
|
||||
{
|
||||
"dandelion_white",
|
||||
"White dandelion",
|
||||
{-5 / 16, -0.5, -5 / 16, 5 / 16, -2 / 16, 5 / 16},
|
||||
{color_white = 1, flammable = 1}
|
||||
},
|
||||
}
|
||||
|
||||
for _,item in pairs(flowers.datas) do
|
||||
add_simple_flower(unpack(item))
|
||||
end
|
||||
|
||||
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,attached_node=1,color_white=1},
|
||||
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.15, -0.5, -0.15, 0.15, 0.2, 0.15 },
|
||||
fixed = {-0.5, -0.5, -0.5, 0.5, -0.4375, 0.5},
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_node("flowers:dandelion_yellow", {
|
||||
description = "Yellow Dandelion",
|
||||
drawtype = "plantlike",
|
||||
tiles = { "flowers_dandelion_yellow.png" },
|
||||
inventory_image = "flowers_dandelion_yellow.png",
|
||||
wield_image = "flowers_dandelion_yellow.png",
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
groups = {snappy=3,flammable=2,flower=1,flora=1,attached_node=1,color_yellow=1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.15, -0.5, -0.15, 0.15, 0.2, 0.15 },
|
||||
},
|
||||
})
|
||||
-- Flower spread
|
||||
-- Public function to enable override by mods
|
||||
|
||||
minetest.register_node("flowers:geranium", {
|
||||
description = "Blue Geranium",
|
||||
drawtype = "plantlike",
|
||||
tiles = { "flowers_geranium.png" },
|
||||
inventory_image = "flowers_geranium.png",
|
||||
wield_image = "flowers_geranium.png",
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
groups = {snappy=3,flammable=2,flower=1,flora=1,attached_node=1,color_blue=1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.15, -0.5, -0.15, 0.15, 0.2, 0.15 },
|
||||
},
|
||||
})
|
||||
function flowers.flower_spread(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"})
|
||||
return
|
||||
elseif under.name ~= "default:dirt_with_grass" and
|
||||
under.name ~= "default:dirt_with_dry_grass" then
|
||||
return
|
||||
end
|
||||
|
||||
minetest.register_node("flowers:rose", {
|
||||
description = "Rose",
|
||||
drawtype = "plantlike",
|
||||
tiles = { "flowers_rose.png" },
|
||||
inventory_image = "flowers_rose.png",
|
||||
wield_image = "flowers_rose.png",
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
groups = {snappy=3,flammable=2,flower=1,flora=1,attached_node=1,color_red=1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.15, -0.5, -0.15, 0.15, 0.2, 0.15 },
|
||||
},
|
||||
})
|
||||
local light = minetest.get_node_light(pos)
|
||||
if not light or light < 13 then
|
||||
return
|
||||
end
|
||||
|
||||
minetest.register_node("flowers:tulip", {
|
||||
description = "Tulip",
|
||||
drawtype = "plantlike",
|
||||
tiles = { "flowers_tulip.png" },
|
||||
inventory_image = "flowers_tulip.png",
|
||||
wield_image = "flowers_tulip.png",
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
groups = {snappy=3,flammable=2,flower=1,flora=1,attached_node=1,color_orange=1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.15, -0.5, -0.15, 0.15, 0.2, 0.15 },
|
||||
},
|
||||
})
|
||||
local pos0 = vector.subtract(pos, 4)
|
||||
local pos1 = vector.add(pos, 4)
|
||||
if #minetest.find_nodes_in_area(pos0, pos1, "group:flora") > 3 then
|
||||
return
|
||||
end
|
||||
|
||||
minetest.register_node("flowers:viola", {
|
||||
description = "Viola",
|
||||
drawtype = "plantlike",
|
||||
tiles = { "flowers_viola.png" },
|
||||
inventory_image = "flowers_viola.png",
|
||||
wield_image = "flowers_viola.png",
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
groups = {snappy=3,flammable=2,flower=1,flora=1,attached_node=1,color_violet=1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.15, -0.5, -0.15, 0.15, 0.2, 0.15 },
|
||||
},
|
||||
})
|
||||
|
||||
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
|
||||
|
||||
local light = minetest.get_node_light(pos)
|
||||
local seedling = minetest.find_nodes_in_area_under_air(pos0, pos1,
|
||||
{"default:dirt_with_grass", "default:dirt_with_dry_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
|
||||
|
||||
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
|
||||
|
||||
local flowers = minetest.find_nodes_in_area(pos0, pos1, "group:flora")
|
||||
if #flowers > 3 then
|
||||
return
|
||||
end
|
||||
|
||||
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
|
||||
minetest.set_node(seedling, {name = node.name})
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
minetest.register_abm({
|
||||
label = "Flower spread",
|
||||
nodenames = {"group:flora"},
|
||||
neighbors = {"default:dirt_with_grass", "default:dirt_with_dry_grass",
|
||||
"default:desert_sand"},
|
||||
interval = 13,
|
||||
chance = 96,
|
||||
action = function(...)
|
||||
flowers.flower_spread(...)
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
--
|
||||
-- Mushrooms
|
||||
--
|
||||
|
||||
minetest.register_node("flowers:mushroom_red", {
|
||||
description = "Red Mushroom",
|
||||
tiles = {"flowers_mushroom_red.png"},
|
||||
inventory_image = "flowers_mushroom_red.png",
|
||||
wield_image = "flowers_mushroom_red.png",
|
||||
drawtype = "plantlike",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
groups = {snappy = 3, attached_node = 1, flammable = 1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
on_use = minetest.item_eat(-5),
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-4 / 16, -0.5, -4 / 16, 4 / 16, -1 / 16, 4 / 16},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_node("flowers:mushroom_brown", {
|
||||
description = "Brown Mushroom",
|
||||
tiles = {"flowers_mushroom_brown.png"},
|
||||
inventory_image = "flowers_mushroom_brown.png",
|
||||
wield_image = "flowers_mushroom_brown.png",
|
||||
drawtype = "plantlike",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
groups = {snappy = 3, attached_node = 1, flammable = 1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
on_use = minetest.item_eat(1),
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-3 / 16, -0.5, -3 / 16, 3 / 16, -2 / 16, 3 / 16},
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
-- Mushroom spread and death
|
||||
|
||||
minetest.register_abm({
|
||||
label = "Mushroom spread",
|
||||
nodenames = {"flowers:mushroom_brown", "flowers:mushroom_red"},
|
||||
interval = 11,
|
||||
chance = 50,
|
||||
action = function(pos, node)
|
||||
if minetest.get_node_light(pos, nil) == 15 then
|
||||
minetest.remove_node(pos)
|
||||
return
|
||||
end
|
||||
local random = {
|
||||
x = pos.x + math.random(-2, 2),
|
||||
y = pos.y + math.random(-1, 1),
|
||||
z = pos.z + math.random(-2, 2)
|
||||
}
|
||||
local random_node = minetest.get_node_or_nil(random)
|
||||
if not random_node or random_node.name ~= "air" then
|
||||
return
|
||||
end
|
||||
local node_under = minetest.get_node_or_nil({x = random.x,
|
||||
y = random.y - 1, z = random.z})
|
||||
if not node_under then
|
||||
return
|
||||
end
|
||||
|
||||
if (minetest.get_item_group(node_under.name, "soil") ~= 0 or
|
||||
minetest.get_item_group(node_under.name, "tree") ~= 0) and
|
||||
minetest.get_node_light(pos, 0.5) <= 3 and
|
||||
minetest.get_node_light(random, 0.5) <= 3 then
|
||||
minetest.set_node(random, {name = node.name})
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
|
||||
-- These old mushroom related nodes can be simplified now
|
||||
|
||||
minetest.register_alias("flowers:mushroom_spores_brown", "flowers:mushroom_brown")
|
||||
minetest.register_alias("flowers:mushroom_spores_red", "flowers:mushroom_red")
|
||||
minetest.register_alias("flowers:mushroom_fertile_brown", "flowers:mushroom_brown")
|
||||
minetest.register_alias("flowers:mushroom_fertile_red", "flowers:mushroom_red")
|
||||
minetest.register_alias("mushroom:brown_natural", "flowers:mushroom_brown")
|
||||
minetest.register_alias("mushroom:red_natural", "flowers:mushroom_red")
|
||||
|
||||
|
||||
--
|
||||
-- Waterlily
|
||||
--
|
||||
|
||||
minetest.register_node("flowers:waterlily", {
|
||||
description = "Waterlily",
|
||||
drawtype = "nodebox",
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
tiles = {"flowers_waterlily.png", "flowers_waterlily_bottom.png"},
|
||||
inventory_image = "flowers_waterlily.png",
|
||||
wield_image = "flowers_waterlily.png",
|
||||
liquids_pointable = true,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
sunlight_propagates = true,
|
||||
floodable = true,
|
||||
groups = {snappy = 3, flower = 1, flammable = 1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
node_placement_prediction = "",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.5, -0.5, -0.5, 0.5, -15 / 32, 0.5}
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-7 / 16, -0.5, -7 / 16, 7 / 16, -15 / 32, 7 / 16}
|
||||
},
|
||||
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
local pos = pointed_thing.above
|
||||
local node = minetest.get_node(pointed_thing.under).name
|
||||
local def = minetest.registered_nodes[node]
|
||||
local player_name = placer:get_player_name()
|
||||
|
||||
if def and def.liquidtype == "source" and
|
||||
minetest.get_item_group(node, "water") > 0 then
|
||||
if not minetest.is_protected(pos, player_name) then
|
||||
minetest.set_node(pos, {name = "flowers:waterlily",
|
||||
param2 = math.random(0, 3)})
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
itemstack:take_item()
|
||||
end
|
||||
else
|
||||
minetest.chat_send_player(player_name, "Node is protected")
|
||||
minetest.record_protection_violation(pos, player_name)
|
||||
end
|
||||
end
|
||||
|
||||
return itemstack
|
||||
end
|
||||
})
|
||||
|
62
mods/flowers/license.txt
Normal file
@ -0,0 +1,62 @@
|
||||
License of source code
|
||||
----------------------
|
||||
|
||||
The MIT License (MIT)
|
||||
Copyright (C) 2012-2016 Ironzorg, VanessaE
|
||||
Copyright (C) 2012-2016 Various Minetest developers and contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
software and associated documentation files (the "Software"), to deal in the Software
|
||||
without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
publish, distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or
|
||||
substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
For more details:
|
||||
https://opensource.org/licenses/MIT
|
||||
|
||||
|
||||
Licenses of media (textures)
|
||||
----------------------------
|
||||
|
||||
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
|
||||
Copyright (C) 2014-2016 RHRhino
|
||||
Copyright (C) 2015-2016 Gambit
|
||||
Copyright (C) 2016 yyt16384
|
||||
|
||||
You are free to:
|
||||
Share — copy and redistribute the material in any medium or format.
|
||||
Adapt — remix, transform, and build upon the material for any purpose, even commercially.
|
||||
The licensor cannot revoke these freedoms as long as you follow the license terms.
|
||||
|
||||
Under the following terms:
|
||||
|
||||
Attribution — You must give appropriate credit, provide a link to the license, and
|
||||
indicate if changes were made. You may do so in any reasonable manner, but not in any way
|
||||
that suggests the licensor endorses you or your use.
|
||||
|
||||
ShareAlike — If you remix, transform, or build upon the material, you must distribute
|
||||
your contributions under the same license as the original.
|
||||
|
||||
No additional restrictions — You may not apply legal terms or technological measures that
|
||||
legally restrict others from doing anything the license permits.
|
||||
|
||||
Notices:
|
||||
|
||||
You do not have to comply with the license for elements of the material in the public
|
||||
domain or where your use is permitted by an applicable exception or limitation.
|
||||
No warranties are given. The license may not give you all of the permissions necessary
|
||||
for your intended use. For example, other rights such as publicity, privacy, or moral
|
||||
rights may limit how you use the material.
|
||||
|
||||
For more details:
|
||||
http://creativecommons.org/licenses/by-sa/3.0/
|
291
mods/flowers/mapgen.lua
Normal file → Executable file
@ -1,62 +1,229 @@
|
||||
minetest.register_on_generated(function(minp, maxp, seed)
|
||||
if maxp.y >= 2 and minp.y <= 0 then
|
||||
-- Generate flowers
|
||||
local perlin1 = minetest.get_perlin(436, 3, 0.6, 100)
|
||||
-- Assume X and Z lengths are equal
|
||||
local divlen = 16
|
||||
local divs = (maxp.x-minp.x)/divlen+1;
|
||||
for divx=0,divs-1 do
|
||||
for divz=0,divs-1 do
|
||||
local x0 = minp.x + math.floor((divx+0)*divlen)
|
||||
local z0 = minp.z + math.floor((divz+0)*divlen)
|
||||
local x1 = minp.x + math.floor((divx+1)*divlen)
|
||||
local z1 = minp.z + math.floor((divz+1)*divlen)
|
||||
-- Determine flowers amount from perlin noise
|
||||
local grass_amount = math.floor(perlin1:get2d({x=x0, y=z0}) ^ 3 * 9)
|
||||
-- Find random positions for flowers based on this random
|
||||
local pr = PseudoRandom(seed+456)
|
||||
for i=0,grass_amount do
|
||||
local x = pr:next(x0, x1)
|
||||
local z = pr:next(z0, z1)
|
||||
-- Find ground level (0...15)
|
||||
local ground_y = nil
|
||||
for y=30,0,-1 do
|
||||
if minetest.get_node({x=x,y=y,z=z}).name ~= "air" then
|
||||
ground_y = y
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if ground_y then
|
||||
local p = {x=x,y=ground_y+1,z=z}
|
||||
local nn = minetest.get_node(p).name
|
||||
-- Check if the node can be replaced
|
||||
if minetest.registered_nodes[nn] and
|
||||
minetest.registered_nodes[nn].buildable_to then
|
||||
nn = minetest.get_node({x=x,y=ground_y,z=z}).name
|
||||
if nn == "default:dirt_with_grass" then
|
||||
local flower_choice = pr:next(1, 6)
|
||||
local flower
|
||||
if flower_choice == 1 then
|
||||
flower = "flowers:tulip"
|
||||
elseif flower_choice == 2 then
|
||||
flower = "flowers:rose"
|
||||
elseif flower_choice == 3 then
|
||||
flower = "flowers:dandelion_yellow"
|
||||
elseif flower_choice == 4 then
|
||||
flower = "flowers:dandelion_white"
|
||||
elseif flower_choice == 5 then
|
||||
flower = "flowers:geranium"
|
||||
elseif flower_choice == 6 then
|
||||
flower = "flowers:viola"
|
||||
end
|
||||
minetest.set_node(p, {name=flower})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
--
|
||||
-- Mgv6
|
||||
--
|
||||
|
||||
local function register_mgv6_flower(name)
|
||||
minetest.register_decoration({
|
||||
deco_type = "simple",
|
||||
place_on = {"default:dirt_with_grass"},
|
||||
sidelen = 16,
|
||||
noise_params = {
|
||||
offset = 0,
|
||||
scale = 0.006,
|
||||
spread = {x = 100, y = 100, z = 100},
|
||||
seed = 436,
|
||||
octaves = 3,
|
||||
persist = 0.6
|
||||
},
|
||||
y_min = 1,
|
||||
y_max = 30,
|
||||
decoration = "flowers:"..name,
|
||||
})
|
||||
end
|
||||
|
||||
local function register_mgv6_mushroom(name)
|
||||
minetest.register_decoration({
|
||||
deco_type = "simple",
|
||||
place_on = {"default:dirt_with_grass"},
|
||||
sidelen = 16,
|
||||
noise_params = {
|
||||
offset = 0,
|
||||
scale = 0.04,
|
||||
spread = {x = 100, y = 100, z = 100},
|
||||
seed = 7133,
|
||||
octaves = 3,
|
||||
persist = 0.6
|
||||
},
|
||||
y_min = 1,
|
||||
y_max = 30,
|
||||
decoration = "flowers:"..name,
|
||||
spawn_by = "default:tree",
|
||||
num_spawn_by = 1,
|
||||
})
|
||||
end
|
||||
|
||||
local function register_mgv6_waterlily()
|
||||
minetest.register_decoration({
|
||||
deco_type = "schematic",
|
||||
place_on = {"default:dirt"},
|
||||
sidelen = 16,
|
||||
noise_params = {
|
||||
offset = -0.12,
|
||||
scale = 0.3,
|
||||
spread = {x = 100, y = 100, z = 100},
|
||||
seed = 33,
|
||||
octaves = 3,
|
||||
persist = 0.7
|
||||
},
|
||||
y_min = 0,
|
||||
y_max = 0,
|
||||
schematic = minetest.get_modpath("flowers").."/schematics/waterlily.mts",
|
||||
rotation = "random",
|
||||
})
|
||||
end
|
||||
|
||||
function flowers.register_mgv6_decorations()
|
||||
register_mgv6_flower("rose")
|
||||
register_mgv6_flower("tulip")
|
||||
register_mgv6_flower("dandelion_yellow")
|
||||
register_mgv6_flower("geranium")
|
||||
register_mgv6_flower("viola")
|
||||
register_mgv6_flower("dandelion_white")
|
||||
|
||||
register_mgv6_mushroom("mushroom_brown")
|
||||
register_mgv6_mushroom("mushroom_red")
|
||||
|
||||
register_mgv6_waterlily()
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- All other biome API mapgens
|
||||
--
|
||||
|
||||
local function register_flower(seed, name)
|
||||
minetest.register_decoration({
|
||||
deco_type = "simple",
|
||||
place_on = {"default:dirt_with_grass"},
|
||||
sidelen = 16,
|
||||
noise_params = {
|
||||
offset = -0.015,
|
||||
scale = 0.025,
|
||||
spread = {x = 200, y = 200, z = 200},
|
||||
seed = seed,
|
||||
octaves = 3,
|
||||
persist = 0.6
|
||||
},
|
||||
biomes = {"stone_grassland", "sandstone_grassland",
|
||||
"deciduous_forest", "coniferous_forest"},
|
||||
y_min = 1,
|
||||
y_max = 31000,
|
||||
decoration = "flowers:"..name,
|
||||
})
|
||||
end
|
||||
|
||||
local function register_mushroom(name)
|
||||
minetest.register_decoration({
|
||||
deco_type = "simple",
|
||||
place_on = {"default:dirt_with_grass"},
|
||||
sidelen = 16,
|
||||
noise_params = {
|
||||
offset = 0,
|
||||
scale = 0.006,
|
||||
spread = {x = 200, y = 200, z = 200},
|
||||
seed = 2,
|
||||
octaves = 3,
|
||||
persist = 0.66
|
||||
},
|
||||
biomes = {"deciduous_forest", "coniferous_forest"},
|
||||
y_min = 1,
|
||||
y_max = 31000,
|
||||
decoration = "flowers:"..name,
|
||||
})
|
||||
end
|
||||
|
||||
local function register_waterlily()
|
||||
minetest.register_decoration({
|
||||
deco_type = "schematic",
|
||||
place_on = {"default:dirt"},
|
||||
sidelen = 16,
|
||||
noise_params = {
|
||||
offset = -0.12,
|
||||
scale = 0.3,
|
||||
spread = {x = 200, y = 200, z = 200},
|
||||
seed = 33,
|
||||
octaves = 3,
|
||||
persist = 0.7
|
||||
},
|
||||
biomes = {"rainforest_swamp", "savanna_swamp", "deciduous_forest_swamp"},
|
||||
y_min = 0,
|
||||
y_max = 0,
|
||||
schematic = minetest.get_modpath("flowers").."/schematics/waterlily.mts",
|
||||
rotation = "random",
|
||||
})
|
||||
end
|
||||
|
||||
function flowers.register_decorations()
|
||||
register_flower(436, "rose")
|
||||
register_flower(19822, "tulip")
|
||||
register_flower(1220999, "dandelion_yellow")
|
||||
register_flower(36662, "geranium")
|
||||
register_flower(1133, "viola")
|
||||
register_flower(73133, "dandelion_white")
|
||||
|
||||
register_mushroom("mushroom_brown")
|
||||
register_mushroom("mushroom_red")
|
||||
|
||||
register_waterlily()
|
||||
end
|
||||
|
||||
|
||||
minetest.register_decoration({
|
||||
deco_type = "simple",
|
||||
place_on = {"default:water_source"},
|
||||
sidelen = 16,
|
||||
noise_params = {
|
||||
offset = 0,
|
||||
scale = 0.006,
|
||||
spread = {x=100, y=100, z=100},
|
||||
seed = 436,
|
||||
octaves = 3,
|
||||
persist = 0.6
|
||||
},
|
||||
y_min = -10,
|
||||
y_max = 30,
|
||||
decoration = "flowers:lily_pad",
|
||||
})
|
||||
|
||||
minetest.register_decoration({
|
||||
deco_type = "simple",
|
||||
place_on = {"default:sand"},
|
||||
sidelen = 16,
|
||||
noise_params = {
|
||||
offset = 0,
|
||||
scale = 0.006,
|
||||
spread = {x=100, y=100, z=100},
|
||||
seed = 436,
|
||||
octaves = 3,
|
||||
persist = 0.6
|
||||
},
|
||||
y_min = -400,
|
||||
y_max = 400,
|
||||
decoration = "default:dry_shrub",
|
||||
})
|
||||
|
||||
minetest.register_decoration({
|
||||
deco_type = "simple",
|
||||
place_on = {"default:snow"},
|
||||
sidelen = 16,
|
||||
noise_params = {
|
||||
offset = 0,
|
||||
scale = 0.006,
|
||||
spread = {x=100, y=100, z=100},
|
||||
seed = 436,
|
||||
octaves = 3,
|
||||
persist = 0.6
|
||||
},
|
||||
y_min = -400,
|
||||
y_max = 400,
|
||||
decoration = "default:snow",
|
||||
})
|
||||
|
||||
|
||||
--
|
||||
-- Detect mapgen to select functions
|
||||
--
|
||||
|
||||
-- Mods using singlenode mapgen can call these functions to enable
|
||||
-- the use of minetest.generate_ores or minetest.generate_decorations
|
||||
|
||||
|
||||
local mg_params = minetest.get_mapgen_params() --(1) MFF IMPORTANT for mt <= 0.14.4 stable
|
||||
if mg_params.mgname == "v6" then --(1)
|
||||
--local mg_name = minetest.get_mapgen_setting("mg_name") --(2) for mt > 0.14.4 stable
|
||||
--if mg_name == "v6" then --(2)
|
||||
flowers.register_mgv6_decorations()
|
||||
elseif mg_params.mgname ~= "singlenode" then --(1)
|
||||
--elseif mg_name ~= "singlenode" then --(2)
|
||||
flowers.register_decorations()
|
||||
end
|
||||
|
BIN
mods/flowers/schematics/waterlily.mts
Executable file
BIN
mods/flowers/textures/flowers_dandelion_white.png
Normal file → Executable file
Before Width: | Height: | Size: 117 B After Width: | Height: | Size: 200 B |
BIN
mods/flowers/textures/flowers_dandelion_yellow.png
Normal file → Executable file
Before Width: | Height: | Size: 116 B After Width: | Height: | Size: 252 B |
BIN
mods/flowers/textures/flowers_geranium.png
Normal file → Executable file
Before Width: | Height: | Size: 271 B After Width: | Height: | Size: 261 B |
BIN
mods/flowers/textures/flowers_lily_pad.png
Executable file
After Width: | Height: | Size: 776 B |
BIN
mods/flowers/textures/flowers_mushroom_brown.png
Executable file
After Width: | Height: | Size: 155 B |
BIN
mods/flowers/textures/flowers_mushroom_red.png
Executable file
After Width: | Height: | Size: 167 B |
BIN
mods/flowers/textures/flowers_mushroom_spores_brown.png
Executable file
After Width: | Height: | Size: 94 B |
BIN
mods/flowers/textures/flowers_mushroom_spores_red.png
Executable file
After Width: | Height: | Size: 92 B |
BIN
mods/flowers/textures/flowers_rose.png
Normal file → Executable file
Before Width: | Height: | Size: 122 B After Width: | Height: | Size: 159 B |
BIN
mods/flowers/textures/flowers_tulip.png
Normal file → Executable file
Before Width: | Height: | Size: 123 B After Width: | Height: | Size: 246 B |
BIN
mods/flowers/textures/flowers_viola.png
Normal file → Executable file
Before Width: | Height: | Size: 111 B After Width: | Height: | Size: 178 B |
BIN
mods/flowers/textures/flowers_waterlily.png
Normal file
After Width: | Height: | Size: 343 B |
BIN
mods/flowers/textures/flowers_waterlily_bottom.png
Normal file
After Width: | Height: | Size: 327 B |