import part of the original nature mod from nature_pack

blossoms/apple spawning portion only
does not include the iron trees or tree-growing code as those are obsolete
This commit is contained in:
Vanessa Ezekowitz 2014-07-04 00:49:32 -04:00
parent f6e5eed2eb
commit 828c2008e7
6 changed files with 129 additions and 0 deletions

View File

@ -0,0 +1,67 @@
-- Blossom
local BLOSSOM_CHANCE = 15
local APPLE_CHANCE = 10
local BLOSSOM_DELAY = 3600
local BLOSSOM_NODE = "nature:blossom"
local function spawn_apple_under(pos)
local below = {
x = pos.x,
y = pos.y - 1,
z = pos.z,
}
if minetest.env:get_node(below).name == "air" then
minetest.env:add_node(below, { name = "default:apple" })
end
end
minetest.register_node(":"..BLOSSOM_NODE, {
description = "Blossom",
drawtype = "allfaces_optional",
tiles = { "default_leaves.png^nature_blossom.png" },
paramtype = "light",
groups = { snappy = 3, leafdecay = 3, flammable = 2 },
sounds = default.node_sound_leaves_defaults(),
drop = BLOSSOM_NODE,
})
minetest.register_craft({
type = "fuel",
recipe = BLOSSOM_NODE,
burntime = 2,
})
-- Blossoming
minetest.register_abm({
nodenames = { "default:leaves" },
interval = BLOSSOM_DELAY,
chance = BLOSSOM_CHANCE,
action = function(pos, node, active_object_count, active_object_count_wider)
nature:grow_node(pos, BLOSSOM_NODE)
end
})
-- Removing blossom
minetest.register_abm({
nodenames = { BLOSSOM_NODE },
interval = BLOSSOM_DELAY,
chance = BLOSSOM_CHANCE,
action = function(pos, node, active_object_count, active_object_count_wider)
nature:grow_node(pos, "default:leaves")
end
})
-- Spawning apples
minetest.register_abm({
nodenames = { BLOSSOM_NODE },
interval = BLOSSOM_DELAY,
chance = APPLE_CHANCE,
action = function(pos, node, active_object_count, active_object_count_wider)
spawn_apple_under(pos)
end
})

View File

@ -0,0 +1,6 @@
-- Set on which distance from water can the tree still grow.
-- Grows anywhere if set to -1.
DISTANCE_FROM_WATER = -1
-- Minimum light level needed to grow. Default is 8, which means daylight.
MINIMUM_GROWTH_LIGHT = 8

View File

@ -0,0 +1 @@
default

View File

@ -0,0 +1,43 @@
local NODE_YOUNG = "young"
nature = {}
local function set_young_node(pos)
local meta = minetest.env:get_meta(pos)
meta:set_string(NODE_YOUNG, "true")
minetest.after(5,
function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_string(NODE_YOUNG, "false")
end,
pos)
end
local function is_not_young(pos)
local meta = minetest.env:get_meta(pos)
local young = meta:get_string(NODE_YOUNG)
return young ~= "true"
end
function nature:grow_node(pos, nodename)
if pos ~= nil then
local light_enough = minetest.env:get_node_light(pos, nil)
>= MINIMUM_GROWTH_LIGHT
if is_not_young(pos) and light_enough then
minetest.env:remove_node(pos)
minetest.env:add_node(pos, { name = nodename })
set_young_node(pos)
minetest.log("info", nodename .. " has grown at " .. pos.x .. ","
.. pos.y .. "," .. pos.z)
end
end
end
function nature:is_near_water(pos)
return minetest.env:find_node_near(pos, DISTANCE_FROM_WATER,
{ "default:water_source" }) ~= nil or DISTANCE_FROM_WATER == -1
end

12
nature_classic/init.lua Normal file
View File

@ -0,0 +1,12 @@
-- Nature Classic mod
-- Originally by neko259
-- Nature is slowly capturing the world!
local current_mod_name = minetest.get_current_modname()
dofile(minetest.get_modpath(current_mod_name) .. "/config.lua")
dofile(minetest.get_modpath(current_mod_name) .. "/global_function.lua")
dofile(minetest.get_modpath(current_mod_name) .. "/blossom.lua")
minetest.log("info", "[Nature Classic] loaded!")

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 B