Teleport now uses new helper functions

This commit is contained in:
Logan G 2022-03-25 23:47:50 -06:00
parent 4ca3dac3df
commit db08604411
Signed by: logan
GPG key ID: E328528C921E7A7A

View file

@ -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