From 841581d4fda32f9e4c663990d247dbc69b845872 Mon Sep 17 00:00:00 2001 From: Sokomine Date: Sat, 5 Jun 2021 22:54:48 +0200 Subject: [PATCH] added register_node_punch.lua --- init.lua | 2 ++ register_node_punch.lua | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 register_node_punch.lua diff --git a/init.lua b/init.lua index e611253..2e9025d 100644 --- a/init.lua +++ b/init.lua @@ -35,6 +35,8 @@ dofile(modpath .. "trade_simple.lua") dofile(modpath .. "trade_list.lua") -- the main functionality of the mod dofile(modpath .. "functions.lua") +-- a way of determining a node position +dofile(modpath .. "register_node_punch.lua") -- the staffs (requires npc_master priv) dofile(modpath .. "tools.lua") -- the actual mobs, using mobs_redo diff --git a/register_node_punch.lua b/register_node_punch.lua new file mode 100644 index 0000000..f5de76f --- /dev/null +++ b/register_node_punch.lua @@ -0,0 +1,16 @@ + +-- some formspecs need a position; let the player punch the node +minetest.register_on_punchnode(function(pos, node, puncher) + local pname = puncher:get_player_name() + if(pname and pname ~= "" + and yl_speak_up.speak_to[pname] + and yl_speak_up.speak_to[pname].expect_block_punch) then + local fs_name = yl_speak_up.speak_to[pname].expect_block_punch + -- the block was punched successfully + yl_speak_up.speak_to[pname].expect_block_punch = nil + -- store *which* block has been punched + yl_speak_up.speak_to[pname].block_punched = pos + -- show the formspec again + yl_speak_up.show_fs(puncher, fs_name) + end +end)