mirror of
https://github.com/Splizard/minetest-mod-snow.git
synced 2024-12-29 16:00:16 +01:00
Make ice freezeover water when placed. Also make water pointable with ice.
This commit is contained in:
parent
c98663085a
commit
a4470eec2a
41
src/abms.lua
41
src/abms.lua
@ -93,6 +93,47 @@ minetest.register_abm({
|
|||||||
end,
|
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.
|
--Spread moss to cobble.
|
||||||
|
@ -317,6 +317,8 @@ minetest.override_item("default:ice", {
|
|||||||
-- The Lines: 1. Alpah to make semi-transparent ice, 2 to work with
|
-- 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
|
-- the dirt_with_grass/snow/just dirt ABMs. ~ LazyJ, 2014_03_09
|
||||||
use_texture_alpha = true, -- 1
|
use_texture_alpha = true, -- 1
|
||||||
|
param2 = 0,
|
||||||
|
--param2 is reserved for how much ice will freezeover.
|
||||||
sunlight_propagates = true, -- 2
|
sunlight_propagates = true, -- 2
|
||||||
drawtype = "glasslike",
|
drawtype = "glasslike",
|
||||||
inventory_image = minetest.inventorycube("default_ice.png"),
|
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
|
or minetest.get_node(pos).name == "default:dirt" then
|
||||||
minetest.set_node(pos, {name="default:dirt_with_snow"})
|
minetest.set_node(pos, {name="default:dirt_with_snow"})
|
||||||
end
|
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
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user