add the old jungletree mod
4
habitat/README.md
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
habitat
|
||||||
|
=======
|
||||||
|
|
||||||
|
adds function for modders to use for spawning for example plants and trees near certain nodes
|
69
habitat/init.lua
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
--Habitat is a mod which adds the function to spawn nodes near certain nodes and away from others on map generate
|
||||||
|
|
||||||
|
local function arrayContains(array, value)
|
||||||
|
for _,v in pairs(array) do
|
||||||
|
if v == value then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
--HOW TO USE
|
||||||
|
--minetest.register_on_generated(function(minp, maxp, seed)
|
||||||
|
--generate("plants:lavender_wild", {"default:dirt_with_grass"}, minp, maxp, -10, 60, 4, 4, {"default:sand",})
|
||||||
|
--end)
|
||||||
|
|
||||||
|
function generate(node, surfaces, minp, maxp, height_min, height_max, spread, habitat_size, habitat_nodes, antitat_size, antitat_nodes)
|
||||||
|
|
||||||
|
if height_min > maxp.y or height_max < minp.y then --stop if min and max height of plant spawning is not generated area
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local y_min = math.max(minp.y, height_min)
|
||||||
|
local y_max = math.min(maxp.y, height_max)
|
||||||
|
|
||||||
|
local width = maxp.x-minp.x
|
||||||
|
local length = maxp.z-minp.z
|
||||||
|
local height = height_max-height_min
|
||||||
|
|
||||||
|
local y_current
|
||||||
|
local x_current
|
||||||
|
local z_current
|
||||||
|
|
||||||
|
local x_deviation
|
||||||
|
local z_deviation
|
||||||
|
|
||||||
|
local p
|
||||||
|
local n
|
||||||
|
local p_top
|
||||||
|
local n_top
|
||||||
|
|
||||||
|
--loop and take steps depending on the spread of the plants
|
||||||
|
for x_current = spread/2, width, spread do
|
||||||
|
for z_current = spread/2, length, spread do
|
||||||
|
|
||||||
|
x_deviation = math.floor(math.random(spread))-spread/2
|
||||||
|
z_deviation = math.floor(math.random(spread))-spread/2
|
||||||
|
|
||||||
|
for y_current = height_max, height_min, -1 do --loop to look for the node that is not air
|
||||||
|
p = {x=minp.x+x_current+x_deviation, y=y_current, z=minp.z+z_current+z_deviation}
|
||||||
|
n = minetest.env:get_node(p)
|
||||||
|
p_top = {x=p.x, y=p.y+1, z=p.z}
|
||||||
|
n_top = minetest.env:get_node(p_top)
|
||||||
|
|
||||||
|
if n.name ~= "air" and n_top.name == "air" then
|
||||||
|
if arrayContains(surfaces, n.name) then
|
||||||
|
if minetest.env:find_node_near(p_top, habitat_size, habitat_nodes) ~= nil and minetest.env:find_node_near(p_top, antitat_size, antitat_nodes) == nil then
|
||||||
|
minetest.env:add_node(p_top, {name=node})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
z_current = z_current + spread
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
print("[Habitat] Loaded!")
|
1
jungletree/README.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
http://minetest.net/forum/viewtopic.php?pid=39943#p39943
|
2
jungletree/depends.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
default
|
||||||
|
habitat
|
171
jungletree/init.lua
Normal file
@ -0,0 +1,171 @@
|
|||||||
|
local leaves = {"green","yellow","red"}
|
||||||
|
|
||||||
|
minetest.register_node("jungletree:sapling", {
|
||||||
|
description = "Jungle Tree Sapling",
|
||||||
|
drawtype = "plantlike",
|
||||||
|
visual_scale = 1.0,
|
||||||
|
tiles = {"jungletree_sapling.png"},
|
||||||
|
inventory_image = "jungletree_sapling.png",
|
||||||
|
wield_image = "default_sapling.png",
|
||||||
|
paramtype = "light",
|
||||||
|
walkable = false,
|
||||||
|
groups = {snappy=2,dig_immediate=3,flammable=2},
|
||||||
|
})
|
||||||
|
|
||||||
|
--if minetest.setting_get("new_style_leaves") == true then
|
||||||
|
--leavesimg = {"jungletree_leaves_trans.png"}
|
||||||
|
--else
|
||||||
|
--leavesimg = {"jungletree_leaves.png"}
|
||||||
|
--end
|
||||||
|
|
||||||
|
for color = 1, 3 do
|
||||||
|
local leave_name = "jungletree:leaves_"..leaves[color]
|
||||||
|
minetest.register_node(leave_name, {
|
||||||
|
description = "Jungle Tree Leaves",
|
||||||
|
drawtype = "allfaces_optional",
|
||||||
|
tiles = {"jungletree_leaves_"..leaves[color]..".png"},
|
||||||
|
paramtype = "light",
|
||||||
|
groups = {snappy=3, leafdecay=3, flammable=2},
|
||||||
|
drop = {
|
||||||
|
max_items = 1,
|
||||||
|
items = {
|
||||||
|
{
|
||||||
|
-- player will get sapling with 1/20 chance
|
||||||
|
items = {'jungletree:sapling'},
|
||||||
|
rarity = 20,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
-- player will get leaves only if he get no saplings,
|
||||||
|
-- this is because max_items is 1
|
||||||
|
items = {leave_name},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
sounds = default.node_sound_leaves_defaults(),
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--[[ minetest.register_node("jungletree:tree", {
|
||||||
|
description = "Tree",
|
||||||
|
tiles = {"default_tree_top.png",
|
||||||
|
"default_tree_top.png",
|
||||||
|
"jungletree_bark.png"},
|
||||||
|
is_ground_content = true,
|
||||||
|
groups = {tree=1,snappy=1,choppy=2,oddly_breakable_by_hand=1,flammable=2},
|
||||||
|
}) --]]
|
||||||
|
|
||||||
|
minetest.register_alias("jungletree:tree", "default:jungletree")
|
||||||
|
|
||||||
|
minetest.register_node(":default:jungletree", {
|
||||||
|
description = "Jungle Tree",
|
||||||
|
tiles = {"default_jungletree_top.png", "default_jungletree_top.png", "default_jungletree.png"},
|
||||||
|
is_ground_content = true,
|
||||||
|
groups = {tree=1,snappy=1,choppy=2,oddly_breakable_by_hand=1,flammable=2},
|
||||||
|
sounds = default.node_sound_wood_defaults(),
|
||||||
|
})
|
||||||
|
|
||||||
|
local function add_tree_branch(pos)
|
||||||
|
|
||||||
|
--chooze random leave
|
||||||
|
--green leaves are more common
|
||||||
|
local chance = math.random(5)
|
||||||
|
local leave = "jungletree:leaves_"..leaves[1]
|
||||||
|
if (chance < 2) then
|
||||||
|
leave = "jungletree:leaves_"..leaves[math.random(1,3)]
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.env:add_node(pos, {name="default:jungletree"})
|
||||||
|
for i = math.floor(math.random(2)), -math.floor(math.random(2)), -1 do
|
||||||
|
for k = math.floor(math.random(2)), -math.floor(math.random(2)), -1 do
|
||||||
|
local p = {x=pos.x+i, y=pos.y, z=pos.z+k}
|
||||||
|
local n = minetest.env:get_node(p)
|
||||||
|
if (n.name=="air") then
|
||||||
|
minetest.env:add_node(p, {name=leave})
|
||||||
|
end
|
||||||
|
local chance = math.abs(i+k)
|
||||||
|
if (chance < 1) then
|
||||||
|
p = {x=pos.x+i, y=pos.y+1, z=pos.z+k}
|
||||||
|
n = minetest.env:get_node(p)
|
||||||
|
if (n.name=="air") then
|
||||||
|
minetest.env:add_node(p, {name=leave})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
minetest.register_abm({
|
||||||
|
nodenames = {"jungletree:sapling"},
|
||||||
|
interval = 1,
|
||||||
|
chance = 1,
|
||||||
|
action = function(pos, node)
|
||||||
|
local height = 5 + math.random(15)
|
||||||
|
if height < 10 then
|
||||||
|
for i = height, -1, -1 do
|
||||||
|
local p = {x=pos.x, y=pos.y+i, z=pos.z}
|
||||||
|
minetest.env:add_node(p, {name="default:jungletree"})
|
||||||
|
if i == height then
|
||||||
|
add_tree_branch({x=pos.x, y=pos.y+height+math.random(0, 1), z=pos.z})
|
||||||
|
add_tree_branch({x=pos.x+1, y=pos.y+i-math.random(2), z=pos.z})
|
||||||
|
add_tree_branch({x=pos.x-1, y=pos.y+i-math.random(2), z=pos.z})
|
||||||
|
add_tree_branch({x=pos.x, y=pos.y+i-math.random(2), z=pos.z+1})
|
||||||
|
add_tree_branch({x=pos.x, y=pos.y+i-math.random(2), z=pos.z-1})
|
||||||
|
end
|
||||||
|
if height <= 0 then
|
||||||
|
minetest.env:add_node({x=pos.x+1, y=pos.y+i-math.random(2), z=pos.z}, {name="default:jungletree"})
|
||||||
|
minetest.env:add_node({x=pos.x, y=pos.y+i-math.random(2), z=pos.z+1}, {name="default:jungletree"})
|
||||||
|
minetest.env:add_node({x=pos.x-1, y=pos.y+i-math.random(2), z=pos.z}, {name="default:jungletree"})
|
||||||
|
minetest.env:add_node({x=pos.x, y=pos.y+i-math.random(2), z=pos.z-1}, {name="default:jungletree"})
|
||||||
|
end
|
||||||
|
if (math.sin(i/height*i) < 0.2 and i > 3 and math.random(0,2) < 1.5) then
|
||||||
|
branch_pos = {x=pos.x+math.random(0,1), y=pos.y+i, z=pos.z-math.random(0,1)}
|
||||||
|
add_tree_branch(branch_pos)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
for i = height, -2, -1 do
|
||||||
|
if (math.sin(i/height*i) < 0.2 and i > 3 and math.random(0,2) < 1.5) then
|
||||||
|
branch_pos = {x=pos.x+math.random(0,1), y=pos.y+i, z=pos.z-math.random(0,1)}
|
||||||
|
add_tree_branch(branch_pos)
|
||||||
|
end
|
||||||
|
if i < math.random(0,1) then
|
||||||
|
minetest.env:add_node({x=pos.x+1, y=pos.y+i, z=pos.z+1}, {name="default:jungletree"})
|
||||||
|
minetest.env:add_node({x=pos.x+2, y=pos.y+i, z=pos.z-1}, {name="default:jungletree"})
|
||||||
|
minetest.env:add_node({x=pos.x, y=pos.y+i, z=pos.z-2}, {name="default:jungletree"})
|
||||||
|
minetest.env:add_node({x=pos.x-1, y=pos.y+i, z=pos.z}, {name="default:jungletree"})
|
||||||
|
end
|
||||||
|
if i == height then
|
||||||
|
add_tree_branch({x=pos.x+1, y=pos.y+i, z=pos.z+1})
|
||||||
|
add_tree_branch({x=pos.x+2, y=pos.y+i, z=pos.z-1})
|
||||||
|
add_tree_branch({x=pos.x, y=pos.y+i, z=pos.z-2})
|
||||||
|
add_tree_branch({x=pos.x-1, y=pos.y+i, z=pos.z})
|
||||||
|
add_tree_branch({x=pos.x+1, y=pos.y+i, z=pos.z+2})
|
||||||
|
add_tree_branch({x=pos.x+3, y=pos.y+i, z=pos.z-1})
|
||||||
|
add_tree_branch({x=pos.x, y=pos.y+i, z=pos.z-3})
|
||||||
|
add_tree_branch({x=pos.x-2, y=pos.y+i, z=pos.z})
|
||||||
|
add_tree_branch({x=pos.x+1, y=pos.y+i, z=pos.z})
|
||||||
|
add_tree_branch({x=pos.x+1, y=pos.y+i, z=pos.z-1})
|
||||||
|
add_tree_branch({x=pos.x, y=pos.y+i, z=pos.z-1})
|
||||||
|
add_tree_branch({x=pos.x, y=pos.y+i, z=pos.z})
|
||||||
|
else
|
||||||
|
minetest.env:add_node({x=pos.x+1, y=pos.y+i, z=pos.z}, {name="default:jungletree"})
|
||||||
|
minetest.env:add_node({x=pos.x+1, y=pos.y+i, z=pos.z-1}, {name="default:jungletree"})
|
||||||
|
minetest.env:add_node({x=pos.x, y=pos.y+i, z=pos.z-1}, {name="default:jungletree"})
|
||||||
|
minetest.env:add_node({x=pos.x, y=pos.y+i, z=pos.z}, {name="default:jungletree"})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end,})
|
||||||
|
|
||||||
|
minetest.register_craft({
|
||||||
|
output = 'default:wood 4',
|
||||||
|
recipe = {
|
||||||
|
{'default:jungletree'},
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
--old mod compatible
|
||||||
|
minetest.register_alias("jungletree:leaves", "jungletree:leaves_green")
|
||||||
|
|
||||||
|
print("[Jungletree] Loaded!")
|
BIN
jungletree/textures/Thumbs.db
Normal file
BIN
jungletree/textures/jungletree_bark.png
Normal file
After Width: | Height: | Size: 705 B |
BIN
jungletree/textures/jungletree_leaves_green.png
Normal file
After Width: | Height: | Size: 456 B |
BIN
jungletree/textures/jungletree_leaves_red.png
Normal file
After Width: | Height: | Size: 469 B |
BIN
jungletree/textures/jungletree_leaves_yellow.png
Normal file
After Width: | Height: | Size: 467 B |
BIN
jungletree/textures/jungletree_sapling.png
Normal file
After Width: | Height: | Size: 215 B |
0
modpack.txt
Normal file
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 145 B After Width: | Height: | Size: 145 B |
Before Width: | Height: | Size: 306 B After Width: | Height: | Size: 306 B |
Before Width: | Height: | Size: 368 B After Width: | Height: | Size: 368 B |
Before Width: | Height: | Size: 416 B After Width: | Height: | Size: 416 B |
Before Width: | Height: | Size: 472 B After Width: | Height: | Size: 472 B |
Before Width: | Height: | Size: 777 B After Width: | Height: | Size: 777 B |
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 72 KiB |
Before Width: | Height: | Size: 55 KiB After Width: | Height: | Size: 55 KiB |
Before Width: | Height: | Size: 348 B After Width: | Height: | Size: 348 B |
Before Width: | Height: | Size: 292 B After Width: | Height: | Size: 292 B |
Before Width: | Height: | Size: 286 B After Width: | Height: | Size: 286 B |
Before Width: | Height: | Size: 235 B After Width: | Height: | Size: 235 B |
Before Width: | Height: | Size: 698 B After Width: | Height: | Size: 698 B |
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 5.2 KiB |
Before Width: | Height: | Size: 581 B After Width: | Height: | Size: 581 B |
Before Width: | Height: | Size: 226 B After Width: | Height: | Size: 226 B |
Before Width: | Height: | Size: 240 B After Width: | Height: | Size: 240 B |
Before Width: | Height: | Size: 251 B After Width: | Height: | Size: 251 B |
Before Width: | Height: | Size: 336 B After Width: | Height: | Size: 336 B |
Before Width: | Height: | Size: 181 B After Width: | Height: | Size: 181 B |
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 5.5 KiB |