falling.lua 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  1. -- Minetest: builtin/item.lua
  2. local builtin_shared = ...
  3. local SCALE = 0.667
  4. local facedir_to_euler = {
  5. {y = 0, x = 0, z = 0},
  6. {y = -math.pi/2, x = 0, z = 0},
  7. {y = math.pi, x = 0, z = 0},
  8. {y = math.pi/2, x = 0, z = 0},
  9. {y = math.pi/2, x = -math.pi/2, z = math.pi/2},
  10. {y = math.pi/2, x = math.pi, z = math.pi/2},
  11. {y = math.pi/2, x = math.pi/2, z = math.pi/2},
  12. {y = math.pi/2, x = 0, z = math.pi/2},
  13. {y = -math.pi/2, x = math.pi/2, z = math.pi/2},
  14. {y = -math.pi/2, x = 0, z = math.pi/2},
  15. {y = -math.pi/2, x = -math.pi/2, z = math.pi/2},
  16. {y = -math.pi/2, x = math.pi, z = math.pi/2},
  17. {y = 0, x = 0, z = math.pi/2},
  18. {y = 0, x = -math.pi/2, z = math.pi/2},
  19. {y = 0, x = math.pi, z = math.pi/2},
  20. {y = 0, x = math.pi/2, z = math.pi/2},
  21. {y = math.pi, x = math.pi, z = math.pi/2},
  22. {y = math.pi, x = math.pi/2, z = math.pi/2},
  23. {y = math.pi, x = 0, z = math.pi/2},
  24. {y = math.pi, x = -math.pi/2, z = math.pi/2},
  25. {y = math.pi, x = math.pi, z = 0},
  26. {y = -math.pi/2, x = math.pi, z = 0},
  27. {y = 0, x = math.pi, z = 0},
  28. {y = math.pi/2, x = math.pi, z = 0}
  29. }
  30. local gravity = tonumber(core.settings:get("movement_gravity")) or 9.81
  31. --
  32. -- Falling stuff
  33. --
  34. core.register_entity(":__builtin:falling_node", {
  35. initial_properties = {
  36. visual = "item",
  37. visual_size = vector.new(SCALE, SCALE, SCALE),
  38. textures = {},
  39. physical = true,
  40. is_visible = false,
  41. collide_with_objects = true,
  42. collisionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
  43. },
  44. node = {},
  45. meta = {},
  46. floats = false,
  47. set_node = function(self, node, meta)
  48. node.param2 = node.param2 or 0
  49. self.node = node
  50. meta = meta or {}
  51. if type(meta.to_table) == "function" then
  52. meta = meta:to_table()
  53. end
  54. for _, list in pairs(meta.inventory or {}) do
  55. for i, stack in pairs(list) do
  56. if type(stack) == "userdata" then
  57. list[i] = stack:to_string()
  58. end
  59. end
  60. end
  61. local def = core.registered_nodes[node.name]
  62. if not def then
  63. -- Don't allow unknown nodes to fall
  64. core.log("info",
  65. "Unknown falling node removed at "..
  66. core.pos_to_string(self.object:get_pos()))
  67. self.object:remove()
  68. return
  69. end
  70. self.meta = meta
  71. -- Cache whether we're supposed to float on water
  72. self.floats = core.get_item_group(node.name, "float") ~= 0
  73. -- Set entity visuals
  74. if def.drawtype == "torchlike" or def.drawtype == "signlike" then
  75. local textures
  76. if def.tiles and def.tiles[1] then
  77. local tile = def.tiles[1]
  78. if type(tile) == "table" then
  79. tile = tile.name
  80. end
  81. if def.drawtype == "torchlike" then
  82. textures = { "("..tile..")^[transformFX", tile }
  83. else
  84. textures = { tile, "("..tile..")^[transformFX" }
  85. end
  86. end
  87. local vsize
  88. if def.visual_scale then
  89. local s = def.visual_scale
  90. vsize = vector.new(s, s, s)
  91. end
  92. self.object:set_properties({
  93. is_visible = true,
  94. visual = "upright_sprite",
  95. visual_size = vsize,
  96. textures = textures,
  97. glow = def.light_source,
  98. })
  99. elseif def.drawtype ~= "airlike" then
  100. local itemstring = node.name
  101. if core.is_colored_paramtype(def.paramtype2) then
  102. itemstring = core.itemstring_with_palette(itemstring, node.param2)
  103. end
  104. -- FIXME: solution needed for paramtype2 == "leveled"
  105. -- Calculate size of falling node
  106. local s = {}
  107. s.x = (def.visual_scale or 1) * SCALE
  108. s.y = s.x
  109. s.z = s.x
  110. -- Compensate for wield_scale
  111. if def.wield_scale then
  112. s.x = s.x / def.wield_scale.x
  113. s.y = s.y / def.wield_scale.y
  114. s.z = s.z / def.wield_scale.z
  115. end
  116. self.object:set_properties({
  117. is_visible = true,
  118. wield_item = itemstring,
  119. visual_size = s,
  120. glow = def.light_source,
  121. })
  122. end
  123. -- Set collision box (certain nodeboxes only for now)
  124. local nb_types = {fixed=true, leveled=true, connected=true}
  125. if def.drawtype == "nodebox" and def.node_box and
  126. nb_types[def.node_box.type] and def.node_box.fixed then
  127. local box = table.copy(def.node_box.fixed)
  128. if type(box[1]) == "table" then
  129. box = #box == 1 and box[1] or nil -- We can only use a single box
  130. end
  131. if box then
  132. if def.paramtype2 == "leveled" and (self.node.level or 0) > 0 then
  133. box[5] = -0.5 + self.node.level / 64
  134. end
  135. self.object:set_properties({
  136. collisionbox = box
  137. })
  138. end
  139. end
  140. -- Rotate entity
  141. if def.drawtype == "torchlike" then
  142. self.object:set_yaw(math.pi*0.25)
  143. elseif ((node.param2 ~= 0 or def.drawtype == "nodebox" or def.drawtype == "mesh")
  144. and (def.wield_image == "" or def.wield_image == nil))
  145. or def.drawtype == "signlike"
  146. or def.drawtype == "mesh"
  147. or def.drawtype == "normal"
  148. or def.drawtype == "nodebox" then
  149. if (def.paramtype2 == "facedir" or def.paramtype2 == "colorfacedir") then
  150. local fdir = node.param2 % 32 % 24
  151. -- Get rotation from a precalculated lookup table
  152. local euler = facedir_to_euler[fdir + 1]
  153. if euler then
  154. self.object:set_rotation(euler)
  155. end
  156. elseif (def.paramtype2 == "4dir" or def.paramtype2 == "color4dir") then
  157. local fdir = node.param2 % 4
  158. -- Get rotation from a precalculated lookup table
  159. local euler = facedir_to_euler[fdir + 1]
  160. if euler then
  161. self.object:set_rotation(euler)
  162. end
  163. elseif (def.drawtype ~= "plantlike" and def.drawtype ~= "plantlike_rooted" and
  164. (def.paramtype2 == "wallmounted" or def.paramtype2 == "colorwallmounted" or def.drawtype == "signlike")) then
  165. local rot = node.param2 % 8
  166. if (def.drawtype == "signlike" and def.paramtype2 ~= "wallmounted" and def.paramtype2 ~= "colorwallmounted") then
  167. -- Change rotation to "floor" by default for non-wallmounted paramtype2
  168. rot = 1
  169. end
  170. local pitch, yaw, roll = 0, 0, 0
  171. if def.drawtype == "nodebox" or def.drawtype == "mesh" then
  172. if rot == 0 then
  173. pitch, yaw = math.pi/2, 0
  174. elseif rot == 1 then
  175. pitch, yaw = -math.pi/2, math.pi
  176. elseif rot == 2 then
  177. pitch, yaw = 0, math.pi/2
  178. elseif rot == 3 then
  179. pitch, yaw = 0, -math.pi/2
  180. elseif rot == 4 then
  181. pitch, yaw = 0, math.pi
  182. end
  183. else
  184. if rot == 1 then
  185. pitch, yaw = math.pi, math.pi
  186. elseif rot == 2 then
  187. pitch, yaw = math.pi/2, math.pi/2
  188. elseif rot == 3 then
  189. pitch, yaw = math.pi/2, -math.pi/2
  190. elseif rot == 4 then
  191. pitch, yaw = math.pi/2, math.pi
  192. elseif rot == 5 then
  193. pitch, yaw = math.pi/2, 0
  194. end
  195. end
  196. if def.drawtype == "signlike" then
  197. pitch = pitch - math.pi/2
  198. if rot == 0 then
  199. yaw = yaw + math.pi/2
  200. elseif rot == 1 then
  201. yaw = yaw - math.pi/2
  202. end
  203. elseif def.drawtype == "mesh" or def.drawtype == "normal" or def.drawtype == "nodebox" then
  204. if rot >= 0 and rot <= 1 then
  205. roll = roll + math.pi
  206. else
  207. yaw = yaw + math.pi
  208. end
  209. end
  210. self.object:set_rotation({x=pitch, y=yaw, z=roll})
  211. elseif (def.drawtype == "mesh" and def.paramtype2 == "degrotate") then
  212. local p2 = (node.param2 - (def.place_param2 or 0)) % 240
  213. local yaw = (p2 / 240) * (math.pi * 2)
  214. self.object:set_yaw(yaw)
  215. elseif (def.drawtype == "mesh" and def.paramtype2 == "colordegrotate") then
  216. local p2 = (node.param2 % 32 - (def.place_param2 or 0) % 32) % 24
  217. local yaw = (p2 / 24) * (math.pi * 2)
  218. self.object:set_yaw(yaw)
  219. end
  220. end
  221. end,
  222. get_staticdata = function(self)
  223. local ds = {
  224. node = self.node,
  225. meta = self.meta,
  226. }
  227. return core.serialize(ds)
  228. end,
  229. on_activate = function(self, staticdata)
  230. self.object:set_armor_groups({immortal = 1})
  231. self.object:set_acceleration(vector.new(0, -gravity, 0))
  232. local ds = core.deserialize(staticdata)
  233. if ds and ds.node then
  234. self:set_node(ds.node, ds.meta)
  235. elseif ds then
  236. self:set_node(ds)
  237. elseif staticdata ~= "" then
  238. self:set_node({name = staticdata})
  239. end
  240. end,
  241. try_place = function(self, bcp, bcn)
  242. local bcd = core.registered_nodes[bcn.name]
  243. -- Add levels if dropped on same leveled node
  244. if bcd and bcd.paramtype2 == "leveled" and
  245. bcn.name == self.node.name then
  246. local addlevel = self.node.level
  247. if (addlevel or 0) <= 0 then
  248. addlevel = bcd.leveled
  249. end
  250. if core.add_node_level(bcp, addlevel) < addlevel then
  251. return true
  252. elseif bcd.buildable_to then
  253. -- Node level has already reached max, don't place anything
  254. return true
  255. end
  256. end
  257. -- Decide if we're replacing the node or placing on top
  258. local np = vector.copy(bcp)
  259. if bcd and bcd.buildable_to and
  260. (not self.floats or bcd.liquidtype == "none") then
  261. core.remove_node(bcp)
  262. else
  263. np.y = np.y + 1
  264. end
  265. -- Check what's here
  266. local n2 = core.get_node(np)
  267. local nd = core.registered_nodes[n2.name]
  268. -- If it's not air or liquid, remove node and replace it with
  269. -- it's drops
  270. if n2.name ~= "air" and (not nd or nd.liquidtype == "none") then
  271. if nd and nd.buildable_to == false then
  272. nd.on_dig(np, n2, nil)
  273. -- If it's still there, it might be protected
  274. if core.get_node(np).name == n2.name then
  275. return false
  276. end
  277. else
  278. core.remove_node(np)
  279. end
  280. end
  281. -- Create node
  282. local def = core.registered_nodes[self.node.name]
  283. if def then
  284. core.add_node(np, self.node)
  285. if self.meta then
  286. core.get_meta(np):from_table(self.meta)
  287. end
  288. if def.sounds and def.sounds.place then
  289. core.sound_play(def.sounds.place, {pos = np}, true)
  290. end
  291. end
  292. core.check_for_falling(np)
  293. return true
  294. end,
  295. on_step = function(self, dtime, moveresult)
  296. -- Fallback code since collision detection can't tell us
  297. -- about liquids (which do not collide)
  298. if self.floats then
  299. local pos = self.object:get_pos()
  300. local bcp = pos:offset(0, -0.7, 0):round()
  301. local bcn = core.get_node(bcp)
  302. local bcd = core.registered_nodes[bcn.name]
  303. if bcd and bcd.liquidtype ~= "none" then
  304. if self:try_place(bcp, bcn) then
  305. self.object:remove()
  306. return
  307. end
  308. end
  309. end
  310. assert(moveresult)
  311. if not moveresult.collides then
  312. return -- Nothing to do :)
  313. end
  314. local bcp, bcn
  315. local player_collision
  316. if moveresult.touching_ground then
  317. for _, info in ipairs(moveresult.collisions) do
  318. if info.type == "object" then
  319. if info.axis == "y" and info.object:is_player() then
  320. player_collision = info
  321. end
  322. elseif info.axis == "y" then
  323. bcp = info.node_pos
  324. bcn = core.get_node(bcp)
  325. break
  326. end
  327. end
  328. end
  329. if not bcp then
  330. -- We're colliding with something, but not the ground. Irrelevant to us.
  331. if player_collision then
  332. -- Continue falling through players by moving a little into
  333. -- their collision box
  334. -- TODO: this hack could be avoided in the future if objects
  335. -- could choose who to collide with
  336. local vel = self.object:get_velocity()
  337. self.object:set_velocity(vector.new(
  338. vel.x,
  339. player_collision.old_velocity.y,
  340. vel.z
  341. ))
  342. self.object:set_pos(self.object:get_pos():offset(0, -0.5, 0))
  343. end
  344. return
  345. elseif bcn.name == "ignore" then
  346. -- Delete on contact with ignore at world edges
  347. self.object:remove()
  348. return
  349. end
  350. local failure = false
  351. local pos = self.object:get_pos()
  352. local distance = vector.apply(vector.subtract(pos, bcp), math.abs)
  353. if distance.x >= 1 or distance.z >= 1 then
  354. -- We're colliding with some part of a node that's sticking out
  355. -- Since we don't want to visually teleport, drop as item
  356. failure = true
  357. elseif distance.y >= 2 then
  358. -- Doors consist of a hidden top node and a bottom node that is
  359. -- the actual door. Despite the top node being solid, the moveresult
  360. -- almost always indicates collision with the bottom node.
  361. -- Compensate for this by checking the top node
  362. bcp.y = bcp.y + 1
  363. bcn = core.get_node(bcp)
  364. local def = core.registered_nodes[bcn.name]
  365. if not (def and def.walkable) then
  366. failure = true -- This is unexpected, fail
  367. end
  368. end
  369. -- Try to actually place ourselves
  370. if not failure then
  371. failure = not self:try_place(bcp, bcn)
  372. end
  373. if failure then
  374. local drops = core.get_node_drops(self.node, "")
  375. for _, item in pairs(drops) do
  376. core.add_item(pos, item)
  377. end
  378. end
  379. self.object:remove()
  380. end
  381. })
  382. local function convert_to_falling_node(pos, node)
  383. local obj = core.add_entity(pos, "__builtin:falling_node")
  384. if not obj then
  385. return false
  386. end
  387. -- remember node level, the entities' set_node() uses this
  388. node.level = core.get_node_level(pos)
  389. local meta = core.get_meta(pos)
  390. local metatable = meta and meta:to_table() or {}
  391. local def = core.registered_nodes[node.name]
  392. if def and def.sounds and def.sounds.fall then
  393. core.sound_play(def.sounds.fall, {pos = pos}, true)
  394. end
  395. obj:get_luaentity():set_node(node, metatable)
  396. core.remove_node(pos)
  397. return true, obj
  398. end
  399. function core.spawn_falling_node(pos)
  400. local node = core.get_node(pos)
  401. if node.name == "air" or node.name == "ignore" then
  402. return false
  403. end
  404. return convert_to_falling_node(pos, node)
  405. end
  406. local function drop_attached_node(p)
  407. local n = core.get_node(p)
  408. local drops = core.get_node_drops(n, "")
  409. local def = core.registered_items[n.name]
  410. if def and def.preserve_metadata then
  411. local oldmeta = core.get_meta(p):to_table().fields
  412. -- Copy pos and node because the callback can modify them.
  413. local pos_copy = vector.copy(p)
  414. local node_copy = {name=n.name, param1=n.param1, param2=n.param2}
  415. local drop_stacks = {}
  416. for k, v in pairs(drops) do
  417. drop_stacks[k] = ItemStack(v)
  418. end
  419. drops = drop_stacks
  420. def.preserve_metadata(pos_copy, node_copy, oldmeta, drops)
  421. end
  422. if def and def.sounds and def.sounds.fall then
  423. core.sound_play(def.sounds.fall, {pos = p}, true)
  424. end
  425. core.remove_node(p)
  426. for _, item in pairs(drops) do
  427. local pos = {
  428. x = p.x + math.random()/2 - 0.25,
  429. y = p.y + math.random()/2 - 0.25,
  430. z = p.z + math.random()/2 - 0.25,
  431. }
  432. core.add_item(pos, item)
  433. end
  434. end
  435. function builtin_shared.check_attached_node(p, n, group_rating)
  436. local def = core.registered_nodes[n.name]
  437. local d = vector.zero()
  438. if group_rating == 3 then
  439. -- always attach to floor
  440. d.y = -1
  441. elseif group_rating == 4 then
  442. -- always attach to ceiling
  443. d.y = 1
  444. elseif group_rating == 2 then
  445. -- attach to facedir or 4dir direction
  446. if (def.paramtype2 == "facedir" or
  447. def.paramtype2 == "colorfacedir") then
  448. -- Attach to whatever facedir is "mounted to".
  449. -- For facedir, this is where tile no. 5 point at.
  450. -- The fallback vector here is in case 'facedir to dir' is nil due
  451. -- to voxelmanip placing a wallmounted node without resetting a
  452. -- pre-existing param2 value that is out-of-range for facedir.
  453. -- The fallback vector corresponds to param2 = 0.
  454. d = core.facedir_to_dir(n.param2) or vector.new(0, 0, 1)
  455. elseif (def.paramtype2 == "4dir" or
  456. def.paramtype2 == "color4dir") then
  457. -- Similar to facedir handling
  458. d = core.fourdir_to_dir(n.param2) or vector.new(0, 0, 1)
  459. end
  460. elseif def.paramtype2 == "wallmounted" or
  461. def.paramtype2 == "colorwallmounted" then
  462. -- Attach to whatever this node is "mounted to".
  463. -- This where tile no. 2 points at.
  464. -- The fallback vector here is used for the same reason as
  465. -- for facedir nodes.
  466. d = core.wallmounted_to_dir(n.param2) or vector.new(0, 1, 0)
  467. else
  468. d.y = -1
  469. end
  470. local p2 = vector.add(p, d)
  471. local nn = core.get_node(p2).name
  472. local def2 = core.registered_nodes[nn]
  473. if def2 and not def2.walkable then
  474. return false
  475. end
  476. return true
  477. end
  478. --
  479. -- Some common functions
  480. --
  481. function core.check_single_for_falling(p)
  482. local n = core.get_node(p)
  483. if core.get_item_group(n.name, "falling_node") ~= 0 then
  484. local p_bottom = vector.offset(p, 0, -1, 0)
  485. -- Only spawn falling node if node below is loaded
  486. local n_bottom = core.get_node_or_nil(p_bottom)
  487. local d_bottom = n_bottom and core.registered_nodes[n_bottom.name]
  488. if d_bottom then
  489. local same = n.name == n_bottom.name
  490. -- Let leveled nodes fall if it can merge with the bottom node
  491. if same and d_bottom.paramtype2 == "leveled" and
  492. core.get_node_level(p_bottom) <
  493. core.get_node_max_level(p_bottom) then
  494. convert_to_falling_node(p, n)
  495. return true
  496. end
  497. -- Otherwise only if the bottom node is considered "fall through"
  498. if not same and
  499. (not d_bottom.walkable or d_bottom.buildable_to) and
  500. (core.get_item_group(n.name, "float") == 0 or
  501. d_bottom.liquidtype == "none") then
  502. convert_to_falling_node(p, n)
  503. return true
  504. end
  505. end
  506. end
  507. local an = core.get_item_group(n.name, "attached_node")
  508. if an ~= 0 then
  509. if not builtin_shared.check_attached_node(p, n, an) then
  510. drop_attached_node(p)
  511. return true
  512. end
  513. end
  514. return false
  515. end
  516. -- This table is specifically ordered.
  517. -- We don't walk diagonals, only our direct neighbors, and self.
  518. -- Down first as likely case, but always before self. The same with sides.
  519. -- Up must come last, so that things above self will also fall all at once.
  520. local check_for_falling_neighbors = {
  521. vector.new(-1, -1, 0),
  522. vector.new( 1, -1, 0),
  523. vector.new( 0, -1, -1),
  524. vector.new( 0, -1, 1),
  525. vector.new( 0, -1, 0),
  526. vector.new(-1, 0, 0),
  527. vector.new( 1, 0, 0),
  528. vector.new( 0, 0, 1),
  529. vector.new( 0, 0, -1),
  530. vector.new( 0, 0, 0),
  531. vector.new( 0, 1, 0),
  532. }
  533. function core.check_for_falling(p)
  534. -- Round p to prevent falling entities to get stuck.
  535. p = vector.round(p)
  536. -- We make a stack, and manually maintain size for performance.
  537. -- Stored in the stack, we will maintain tables with pos, and
  538. -- last neighbor visited. This way, when we get back to each
  539. -- node, we know which directions we have already walked, and
  540. -- which direction is the next to walk.
  541. local s = {}
  542. local n = 0
  543. -- The neighbor order we will visit from our table.
  544. local v = 1
  545. while true do
  546. -- Push current pos onto the stack.
  547. n = n + 1
  548. s[n] = {p = p, v = v}
  549. -- Select next node from neighbor list.
  550. p = vector.add(p, check_for_falling_neighbors[v])
  551. -- Now we check out the node. If it is in need of an update,
  552. -- it will let us know in the return value (true = updated).
  553. if not core.check_single_for_falling(p) then
  554. -- If we don't need to "recurse" (walk) to it then pop
  555. -- our previous pos off the stack and continue from there,
  556. -- with the v value we were at when we last were at that
  557. -- node
  558. repeat
  559. local pop = s[n]
  560. p = pop.p
  561. v = pop.v
  562. s[n] = nil
  563. n = n - 1
  564. -- If there's nothing left on the stack, and no
  565. -- more sides to walk to, we're done and can exit
  566. if n == 0 and v == 11 then
  567. return
  568. end
  569. until v < 11
  570. -- The next round walk the next neighbor in list.
  571. v = v + 1
  572. else
  573. -- If we did need to walk the neighbor, then
  574. -- start walking it from the walk order start (1),
  575. -- and not the order we just pushed up the stack.
  576. v = 1
  577. end
  578. end
  579. end
  580. --
  581. -- Global callbacks
  582. --
  583. local function on_placenode(p, node)
  584. core.check_for_falling(p)
  585. end
  586. core.register_on_placenode(on_placenode)
  587. local function on_dignode(p, node)
  588. core.check_for_falling(p)
  589. end
  590. core.register_on_dignode(on_dignode)
  591. local function on_punchnode(p, node)
  592. core.check_for_falling(p)
  593. end
  594. core.register_on_punchnode(on_punchnode)