aboutsummaryrefslogtreecommitdiff
path: root/builtin/game/chatcommands.lua
diff options
context:
space:
mode:
authorWuzzy <wuzzy2@mail.ru>2018-05-20 14:51:26 +0200
committerSmallJoker <SmallJoker@users.noreply.github.com>2018-05-20 14:51:26 +0200
commit6d6b894c7ad7fbd2dcfab25488738149dc0efb06 (patch)
treea3b0d778cddfc0e6b37da8b10a99a0e4ec537e65 /builtin/game/chatcommands.lua
parent122eed7a3449eead6f87f45f2eb55c11c3cf171e (diff)
downloadhax-minetest-server-6d6b894c7ad7fbd2dcfab25488738149dc0efb06.tar.gz
hax-minetest-server-6d6b894c7ad7fbd2dcfab25488738149dc0efb06.zip
Small usage changes for air and ignore items (#7305)
* Remove “you hacker you!” from node description * Prevent placement of ignore in builtin * Prevent giving of "unknown" explicitly
Diffstat (limited to 'builtin/game/chatcommands.lua')
-rw-r--r--builtin/game/chatcommands.lua13
1 files changed, 8 insertions, 5 deletions
diff --git a/builtin/game/chatcommands.lua b/builtin/game/chatcommands.lua
index e349eec7e..3b701c1fd 100644
--- a/builtin/game/chatcommands.lua
+++ b/builtin/game/chatcommands.lua
@@ -557,8 +557,11 @@ local function handle_give_command(cmd, giver, receiver, stackstring)
local itemstack = ItemStack(stackstring)
if itemstack:is_empty() then
return false, "Cannot give an empty item"
- elseif not itemstack:is_known() then
+ elseif (not itemstack:is_known()) or (itemstack:get_name() == "unknown") then
return false, "Cannot give an unknown item"
+ -- Forbid giving 'ignore' due to unwanted side effects
+ elseif itemstack:get_name() == "ignore" then
+ return false, "Giving 'ignore' is not allowed"
end
local receiverref = core.get_player_by_name(receiver)
if receiverref == nil then
@@ -577,13 +580,13 @@ local function handle_give_command(cmd, giver, receiver, stackstring)
-- entered (e.g. big numbers are always interpreted as 2^16-1).
stackstring = itemstack:to_string()
if giver == receiver then
- return true, ("%q %sadded to inventory.")
- :format(stackstring, partiality)
+ local msg = "%q %sadded to inventory."
+ return true, msg:format(stackstring, partiality)
else
core.chat_send_player(receiver, ("%q %sadded to inventory.")
:format(stackstring, partiality))
- return true, ("%q %sadded to %s's inventory.")
- :format(stackstring, partiality, receiver)
+ local msg = "%q %sadded to %s's inventory."
+ return true, msg:format(stackstring, partiality, receiver)
end
end