I understand the intent of your method. It's not a bad idea and I'm not sure which way I will go. But your functions are messed up. Looks like you are having trouble with tables. You are are actually not creating any. If it seemed to work for you it might be because the quest you were testing would always end up last in the list.
For example:
Code: Select all
quests = {};
if numquests > 0 then
for lidx0 = 1, numquests do
_, _, quests["qName"], _, _, _, _, _, quests["qId"], _, _ = RoMScript("GetQuestInfo("..lidx0..")")
You are not filling a table. You are changing the same 2 variables, quests.qName and quests.qId, each time it goes through the loop. I think you meant
Code: Select all
quests = {};
if numquests > 0 then
for lidx0 = 1, numquests do
quests[lidx0] = {}
_, _, quests[lidx0]["qName"], _, _, _, _, _, quests[lidx0]["qId"], _, _ = RoMScript("GetQuestInfo("..lidx0..")")
That will create a table.
And, this ones funny,
Code: Select all
for kb, vb in pairs(quests2) do
if quests.qId == quests2.qId then
foundflag = true;
break
end
end
You are supposedly iterating though the quests2 table but you never use kb
or vb. You just keep comparing the same 2 values quests.qId and quests2.qId.
Here, I made those changes.