diff options
author | Anthony Zhang <azhang9@gmail.com> | 2013-04-02 17:14:48 -0400 |
---|---|---|
committer | Anthony Zhang <azhang9@gmail.com> | 2013-04-02 17:15:38 -0400 |
commit | e45a2a511e4e371642cf60a8d0cb5df0123eead1 (patch) | |
tree | ba65cec9697e58dd32b87479bdebce3c18106d5c | |
parent | 63a18f1a51ebe60da7e76f70ce2577b8899a3d85 (diff) | |
download | mesecons-e45a2a511e4e371642cf60a8d0cb5df0123eead1.tar mesecons-e45a2a511e4e371642cf60a8d0cb5df0123eead1.tar.gz mesecons-e45a2a511e4e371642cf60a8d0cb5df0123eead1.tar.bz2 mesecons-e45a2a511e4e371642cf60a8d0cb5df0123eead1.tar.xz mesecons-e45a2a511e4e371642cf60a8d0cb5df0123eead1.zip |
Sanity checks for commandblock commands.
-rw-r--r-- | mesecons_commandblock/init.lua | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/mesecons_commandblock/init.lua b/mesecons_commandblock/init.lua index 9e868bc..7ec6312 100644 --- a/mesecons_commandblock/init.lua +++ b/mesecons_commandblock/init.lua @@ -16,6 +16,9 @@ minetest.register_chatcommand("tell", { minetest.chat_send_player(name, "Invalid usage: " .. param)
return
end
+ if not minetest.env:get_player_by_name(target) then
+ minetest.chat_send_player(name, "Invalid target: " .. target)
+ end
minetest.chat_send_player(target, name .. " whispers: " .. message)
end
})
@@ -38,7 +41,12 @@ minetest.register_chatcommand("hp", { minetest.chat_send_player(name, "Invalid usage: " .. param)
return
end
- minetest.get_player_by_name(target):set_hp(value)
+ local player = minetest.env:get_player_by_name(target)
+ if player then
+ player:set_hp(value)
+ else
+ minetest.chat_send_player(name, "Invalid target: " .. target)
+ end
end
})
|