diff options
author | Anthony Zhang <azhang9@gmail.com> | 2013-03-07 16:47:32 -0500 |
---|---|---|
committer | Anthony Zhang <azhang9@gmail.com> | 2013-03-07 16:47:32 -0500 |
commit | db90c1cb4b351a533145e7c246ee3a625af63c2b (patch) | |
tree | 1ab625e67e62d3a114bce90e654f7ca99d702171 | |
parent | 3792b692aafed0ce6b0092b34278ad391b9eaf27 (diff) | |
download | mesecons-db90c1cb4b351a533145e7c246ee3a625af63c2b.tar mesecons-db90c1cb4b351a533145e7c246ee3a625af63c2b.tar.gz mesecons-db90c1cb4b351a533145e7c246ee3a625af63c2b.tar.bz2 mesecons-db90c1cb4b351a533145e7c246ee3a625af63c2b.tar.xz mesecons-db90c1cb4b351a533145e7c246ee3a625af63c2b.zip |
Add /hp command to set the HP of a given player, requires the ban privelege.
-rw-r--r-- | mesecons_commandblock/init.lua | 16 |
1 files changed, 15 insertions, 1 deletions
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 <text> 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 = "<name> <value>",
+ description = "Set health of <name> to <value> 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;]" ..
|