WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Search for multiple variables (https://www.wowinterface.com/forums/showthread.php?t=57621)

Dissosiative 10-21-19 04:07 AM

Search for multiple variables
 
Code:

Rawr_Locations = {}
Rawr_Locations["North"] = {x = 35, y = 24}
Rawr_Locations["South"] = {x = 32, y = 36}


function Rawr_GetClosest()
        local closestSpot = "";
        local closestDistance = 999999999;
        --local px,py=GetPlayerMapPosition("player")
       
        local px, py = Rawr_GetPosition();
       
        for locationName, loc in pairs(Rawr_Locations)
        do
                local distance = math.dist(loc.x, loc.y, px*100, py*100)
                if distance < closestDistance
                then
                        closestSpot = locationName;
                        closestDistance = distance;
                end
        end
       
        return closestSpot;
end

I need to keep North and south static but I need to search multiple X and Y cordinates North and South.

ie: Rawr_Locations["North"] = {x = 35, y = 24 OR x = 31, y = 12 }

Xrystal 10-21-19 05:28 AM

Sounds like you need a table within a table.

Lua Code:
  1. Rawr_Locations["South"] =
  2. {
  3.        [1] = { x = 32, y = 3 },
  4.        [2] = { x = 32, y = 5 },
  5. }


All times are GMT -6. The time now is 10:49 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI