minetest.register_on_punchnode(function(pos, node, puncher, pointed_thing))
pos— position of punched node
pointed_thing— pointed_thing (only in 0.4.10+)
Called when a node is punched.
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)
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.