-
Notifications
You must be signed in to change notification settings - Fork 0
/
abms.lua
175 lines (147 loc) · 6.54 KB
/
abms.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
--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, active_object_count, active_object_count_wider)
local level = 7*(tonumber(node.name:sub(-1)))
minetest.add_node(pos,{name="default:snow"})
minetest.set_node_level(pos, level)
end,
})
-- 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)
local above = {x=pos.x, y=pos.y+1, z=pos.z}
local name = minetest.get_node(above).name
local nodedef = minetest.registered_nodes[name]
if name ~= "ignore" and nodedef
and not ((nodedef.sunlight_propagates or nodedef.paramtype == "light")
and nodedef.liquidtype == "none") then
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({
nodenames = {"group:melts"},
neighbors = {"group:igniter","default:torch","default:furnace_active","group:hot"},
interval = 2,
chance = 2,
action = function(pos, node, active_object_count, active_object_count_wider)
local intensity = minetest.get_item_group(node.name,"melts")
if intensity == 1 then
minetest.add_node(pos,{name="default:water_source"})
elseif intensity == 2 then
--[[ This was causing "melts=2" nodes to just disappear so I changed it to replace the
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
--]]
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
-- water_source is changed to air. ~ LazyJ
if minetest.get_node(pos).name == "default:water_source" then
minetest.add_node(pos,{name="air"})
end
end)
end
nodeupdate(pos)
end,
})
--Freezing
--Water freezes when in contact with snow.
minetest.register_abm({
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, node, active_object_count, active_object_count_wider)
minetest.add_node(pos,{name="default:ice"})
end,
})
--Spread moss to cobble.
minetest.register_abm({
nodenames = {"default:cobble"},
neighbors = {"snow:moss"},
interval = 20,
chance = 6,
action = function(pos, node, active_object_count, active_object_count_wider)
minetest.add_node(pos,{name="default:mossycobble"})
end,
})
--Grow Pine Saplings
minetest.register_abm({
nodenames = {"snow:sapling_pine"},
interval = 10,
chance = 50,
action = function(pos, node, active_object_count, active_object_count_wider)
-- Check if there is enough vertical-space for the sapling to grow without
-- hitting anything else. ~ LazyJ, 2014_04_10
if -- 'If' there is air in each of the 8 nodes dirctly above the sapling,... ~LazyJ
minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z}).name == "air" and
minetest.get_node({x=pos.x, y=pos.y+2, z=pos.z}).name == "air" and
minetest.get_node({x=pos.x, y=pos.y+3, z=pos.z}).name == "air" and
minetest.get_node({x=pos.x, y=pos.y+4, z=pos.z}).name == "air" and
minetest.get_node({x=pos.x, y=pos.y+5, z=pos.z}).name == "air" and
minetest.get_node({x=pos.x, y=pos.y+6, z=pos.z}).name == "air" and
minetest.get_node({x=pos.x, y=pos.y+7, z=pos.z}).name == "air" and
minetest.get_node({x=pos.x, y=pos.y+8, z=pos.z}).name == "air"
then -- 'then' let the sapling grow into a tree. ~ LazyJ
snow.make_pine(pos,false)
-- This finds the sapling under the grown tree. ~ LazyJ
if minetest.get_node({x = pos.x, y = pos.y, z = pos.z}).name == "snow:sapling_pine" then
-- This switches the sapling to a tree trunk. ~ LazyJ
minetest.set_node(pos, {name="default:tree"})
-- This is more for testing but it may be useful info to some admins when
-- grepping the server logs too. ~ LazyJ
minetest.log("action", "A pine sapling grows into a tree at "..minetest.pos_to_string(pos))
end
else
end
end
})
--Grow Christmas Tree Saplings
minetest.register_abm({
nodenames = {"snow:xmas_tree"},
interval = 10,
chance = 50,
action = function(pos, node, active_object_count, active_object_count_wider)
if -- 'If' there is air in each of the 8 nodes dirctly above the sapling,... ~LazyJ
minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z}).name == "air" and
minetest.get_node({x=pos.x, y=pos.y+2, z=pos.z}).name == "air" and
minetest.get_node({x=pos.x, y=pos.y+3, z=pos.z}).name == "air" and
minetest.get_node({x=pos.x, y=pos.y+4, z=pos.z}).name == "air" and
minetest.get_node({x=pos.x, y=pos.y+5, z=pos.z}).name == "air" and
minetest.get_node({x=pos.x, y=pos.y+6, z=pos.z}).name == "air" and
minetest.get_node({x=pos.x, y=pos.y+7, z=pos.z}).name == "air" and
minetest.get_node({x=pos.x, y=pos.y+8, z=pos.z}).name == "air"
then -- 'then' let the sapling grow into a tree. ~ LazyJ
snow.make_pine(pos,false,true)
minetest.log("action", "A pine sapling grows into a Christmas tree at "..minetest.pos_to_string(pos)) -- ~ LazyJ
else -- 'Else', if there isn't air in each of the 8 nodes above the sapling,
-- then don't anything; including not allowing the sapling to grow.
-- ~ LazyJ, 2014_04_10
end
end
})