12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- minetest.register_abm({
- label = 'Firevine Growth/Spread',
- nodenames = {'caverealms:fire_vine'},
- neighbors = {'group:stone'},
- interval = 104,
- chance = 40,
- action = function(pos)
- local node_below = ({x=pos.x, y=pos.y-1, z=pos.z})
- local below_name = minetest.get_node(node_below).name
- local spread_chance = math.random(0,3)
- if spread_chance < 2 then
- if below_name ~= 'caverealms:fire_vine' or 'air' then
- local ran_num = math.random(1,4)
- local location = {}
- if ran_num == 1 then
- location = {x=pos.x+1, y=pos.y, z=pos.z}
- elseif ran_num == 2 then
- location = {x=pos.x-1, y=pos.y, z=pos.z}
- elseif ran_num == 3 then
- location = {x=pos.x, y=pos.y, z=pos.z+1}
- elseif ran_num == 4 then
- location = {x=pos.x, y=pos.y, z=pos.z-1}
- end
- local below_location = ({x=location.x, y=location.y-1, z=location.z})
- local below_location_node = minetest.get_node(below_location).name
- if below_location_node ~= 'air' then
- local location_node = minetest.get_node(location)
- local location_name = location_node.name
- if location_name == 'air' or minetest.get_item_group(location_name, 'flammable') > 0 then
- minetest.set_node(location, {name = 'caverealms:fire_vine'})
- end
- end
- if below_name == 'air' then
- minetest.remove_node(pos)
- end
- end
- else
- local above_pos = {x=pos.x, y=pos.y+1, z=pos.z}
- local above_node = minetest.get_node(above_pos).name
- local node_count = 0
- while above_node == 'caverealms:fire_vine' and node_count < 15 do
- above_pos.y = above_pos.y + 1
- above_node = minetest.get_node(above_pos).name
- local node_count = node_count + 1
- end
- if minetest.get_item_group(above_node, 'flammable') > 0 or above_node == 'air' then
- minetest.set_node(above_pos, {name = 'caverealms:fire_vine'})
- end
- end
- end
- })
|