09-28-2014, 08:42 PM
I need to compare 2 position variables, and they are always diferent because they are X.135369.. Or Z.168375
Any way to solve this?
Any way to solve this?
Get player coords with no decimals
|
09-28-2014, 08:42 PM
I need to compare 2 position variables, and they are always diferent because they are X.135369.. Or Z.168375
Any way to solve this?
09-28-2014, 08:55 PM
This should work:
local Pos1 = Vector3i(Player1:GetPosition()) local Pos2 = Vector3i(Player2:GetPosition()) return Pos1:Equals(Pos2) Thanks given by: tonibm19
09-28-2014, 09:39 PM
Either that, or use Lua's built-in math.floor() or math.ceil() functions.
Thanks given by: tonibm19
09-28-2014, 09:50 PM
Do they work with Vectors?
09-29-2014, 04:19 PM
And anyway, what is it that you're trying to do? Wouldn't it be eaiser to check if the distance between the two positions, if it's below a threshold?
local Pos1 = Player1:GetPosition() local Pos2 = Player2:GetPosition() if ((Pos1 - Pos2):Length() < 1) then -- The positions are less than 1 block apart end
09-30-2014, 12:02 AM
I need to compare a variable to the players position, and if its the same , teleport to another position (in a variable)
The code STR said worked fine, would your code be less performance-heavy doing it every tick as I do now?
09-30-2014, 12:21 AM
Doesn't really matter, they perform roughly the same.
10-05-2014, 03:27 AM
Oh this should also work btw:
local Pos1 = Player1:GetPosition():Floor() local Pos2 = Player2:GetPosition():Floor() if (Pos1 == Pos2) then -- Do stuff end |
« Next Oldest | Next Newest »
|