Fix a couple minor bugs
This commit is contained in:
parent
af33315061
commit
14c51b153f
@ -32,11 +32,42 @@ end
|
|||||||
function default.grow_tree(pos, variety)
|
function default.grow_tree(pos, variety)
|
||||||
local function grow()
|
local function grow()
|
||||||
if variety == "apple" then
|
if variety == "apple" then
|
||||||
minetest.place_schematic({x = pos.x-2, y = pos.y-1, z = pos.z-2}, minetest.get_modpath("default").."/schematics/default_tree.mts", "0", {}, false)
|
minetest.place_schematic(
|
||||||
|
{
|
||||||
|
x = pos.x-2,
|
||||||
|
y = pos.y-1,
|
||||||
|
z = pos.z-2
|
||||||
|
},
|
||||||
|
minetest.get_modpath("default")
|
||||||
|
.. "/schematics/default_tree.mts", "0", {}, false)
|
||||||
elseif variety == "oak" then
|
elseif variety == "oak" then
|
||||||
minetest.place_schematic({x = pos.x-2, y = pos.y-1, z = pos.z-2}, minetest.get_modpath("default").."/schematics/default_tree.mts", "0", {["default:leaves"] = "default:leaves_oak", ["default:tree"] = "default:tree_oak", ["default:apple"] = "air"}, false)
|
minetest.place_schematic(
|
||||||
|
{
|
||||||
|
x = pos.x-2,
|
||||||
|
y = pos.y-1,
|
||||||
|
z = pos.z-2
|
||||||
|
},
|
||||||
|
minetest.get_modpath("default")
|
||||||
|
.. "/schematics/default_tree.mts", "0",
|
||||||
|
{
|
||||||
|
["default:leaves"] = "default:leaves_oak",
|
||||||
|
["default:tree"] = "default:tree_oak",
|
||||||
|
["default:apple"] = "air"
|
||||||
|
}, false)
|
||||||
elseif variety == "birch" then
|
elseif variety == "birch" then
|
||||||
minetest.place_schematic({x = pos.x-1, y = pos.y-1, z = pos.z-1}, minetest.get_modpath("default").."/schematics/default_squaretree.mts", "0", {["default:leaves"] = "default:leaves_birch", ["default:tree"] = "default:tree_birch", ["default:apple"] = "air"}, false)
|
minetest.place_schematic(
|
||||||
|
{
|
||||||
|
x = pos.x-1,
|
||||||
|
y = pos.y-1,
|
||||||
|
z = pos.z-1
|
||||||
|
},
|
||||||
|
minetest.get_modpath("default")
|
||||||
|
.. "/schematics/default_squaretree.mts", "0",
|
||||||
|
{
|
||||||
|
["default:leaves"] = "default:leaves_birch",
|
||||||
|
["default:tree"] = "default:tree_birch",
|
||||||
|
["default:apple"] = "air"
|
||||||
|
}, false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -49,41 +80,54 @@ end
|
|||||||
|
|
||||||
minetest.register_abm( -- apple trees or default trees
|
minetest.register_abm( -- apple trees or default trees
|
||||||
{
|
{
|
||||||
|
label = "Grow apple saplings",
|
||||||
nodenames = {"default:sapling"},
|
nodenames = {"default:sapling"},
|
||||||
interval = 10,
|
interval = 10,
|
||||||
chance = 40,
|
chance = 40,
|
||||||
action = function(pos, node)
|
action = function(pos, node)
|
||||||
local is_soil = minetest.registered_nodes[minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name].groups.soil
|
local is_soil = minetest.registered_nodes[minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name].groups.soil
|
||||||
|
|
||||||
if is_soil == nil or is_soil == 0 then return end
|
if is_soil == nil or is_soil == 0 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
default.grow_tree(pos, "apple")
|
default.grow_tree(pos, "apple")
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_abm( -- oak trees
|
minetest.register_abm( -- oak trees
|
||||||
{
|
{
|
||||||
|
label = "Grow oak saplings",
|
||||||
nodenames = {"default:sapling_oak"},
|
nodenames = {"default:sapling_oak"},
|
||||||
interval = 10,
|
interval = 10,
|
||||||
chance = 60,
|
chance = 60,
|
||||||
action = function(pos, node)
|
action = function(pos, node)
|
||||||
local is_soil = minetest.registered_nodes[minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name].groups.soil
|
local is_soil = minetest.registered_nodes[minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name].groups.soil
|
||||||
if is_soil == nil or is_soil == 0 then return end
|
|
||||||
default.grow_tree(pos, "oak")
|
if is_soil == nil or is_soil == 0 then
|
||||||
end
|
return
|
||||||
})
|
end
|
||||||
|
|
||||||
|
default.grow_tree(pos, "oak")
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
minetest.register_abm( -- birch trees
|
minetest.register_abm( -- birch trees
|
||||||
{
|
{
|
||||||
|
label = "Grow birch saplings",
|
||||||
nodenames = {"default:sapling_birch"},
|
nodenames = {"default:sapling_birch"},
|
||||||
interval = 10,
|
interval = 10,
|
||||||
chance = 50,
|
chance = 50,
|
||||||
action = function(pos, node)
|
action = function(pos, node)
|
||||||
local is_soil = minetest.registered_nodes[minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name].groups.soil
|
local is_soil = minetest.registered_nodes[minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name].groups.soil
|
||||||
if is_soil == nil or is_soil == 0 then return end
|
|
||||||
default.grow_tree(pos, "birch")
|
if is_soil == nil or is_soil == 0 then
|
||||||
end
|
return
|
||||||
})
|
end
|
||||||
|
|
||||||
|
default.grow_tree(pos, "birch")
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
-- Vertical plants
|
-- Vertical plants
|
||||||
|
|
||||||
@ -97,7 +141,6 @@ function default.dig_up(pos, node, digger)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function default.dig_down(pos, node, digger)
|
function default.dig_down(pos, node, digger)
|
||||||
-- if digger == nil then return end
|
|
||||||
local np = {x = pos.x, y = pos.y - 1, z = pos.z}
|
local np = {x = pos.x, y = pos.y - 1, z = pos.z}
|
||||||
local nn = minetest.get_node(np)
|
local nn = minetest.get_node(np)
|
||||||
if nn.name == node.name then
|
if nn.name == node.name then
|
||||||
@ -113,19 +156,21 @@ default.leafdecay_enable_cache = true
|
|||||||
default.leafdecay_trunk_find_allow_accumulator = 0
|
default.leafdecay_trunk_find_allow_accumulator = 0
|
||||||
|
|
||||||
minetest.register_globalstep(function(dtime)
|
minetest.register_globalstep(function(dtime)
|
||||||
local finds_per_second = 5000
|
local finds_per_second = 5000
|
||||||
default.leafdecay_trunk_find_allow_accumulator =
|
default.leafdecay_trunk_find_allow_accumulator =
|
||||||
math.floor(dtime * finds_per_second)
|
math.floor(dtime * finds_per_second)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
default.after_place_leaves = function(pos, placer, itemstack, pointed_thing)
|
default.after_place_leaves = function(pos, placer, itemstack, pointed_thing)
|
||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
node.param2 = 1
|
node.param2 = 1
|
||||||
minetest.set_node(pos, node)
|
minetest.set_node(pos, node)
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_abm( -- leaf decay
|
minetest.register_abm( -- leaf decay
|
||||||
{
|
{
|
||||||
|
|
||||||
|
label = "Leaf decay",
|
||||||
nodenames = {"group:leafdecay"},
|
nodenames = {"group:leafdecay"},
|
||||||
neighbors = {"air", "group:liquid"},
|
neighbors = {"air", "group:liquid"},
|
||||||
-- A low interval and a high inverse chance spreads the load
|
-- A low interval and a high inverse chance spreads the load
|
||||||
@ -133,247 +178,207 @@ minetest.register_abm( -- leaf decay
|
|||||||
chance = 3,
|
chance = 3,
|
||||||
|
|
||||||
action = function(p0, node, _, _)
|
action = function(p0, node, _, _)
|
||||||
--print("leafdecay ABM at "..p0.x..", "..p0.y..", "..p0.z..")")
|
--print("leafdecay ABM at "..p0.x..", "..p0.y..", "..p0.z..")")
|
||||||
local do_preserve = false
|
local do_preserve = false
|
||||||
local d = minetest.registered_nodes[node.name].groups.leafdecay
|
local d = minetest.registered_nodes[node.name].groups.leafdecay
|
||||||
if not d or d == 0 then
|
if not d or d == 0 then
|
||||||
--print("not groups.leafdecay")
|
--print("not groups.leafdecay")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local n0 = minetest.get_node(p0)
|
local n0 = minetest.get_node(p0)
|
||||||
if n0.param2 ~= 0 then
|
if n0.param2 ~= 0 then
|
||||||
--print("param2 ~= 0")
|
--print("param2 ~= 0")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local p0_hash = nil
|
local p0_hash = nil
|
||||||
if default.leafdecay_enable_cache then
|
if default.leafdecay_enable_cache then
|
||||||
p0_hash = minetest.hash_node_position(p0)
|
p0_hash = minetest.hash_node_position(p0)
|
||||||
local trunkp = default.leafdecay_trunk_cache[p0_hash]
|
local trunkp = default.leafdecay_trunk_cache[p0_hash]
|
||||||
if trunkp then
|
if trunkp then
|
||||||
local n = minetest.get_node(trunkp)
|
local n = minetest.get_node(trunkp)
|
||||||
local reg = minetest.registered_nodes[n.name]
|
local reg = minetest.registered_nodes[n.name]
|
||||||
-- Assume ignore is a trunk, to make the thing work at the border of the active area
|
-- 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
|
if n.name == "ignore" or (reg and reg.groups.tree and reg.groups.tree ~= 0) then
|
||||||
--print("cached trunk still exists")
|
--print("cached trunk still exists")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
--print("cached trunk is invalid")
|
--print("cached trunk is invalid")
|
||||||
-- Cache is invalid
|
-- Cache is invalid
|
||||||
table.remove(default.leafdecay_trunk_cache, p0_hash)
|
table.remove(default.leafdecay_trunk_cache, p0_hash)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if default.leafdecay_trunk_find_allow_accumulator <= 0 then
|
if default.leafdecay_trunk_find_allow_accumulator <= 0 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
default.leafdecay_trunk_find_allow_accumulator =
|
default.leafdecay_trunk_find_allow_accumulator =
|
||||||
default.leafdecay_trunk_find_allow_accumulator - 1
|
default.leafdecay_trunk_find_allow_accumulator - 1
|
||||||
-- Assume ignore is a trunk, to make the thing work at the border of the active area
|
-- 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"})
|
local p1 = minetest.find_node_near(p0, d, {"ignore", "group:tree"})
|
||||||
if p1 then
|
if p1 then
|
||||||
do_preserve = true
|
do_preserve = true
|
||||||
if default.leafdecay_enable_cache then
|
if default.leafdecay_enable_cache then
|
||||||
--print("caching trunk")
|
--print("caching trunk")
|
||||||
-- Cache the trunk
|
-- Cache the trunk
|
||||||
default.leafdecay_trunk_cache[p0_hash] = p1
|
default.leafdecay_trunk_cache[p0_hash] = p1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if not do_preserve then
|
if not do_preserve then
|
||||||
-- Drop stuff other than the node itself
|
-- Drop stuff other than the node itself
|
||||||
local itemstacks = minetest.get_node_drops(n0.name)
|
local itemstacks = minetest.get_node_drops(n0.name)
|
||||||
for _, itemname in ipairs(itemstacks) do
|
for _, itemname in ipairs(itemstacks) do
|
||||||
if minetest.get_item_group(n0.name, "leafdecay_drop") ~= 0 or itemname ~= n0.name then
|
if minetest.get_item_group(n0.name, "leafdecay_drop") ~= 0 or itemname ~= n0.name then
|
||||||
local p_drop = {
|
local p_drop = {
|
||||||
x = p0.x - 0.5 + math.random(),
|
x = p0.x - 0.5 + math.random(),
|
||||||
y = p0.y - 0.5 + math.random(),
|
y = p0.y - 0.5 + math.random(),
|
||||||
z = p0.z - 0.5 + math.random(),
|
z = p0.z - 0.5 + math.random(),
|
||||||
}
|
}
|
||||||
minetest.add_item(p_drop, itemname)
|
minetest.add_item(p_drop, itemname)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- Remove node
|
-- Remove node
|
||||||
minetest.remove_node(p0)
|
minetest.remove_node(p0)
|
||||||
nodeupdate(p0)
|
nodeupdate(p0)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_abm( -- dirt and grass footsteps becomes dirt with grass if uncovered
|
minetest.register_abm( -- dirt and grass footsteps becomes dirt with grass if uncovered
|
||||||
{
|
{
|
||||||
|
label = "Grow dirt",
|
||||||
nodenames = {"default:dirt", "default:dirt_with_grass_footsteps"},
|
nodenames = {"default:dirt", "default:dirt_with_grass_footsteps"},
|
||||||
interval = 2,
|
interval = 2,
|
||||||
chance = 40,
|
chance = 40,
|
||||||
action = function(pos, node)
|
action = function(pos, node)
|
||||||
local above = {x=pos.x, y=pos.y+1, z=pos.z}
|
local above = {x=pos.x, y=pos.y+1, z=pos.z}
|
||||||
local name = minetest.get_node(above).name
|
local name = minetest.get_node(above).name
|
||||||
local nodedef = minetest.registered_nodes[name]
|
local nodedef = minetest.registered_nodes[name]
|
||||||
if nodedef and (nodedef.sunlight_propagates or nodedef.paramtype == "light") and nodedef.liquidtype == "none" and (minetest.get_node_light(above) or 0) >= 8 then
|
if nodedef and (nodedef.sunlight_propagates or nodedef.paramtype == "light") and nodedef.liquidtype == "none" and (minetest.get_node_light(above) or 0) >= 8 then
|
||||||
minetest.set_node(pos, {name = "default:dirt_with_grass"})
|
minetest.set_node(pos, {name = "default:dirt_with_grass"})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_abm( -- dirt with grass becomes dirt if covered
|
minetest.register_abm( -- dirt with grass becomes dirt if covered
|
||||||
{
|
{
|
||||||
|
label = "Remove grass on covered dirt",
|
||||||
nodenames = {"default:dirt_with_grass"},
|
nodenames = {"default:dirt_with_grass"},
|
||||||
interval = 2,
|
interval = 2,
|
||||||
chance = 10,
|
chance = 10,
|
||||||
action = function(pos, node)
|
action = function(pos, node)
|
||||||
local above = {x=pos.x, y=pos.y+1, z=pos.z}
|
local above = {x=pos.x, y=pos.y+1, z=pos.z}
|
||||||
local name = minetest.get_node(above).name
|
local name = minetest.get_node(above).name
|
||||||
local nodedef = minetest.registered_nodes[name]
|
local nodedef = minetest.registered_nodes[name]
|
||||||
if name ~= "ignore" and nodedef and not ((nodedef.sunlight_propagates or nodedef.paramtype == "light") and nodedef.liquidtype == "none") then
|
if name ~= "ignore" and nodedef and not ((nodedef.sunlight_propagates or nodedef.paramtype == "light") and nodedef.liquidtype == "none") then
|
||||||
minetest.set_node(pos, {name = "default:dirt"})
|
minetest.set_node(pos, {name = "default:dirt"})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_abm( -- grass expands
|
minetest.register_abm( -- grass expands
|
||||||
{
|
{
|
||||||
|
label = "Grass expansion",
|
||||||
nodenames = {"default:grass"},
|
nodenames = {"default:grass"},
|
||||||
interval = 20,
|
interval = 20,
|
||||||
chance = 160,
|
chance = 160,
|
||||||
action = function(pos, node)
|
action = function(pos, node)
|
||||||
local rx = math.random(0, 2) - 1
|
local rx = math.random(0, 2) - 1
|
||||||
local rz = math.random(0, 2) - 1
|
local rz = math.random(0, 2) - 1
|
||||||
|
|
||||||
local edgepos = {x = pos.x+rx, y = pos.y, z = pos.z+rz}
|
local edgepos = {x = pos.x+rx, y = pos.y, z = pos.z+rz}
|
||||||
local downpos = {x = pos.x+rx, y = pos.y-1, z = pos.z+rz}
|
local downpos = {x = pos.x+rx, y = pos.y-1, z = pos.z+rz}
|
||||||
local edgenode = minetest.get_node(edgepos)
|
local edgenode = minetest.get_node(edgepos)
|
||||||
local downnode = minetest.get_node(downpos)
|
local downnode = minetest.get_node(downpos)
|
||||||
|
|
||||||
if edgenode.name == "air" and downnode.name ~= "air" and downnode.buildable_to == false and walkable == true then
|
if edgenode.name == "air" and downnode.name ~= "air" and downnode.buildable_to == false and walkable == true then
|
||||||
minetest.set_node(edgepos, {name = "default:grass"})
|
minetest.set_node(edgepos, {name = "default:grass"})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_abm( -- clams grow
|
minetest.register_abm( -- clams grow
|
||||||
{
|
{
|
||||||
|
label = "Growing clams",
|
||||||
nodenames = {"default:clam"},
|
nodenames = {"default:clam"},
|
||||||
interval = 20,
|
interval = 20,
|
||||||
chance = 160,
|
chance = 160,
|
||||||
action = function(pos, node)
|
action = function(pos, node)
|
||||||
local rx = math.random(0, 2) - 1
|
local rx = math.random(0, 2) - 1
|
||||||
local rz = math.random(0, 2) - 1
|
local rz = math.random(0, 2) - 1
|
||||||
|
|
||||||
local edgepos = {x = pos.x+rx, y = pos.y, z = pos.z+rz}
|
local edgepos = {x = pos.x+rx, y = pos.y, z = pos.z+rz}
|
||||||
local downpos = {x = pos.x+rx, y = pos.y-1, z = pos.z+rz}
|
local downpos = {x = pos.x+rx, y = pos.y-1, z = pos.z+rz}
|
||||||
local edgenode = minetest.get_node(edgepos)
|
local edgenode = minetest.get_node(edgepos)
|
||||||
local downnode = minetest.get_node(downpos)
|
local downnode = minetest.get_node(downpos)
|
||||||
|
|
||||||
if edgenode.name == "air" and downnode.name ~= "air" and downnode.buildable_to == false and walkable == true then
|
if edgenode.name == "air" and downnode.name ~= "air" and downnode.buildable_to == false and walkable == true then
|
||||||
minetest.set_node(edgepos, {name = "default:clam"})
|
minetest.set_node(edgepos, {name = "default:clam"})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_abm( -- cactus grows
|
minetest.register_abm( -- cactus grows
|
||||||
{
|
{
|
||||||
|
label = "Growing cacti",
|
||||||
nodenames = {"default:cactus"},
|
nodenames = {"default:cactus"},
|
||||||
neighbors = {"group:sand"},
|
neighbors = {"group:sand"},
|
||||||
interval = 20,
|
interval = 20,
|
||||||
chance = 10,
|
chance = 10,
|
||||||
action = function(pos, node)
|
action = function(pos, node)
|
||||||
pos.y = pos.y-1
|
pos.y = pos.y-1
|
||||||
local name = minetest.get_node(pos).name
|
local name = minetest.get_node(pos).name
|
||||||
if minetest.get_item_group(name, "sand") ~= 0 then
|
if minetest.get_item_group(name, "sand") ~= 0 then
|
||||||
pos.y = pos.y+1
|
pos.y = pos.y+1
|
||||||
local height = 0
|
local height = 0
|
||||||
while minetest.get_node(pos).name == "default:cactus" and height < 3 do
|
while minetest.get_node(pos).name == "default:cactus" and height < 3 do
|
||||||
height = height+1
|
height = height+1
|
||||||
pos.y = pos.y+1
|
pos.y = pos.y+1
|
||||||
end
|
end
|
||||||
if height < 3 then
|
if height < 3 then
|
||||||
if minetest.get_node(pos).name == "air" then
|
if minetest.get_node(pos).name == "air" then
|
||||||
minetest.set_node(pos, {name="default:cactus"})
|
minetest.set_node(pos, {name="default:cactus"})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_abm( -- papyrus grows
|
minetest.register_abm( -- papyrus grows
|
||||||
{
|
{
|
||||||
|
label = "Growing papyrus",
|
||||||
nodenames = {"default:papyrus"},
|
nodenames = {"default:papyrus"},
|
||||||
neighbors = {"group:plantable_sandy", "group:plantable_soil"},
|
neighbors = {"group:plantable_sandy", "group:plantable_soil"},
|
||||||
interval = 20,
|
interval = 20,
|
||||||
chance = 10,
|
chance = 10,
|
||||||
action = function(pos, node)
|
action = function(pos, node)
|
||||||
pos.y = pos.y-1
|
pos.y = pos.y-1
|
||||||
local name = minetest.get_node(pos).name
|
local name = minetest.get_node(pos).name
|
||||||
|
|
||||||
if minetest.find_node_near(pos, 3, {"group:water"}) == nil then
|
if minetest.find_node_near(pos, 3, {"group:water"}) == nil then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
pos.y = pos.y+1
|
pos.y = pos.y+1
|
||||||
local height = 0
|
local height = 0
|
||||||
while minetest.get_node(pos).name == "default:papyrus" and height < 3 do
|
while minetest.get_node(pos).name == "default:papyrus" and height < 3 do
|
||||||
height = height+1
|
height = height+1
|
||||||
pos.y = pos.y+1
|
pos.y = pos.y+1
|
||||||
end
|
end
|
||||||
if height < 3 then
|
if height < 3 then
|
||||||
if minetest.get_node(pos).name == "air" then
|
if minetest.get_node(pos).name == "air" then
|
||||||
minetest.set_node(pos, {name="default:papyrus"})
|
minetest.set_node(pos, {name="default:papyrus"})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_abm( -- papyrus grows
|
|
||||||
{
|
|
||||||
nodenames = {"default:thistle"},
|
|
||||||
neighbors = {"group:plantable_soil"},
|
|
||||||
interval = 20,
|
|
||||||
chance = 30,
|
|
||||||
action = function(pos, node)
|
|
||||||
local height = 0
|
|
||||||
while minetest.get_node(pos).name == "default:thistle" and height < 3 do
|
|
||||||
height = height+1
|
|
||||||
pos.y = pos.y+1
|
|
||||||
end
|
|
||||||
if height < 3 then
|
|
||||||
if minetest.get_node(pos).name == "air" then
|
|
||||||
minetest.set_node(pos, {name="default:thistle"})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
--[[ TORCH FLAME IS VERY, VERY SLOW, THERE ARE NOW ANIMATIONS INSTEAD
|
|
||||||
minetest.register_abm( -- torch flame
|
|
||||||
{
|
|
||||||
nodenames = {"default:torch", "default:torch_weak"},
|
|
||||||
interval = 5,
|
|
||||||
chance = 1,
|
|
||||||
action = function(pos, node)
|
|
||||||
minetest.add_particlespawner(
|
|
||||||
{
|
|
||||||
amount = 10,
|
|
||||||
time = 5,
|
|
||||||
minpos = {x = pos.x-0.1, y = pos.y-0.4, z = pos.z-0.1},
|
|
||||||
maxpos = {x = pos.x+0.1, y = pos.y, z = pos.z+0.1},
|
|
||||||
minvel = {x = -0.3, y = 0.3, z = -0.3},
|
|
||||||
maxvel = {x = 0.3, y = 1, z = 0.3},
|
|
||||||
minacc = {x = 0, y = 0.5, z = -0},
|
|
||||||
maxacc = {x = 0, y = 2, z = 0},
|
|
||||||
minexptime = 0.3,
|
|
||||||
maxexptime = 0.6,
|
|
||||||
minsize = 4,
|
|
||||||
maxsize = 6,
|
|
||||||
texture = "spark.png"
|
|
||||||
})
|
|
||||||
end
|
|
||||||
})
|
|
||||||
--]]
|
|
||||||
|
|
||||||
minetest.register_abm( -- weak torchs burn out and die after ~3 minutes
|
minetest.register_abm( -- weak torchs burn out and die after ~3 minutes
|
||||||
{
|
{
|
||||||
|
label = "Burning out weak torches",
|
||||||
nodenames = {"default:torch_weak"},
|
nodenames = {"default:torch_weak"},
|
||||||
interval = 3,
|
interval = 3,
|
||||||
chance = 60,
|
chance = 60,
|
||||||
action = function(pos, node)
|
action = function(pos, node)
|
||||||
minetest.set_node(pos, {name = "default:torch_dead", param = node.param, param2 = node.param2})
|
minetest.set_node(pos, {name = "default:torch_dead", param = node.param, param2 = node.param2})
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
default.log("functions", "loaded")
|
default.log("functions", "loaded")
|
||||||
|
@ -131,6 +131,7 @@ end
|
|||||||
|
|
||||||
minetest.register_abm(
|
minetest.register_abm(
|
||||||
{
|
{
|
||||||
|
label = "Furnace",
|
||||||
nodenames = {"default:furnace", "default:furnace_active"},
|
nodenames = {"default:furnace", "default:furnace_active"},
|
||||||
interval = 1.0,
|
interval = 1.0,
|
||||||
chance = 1,
|
chance = 1,
|
||||||
|
@ -3,9 +3,9 @@
|
|||||||
-- Tool definitions
|
-- Tool definitions
|
||||||
--
|
--
|
||||||
|
|
||||||
local creative_digtime=0.5
|
local creative_digtime = 0.15
|
||||||
|
|
||||||
local tool_levels=nil
|
local tool_levels = nil
|
||||||
|
|
||||||
-- Creative mode/hand defs
|
-- Creative mode/hand defs
|
||||||
if minetest.setting_getbool("creative_mode") == true then
|
if minetest.setting_getbool("creative_mode") == true then
|
||||||
|
@ -41,6 +41,7 @@ function farming.register_plant(name, plant)
|
|||||||
|
|
||||||
minetest.register_abm(
|
minetest.register_abm(
|
||||||
{
|
{
|
||||||
|
label = "Farming growing (" .. name .. ")",
|
||||||
nodenames = {
|
nodenames = {
|
||||||
"farming:"..name.."_1",
|
"farming:"..name.."_1",
|
||||||
"farming:"..name.."_2",
|
"farming:"..name.."_2",
|
||||||
|
@ -336,7 +336,7 @@ local function fake_on_item_eat(hpdata, replace_with_item, itemstack,
|
|||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
if minetest.setting_getbool("hunger_enable") then
|
if minetest.setting_getbool("enable_damage") and minetest.setting_getbool("hunger_enable") then
|
||||||
|
|
||||||
minetest.after(0, on_load)
|
minetest.after(0, on_load)
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
--
|
--
|
||||||
-- Item drop mod
|
-- Item drop mod
|
||||||
-- By PilzAdam
|
-- By PilzAdam
|
||||||
@ -14,53 +15,80 @@ minetest.register_globalstep(
|
|||||||
if player:get_hp() > 0 or not minetest.setting_getbool("enable_damage") then
|
if player:get_hp() > 0 or not minetest.setting_getbool("enable_damage") then
|
||||||
local pos = player:getpos()
|
local pos = player:getpos()
|
||||||
local inv = player:get_inventory()
|
local inv = player:get_inventory()
|
||||||
|
|
||||||
for _,object in ipairs(minetest.get_objects_inside_radius(pos, 1.35)) do
|
local in_radius = minetest.get_objects_inside_radius(pos, 6.0)
|
||||||
if not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "__builtin:item" and valid(object) then
|
|
||||||
if inv and inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then
|
for _,object in ipairs(in_radius) do
|
||||||
local pos1 = pos
|
if not object:is_player() and object:get_luaentity()
|
||||||
pos1.y = pos1.y+0.2
|
and object:get_luaentity().name == "__builtin:item" and valid(object) then
|
||||||
local pos2 = object:getpos()
|
local pos1 = pos
|
||||||
local vec = {x=pos1.x-pos2.x, y=pos1.y-pos2.y, z=pos1.z-pos2.z}
|
|
||||||
local len = vector.length(vec)
|
pos1.y = pos1.y + 0.2
|
||||||
if len > 0.5 then
|
|
||||||
vec = vector.divide(vec, len) -- it's a normalize but we have len yet (vector.normalize(vec))
|
local pos2 = object:getpos()
|
||||||
vec.x = vec.x*3
|
|
||||||
vec.y = vec.y*3
|
local vec = {
|
||||||
vec.z = vec.z*3
|
x = pos1.x - pos2.x,
|
||||||
object:setvelocity(vec)
|
y = pos1.y - pos2.y,
|
||||||
object:get_luaentity().physical_state = false
|
z = pos1.z - pos2.z
|
||||||
object:get_luaentity().object:set_properties(
|
}
|
||||||
{
|
|
||||||
physical = false
|
local len = vector.length(vec)
|
||||||
})
|
|
||||||
else
|
if len < 1.35 then
|
||||||
local lua = object:get_luaentity()
|
if inv and inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then
|
||||||
if object == nil or lua == nil or lua.itemstring == nil then
|
if len > 0.5 then
|
||||||
return
|
vec = vector.divide(vec, len) -- It's a normalize but we have len yet (vector.normalize(vec))
|
||||||
end
|
|
||||||
if inv:room_for_item("main", ItemStack(lua.itemstring)) then
|
vec.x = vec.x*3
|
||||||
inv:add_item("main", ItemStack(lua.itemstring))
|
vec.y = vec.y*3
|
||||||
if lua.itemstring ~= "" then
|
vec.z = vec.z*3
|
||||||
minetest.sound_play("item_drop_pickup", {pos = pos, gain = 0.3, max_hear_distance = 16})
|
|
||||||
end
|
object:setvelocity(vec)
|
||||||
lua.itemstring = ""
|
|
||||||
object:remove()
|
object:get_luaentity().physical_state = false
|
||||||
else
|
|
||||||
object:setvelocity({x = 0, y = 0, z = 0})
|
object:get_luaentity().object:set_properties({physical = false})
|
||||||
lua.physical_state = true
|
else
|
||||||
lua.object:set_properties(
|
local lua = object:get_luaentity()
|
||||||
{
|
|
||||||
physical = true
|
if object == nil or lua == nil or lua.itemstring == nil then
|
||||||
})
|
return
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
if inv:room_for_item("main", ItemStack(lua.itemstring)) then
|
||||||
end
|
inv:add_item("main", ItemStack(lua.itemstring))
|
||||||
end
|
|
||||||
end
|
if lua.itemstring ~= "" then
|
||||||
|
minetest.sound_play(
|
||||||
|
"item_drop_pickup",
|
||||||
|
{
|
||||||
|
pos = pos,
|
||||||
|
gain = 0.3,
|
||||||
|
max_hear_distance = 16
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
lua.itemstring = ""
|
||||||
|
object:remove()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
object:setvelocity({x = 0, y = 0, z = 0})
|
||||||
|
|
||||||
|
object:get_luaentity().physical_state = true
|
||||||
|
|
||||||
|
object:get_luaentity().object:set_properties(
|
||||||
|
{
|
||||||
|
physical = true
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
function minetest.handle_node_drops(pos, drops, digger)
|
function minetest.handle_node_drops(pos, drops, digger)
|
||||||
for _,item in ipairs(drops) do
|
for _,item in ipairs(drops) do
|
||||||
@ -84,11 +112,11 @@ function minetest.handle_node_drops(pos, drops, digger)
|
|||||||
z = -z
|
z = -z
|
||||||
end
|
end
|
||||||
obj:setvelocity({x=1/x, y=obj:getvelocity().y, z=1/z})
|
obj:setvelocity({x=1/x, y=obj:getvelocity().y, z=1/z})
|
||||||
|
|
||||||
-- FIXME this doesnt work for deactiveted objects
|
-- FIXME this doesnt work for deactiveted objects
|
||||||
if minetest.setting_get("remove_items") and tonumber(minetest.setting_get("remove_items")) then
|
if minetest.setting_get("remove_items") and tonumber(minetest.setting_get("remove_items")) then
|
||||||
minetest.after(tonumber(minetest.setting_get("remove_items")), function(obj)
|
minetest.after(tonumber(minetest.setting_get("remove_items")), function(obj)
|
||||||
obj:remove()
|
obj:remove()
|
||||||
end, obj)
|
end, obj)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -137,6 +137,7 @@ minetest.register_ore(
|
|||||||
|
|
||||||
minetest.register_abm(
|
minetest.register_abm(
|
||||||
{
|
{
|
||||||
|
label = "Lumien crystals",
|
||||||
nodenames = {"lumien:crystal_on"},
|
nodenames = {"lumien:crystal_on"},
|
||||||
interval = timer_interval,
|
interval = timer_interval,
|
||||||
chance = 1,
|
chance = 1,
|
||||||
|
@ -1293,6 +1293,7 @@ function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light, inter
|
|||||||
mobs.spawning_mobs[name] = true
|
mobs.spawning_mobs[name] = true
|
||||||
minetest.register_abm(
|
minetest.register_abm(
|
||||||
{
|
{
|
||||||
|
label = "Mob spawn (" .. name .. ")",
|
||||||
nodenames = nodes,
|
nodenames = nodes,
|
||||||
neighbors = neighbors,
|
neighbors = neighbors,
|
||||||
interval = interval,
|
interval = interval,
|
||||||
|
@ -131,6 +131,7 @@ if minetest.setting_getbool("music_enable") then
|
|||||||
|
|
||||||
minetest.register_abm(
|
minetest.register_abm(
|
||||||
{
|
{
|
||||||
|
label = "Music player",
|
||||||
nodenames = {"music:player"},
|
nodenames = {"music:player"},
|
||||||
chance = 1,
|
chance = 1,
|
||||||
interval = 1,
|
interval = 1,
|
||||||
|
Loading…
Reference in New Issue
Block a user