mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-29 12:16:37 +09:00
Feature Update (#237)
See PR for details, there are too many to be included here.
This commit is contained in:
@@ -10,9 +10,29 @@ local function teleport(player)
|
||||
local surface = player.surface
|
||||
local spawn = player.force.get_spawn_position(surface)
|
||||
local position = surface.find_non_colliding_position('character', spawn, 32, 1)
|
||||
if not position then return false end
|
||||
if player.driving then player.driving = false end -- kicks a player out a vehicle if in one
|
||||
player.teleport(position, surface)
|
||||
-- return false if no new position
|
||||
if not position then
|
||||
return false
|
||||
end
|
||||
if player.vehicle then
|
||||
-- Teleport the entity
|
||||
local entity = player.vehicle
|
||||
local goto_position = surface.find_non_colliding_position(entity.name, position, 32, 1)
|
||||
-- Surface teleport can only be done for players and cars at the moment. (with surface as an peramitor it gives this error)
|
||||
if entity.type == "car" then
|
||||
entity.teleport(goto_position, surface)
|
||||
elseif surface.index == entity.surface.index then
|
||||
-- Try teleport the entity
|
||||
if not entity.teleport(goto_position) then
|
||||
player.driving = false
|
||||
player.teleport(position, surface)
|
||||
end
|
||||
end
|
||||
else
|
||||
-- Teleport the player
|
||||
player.teleport(position, surface)
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user