Thread Tools Display Modes
Prev Previous Post   Next Post Next
04/12/14, 09:16 PM   #1
Sharlikran
 
Sharlikran's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 666
Function to check values in a Set

Can you help me with something?
Code:
if profession == 6 then
    profession = 5
end
Looking at the Esohead.lua, it seems that Wood is assigned to profession number 6. In HarvestMap Wood is 5. The author HarvestMap uses this simple method to assign which set is to be used. I need help with some coding since I don't know lua, because I want to do something different. I want to parse through the set.

Example of one of 9 sets of numbers.
Code:
	-- Added: Supplies
    [8] = {
        1187,
        23265,
        23267,
        45835,
    },
If I have a list of IDs as noted above how do I make it look at all the ID numbers in the Set, and if it finds one, then do something. Here is what I was thinking.

Arguments:
ProfessionId = a valid number 1 to 9 in set Harvest.professions in file HarvestMapData.lua

Intention:
function CheckInProfessionSet returns True if the ItemId exists in that specific set.
Code:
function CheckInProfessionSet(ProfessionId)
    ProfessionId = tonumber(ProfessionId)

    for tsId, tsData in pairs(EH.rawMaterials[ProfessionId]) do
        for key, value in pairs(tsData) do
            if value == key then
                return true
            end
        end
    end
    return false
end
How do I change this, I don't know if that is even correct at all. Also, does that need an Else statement before last 'return false'?

I got this from the Esohead files. I'd like to use something similar. How can I make it return true or false if the ItemId is in the set?

Last edited by Sharlikran : 04/12/14 at 10:46 PM.
  Reply With Quote
 

ESOUI » Developer Discussions » Lua/XML Help » Function to check values in a Set


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