Thread Tools Display Modes
10-21-19, 04:07 AM   #1
Dissosiative
A Defias Bandit
Join Date: Dec 2008
Posts: 2
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 }
  Reply With Quote
10-21-19, 05:28 AM   #2
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,892
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. }
__________________
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Search for multiple variables

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off