-
Notifications
You must be signed in to change notification settings - Fork 0
/
vapors.lua
182 lines (139 loc) · 4.02 KB
/
vapors.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
176
177
178
179
-- more concentrated
minetest.register_node("bitumen:vapor_2", {
description = "Vapor",
drawtype = "airlike",
pointable = false,
diggable = false,
walkable = false,
buildable_to = true,
paramtype = "light",
sunlight_propagates = true,
-- post_effect_color = info.post_effect_color,
-- tiles = { "default_copper_block.png" },
groups = { not_in_creative_inventory = 1, bitumen_vapor = 1 },
})
-- less concentrated
minetest.register_node("bitumen:vapor_1", {
description = "Vapor",
drawtype = "airlike",
pointable = false,
diggable = false,
walkable = false,
buildable_to = true,
paramtype = "light",
sunlight_propagates = true,
-- tiles = { "default_steel_block.png" },
groups = { not_in_creative_inventory = 1, bitumen_vapor = 1 },
})
--[[ for testing
minetest.register_node("bitumen:vapor_gen", {
description = "Vapor Generator",
tiles = { "default_steel_block.png" },
groups = { cracky = 1 },
})
minetest.register_abm({
nodenames = {"bitumen:vapor_gen"},
neighbors = {"air"},
interval = 3,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
pos.y = pos.y + 1
minetest.set_node(pos, {name="bitumen:vapor_2"})
end
})
]]
-- move around randomly
minetest.register_abm({
nodenames = {"bitumen:vapor_2", "bitumen:vapor_1"},
neighbors = {"air"},
interval = 4,
chance = 8,
action = function(pos, node, active_object_count, active_object_count_wider)
local name = node.name
local air_nodes = minetest.find_nodes_in_area(
{x=pos.x - 1, y=pos.y - 1, z=pos.z - 1},
{x=pos.x + 1, y=pos.y, z=pos.z + 1},
"air"
)
-- try to go down first
if #air_nodes > 0 and math.random(6) > 1 then
local off = math.random(#air_nodes)
--print("off "..dump(off).. " - " .. dump(#air_nodes))
minetest.set_node(pos, {name="air"})
minetest.set_node(air_nodes[off], {name=name})
return
end
-- go up if there's no down
air_nodes = minetest.find_nodes_in_area(
{x=pos.x - 1, y=pos.y + 1, z=pos.z - 1},
{x=pos.x + 1, y=pos.y + 1, z=pos.z + 1},
"air"
)
if #air_nodes > 0 then
local off = math.random(#air_nodes)
minetest.set_node(pos, {name="air"})
minetest.set_node(air_nodes[off], {name=name})
end
end
})
-- diffuse away completely
minetest.register_abm({
nodenames = {"bitumen:vapor_1"},
neighbors = {"air"},
interval = 8,
chance = 16,
action = function(pos, node)
local air_nodes = minetest.find_nodes_in_area(
{x=pos.x - 1, y=pos.y - 1, z=pos.z - 1},
{x=pos.x + 1, y=pos.y + 1, z=pos.z + 1},
"air"
)
if #air_nodes > 12 then
minetest.set_node(pos, {name="air"})
end
end
})
-- diffuse
minetest.register_abm({
nodenames = {"bitumen:vapor_2"},
neighbors = {"air"},
interval = 4,
chance = 4,
action = function(pos, node, active_object_count, active_object_count_wider)
local air_nodes = minetest.find_nodes_in_area(
{x=pos.x - 1, y=pos.y - 1, z=pos.z - 1},
{x=pos.x + 1, y=pos.y + 1, z=pos.z + 1},
"air"
)
if #air_nodes > 0 then
local off = math.random(#air_nodes)
--print("off "..dump(off).. " - " .. dump(#air_nodes))
minetest.set_node(pos, {name="bitumen:vapor_1"})
minetest.set_node(air_nodes[off], {name="bitumen:vapor_1"})
end
end
})
-- go up in flames
minetest.register_abm({
nodenames = {"bitumen:vapor_1", "bitumen:vapor_2"},
neighbors = {"group:igniter", "default:torch", "default:furnace_active"},
interval = 1,
chance = 3,
action = function(pos, node, active_object_count, active_object_count_wider)
local air_nodes = minetest.find_nodes_in_area(
{x=pos.x - 1, y=pos.y - 1, z=pos.z - 1},
{x=pos.x + 1, y=pos.y + 1, z=pos.z + 1},
{"air", "group:flammable"}
)
if #air_nodes > 0 then
local off = math.random(#air_nodes)
local num = math.random(#air_nodes / 2)
for i = 1,num do
--local theirlevel = minetest.get_node_level(fp)
local fp = air_nodes[((i + off) % #air_nodes) + 1]
minetest.set_node(fp, {name="fire:basic_flame"})
end
end
minetest.set_node(pos, {name="fire:basic_flame"})
end
})