From db90c1cb4b351a533145e7c246ee3a625af63c2b Mon Sep 17 00:00:00 2001 From: Anthony Zhang Date: Thu, 7 Mar 2013 16:47:32 -0500 Subject: [PATCH] Add /hp command to set the HP of a given player, requires the ban privelege. --- mesecons_commandblock/init.lua | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/mesecons_commandblock/init.lua b/mesecons_commandblock/init.lua index 0ae1321..0cc91c9 100644 --- a/mesecons_commandblock/init.lua +++ b/mesecons_commandblock/init.lua @@ -3,7 +3,7 @@ minetest.register_chatcommand("say", { description = "Say as the server", privs = {server=true}, func = function(name, param) - minetest.chat_send_all(param) + minetest.chat_send_all(name .. ": " .. param) end }) @@ -20,6 +20,20 @@ minetest.register_chatcommand("tell", { end }) +minetest.register_chatcommand("hp", { + params = " ", + description = "Set health of to hitpoints", + privs = {ban=true}, + func = function(name, param) + local found, _, target, value = param:find("^([^%s]+)%s+(%d+)$") + if found == nil then + minetest.chat_send_player(name, "Invalid usage: " .. param) + return + end + minetest.get_player_by_name(target):set_hp(value) + end +}) + local initialize_data = function(meta, player, command, param) meta:set_string("formspec", "invsize[9,6;]" ..