From 81f2bfdcd4abcf158bb97780d3ae75b0249db66e Mon Sep 17 00:00:00 2001 From: Marcin Date: Thu, 25 Jun 2015 18:14:01 +0200 Subject: [PATCH] Added ability to specify coordinates for /spawnentity --- builtin/game/chatcommands.lua | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/builtin/game/chatcommands.lua b/builtin/game/chatcommands.lua index d656f1c91..39511225f 100644 --- a/builtin/game/chatcommands.lua +++ b/builtin/game/chatcommands.lua @@ -530,11 +530,11 @@ core.register_chatcommand("giveme", { }) core.register_chatcommand("spawnentity", { - params = "", - description = "Spawn entity at your position", + params = " [,,]", + 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 @@ -545,7 +545,14 @@ core.register_chatcommand("spawnentity", { 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)