Okay, on the MUD I am playing you have a set of skills. For example, you might see something like
Alchemy: 10% Engineering: 5%
Herbalism: 8% Tailoring: 32%
and on and on, up to about 60 skills. I would like to store each of the skills with their respective percentage points into Lua tables, upon which my script will 'rank' each of these skills into prioritized lists of skills I need to improve (i.e. it will find skills below x% and add it to a list, then when it has iterated throughout the entire table will print the list to me, in order from the lowest to highest.)
I wrote this trigger to capture each skill:
This will insert every skill to the table nicely, but I'm not quite sure where to proceed from here. I'm fairly sure my method of storing the skills is incorrect for what I want to do. How can I take 'm', what the trigger matched on, and break that down into both the skill name and its percentage? I tried using named expressions and then calling these in the function. I changed my match to:
and then tried accessing these in the function, but it then would no longer store all the skills. I changed the function to look like this:
This works somewhat, but it only stores the skills in the first column. Given the above example of skills, I would get something like this:
Is there some easier way to go about this?
Alchemy: 10% Engineering: 5%
Herbalism: 8% Tailoring: 32%
and on and on, up to about 60 skills. I would like to store each of the skills with their respective percentage points into Lua tables, upon which my script will 'rank' each of these skills into prioritized lists of skills I need to improve (i.e. it will find skills below x% and add it to a list, then when it has iterated throughout the entire table will print the list to me, in order from the lowest to highest.)
I wrote this trigger to capture each skill:
<triggers>
<trigger
enabled="y"
match="(.*?) (.*?[0-9.])\%"
name="skill"
regexp="y"
script="skill_function"
sequence="100"
>
</trigger>
</triggers>
Here is the skill_function:
function skill_function (name, line, wildcards)
local function skill (m, t)
table.insert (skills, m)
end
local re = rex.new (GetTriggerInfo (name, 1))
re:gmatch (line, skill)
end
This will insert every skill to the table nicely, but I'm not quite sure where to proceed from here. I'm fairly sure my method of storing the skills is incorrect for what I want to do. How can I take 'm', what the trigger matched on, and break that down into both the skill name and its percentage? I tried using named expressions and then calling these in the function. I changed my match to:
(?P<skill>.*?)\: (?P<level>.*?[0-9.])\%and then tried accessing these in the function, but it then would no longer store all the skills. I changed the function to look like this:
skills [wildcards.skill] = wildcards.levelThis works somewhat, but it only stores the skills in the first column. Given the above example of skills, I would get something like this:
/table.foreach (skills, print)
Alchemy 10
Herbalism 8Is there some easier way to go about this?