Epic/mods/epic/ABMs.lua

166 lines
4.8 KiB
Lua

minetest.register_abm({
label = 'Floating stones',
nodenames = {'epic:float_stone'},
neighbors = {'air'},
interval = 17,
chance = 3,
action = function(pos, node)
local new_pos = ({x=pos.x, y=pos.y+1, z=pos.z})
local abovenode = minetest.get_node(new_pos).name
if abovenode == 'air' then
local timer = minetest.get_node_timer(pos)
timer:start(1)
end
end,
})
--[[
minetest.register_abm({
label = 'Fire Embers',
nodenames = {'default:lava_source', 'default:lava_flowing', 'fire:permanent_flame', 'fire:basic_flame'},
interval = 13,
chance = 7,
action = function(pos, node)
if minetest.get_node({x=pos.x, y=pos.y+1.0, z=pos.z}).name == 'air' then
particles_embers(pos)
end
end
})
--]]
minetest.register_abm({
label = 'sulfur formation',
nodenames = {'default:stone'},
neighbors = {'default:lava_source', 'default:lava_flowing'},
interval = 20,
chance = 60,
action = function(pos, node)
if pos.y < -100 then
if minetest.find_node_near(pos, 3, {'epic:mineral_sulfur'}) ~= nil then
return
end
minetest.set_node(pos, {name='epic:mineral_sulfur'})
end
end,
})
minetest.register_abm({
label = 'lumberjack step removal',
nodenames = {'lumberjack:step'},
interval = 151,
chance = 21,
action = function(pos)
minetest.remove_node(pos)
end
})
minetest.register_abm({
label = 'Glow sapphire growth',
nodenames = {'caverealms:glow_crystal'},
neighbors = {'caverealms:glow_ore'},
interval = 30,
chance = 17,
action = function(pos, node)
local pos1 = {x=pos.x+1, y=pos.y-1, z=pos.z+1}
local pos0 = {x=pos.x-1, y=pos.y-1, z=pos.z-1}
local can_replace = minetest.find_nodes_in_area(pos0, pos1, 'default:lava_source')
local replace_num = #can_replace
if replace_num ~= 8 then
return
end
local height = 0
while node.name == "caverealms:glow_crystal" and height < 4 do
height = height + 1
pos.y = pos.y + 1
node = minetest.get_node(pos)
end
if height == 4 or node.name ~= 'air' then
return
end
minetest.set_node(pos, {name = 'caverealms:glow_crystal'})
return true
end
})
minetest.register_abm({
label = 'Glow amethyst growth',
nodenames = {'caverealms:glow_amethyst'},
neighbors = {'caverealms:glow_amethyst_ore'},
interval = 30,
chance = 17,
action = function(pos, node)
local pos1 = {x=pos.x+1, y=pos.y-1, z=pos.z+1}
local pos0 = {x=pos.x-1, y=pos.y-1, z=pos.z-1}
local can_replace = minetest.find_nodes_in_area(pos0, pos1, 'default:lava_source')
local replace_num = #can_replace
if replace_num ~= 8 then
return
end
local height = 0
while node.name == "caverealms:glow_amethyst" and height < 4 do
height = height + 1
pos.y = pos.y + 1
node = minetest.get_node(pos)
end
if height == 4 or node.name ~= 'air' then
return
end
minetest.set_node(pos, {name = 'caverealms:glow_amethyst'})
return true
end
})
minetest.register_abm({
label = 'Glow sapphire growth',
nodenames = {'caverealms:glow_emerald'},
neighbors = {'caverealms:glow_emerald_ore'},
interval = 30,
chance = 17,
action = function(pos, node)
local pos1 = {x=pos.x+1, y=pos.y-1, z=pos.z+1}
local pos0 = {x=pos.x-1, y=pos.y-1, z=pos.z-1}
local can_replace = minetest.find_nodes_in_area(pos0, pos1, 'default:lava_source')
local replace_num = #can_replace
if replace_num ~= 8 then
return
end
local height = 0
while node.name == "caverealms:glow_emerald" and height < 4 do
height = height + 1
pos.y = pos.y + 1
node = minetest.get_node(pos)
end
if height == 4 or node.name ~= 'air' then
return
end
minetest.set_node(pos, {name = 'caverealms:glow_emerald'})
return true
end
})
minetest.register_abm({
label = 'Glow ruby growth',
nodenames = {'caverealms:glow_ruby'},
neighbors = {'caverealms:glow_ruby_ore'},
interval = 30,
chance = 17,
action = function(pos, node)
local pos1 = {x=pos.x+1, y=pos.y-1, z=pos.z+1}
local pos0 = {x=pos.x-1, y=pos.y-1, z=pos.z-1}
local can_replace = minetest.find_nodes_in_area(pos0, pos1, 'default:lava_source')
local replace_num = #can_replace
if replace_num ~= 8 then
return
end
local height = 0
while node.name == 'caverealms:glow_ruby' and height < 4 do
height = height + 1
pos.y = pos.y + 1
node = minetest.get_node(pos)
end
if height == 4 or node.name ~= 'air' then
return
end
minetest.set_node(pos, {name = 'caverealms:glow_ruby'})
return true
end
})