From b14eb70241661035c3f4aea6bdf93da613dba004 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Wed, 19 Aug 2020 16:27:56 +0200 Subject: [PATCH] Add after_rotate in screwdriver API --- mods/ITEMS/screwdriver/API.md | 8 ++++++++ mods/ITEMS/screwdriver/init.lua | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/mods/ITEMS/screwdriver/API.md b/mods/ITEMS/screwdriver/API.md index 03cc6fdd..0c17ee68 100644 --- a/mods/ITEMS/screwdriver/API.md +++ b/mods/ITEMS/screwdriver/API.md @@ -18,3 +18,11 @@ To use it, add the `on_rotate` function to the node definition. * use `on_rotate = false` to always disallow rotation * use `on_rotate = screwdriver.rotate_simple` to allow only face rotation * use `on_rotate = screwdriver.rotate_3way` (MineClone 2 extension) for pillar-like nodes that should only have 3 possible orientations) + + + +`after_rotate(pos)` (MineClone 2 extension) + +Called after the rotation has been completed + + * `pos`: Position of the node that the screwdriver was used on diff --git a/mods/ITEMS/screwdriver/init.lua b/mods/ITEMS/screwdriver/init.lua index 1fb9745a..ec4f1a2a 100644 --- a/mods/ITEMS/screwdriver/init.lua +++ b/mods/ITEMS/screwdriver/init.lua @@ -157,7 +157,11 @@ screwdriver.handler = function(itemstack, user, pointed_thing, mode, uses) if should_rotate and new_param2 ~= node.param2 then node.param2 = new_param2 minetest.swap_node(pos, node) + minetest.check_for_falling(pos) + if ndef.after_rotate then + ndef.after_rotate(vector.new(pos)) + end end if not (minetest.is_creative_enabled(user:get_player_name())) then