diff --git a/src/abms.lua b/src/abms.lua index 010342a..8a595a1 100644 --- a/src/abms.lua +++ b/src/abms.lua @@ -93,6 +93,47 @@ minetest.register_abm({ end, }) +--Freeze Ice according to it's param2 value. +minetest.register_abm({ + nodenames = {"default:ice"}, + neighbors = {"default:water_source"}, + interval = 20, + chance = 4, + action = function(pos, node, active_object_count, active_object_count_wider) + if node.param2 > 0 then + if math.random(2) == 2 and minetest.get_node({x=pos.x+1, y=pos.y, z=pos.z}).name == "default:water_source" then + minetest.add_node({x=pos.x+1, y=pos.y, z=pos.z},{name="default:ice", param2 = math.random(0,node.param2-1)}) + end + if math.random(2) == 2 and minetest.get_node({x=pos.x-1, y=pos.y, z=pos.z}).name == "default:water_source" then + minetest.add_node({x=pos.x-1, y=pos.y, z=pos.z},{name="default:ice", param2 = math.random(0,node.param2-1)}) + end + if math.random(2) == 2 and minetest.get_node({x=pos.x, y=pos.y, z=pos.z-1}).name == "default:water_source" then + minetest.add_node({x=pos.x, y=pos.y, z=pos.z-1},{name="default:ice", param2 = math.random(0,node.param2-1)}) + end + if math.random(2) == 2 and minetest.get_node({x=pos.x, y=pos.y, z=pos.z+1}).name == "default:water_source" then + minetest.add_node({x=pos.x, y=pos.y, z=pos.z+1},{name="default:ice", param2 = math.random(0,node.param2-1)}) + end + if math.random(2) == 2 and minetest.get_node({x=pos.x+1, y=pos.y, z=pos.z-1}).name == "default:water_source" then + minetest.add_node({x=pos.x+1, y=pos.y, z=pos.z-1},{name="default:ice", param2 = math.random(0,node.param2-1)}) + end + if math.random(2) == 2 and minetest.get_node({x=pos.x-1, y=pos.y, z=pos.z+1}).name == "default:water_source" then + minetest.add_node({x=pos.x-1, y=pos.y, z=pos.z+1},{name="default:ice", param2 = math.random(0,node.param2-1)}) + end + if math.random(2) == 2 and minetest.get_node({x=pos.x+1, y=pos.y, z=pos.z+1}).name == "default:water_source" then + minetest.add_node({x=pos.x+1, y=pos.y, z=pos.z+1},{name="default:ice", param2 = math.random(0,node.param2-1)}) + end + if math.random(2) == 2 and minetest.get_node({x=pos.x-1, y=pos.y, z=pos.z-1}).name == "default:water_source" then + minetest.add_node({x=pos.x-1, y=pos.y, z=pos.z-1},{name="default:ice", param2 = math.random(0,node.param2-1)}) + end + if math.random(8) == 8 then + minetest.add_node({x=pos.x, y=pos.y, z=pos.z}, {name="default:water_source"}) + else + minetest.add_node({x=pos.x, y=pos.y, z=pos.z}, {name="default:ice", param2 = 0}) + end + end + end, +}) + --Spread moss to cobble. diff --git a/src/nodes.lua b/src/nodes.lua index 6a043b7..22ebca6 100644 --- a/src/nodes.lua +++ b/src/nodes.lua @@ -317,6 +317,8 @@ minetest.override_item("default:ice", { -- The Lines: 1. Alpah to make semi-transparent ice, 2 to work with -- the dirt_with_grass/snow/just dirt ABMs. ~ LazyJ, 2014_03_09 use_texture_alpha = true, -- 1 + param2 = 0, + --param2 is reserved for how much ice will freezeover. sunlight_propagates = true, -- 2 drawtype = "glasslike", inventory_image = minetest.inventorycube("default_ice.png"), @@ -330,6 +332,11 @@ minetest.override_item("default:ice", { or minetest.get_node(pos).name == "default:dirt" then minetest.set_node(pos, {name="default:dirt_with_snow"}) end + end, + liquids_pointable = true, + --Make ice freeze over when placed by a maximum of 10 blocks. + after_place_node = function(pos, placer, itemstack, pointed_thing) + minetest.set_node(pos, {name="default:ice", param2=math.random(0,10)}) end })