diff options
author | Perttu Ahola <celeron55@gmail.com> | 2011-12-02 02:17:01 +0200 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2011-12-02 02:17:01 +0200 |
commit | 89bc3066328cf7500a8ef978d5e5ed6c1c154576 (patch) | |
tree | 4509c83a549fbd3a1c017946d3c7371f585bec5f /data/mods | |
parent | dc05b106f2011fe7e339a62b0ac15fab4fd54a91 (diff) | |
download | minetest-89bc3066328cf7500a8ef978d5e5ed6c1c154576.tar.gz minetest-89bc3066328cf7500a8ef978d5e5ed6c1c154576.tar.bz2 minetest-89bc3066328cf7500a8ef978d5e5ed6c1c154576.zip |
Fix /give(me) commands a bit in default mod
Diffstat (limited to 'data/mods')
-rw-r--r-- | data/mods/default/init.lua | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/data/mods/default/init.lua b/data/mods/default/init.lua index 79976f2c4..c6c679b63 100644 --- a/data/mods/default/init.lua +++ b/data/mods/default/init.lua @@ -1448,14 +1448,18 @@ minetest.register_on_chat_message(function(name, message) minetest.chat_send_player(name, "you don't have permission to give") return true -- Handled chat message end - stackstring = string.match(message, cmd.." (.*)") + local stackstring = string.match(message, cmd.." (.*)") if stackstring == nil then minetest.chat_send_player(name, 'usage: '..cmd..' stackstring') return true -- Handled chat message end print(cmd..' invoked, stackstring="'..stackstring..'"') - player = minetest.env:get_player_by_name(name) - added, error_msg = player:add_to_inventory(stackstring) + local player = minetest.env:get_player_by_name(name) + if player == nil then + minetest.chat_send_player(name, name2..' is not a known player') + return true -- Handled chat message + end + local added, error_msg = player:add_to_inventory(stackstring) if added then minetest.chat_send_player(name, '"'..stackstring ..'" added to inventory.'); @@ -1473,19 +1477,19 @@ minetest.register_on_chat_message(function(name, message) minetest.chat_send_player(name, "you don't have permission to give") return true -- Handled chat message end - name2, stackstring = string.match(message, cmd.." ([%a%d_-]+) (.*)") + local name2, stackstring = string.match(message, cmd.." ([%a%d_-]+) (.*)") if name == nil or stackstring == nil then minetest.chat_send_player(name, 'usage: '..cmd..' name stackstring') return true -- Handled chat message end print(cmd..' invoked, name2="'..name2 ..'" stackstring="'..stackstring..'"') - player = minetest.env:get_player_by_name(name2) + local player = minetest.env:get_player_by_name(name2) if player == nil then minetest.chat_send_player(name, name2..' is not a known player') return true -- Handled chat message end - added, error_msg = player:add_to_inventory(stackstring) + local added, error_msg = player:add_to_inventory(stackstring) if added then minetest.chat_send_player(name, '"'..stackstring ..'" added to '..name2..'\'s inventory.'); |