Get player coords with no decimals - Printable Version +- Cuberite Forum (https://forum.cuberite.org) +-- Forum: Plugins (https://forum.cuberite.org/forum-1.html) +--- Forum: Plugin Discussion (https://forum.cuberite.org/forum-8.html) +--- Thread: Get player coords with no decimals (/thread-1602.html) |
Get player coords with no decimals - tonibm19 - 09-28-2014 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? RE: Get player coords with no decimals - NiLSPACE - 09-28-2014 This should work: local Pos1 = Vector3i(Player1:GetPosition()) local Pos2 = Vector3i(Player2:GetPosition()) return Pos1:Equals(Pos2) RE: Get player coords with no decimals - xoft - 09-28-2014 Either that, or use Lua's built-in math.floor() or math.ceil() functions. RE: Get player coords with no decimals - NiLSPACE - 09-28-2014 Do they work with Vectors? RE: Get player coords with no decimals - xoft - 09-29-2014 No, they only work with individual coords. RE: Get player coords with no decimals - xoft - 09-29-2014 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 RE: Get player coords with no decimals - tonibm19 - 09-30-2014 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? RE: Get player coords with no decimals - xoft - 09-30-2014 Doesn't really matter, they perform roughly the same. RE: Get player coords with no decimals - NiLSPACE - 10-05-2014 Oh this should also work btw: local Pos1 = Player1:GetPosition():Floor() local Pos2 = Player2:GetPosition():Floor() if (Pos1 == Pos2) then -- Do stuff end |