summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorMarcin <beyondlimits@10g.pl>2015-06-25 18:14:01 +0200
committerest31 <MTest31@outlook.com>2015-07-18 08:35:36 +0200
commitc5c609ce3d0ff7b959adc72c26486c14b2219046 (patch)
treee4e35b3e4c5cc5808da64f525817e9b6f5383be4 /builtin
parentdd2e08e11764e045f4eb7a25475a8ecaa77b58de (diff)
downloadminetest-c5c609ce3d0ff7b959adc72c26486c14b2219046.tar.gz
minetest-c5c609ce3d0ff7b959adc72c26486c14b2219046.tar.bz2
minetest-c5c609ce3d0ff7b959adc72c26486c14b2219046.zip
Add ability to specify coordinates for /spawnentity
Diffstat (limited to 'builtin')
-rw-r--r--builtin/game/chatcommands.lua19
1 files changed, 13 insertions, 6 deletions
diff --git a/builtin/game/chatcommands.lua b/builtin/game/chatcommands.lua
index d656f1c91..6c8ca8699 100644
--- a/builtin/game/chatcommands.lua
+++ b/builtin/game/chatcommands.lua
@@ -530,22 +530,29 @@ core.register_chatcommand("giveme", {
})
core.register_chatcommand("spawnentity", {
- params = "<EntityName>",
- description = "Spawn entity at your position",
+ params = "<EntityName> [<X>,<Y>,<Z>]",
+ description = "Spawn entity at given (or your) position",
privs = {give=true, interact=true},
func = function(name, param)
- local entityname = string.match(param, "(.+)$")
+ local entityname, p = string.match(param, "^([^ ]+) *(.*)$")
if not entityname then
return false, "EntityName required"
end
- core.log("action", ("/spawnentity invoked, entityname=%q")
- :format(entityname))
+ core.log("action", ("%s invokes /spawnentity, entityname=%q")
+ :format(name, entityname))
local player = core.get_player_by_name(name)
if player == nil then
core.log("error", "Unable to spawn entity, player is nil")
return false, "Unable to spawn entity, player is nil"
end
- local p = player:getpos()
+ if p == "" then
+ p = player:getpos()
+ else
+ p = core.string_to_pos(p)
+ if p == nil then
+ return false, "Invalid parameters ('" .. param .. "')"
+ end
+ end
p.y = p.y + 1
core.add_entity(p, entityname)
return true, ("%q spawned."):format(entityname)