• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Solved How to compare getPosition() effectively?

whitevo

Feeling good, thats what I do.
Joined
Jan 2, 2015
Messages
3,454
Solutions
1
Reaction score
627
Location
Estonia
Im trying to compare same positions, but they are both required differently.
When i use the metaValue (not sure is it called like that, if not, let me know, what is the name of that term)

this is part of how i generated Location1
Code:
for x = 674, 681 do
  for y = 554, 563 do
  local tempPos = {x=x, y=y, z=9}
table.insert(pos, tempPos)

here i compare Location1 with Location 2
Code:
for i = 1, #players do
        local tempPos = players[i]:getPosition()
        for a=1, #pos do
       print(tostring(tempPos).." == "..tostring(pos[a]))
problem is.. Even though i know the player is in the same position i generated and named Location1. The location metaValue Does not match.
The closest print value is: 0x0204f4d0 == 0x0204f388

Do i have to open up tables separately and compare X and Y values?
or there is better way to compare these values?
or getPosition is taking a little too much unneeded information i have to strip off somehow?


currently using this solution to compare values
Code:
    for i = 1, #players do
        local tempPos = players[i]:getPosition()
        for a=1, #pos do
       --print(tempPos.x.." "..tempPos.y.." == "..pos[a].x.." "..pos[a].y)
            if pos[a].x == tempPos.x and tempPos.y == pos[a].y then
 
Last edited:
Do i have to open up tables separately and compare X and Y values?
or there is better way to compare these values?
You can compare the x and y values inside the tables or you can use Position:getDistance(positionEx). I can't say which way would be the best in terms of performance though. I'd probably go with Position:getDistance(positionEx).
 
You can compare the x and y values inside the tables or you can use Position:getDistance(positionEx). I can't say which way would be the best in terms of performance though. I'd probably go with Position:getDistance(positionEx).
o dats clever, i like it

Edit: Incase TFS1.x users are interested how i used forgee idea.
Code:
getDistanceBetween(tempPos, pos[a])
 
Last edited:
Back
Top