2015-06-29 17:55:56 +00:00
|
|
|
--
|
|
|
|
-- Lavacooling
|
|
|
|
--
|
|
|
|
|
2017-01-31 22:32:56 +00:00
|
|
|
mcl_core.cool_lava_source = function(pos)
|
|
|
|
minetest.set_node(pos, {name="mcl_core:obsidian"})
|
2015-06-29 17:55:56 +00:00
|
|
|
end
|
|
|
|
|
2017-01-31 22:32:56 +00:00
|
|
|
mcl_core.cool_lava_flowing = function(pos)
|
|
|
|
minetest.set_node(pos, {name="mcl_core:stone"})
|
2015-06-29 17:55:56 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
minetest.register_abm({
|
2017-01-31 22:32:56 +00:00
|
|
|
nodenames = {"mcl_core:lava_flowing"},
|
2015-06-29 17:55:56 +00:00
|
|
|
neighbors = {"group:water"},
|
|
|
|
interval = 1,
|
|
|
|
chance = 1,
|
|
|
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
2017-01-31 22:32:56 +00:00
|
|
|
mcl_core.cool_lava_flowing(pos, node, active_object_count, active_object_count_wider)
|
2015-06-29 17:55:56 +00:00
|
|
|
end,
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_abm({
|
2017-01-31 22:32:56 +00:00
|
|
|
nodenames = {"mcl_core:lava_source"},
|
2015-06-29 17:55:56 +00:00
|
|
|
neighbors = {"group:water"},
|
|
|
|
interval = 1,
|
|
|
|
chance = 1,
|
|
|
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
2017-01-31 22:32:56 +00:00
|
|
|
mcl_core.cool_lava_source(pos, node, active_object_count, active_object_count_wider)
|
2015-06-29 17:55:56 +00:00
|
|
|
end,
|
|
|
|
})
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Papyrus and cactus growing
|
|
|
|
--
|
|
|
|
|
|
|
|
-- Functions
|
2017-02-11 18:03:26 +00:00
|
|
|
mcl_core.grow_cactus = function(pos, node)
|
2015-06-29 17:55:56 +00:00
|
|
|
pos.y = pos.y-1
|
2015-07-04 02:56:02 +00:00
|
|
|
local name = minetest.get_node(pos).name
|
2015-06-29 17:55:56 +00:00
|
|
|
if minetest.get_item_group(name, "sand") ~= 0 then
|
|
|
|
pos.y = pos.y+1
|
|
|
|
local height = 0
|
2017-01-31 22:32:56 +00:00
|
|
|
while minetest.get_node(pos).name == "mcl_core:cactus" and height < 4 do
|
2015-06-29 17:55:56 +00:00
|
|
|
height = height+1
|
|
|
|
pos.y = pos.y+1
|
|
|
|
end
|
2017-01-12 06:13:58 +00:00
|
|
|
if height < 3 then
|
2015-07-04 02:56:02 +00:00
|
|
|
if minetest.get_node(pos).name == "air" then
|
2017-01-31 22:32:56 +00:00
|
|
|
minetest.set_node(pos, {name="mcl_core:cactus"})
|
2015-06-29 17:55:56 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-02-11 18:03:26 +00:00
|
|
|
mcl_core.grow_reeds = function(pos, node)
|
2015-06-29 17:55:56 +00:00
|
|
|
pos.y = pos.y-1
|
2015-07-04 02:56:02 +00:00
|
|
|
local name = minetest.get_node(pos).name
|
2017-01-12 05:54:16 +00:00
|
|
|
if minetest.get_node_group(name, "soil_sugarcane") ~= 0 then
|
2017-02-18 01:23:27 +00:00
|
|
|
if minetest.find_node_near(pos, 1, {"group:water"}) == nil and minetest.find_node_near(pos, 1, {"group:frosted_ice"}) == nil then
|
2015-06-29 17:55:56 +00:00
|
|
|
return
|
|
|
|
end
|
|
|
|
pos.y = pos.y+1
|
|
|
|
local height = 0
|
2017-01-31 22:32:56 +00:00
|
|
|
while minetest.get_node(pos).name == "mcl_core:reeds" and height < 3 do
|
2015-06-29 17:55:56 +00:00
|
|
|
height = height+1
|
|
|
|
pos.y = pos.y+1
|
|
|
|
end
|
|
|
|
if height < 3 then
|
2015-07-04 02:56:02 +00:00
|
|
|
if minetest.get_node(pos).name == "air" then
|
2017-01-31 22:32:56 +00:00
|
|
|
minetest.set_node(pos, {name="mcl_core:reeds"})
|
2015-06-29 17:55:56 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
-- ABMs
|
2015-07-01 05:56:51 +00:00
|
|
|
|
2017-01-07 23:22:10 +00:00
|
|
|
|
|
|
|
local function drop_attached_node(p)
|
|
|
|
local nn = minetest.get_node(p).name
|
|
|
|
minetest.remove_node(p)
|
|
|
|
for _, item in pairs(minetest.get_node_drops(nn, "")) do
|
|
|
|
local pos = {
|
|
|
|
x = p.x + math.random()/2 - 0.25,
|
|
|
|
y = p.y + math.random()/2 - 0.25,
|
|
|
|
z = p.z + math.random()/2 - 0.25,
|
|
|
|
}
|
|
|
|
minetest.add_item(pos, item)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Remove attached nodes next to flowing water
|
2015-07-01 05:37:51 +00:00
|
|
|
minetest.register_abm({
|
|
|
|
nodenames = {"group:dig_by_water"},
|
|
|
|
neighbors = {"group:water"},
|
|
|
|
interval = 1,
|
|
|
|
chance = 1,
|
2015-07-01 05:56:51 +00:00
|
|
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
|
|
|
for xp=-1,1 do
|
|
|
|
for zp=-1,1 do
|
|
|
|
local p = {x=pos.x+xp, y=pos.y, z=pos.z+zp}
|
2015-07-04 02:56:02 +00:00
|
|
|
local n = minetest.get_node(p)
|
2017-02-16 21:07:54 +00:00
|
|
|
local d = minetest.registered_nodes[n.name]
|
|
|
|
if (d.groups.water and d.liquidtype == "flowing") then
|
2017-01-07 23:22:10 +00:00
|
|
|
drop_attached_node(pos)
|
|
|
|
minetest.dig_node(pos)
|
|
|
|
break
|
2017-01-06 01:35:45 +00:00
|
|
|
end
|
2015-07-01 05:37:51 +00:00
|
|
|
end
|
|
|
|
end
|
2015-07-01 05:56:51 +00:00
|
|
|
for yp=-1,1 do
|
|
|
|
local p = {x=pos.x, y=pos.y+yp, z=pos.z}
|
2015-07-04 02:56:02 +00:00
|
|
|
local n = minetest.get_node(p)
|
2017-02-16 21:07:54 +00:00
|
|
|
local d = minetest.registered_nodes[n.name]
|
|
|
|
if (d.groups.water and d.liquidtype == "flowing") then
|
2017-01-06 01:35:45 +00:00
|
|
|
drop_attached_node(pos)
|
|
|
|
minetest.dig_node(pos)
|
|
|
|
break
|
|
|
|
end
|
2015-07-01 05:56:51 +00:00
|
|
|
end
|
|
|
|
|
2015-07-01 05:37:51 +00:00
|
|
|
end,
|
|
|
|
})
|
|
|
|
|
2015-06-29 17:55:56 +00:00
|
|
|
minetest.register_abm({
|
2017-01-31 22:32:56 +00:00
|
|
|
nodenames = {"mcl_core:cactus"},
|
2015-06-29 17:55:56 +00:00
|
|
|
neighbors = {"group:sand"},
|
|
|
|
interval = 25,
|
|
|
|
chance = 10,
|
|
|
|
action = function(pos)
|
2017-02-11 18:03:26 +00:00
|
|
|
mcl_core.grow_cactus(pos)
|
2015-06-29 17:55:56 +00:00
|
|
|
end,
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_abm({
|
2017-01-31 22:32:56 +00:00
|
|
|
nodenames = {"mcl_core:reeds"},
|
2017-02-17 22:39:23 +00:00
|
|
|
neighbors = {"group:soil_sugarcane"},
|
2015-06-29 17:55:56 +00:00
|
|
|
interval = 25,
|
|
|
|
chance = 10,
|
|
|
|
action = function(pos)
|
2017-02-11 18:03:26 +00:00
|
|
|
mcl_core.grow_reeds(pos)
|
2015-06-29 17:55:56 +00:00
|
|
|
end,
|
|
|
|
})
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Papyrus and cactus drop
|
|
|
|
--
|
|
|
|
|
2017-01-31 22:32:56 +00:00
|
|
|
local timber_nodenames={"mcl_core:reeds", "mcl_core:cactus"}
|
2015-06-29 17:55:56 +00:00
|
|
|
|
|
|
|
minetest.register_on_dignode(function(pos, node)
|
|
|
|
local i=1
|
|
|
|
while timber_nodenames[i]~=nil do
|
|
|
|
if node.name==timber_nodenames[i] then
|
2017-01-27 12:45:21 +00:00
|
|
|
local np={x=pos.x, y=pos.y+1, z=pos.z}
|
2015-07-04 02:56:02 +00:00
|
|
|
while minetest.get_node(np).name==timber_nodenames[i] do
|
|
|
|
minetest.remove_node(np)
|
2017-02-18 20:51:50 +00:00
|
|
|
if not minetest.setting_getbool("creative_mode") then
|
|
|
|
minetest.add_item(np, timber_nodenames[i])
|
|
|
|
end
|
2015-06-29 17:55:56 +00:00
|
|
|
np={x=np.x, y=np.y+1, z=np.z}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
i=i+1
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
2017-01-27 12:45:21 +00:00
|
|
|
local function air_leave()
|
2015-06-29 17:55:56 +00:00
|
|
|
if math.random(0, 50) == 3 then
|
|
|
|
return {name = "air"}
|
|
|
|
else
|
2017-01-31 22:32:56 +00:00
|
|
|
return {name = "mcl_core:leaves"}
|
2015-06-29 17:55:56 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-02-11 18:03:26 +00:00
|
|
|
function mcl_core.generate_tree(pos, trunk, leaves, typearbre)
|
2015-06-29 17:55:56 +00:00
|
|
|
pos.y = pos.y-1
|
2015-07-04 02:56:02 +00:00
|
|
|
local nodename = minetest.get_node(pos).name
|
2015-06-29 17:55:56 +00:00
|
|
|
|
|
|
|
pos.y = pos.y+1
|
2015-07-04 02:56:02 +00:00
|
|
|
if not minetest.get_node_light(pos) then
|
2015-06-29 17:55:56 +00:00
|
|
|
return
|
|
|
|
end
|
2017-01-27 12:45:21 +00:00
|
|
|
local node
|
2015-06-29 17:55:56 +00:00
|
|
|
if typearbre == nil or typearbre == 1 then
|
|
|
|
node = {name = ""}
|
|
|
|
for dy=1,4 do
|
|
|
|
pos.y = pos.y+dy
|
2015-07-04 02:56:02 +00:00
|
|
|
if minetest.get_node(pos).name ~= "air" then
|
2015-06-29 17:55:56 +00:00
|
|
|
return
|
|
|
|
end
|
|
|
|
pos.y = pos.y-dy
|
|
|
|
end
|
|
|
|
node = {name = trunk}
|
|
|
|
for dy=0,4 do
|
|
|
|
pos.y = pos.y+dy
|
2015-07-04 02:56:02 +00:00
|
|
|
if minetest.get_node(pos).name == "air" then
|
|
|
|
minetest.add_node(pos, node)
|
2015-06-29 17:55:56 +00:00
|
|
|
end
|
|
|
|
pos.y = pos.y-dy
|
|
|
|
end
|
|
|
|
|
|
|
|
node = {name = leaves}
|
|
|
|
pos.y = pos.y+3
|
|
|
|
local rarity = 0
|
|
|
|
if math.random(0, 10) == 3 then
|
|
|
|
rarity = 1
|
|
|
|
end
|
|
|
|
for dx=-2,2 do
|
|
|
|
for dz=-2,2 do
|
|
|
|
for dy=0,3 do
|
|
|
|
pos.x = pos.x+dx
|
|
|
|
pos.y = pos.y+dy
|
|
|
|
pos.z = pos.z+dz
|
|
|
|
|
|
|
|
if dx == 0 and dz == 0 and dy==3 then
|
2015-07-04 02:56:02 +00:00
|
|
|
if minetest.get_node(pos).name == "air" and math.random(1, 5) <= 4 then
|
|
|
|
minetest.add_node(pos, node)
|
2017-02-17 02:46:12 +00:00
|
|
|
minetest.add_node(pos, air_leave())
|
2015-06-29 17:55:56 +00:00
|
|
|
end
|
|
|
|
elseif dx == 0 and dz == 0 and dy==4 then
|
2015-07-04 02:56:02 +00:00
|
|
|
if minetest.get_node(pos).name == "air" and math.random(1, 5) <= 4 then
|
|
|
|
minetest.add_node(pos, node)
|
2017-02-17 02:46:12 +00:00
|
|
|
minetest.add_node(pos, air_leave())
|
2015-06-29 17:55:56 +00:00
|
|
|
end
|
|
|
|
elseif math.abs(dx) ~= 2 and math.abs(dz) ~= 2 then
|
2015-07-04 02:56:02 +00:00
|
|
|
if minetest.get_node(pos).name == "air" then
|
|
|
|
minetest.add_node(pos, node)
|
2017-02-17 02:46:12 +00:00
|
|
|
minetest.add_node(pos, air_leave())
|
2015-06-29 17:55:56 +00:00
|
|
|
end
|
|
|
|
else
|
|
|
|
if math.abs(dx) ~= 2 or math.abs(dz) ~= 2 then
|
2015-07-04 02:56:02 +00:00
|
|
|
if minetest.get_node(pos).name == "air" and math.random(1, 5) <= 4 then
|
|
|
|
minetest.add_node(pos, node)
|
|
|
|
minetest.add_node(pos, air_leave())
|
2015-06-29 17:55:56 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
pos.x = pos.x-dx
|
|
|
|
pos.y = pos.y-dy
|
|
|
|
pos.z = pos.z-dz
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
elseif typearbre == 2 then
|
|
|
|
node = {name = ""}
|
|
|
|
|
|
|
|
-- can place big tree ?
|
|
|
|
local tree_size = math.random(15, 25)
|
|
|
|
for dy=1,4 do
|
|
|
|
pos.y = pos.y+dy
|
2015-07-04 02:56:02 +00:00
|
|
|
if minetest.get_node(pos).name ~= "air" then
|
2015-06-29 17:55:56 +00:00
|
|
|
return
|
|
|
|
end
|
|
|
|
pos.y = pos.y-dy
|
|
|
|
end
|
|
|
|
|
|
|
|
--Cheak for placing big tree
|
|
|
|
pos.y = pos.y-1
|
|
|
|
for dz=0,1 do
|
|
|
|
pos.z = pos.z + dz
|
|
|
|
--> 0
|
2017-01-31 22:32:56 +00:00
|
|
|
if minetest.get_node(pos).name == "mcl_core:dirt_with_grass"
|
|
|
|
or minetest.get_node(pos).name == "mcl_core:dirt" then else
|
2015-06-29 17:55:56 +00:00
|
|
|
return
|
|
|
|
end
|
|
|
|
pos.x = pos.x+1
|
|
|
|
--> 1
|
2017-01-31 22:32:56 +00:00
|
|
|
if minetest.get_node(pos).name == "mcl_core:dirt_with_grass"
|
|
|
|
or minetest.get_node(pos).name == "mcl_core:dirt" then else
|
2015-06-29 17:55:56 +00:00
|
|
|
return
|
|
|
|
end
|
|
|
|
pos.x = pos.x-1
|
|
|
|
pos.z = pos.z - dz
|
|
|
|
end
|
|
|
|
pos.y = pos.y+1
|
|
|
|
|
|
|
|
|
|
|
|
-- Make tree with vine
|
|
|
|
node = {name = trunk}
|
|
|
|
for dy=0,tree_size do
|
|
|
|
pos.y = pos.y+dy
|
|
|
|
|
|
|
|
for dz=-1,2 do
|
|
|
|
if dz == -1 then
|
|
|
|
pos.z = pos.z + dz
|
2015-07-04 02:56:02 +00:00
|
|
|
if math.random(1, 3) == 1 and minetest.get_node(pos).name == "air" then
|
2017-01-31 22:32:56 +00:00
|
|
|
minetest.add_node(pos, {name = "mcl_core:vine", param2 = 4})
|
2015-06-29 17:55:56 +00:00
|
|
|
end
|
|
|
|
pos.x = pos.x+1
|
2015-07-04 02:56:02 +00:00
|
|
|
if math.random(1, 3) == 1 and minetest.get_node(pos).name == "air" then
|
2017-01-31 22:32:56 +00:00
|
|
|
minetest.add_node(pos, {name = "mcl_core:vine", param2 = 4})
|
2015-06-29 17:55:56 +00:00
|
|
|
end
|
|
|
|
pos.x = pos.x-1
|
|
|
|
pos.z = pos.z - dz
|
|
|
|
elseif dz == 2 then
|
|
|
|
pos.z = pos.z + dz
|
2015-07-04 02:56:02 +00:00
|
|
|
if math.random(1, 3) == 1 and minetest.get_node(pos).name == "air"then
|
2017-01-31 22:32:56 +00:00
|
|
|
minetest.add_node(pos, {name = "mcl_core:vine", param2 = 5})
|
2015-06-29 17:55:56 +00:00
|
|
|
end
|
|
|
|
pos.x = pos.x+1
|
2015-07-04 02:56:02 +00:00
|
|
|
if math.random(1, 3) == 1 and minetest.get_node(pos).name == "air" then
|
2017-01-31 22:32:56 +00:00
|
|
|
minetest.add_node(pos, {name = "mcl_core:vine", param2 = 5})
|
2015-06-29 17:55:56 +00:00
|
|
|
end
|
|
|
|
pos.x = pos.x-1
|
|
|
|
pos.z = pos.z - dz
|
|
|
|
else
|
|
|
|
pos.z = pos.z + dz
|
|
|
|
pos.x = pos.x-1
|
2015-07-04 02:56:02 +00:00
|
|
|
if math.random(1, 3) == 1 and minetest.get_node(pos).name == "air" then
|
2017-01-31 22:32:56 +00:00
|
|
|
minetest.add_node(pos, {name = "mcl_core:vine", param2 = 2})
|
2015-06-29 17:55:56 +00:00
|
|
|
end
|
|
|
|
pos.x = pos.x+1
|
2015-07-04 02:56:02 +00:00
|
|
|
if minetest.get_node(pos).name == "air" then
|
|
|
|
minetest.add_node(pos, {name = trunk, param2=2})
|
2015-06-29 17:55:56 +00:00
|
|
|
end
|
|
|
|
pos.x = pos.x+1
|
2015-07-04 02:56:02 +00:00
|
|
|
if minetest.get_node(pos).name == "air" then
|
|
|
|
minetest.add_node(pos, {name = trunk, param2=2})
|
2015-06-29 17:55:56 +00:00
|
|
|
end
|
|
|
|
pos.x = pos.x+1
|
2015-07-04 02:56:02 +00:00
|
|
|
if math.random(1, 3) == 1 and minetest.get_node(pos).name == "air" then
|
2017-01-31 22:32:56 +00:00
|
|
|
minetest.add_node(pos, {name = "mcl_core:vine", param2 = 3})
|
2015-06-29 17:55:56 +00:00
|
|
|
end
|
|
|
|
pos.x = pos.x-2
|
|
|
|
pos.z = pos.z - dz
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
pos.y = pos.y-dy
|
|
|
|
end
|
|
|
|
|
|
|
|
-- make leaves
|
|
|
|
node = {name = leaves}
|
|
|
|
pos.y = pos.y+tree_size-4
|
|
|
|
for dx=-5,5 do
|
|
|
|
for dz=-5,5 do
|
|
|
|
for dy=0,3 do
|
|
|
|
pos.x = pos.x+dx
|
|
|
|
pos.y = pos.y+dy
|
|
|
|
pos.z = pos.z+dz
|
|
|
|
|
|
|
|
if dx == 0 and dz == 0 and dy==3 then
|
2017-01-31 22:32:56 +00:00
|
|
|
if minetest.get_node(pos).name == "air" or minetest.get_node(pos).name == "mcl_core:vine" and math.random(1, 2) == 1 then
|
2015-07-04 02:56:02 +00:00
|
|
|
minetest.add_node(pos, node)
|
2015-06-29 17:55:56 +00:00
|
|
|
end
|
|
|
|
elseif dx == 0 and dz == 0 and dy==4 then
|
2017-01-31 22:32:56 +00:00
|
|
|
if minetest.get_node(pos).name == "air" or minetest.get_node(pos).name == "mcl_core:vine" and math.random(1, 5) == 1 then
|
2015-07-04 02:56:02 +00:00
|
|
|
minetest.add_node(pos, node)
|
|
|
|
minetest.add_node(pos, air_leave())
|
2015-06-29 17:55:56 +00:00
|
|
|
end
|
|
|
|
elseif math.abs(dx) ~= 2 and math.abs(dz) ~= 2 then
|
2017-01-31 22:32:56 +00:00
|
|
|
if minetest.get_node(pos).name == "air" or minetest.get_node(pos).name == "mcl_core:vine" then
|
2015-07-04 02:56:02 +00:00
|
|
|
minetest.add_node(pos, node)
|
2015-06-29 17:55:56 +00:00
|
|
|
end
|
|
|
|
else
|
|
|
|
if math.abs(dx) ~= 2 or math.abs(dz) ~= 2 then
|
2017-01-31 22:32:56 +00:00
|
|
|
if minetest.get_node(pos).name == "air" or minetest.get_node(pos).name == "mcl_core:vine" and math.random(1, 3) == 1 then
|
2015-07-04 02:56:02 +00:00
|
|
|
minetest.add_node(pos, node)
|
2015-06-29 17:55:56 +00:00
|
|
|
end
|
|
|
|
else
|
2015-07-04 02:56:02 +00:00
|
|
|
if math.random(1, 5) == 1 and minetest.get_node(pos).name == "air" then
|
|
|
|
minetest.add_node(pos, node)
|
2015-06-29 17:55:56 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
pos.x = pos.x-dx
|
|
|
|
pos.y = pos.y-dy
|
|
|
|
pos.z = pos.z-dz
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
------------------------------
|
|
|
|
-- Try generate grass dirt ---
|
|
|
|
------------------------------
|
|
|
|
-- turn dirt to dirt with grass
|
|
|
|
minetest.register_abm({
|
2017-01-31 22:32:56 +00:00
|
|
|
nodenames = {"mcl_core:dirt"},
|
2015-06-29 17:55:56 +00:00
|
|
|
neighbors = {"air"},
|
|
|
|
interval = 30,
|
|
|
|
chance = 20,
|
|
|
|
action = function(pos)
|
2015-07-03 04:57:09 +00:00
|
|
|
if pos == nil then
|
|
|
|
return
|
|
|
|
end
|
2015-06-29 17:55:56 +00:00
|
|
|
local can_change = 0
|
|
|
|
for i=1,4 do
|
2015-07-03 04:57:09 +00:00
|
|
|
local p = {x=pos.x, y=pos.y+i, z=pos.z}
|
2015-07-04 02:56:02 +00:00
|
|
|
local n = minetest.get_node(p)
|
2015-06-29 17:55:56 +00:00
|
|
|
-- On verifie si il y a de l'air
|
|
|
|
if (n.name=="air") then
|
|
|
|
can_change = can_change + 1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if can_change > 3 then
|
|
|
|
local light = minetest.get_node_light(pos)
|
|
|
|
if light or light > 10 then
|
2017-01-31 22:32:56 +00:00
|
|
|
minetest.add_node(pos, {name="mcl_core:dirt_with_grass"})
|
2015-06-29 17:55:56 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--------------------------
|
|
|
|
-- Try generate tree ---
|
|
|
|
--------------------------
|
2017-01-09 03:44:07 +00:00
|
|
|
-- TODO: Acacia, dark oak, spruce, birch
|
|
|
|
|
2015-06-29 17:55:56 +00:00
|
|
|
-- Normal tree
|
|
|
|
minetest.register_abm({
|
2017-01-31 22:32:56 +00:00
|
|
|
nodenames = {"mcl_core:sapling"},
|
2017-01-12 06:07:30 +00:00
|
|
|
neighbors = {"group:soil_sapling"},
|
2015-06-29 17:55:56 +00:00
|
|
|
interval = 30,
|
|
|
|
chance = 15,
|
|
|
|
action = function(pos)
|
|
|
|
local light = minetest.get_node_light(pos)
|
2017-01-12 06:07:30 +00:00
|
|
|
local soilnode = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z})
|
2017-01-12 20:01:01 +00:00
|
|
|
local soiltype = minetest.get_item_group(soilnode.name, "soil_sapling")
|
2017-01-12 06:07:30 +00:00
|
|
|
if soiltype >= 1 and light and light >= 9 then
|
|
|
|
minetest.add_node(pos, {name="air"})
|
2017-02-11 18:03:26 +00:00
|
|
|
mcl_core.generate_tree(pos, "mcl_core:tree", "mcl_core:leaves", 1)
|
2015-06-29 17:55:56 +00:00
|
|
|
end
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
|
|
|
|
-- Jungle Tree
|
|
|
|
minetest.register_abm({
|
2017-01-31 22:32:56 +00:00
|
|
|
nodenames = {"mcl_core:junglesapling"},
|
2017-01-12 06:07:30 +00:00
|
|
|
neighbors = {"group:soil_sapling"},
|
2015-06-29 17:55:56 +00:00
|
|
|
interval = 30,
|
|
|
|
chance = 15,
|
|
|
|
action = function(pos)
|
|
|
|
local light = minetest.get_node_light(pos)
|
2017-01-12 06:07:30 +00:00
|
|
|
local soilnode = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z})
|
2017-01-12 20:01:01 +00:00
|
|
|
local soiltype = minetest.get_item_group(soilnode.name, "soil_sapling")
|
2017-01-12 06:07:30 +00:00
|
|
|
if soiltype == 2 and light and light >= 9 then
|
2015-07-04 02:56:02 +00:00
|
|
|
minetest.add_node(pos, {name="air"})
|
2017-02-11 18:03:26 +00:00
|
|
|
mcl_core.generate_tree(pos, "mcl_core:jungletree", "mcl_core:jungleleaves", 2)
|
2015-06-29 17:55:56 +00:00
|
|
|
end
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
|
|
|
|
---------------------
|
|
|
|
-- Vine generating --
|
|
|
|
---------------------
|
|
|
|
minetest.register_abm({
|
2017-01-31 22:32:56 +00:00
|
|
|
nodenames = {"mcl_core:vine"},
|
2015-06-29 17:55:56 +00:00
|
|
|
interval = 80,
|
|
|
|
chance = 5,
|
|
|
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
|
|
|
local newpos = {x=pos.x, y=pos.y-1, z=pos.z}
|
2015-07-04 02:56:02 +00:00
|
|
|
local n = minetest.get_node(newpos)
|
2015-06-29 17:55:56 +00:00
|
|
|
if n.name == "air" then
|
2017-01-27 12:45:21 +00:00
|
|
|
local walldir = node.param2
|
2017-01-31 22:32:56 +00:00
|
|
|
minetest.add_node(newpos, {name = "mcl_core:vine", param2 = walldir})
|
2015-06-29 17:55:56 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Leaf Decay
|
|
|
|
|
|
|
|
-- To enable leaf decay for a node, add it to the "leafdecay" group.
|
|
|
|
--
|
|
|
|
-- The rating of the group determines how far from a node in the group "tree"
|
|
|
|
-- the node can be without decaying.
|
|
|
|
--
|
|
|
|
-- If param2 of the node is ~= 0, the node will always be preserved. Thus, if
|
|
|
|
-- the player places a node of that kind, you will want to set param2=1 or so.
|
|
|
|
--
|
|
|
|
-- If the node is in the leafdecay_drop group then the it will always be dropped
|
|
|
|
-- as an item
|
|
|
|
|
2017-01-31 22:32:56 +00:00
|
|
|
mcl_core.leafdecay_trunk_cache = {}
|
|
|
|
mcl_core.leafdecay_enable_cache = true
|
2015-06-29 17:55:56 +00:00
|
|
|
-- Spread the load of finding trunks
|
2017-01-31 22:32:56 +00:00
|
|
|
mcl_core.leafdecay_trunk_find_allow_accumulator = 0
|
2015-06-29 17:55:56 +00:00
|
|
|
|
|
|
|
minetest.register_globalstep(function(dtime)
|
|
|
|
local finds_per_second = 5000
|
2017-01-31 22:32:56 +00:00
|
|
|
mcl_core.leafdecay_trunk_find_allow_accumulator =
|
2015-06-29 17:55:56 +00:00
|
|
|
math.floor(dtime * finds_per_second)
|
|
|
|
end)
|
|
|
|
|
|
|
|
minetest.register_abm({
|
|
|
|
nodenames = {"group:leafdecay"},
|
|
|
|
neighbors = {"air", "group:liquid"},
|
|
|
|
-- A low interval and a high inverse chance spreads the load
|
|
|
|
interval = 2,
|
|
|
|
chance = 5,
|
|
|
|
|
|
|
|
action = function(p0, node, _, _)
|
|
|
|
--print("leafdecay ABM at "..p0.x..", "..p0.y..", "..p0.z..")")
|
|
|
|
local do_preserve = false
|
|
|
|
local d = minetest.registered_nodes[node.name].groups.leafdecay
|
|
|
|
if not d or d == 0 then
|
|
|
|
--print("not groups.leafdecay")
|
|
|
|
return
|
|
|
|
end
|
|
|
|
local n0 = minetest.get_node(p0)
|
|
|
|
if n0.param2 ~= 0 then
|
|
|
|
--print("param2 ~= 0")
|
|
|
|
return
|
|
|
|
end
|
|
|
|
local p0_hash = nil
|
2017-01-31 22:32:56 +00:00
|
|
|
if mcl_core.leafdecay_enable_cache then
|
2015-06-29 17:55:56 +00:00
|
|
|
p0_hash = minetest.hash_node_position(p0)
|
2017-01-31 22:32:56 +00:00
|
|
|
local trunkp = mcl_core.leafdecay_trunk_cache[p0_hash]
|
2015-06-29 17:55:56 +00:00
|
|
|
if trunkp then
|
|
|
|
local n = minetest.get_node(trunkp)
|
|
|
|
local reg = minetest.registered_nodes[n.name]
|
|
|
|
-- Assume ignore is a trunk, to make the thing work at the border of the active area
|
|
|
|
if n.name == "ignore" or (reg and reg.groups.tree and reg.groups.tree ~= 0) then
|
|
|
|
--print("cached trunk still exists")
|
|
|
|
return
|
|
|
|
end
|
|
|
|
--print("cached trunk is invalid")
|
|
|
|
-- Cache is invalid
|
2017-01-31 22:32:56 +00:00
|
|
|
table.remove(mcl_core.leafdecay_trunk_cache, p0_hash)
|
2015-06-29 17:55:56 +00:00
|
|
|
end
|
|
|
|
end
|
2017-01-31 22:32:56 +00:00
|
|
|
if mcl_core.leafdecay_trunk_find_allow_accumulator <= 0 then
|
2015-06-29 17:55:56 +00:00
|
|
|
return
|
|
|
|
end
|
2017-01-31 22:32:56 +00:00
|
|
|
mcl_core.leafdecay_trunk_find_allow_accumulator =
|
|
|
|
mcl_core.leafdecay_trunk_find_allow_accumulator - 1
|
2015-06-29 17:55:56 +00:00
|
|
|
-- Assume ignore is a trunk, to make the thing work at the border of the active area
|
|
|
|
local p1 = minetest.find_node_near(p0, d, {"ignore", "group:tree"})
|
|
|
|
if p1 then
|
|
|
|
do_preserve = true
|
2017-01-31 22:32:56 +00:00
|
|
|
if mcl_core.leafdecay_enable_cache then
|
2015-06-29 17:55:56 +00:00
|
|
|
--print("caching trunk")
|
|
|
|
-- Cache the trunk
|
2017-01-31 22:32:56 +00:00
|
|
|
mcl_core.leafdecay_trunk_cache[p0_hash] = p1
|
2015-06-29 17:55:56 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
if not do_preserve then
|
|
|
|
-- Drop stuff other than the node itself
|
2015-07-04 02:56:02 +00:00
|
|
|
local itemstacks = minetest.get_node_drops(n0.name)
|
2015-06-29 17:55:56 +00:00
|
|
|
for _, itemname in ipairs(itemstacks) do
|
|
|
|
if minetest.get_item_group(n0.name, "leafdecay_drop") ~= 0 or
|
|
|
|
itemname ~= n0.name then
|
|
|
|
local p_drop = {
|
|
|
|
x = p0.x - 0.5 + math.random(),
|
|
|
|
y = p0.y - 0.5 + math.random(),
|
|
|
|
z = p0.z - 0.5 + math.random(),
|
|
|
|
}
|
|
|
|
minetest.add_item(p_drop, itemname)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
-- Remove node
|
|
|
|
minetest.remove_node(p0)
|
2017-01-26 18:14:07 +00:00
|
|
|
core.check_for_falling(p0)
|
2015-06-29 17:55:56 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
})
|
|
|
|
|
|
|
|
------------------------
|
|
|
|
-- Create Color Glass --
|
|
|
|
------------------------
|
2017-01-31 22:32:56 +00:00
|
|
|
function mcl_core.add_glass(desc, recipeitem, color)
|
2015-06-29 17:55:56 +00:00
|
|
|
|
2017-01-31 22:32:56 +00:00
|
|
|
minetest.register_node("mcl_core:glass_"..color, {
|
2015-06-29 17:55:56 +00:00
|
|
|
description = desc,
|
|
|
|
drawtype = "glasslike",
|
2017-01-04 21:36:51 +00:00
|
|
|
is_ground_content = false,
|
2017-01-16 12:00:20 +00:00
|
|
|
tiles = {"xpanes_pane_glass_"..color..".png"},
|
2017-01-04 11:50:23 +00:00
|
|
|
inventory_image = minetest.inventorycube("xpanes_pane_glass_"..color..".png"),
|
2015-06-29 17:55:56 +00:00
|
|
|
paramtype = "light",
|
|
|
|
use_texture_alpha = true,
|
|
|
|
stack_max = 64,
|
2017-02-26 23:52:02 +00:00
|
|
|
groups = {handy=1, building_block=1},
|
2017-02-11 17:46:23 +00:00
|
|
|
sounds = mcl_sounds.node_sound_glass_defaults(),
|
2015-06-29 17:55:56 +00:00
|
|
|
drop = "",
|
2017-02-22 14:40:22 +00:00
|
|
|
_mcl_blast_resistance = 1.5,
|
2017-02-24 14:56:46 +00:00
|
|
|
_mcl_hardness = 0.3,
|
2015-06-29 17:55:56 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_craft({
|
2017-01-31 22:32:56 +00:00
|
|
|
output = 'mcl_core:glass_'..color..' 8',
|
2015-06-29 17:55:56 +00:00
|
|
|
recipe = {
|
2017-01-31 22:32:56 +00:00
|
|
|
{'mcl_core:glass','mcl_core:glass','mcl_core:glass'},
|
|
|
|
{'mcl_core:glass','group:dye,'..recipeitem,'mcl_core:glass'},
|
|
|
|
{'mcl_core:glass','mcl_core:glass','mcl_core:glass'},
|
2015-06-29 17:55:56 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
|
|
|
|