Skip to content
View in the app

A better way to browse. Learn more.

WRobot

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

How To Handle Returning A Full Lua Table

Featured Replies

Howdy y'all!

I'm working on a little plugin to help me recruit to get that 8th Guild Bank slot (because, you know, I'm a bit spoiled ?).

I pulled the following from a pure Lua project I had been working on to do this recruitment (more) manually.

Problem is, there are a shit ton of queries (and not a predictable number) and I can't think of a sane way of doing it individually.

Feels like there must be a way to take the table and turn it into a Dictionary<int,string> (or just get rid of the damn indexes and turn it into a list of strings)...but I can't figure out how.

Can anyone help?

--	Everything here is Horde-specific; the plugin will have both
local ClassyRaceAchievementIDs= {5163,5165,5160,6625,5161,5162,5164}
local Races = {"Blood Elf","Goblin","Orc","Pandaren","Tauren","Troll","Undead"}
local Classes = {"Death Knight","Demon Hunter","Druid","Hunter","Mage","Monk",
  "Paladin","Priest","Rogue","Shaman","Warlock","Warrior"}
local RaceAchievementIDs= {[5163]="Blood Elf", [5165]="Goblin", [5160]="Orc", [6625]="Pandaren", [5161]="Tauren", [5162]="Troll", [5164]="Undead"}

local queries={}
for i=1,#ClassyRaceAchievementIDs do
	local id = ClassyRaceAchievementIDs[i]
	local numCriteria= GetAchievementNumCriteria(id)
	local raceStr= RaceAchievementIDs[id]
	for c=1,numCriteria do
		local criteriaString, criteriaType, completed, quantity, reqQuantity, charName, flags, assetID, quantityString, criteriaID, eligible = GetAchievementCriteriaInfo(id,c)
		local classStr if tContains(Classes,criteriaString) then for i=1,#Classes do if Classes[i] == criteriaString then classStr=Classes[i] end end end
		local query="r-\""..raceStr.."\" c-\""..classStr.."\" 120"
		if completed==false then tinsert(queries, query) end
	end
end

return queries

 

hi,

No tested, bu like that:

var result = new Dictionary<int, string>();

var r = Lua.LuaDoString<List<string>>(@"
local ClassyRaceAchievementIDs= {5163,5165,5160,6625,5161,5162,5164}
local Races = {""Blood Elf"",""Goblin"",""Orc"",""Pandaren"",""Tauren"",""Troll"",""Undead""}
local Classes = {""Death Knight"",""DemonHunter"",""Druid"",""Hunter"",""Mage"",""Monk"",""Paladin"",""Priest"",""Rogue"",""Shaman"",""Warlock"",""Warrior""}
local RaceAchievementIDs= {[5163]=""Blood Elf"", [5165]=""Goblin"", [5160]=""Orc"", [6625]=""Pandaren"", [5161]=""Tauren"", [5162]=""Troll"", [5164]=""Undead""}

local queries={}
for i=1,#ClassyRaceAchievementIDs do
	local id = ClassyRaceAchievementIDs[i]
	local numCriteria= GetAchievementNumCriteria(id)
	local raceStr= RaceAchievementIDs[id]
	for c=1,numCriteria do
		local criteriaString, criteriaType, completed, quantity, reqQuantity, charName, flags, assetID, quantityString, criteriaID, eligible = GetAchievementCriteriaInfo(id,c)
		local classStrif tContains(Classes,criteriaString) then for i= 1,#Classes do if Classes[i] == criteriaStringthen classStr=Classes[i] end end end
		local query=""r-\""""..raceStr..""\"" c-\""""..classStr..""\"" 120""
		if completed==false then tinsert(queries, id) tinsert(queries, query) end
	end
end

return unpack(queries)
");

if (r.Count % 2 == 0)
{
    for (int i = 0; i < r.Count; i += 2)
    {
        int q;
        if (robotManager.Helpful.Others.ParseInt(r[i], out q))
            result.Add(q, r[i+1]);
    }
}

 

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.