Make ice freezeover water when placed. Also make water pointable with ice.

This commit is contained in:
Splizard 2014-06-05 16:39:38 +12:00
parent c98663085a
commit a4470eec2a
2 changed files with 48 additions and 0 deletions

View File

@ -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.

View File

@ -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
})