|This page contains unofficial, low-quality Lua API documentation and is likely to be outdated or wrong. Do not rely on it!
For the official and up-to-date documentation, see Lua API Documentation.
|This page has been proposed for deletion for the following reason: "Contains unofficial and potentially outdated, redundant and inconsistent Lua API information"
If you don't think that this page should be deleted, please explain why on the talk page.
<source>minetest.register_on_punchnode(function(pos, node, puncher, pointed_thing))</source>
pos— position of punched node
pointed_thing— pointed_thing (only in 0.4.10+)
Called when a node is punched.
<source>minetest.register_on_punchnode(function(pos, node, puncher, pointed_thing) if puncher:get_wielded_item():get_name() == "moretools:pick" and node.name ~= "air" then minetest.remove_node(pos) puncher:get_inventory():add_item('main', node) end end)</source>
<source>minetest.register_on_punchnode(function(pos, node, puncher, pointed_thing) if node.name == "default:brick" then local puncher_name = puncher:get_player_name() local mypos = minetest.pos_to_string(pos) -- Sets variable to (X,Y,Z.. where Y is up) minetest.chat_send_all("Hey!! ".. puncher_name .." is hitting me. I'm located at ".. mypos .." Send help!!") end if node.name == "default:desert_stonebrick" then local puncher_name = puncher:get_player_name() minetest.chat_send_player(puncher_name, "That's got to hurt!!") end end) </source> If the player punches a default:brick, minetest will send chat message to all online players advising them that a particular player has punched the node. If a default:desert_stonebrick node has been punched, the server sends a message to the player only.