mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-30 20:41:41 +09:00
Added ability to warp while driving in a vehicle
This commit is contained in:
@@ -273,11 +273,29 @@ function Warps.teleport_player(warp_id, player)
|
|||||||
y=warp.position.y+0.5
|
y=warp.position.y+0.5
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
-- Need to calculate new goto_position because entities have different collision boxes
|
||||||
|
goto_position = surface.find_non_colliding_position('character', position, 32, 1)
|
||||||
|
player.teleport(goto_position, surface)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
-- Teleport the player
|
-- Teleport the player
|
||||||
local goto_position = surface.find_non_colliding_position('character', position, 32, 1)
|
local goto_position = surface.find_non_colliding_position('character', position, 32, 1)
|
||||||
if player.driving then player.driving = false end
|
if player.driving then player.driving = false end
|
||||||
player.teleport(goto_position, surface)
|
player.teleport(goto_position, surface)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
--- Setters.
|
--- Setters.
|
||||||
-- functions used to created and alter warps
|
-- functions used to created and alter warps
|
||||||
|
|||||||
Reference in New Issue
Block a user