Teleport now uses new helper functions
This commit is contained in:
parent
4ca3dac3df
commit
db08604411
1 changed files with 4 additions and 15 deletions
|
@ -82,28 +82,17 @@ do
|
||||||
end
|
end
|
||||||
|
|
||||||
function teleport:tpgoto(args)
|
function teleport:tpgoto(args)
|
||||||
local targets = find.playersByName(args[1])
|
local target = core:get_entity(args[1])
|
||||||
|
if target == nil then
|
||||||
if #targets == 0 or targets == nil then
|
|
||||||
core:log(log.ERROR, "No targets found!")
|
|
||||||
return
|
|
||||||
elseif #targets > 1 then
|
|
||||||
local list = ""
|
|
||||||
for i, v in pairs(target) do
|
|
||||||
list = list..v..", "
|
|
||||||
end
|
|
||||||
|
|
||||||
list:sub(1, -2)
|
|
||||||
core:log(log.ERROR, "Muliple targets found! ("..list..")")
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local targetpos = findSafeCoords(targets[1]:getPos())
|
local targetpos = findSafeCoords(target:getPos())
|
||||||
|
|
||||||
local result = teleport:tpteleport({targetpos.x, targetpos.y, targetpos.z})
|
local result = teleport:tpteleport({targetpos.x, targetpos.y, targetpos.z})
|
||||||
|
|
||||||
if result then
|
if result then
|
||||||
core:log(log.INFO, "Successfully teleported to \""..targets[1]:getName().."\".")
|
core:log(log.INFO, "Successfully teleported to \""..target:getName().."\".")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue