2014-06-04 00:34:58 +02:00
-- Added to change dirt_with_snow to dirt if covered with blocks that don't let light through (sunlight_propagates) or have a light paramtype and liquidtype combination. ~ LazyJ, 2014_03_08
minetest.register_abm ( {
nodenames = { " default:dirt_with_snow " } ,
interval = 2 ,
chance = 20 ,
action = function ( pos , node )
2015-03-06 19:22:45 +01:00
local name = minetest.get_node ( { x = pos.x , y = pos.y + 1 , z = pos.z } ) . name
2014-06-04 00:34:58 +02:00
local nodedef = minetest.registered_nodes [ name ]
2015-03-06 19:22:45 +01:00
if name ~= " ignore "
and nodedef
and not (
( nodedef.sunlight_propagates or nodedef.paramtype == " light " )
and nodedef.liquidtype == " none "
) then
2014-06-04 00:34:58 +02:00
minetest.set_node ( pos , { name = " default:dirt " } )
end
end
} )
--Melting
--Any node part of the group melting will melt when near warm nodes such as lava, fire, torches, etc.
--The amount of water that replaces the node is defined by the number on the group:
--1: one water_source
--2: four water_flowings
--3: one water_flowing
minetest.register_abm ( {
2015-03-06 19:22:45 +01:00
nodenames = { " group:melts " } ,
2015-06-13 10:36:08 +02:00
neighbors = { " group:igniter " , " default:torch " , " default:furnace_active " , " group:hot " } ,
interval = 10 ,
2015-03-06 19:22:45 +01:00
chance = 2 ,
action = function ( pos , node )
2014-06-04 00:34:58 +02:00
local intensity = minetest.get_item_group ( node.name , " melts " )
if intensity == 1 then
2015-06-13 10:36:08 +02:00
minetest.set_node ( pos , { name = " default:water_source " } )
2014-06-04 00:34:58 +02:00
elseif intensity == 2 then
2015-06-13 10:36:08 +02:00
minetest.set_node ( pos , { name = " default:water_flowing " , param2 = 7 } )
elseif intensity == 3 then
minetest.set_node ( pos , { name = " default:water_flowing " , param2 = 3 } )
2015-03-06 19:22:45 +01:00
--[[ LazyJ, you need to add param2, which defines the amount of the flowing water ~ HybridDog 2015_03_06
2015-05-29 12:11:17 +02:00
This was causing " melts=2 " nodes to just disappear so I changed it to replace the
2014-06-04 00:34:58 +02:00
node with a water_source for a couple seconds and then replace the water_source with
air . This way it made a watery mess that quickly evaporated . ~ LazyJ 2014 _04_24
local check_place = function ( pos , node )
if minetest.get_node ( pos ) . name == " air " then
minetest.place_node ( pos , node )
end
end
minetest.add_node ( pos , { name = " default:water_flowing " } )
check_place ( { x = pos.x + 1 , y = pos.y , z = pos.z } , { name = " default:water_flowing " } )
check_place ( { x = pos.x - 1 , y = pos.y , z = pos.z } , { name = " default:water_flowing " } )
check_place ( { x = pos.x , y = pos.y + 1 , z = pos.z } , { name = " default:water_flowing " } )
check_place ( { x = pos.x , y = pos.y - 1 , z = pos.z } , { name = " default:water_flowing " } )
elseif intensity == 3 then
2015-03-06 19:22:45 +01:00
--]
2014-06-04 00:34:58 +02:00
minetest.add_node ( pos , { name = " default:water_source " } )
minetest.after ( 2 , function ( ) -- 2 seconds gives just enough time for
-- the water to flow and spread before the
2015-05-29 12:11:17 +02:00
-- water_source is changed to air. ~ LazyJ
2014-06-04 00:34:58 +02:00
if minetest.get_node ( pos ) . name == " default:water_source " then
minetest.add_node ( pos , { name = " air " } )
end
end )
2015-03-06 19:22:45 +01:00
--]]
2015-06-13 10:36:08 +02:00
else
return
end
2014-06-04 00:34:58 +02:00
nodeupdate ( pos )
2015-03-06 19:22:45 +01:00
end ,
2014-06-04 00:34:58 +02:00
} )
--Freezing
--Water freezes when in contact with snow.
minetest.register_abm ( {
2015-03-06 19:22:45 +01:00
nodenames = { " default:water_source " } ,
-- Added "group:icemaker" and snowbrick. ~ LazyJ
neighbors = { " default:snow " , " default:snowblock " , " snow:snow_brick " , " group:icemaker " } ,
interval = 20 ,
chance = 4 ,
action = function ( pos )
2014-06-04 00:34:58 +02:00
minetest.add_node ( pos , { name = " default:ice " } )
2015-03-06 19:22:45 +01:00
end ,
2014-06-04 00:34:58 +02:00
} )
2014-06-05 06:39:38 +02:00
--Freeze Ice according to it's param2 value.
minetest.register_abm ( {
2015-03-06 19:22:45 +01:00
nodenames = { " default:ice " } ,
neighbors = { " default:water_source " } ,
interval = 20 ,
chance = 4 ,
action = function ( pos , node )
2015-12-30 10:31:23 +01:00
if node.param2 == 0 then
return
end
for l = 0 , 1 do
for i = - 1 , 1 , 2 do
for _ , p in pairs ( {
{ x = pos.x + i , z = pos.z - l * i } ,
{ x = pos.x + l * i , z = pos.z + i }
} ) do
if math.random ( 2 ) == 2 then
p.y = pos.y
if minetest.get_node ( p ) . name == " default:water_source " then
minetest.add_node ( p , { name = " default:ice " , param2 = math.random ( 0 , node.param2 - 1 ) } )
2015-03-06 19:22:45 +01:00
end
end
end
2014-06-05 06:39:38 +02:00
end
2015-12-30 10:31:23 +01:00
end
if math.random ( 8 ) == 8 then
minetest.add_node ( pos , { name = " default:water_source " } )
else
node.param2 = 0
minetest.add_node ( pos , node )
2014-06-05 06:39:38 +02:00
end
2015-03-06 19:22:45 +01:00
end ,
2014-06-05 06:39:38 +02:00
} )
2014-06-04 00:34:58 +02:00
--Spread moss to cobble.
minetest.register_abm ( {
2015-03-06 19:22:45 +01:00
nodenames = { " default:cobble " } ,
neighbors = { " snow:moss " } ,
interval = 20 ,
chance = 6 ,
2015-12-30 10:31:23 +01:00
catch_up = false ,
2015-03-06 19:22:45 +01:00
action = function ( pos , node )
node.name = " default:mossycobble "
minetest.add_node ( pos , node )
end ,
2014-06-04 00:34:58 +02:00
} )
--Grow Pine Saplings
minetest.register_abm ( {
2015-03-06 19:22:45 +01:00
nodenames = { " snow:sapling_pine " } ,
interval = 10 ,
2015-05-29 12:11:17 +02:00
chance = 50 ,
2015-03-06 19:22:45 +01:00
action = function ( pos , node )
2014-06-04 00:34:58 +02:00
-- Check if there is enough vertical-space for the sapling to grow without
-- hitting anything else. ~ LazyJ, 2014_04_10
2015-03-06 19:22:45 +01:00
-- 'If' there is air in each of the 8 nodes dirctly above the sapling,... ~LazyJ
for i = 1 , 8 do
if minetest.get_node ( { x = pos.x , y = pos.y + i , z = pos.z } ) . name ~= " air " then
return
end
end
-- 'then' let the sapling grow into a tree. ~ LazyJ
2014-06-04 00:34:58 +02:00
snow.make_pine ( pos , false )
2015-03-06 19:22:45 +01:00
-- This finds the sapling under the grown tree. ~ LazyJ
if minetest.get_node ( pos ) . name == " snow:sapling_pine " then
-- This switches the sapling to a tree trunk. ~ LazyJ
2015-12-30 10:31:23 +01:00
minetest.set_node ( pos , { name = " default:pinetree " } )
2015-05-29 12:11:17 +02:00
-- This is more for testing but it may be useful info to some admins when
2015-03-06 19:22:45 +01:00
-- grepping the server logs too. ~ LazyJ
2015-12-30 10:31:23 +01:00
minetest.log ( " action " , " A pine sapling grows into a tree at " .. minetest.pos_to_string ( pos ) )
2014-06-04 00:34:58 +02:00
end
end
} )
--Grow Christmas Tree Saplings
minetest.register_abm ( {
2015-03-06 19:22:45 +01:00
nodenames = { " snow:xmas_tree " } ,
interval = 10 ,
chance = 50 ,
2015-06-13 10:36:08 +02:00
action = function ( pos , node )
2015-03-06 19:22:45 +01:00
-- 'If' there is air in each of the 8 nodes dirctly above the sapling,... ~LazyJ
for i = 1 , 8 do
if minetest.get_node ( { x = pos.x , y = pos.y + i , z = pos.z } ) . name ~= " air " then
return
end
end
-- 'then' let the sapling grow into a tree. ~ LazyJ
2014-06-04 00:34:58 +02:00
snow.make_pine ( pos , false , true )
minetest.log ( " action " , " A pine sapling grows into a Christmas tree at " .. minetest.pos_to_string ( pos ) ) -- ~ LazyJ
2015-03-06 19:22:45 +01:00
--else -- 'Else', if there isn't air in each of the 8 nodes above the sapling,
2014-06-04 00:34:58 +02:00
-- then don't anything; including not allowing the sapling to grow.
-- ~ LazyJ, 2014_04_10
2015-03-06 19:22:45 +01:00
--end
end
2014-06-04 00:34:58 +02:00
} )
2015-12-30 10:31:23 +01:00
--Backwards Compatability.
minetest.register_abm ( {
nodenames = { " snow:snow1 " , " snow:snow2 " , " snow:snow3 " , " gsnow4 " , " snow:snow5 " , " snow:snow6 " , " snow:snow7 " , " snow:snow8 " } ,
interval = 1 ,
chance = 1 ,
action = function ( pos , node )
minetest.add_node ( pos , { name = " default:snow " } )
minetest.set_node_level ( pos , 7 * ( tonumber ( node.name : sub ( - 1 ) ) ) )
end ,
} )