Jump to content
This site uses cookies! Learn More

This site uses cookies!

By continuing to use this site, you agree to allow us to store cookies on your computer. :)

Stresse

How To Handle Returning A Full Lua Table

Recommended Posts

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

 

Share this post


Link to post
Share on other sites

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]);
    }
}

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...