@@ -98,7 +98,7 @@ core.register_entity(":__builtin:falling_node", {
98
98
core .add_node (np , self .node )
99
99
end
100
100
self .object :remove ()
101
- nodeupdate (np )
101
+ core . check_for_falling (np )
102
102
return
103
103
end
104
104
local vel = self .object :getvelocity ()
@@ -109,12 +109,12 @@ core.register_entity(":__builtin:falling_node", {
109
109
end
110
110
})
111
111
112
- function spawn_falling_node (p , node )
112
+ local function spawn_falling_node (p , node )
113
113
local obj = core .add_entity (p , " __builtin:falling_node" )
114
114
obj :get_luaentity ():set_node (node )
115
115
end
116
116
117
- function drop_attached_node (p )
117
+ local function drop_attached_node (p )
118
118
local nn = core .get_node (p ).name
119
119
core .remove_node (p )
120
120
for _ , item in pairs (core .get_node_drops (nn , " " )) do
@@ -127,7 +127,7 @@ function drop_attached_node(p)
127
127
end
128
128
end
129
129
130
- function check_attached_node (p , n )
130
+ local function check_attached_node (p , n )
131
131
local def = core .registered_nodes [n .name ]
132
132
local d = {x = 0 , y = 0 , z = 0 }
133
133
if def .paramtype2 == " wallmounted" then
152
152
-- Some common functions
153
153
--
154
154
155
- function nodeupdate_single (p )
155
+ function core . check_single_for_falling (p )
156
156
local n = core .get_node (p )
157
157
if core .get_item_group (n .name , " falling_node" ) ~= 0 then
158
158
local p_bottom = {x = p .x , y = p .y - 1 , z = p .z }
190
190
-- We don't walk diagonals, only our direct neighbors, and self.
191
191
-- Down first as likely case, but always before self. The same with sides.
192
192
-- Up must come last, so that things above self will also fall all at once.
193
- local nodeupdate_neighbors = {
193
+ local check_for_falling_neighbors = {
194
194
{x = - 1 , y = - 1 , z = 0 },
195
195
{x = 1 , y = - 1 , z = 0 },
196
196
{x = 0 , y = - 1 , z = - 1 },
@@ -204,7 +204,7 @@ local nodeupdate_neighbors = {
204
204
{x = 0 , y = 1 , z = 0 },
205
205
}
206
206
207
- function nodeupdate (p )
207
+ function core . check_for_falling (p )
208
208
-- Round p to prevent falling entities to get stuck.
209
209
p = vector .round (p )
210
210
@@ -223,10 +223,10 @@ function nodeupdate(p)
223
223
n = n + 1
224
224
s [n ] = {p = p , v = v }
225
225
-- Select next node from neighbor list.
226
- p = vector .add (p , nodeupdate_neighbors [v ])
226
+ p = vector .add (p , check_for_falling_neighbors [v ])
227
227
-- Now we check out the node. If it is in need of an update,
228
228
-- it will let us know in the return value (true = updated).
229
- if not nodeupdate_single (p ) then
229
+ if not core . check_single_for_falling (p ) then
230
230
-- If we don't need to "recurse" (walk) to it then pop
231
231
-- our previous pos off the stack and continue from there,
232
232
-- with the v value we were at when we last were at that
@@ -258,17 +258,33 @@ end
258
258
-- Global callbacks
259
259
--
260
260
261
- function on_placenode (p , node )
262
- nodeupdate (p )
261
+ local function on_placenode (p , node )
262
+ core . check_for_falling (p )
263
263
end
264
264
core .register_on_placenode (on_placenode )
265
265
266
- function on_dignode (p , node )
267
- nodeupdate (p )
266
+ local function on_dignode (p , node )
267
+ core . check_for_falling (p )
268
268
end
269
269
core .register_on_dignode (on_dignode )
270
270
271
- function on_punchnode (p , node )
272
- nodeupdate (p )
271
+ local function on_punchnode (p , node )
272
+ core . check_for_falling (p )
273
273
end
274
274
core .register_on_punchnode (on_punchnode )
275
+
276
+ --
277
+ -- Globally exported functions
278
+ --
279
+
280
+ -- TODO remove this function after the 0.4.15 release
281
+ function nodeupdate (p )
282
+ core .log (" deprecated" , " nodeupdate: deprecated, please use core.check_for_falling instead" )
283
+ core .check_for_falling (p )
284
+ end
285
+
286
+ -- TODO remove this function after the 0.4.15 release
287
+ function nodeupdate_single (p )
288
+ core .log (" deprecated" , " nodeupdate_single: deprecated, please use core.check_single_for_falling instead" )
289
+ core .check_single_for_falling (p )
290
+ end
0 commit comments