Help with Table - Regex
Posted: Sat Sep 22, 2012 10:33 am
Hey guys, I've been trying to reach the IRC help channel for the past 2 days, but apparently I come at odd times and people can't assist me. Anyhow what I wish to accomplish is to write an Autoresearch script. On the mud I play at, we are able to use a skill that is called research, which increases the percentage of some skills by 10-15 or something like that.
My aim is;
1- To capture the date when I type practice.
2- Turn this data into a table.
a) Write a regex that can accomplish this.
b) Write the lua code to turn the data regex captures, into a table.
3- Then add bunch of triggers to make the research automatic.
4- (Miscellenous) Colour the code within which the practice list will appear.
So far I completed 1. I'm stuck on the second goal. I'll give a brief understanding of the system;
There are 11 classes; Combat, Piloting, Engineering, Diplomacy, Leadership, Slicer, Smuggling, Espionage, Medical, Science and Bounty Hunting.
When we type practice, it shows all the skills we have the necessary level of in every class. When we type practice <class name>, it only shows the skills list of that particular class we have unlocked.
This is the full practice list;
http://pastebin.com/FUvBAYeC
This is an example for the combat practice list;
http://pastebin.com/wBKkSWyE
--------
I have achieved the first goal by starting to capture when it says ---skills---, and ending the data capture when it says ----feats----.
I spent 2-3 days trying to write the regex needed to capture the data I wanted. The challenge was that, as you can see, on every line 3 skills come up with. So I needed to write a regex that'll capture all three skills per line. Then the advanced challenges were including two worded skills in regex and finally including space combat 1.
Then the challenge was that whenever a line had less than 3 skills, (Usually in the end). I managed to overcome that, but I have failed to apply this into the list code.
Here is my regex code;
\s*(\w+|\w+[ -]\w+|\w+ \w+ \d)\s*\d*%\s*(\w+|\w+[ -]\w+|\w+ \w+ \d)\s*\d*%\s*(\w+|\w+[ -]\w+|\w+ \w+ \d)\s*\d*%|\s*(\w+|\w+[ -]\w+|\w+ \w+ \d)\s*\d*%\s*(\w+|\w+[ -]\w+|\w+ \w+ \d)\s*\d*%|\s*(\w+|\w+[ -]\w+|\w+ \w+ \d)\s*\d*%
Here is my table code;
table.insert(my_skills, matches [2])
table.insert(my_skills, matches [3])
My ultimate goal is to create a table that captures each skill with its name and the percentage. Then skills with less than 80% will be added into the Autoresearch pool, where the script will research them until they are above 80%.
However while fiddling with the regex code, I think I got really stupid. Because currently the code I wrote only acquires the name of the skills. Which is useless without its percentage.
I've been using Mudlet for a while now, I'm trying to better myself so if you guys could guide me, I'd really appreciate it.
My aim is;
1- To capture the date when I type practice.
2- Turn this data into a table.
a) Write a regex that can accomplish this.
b) Write the lua code to turn the data regex captures, into a table.
3- Then add bunch of triggers to make the research automatic.
4- (Miscellenous) Colour the code within which the practice list will appear.
So far I completed 1. I'm stuck on the second goal. I'll give a brief understanding of the system;
There are 11 classes; Combat, Piloting, Engineering, Diplomacy, Leadership, Slicer, Smuggling, Espionage, Medical, Science and Bounty Hunting.
When we type practice, it shows all the skills we have the necessary level of in every class. When we type practice <class name>, it only shows the skills list of that particular class we have unlocked.
This is the full practice list;
http://pastebin.com/FUvBAYeC
This is an example for the combat practice list;
http://pastebin.com/wBKkSWyE
--------
I have achieved the first goal by starting to capture when it says ---skills---, and ending the data capture when it says ----feats----.
I spent 2-3 days trying to write the regex needed to capture the data I wanted. The challenge was that, as you can see, on every line 3 skills come up with. So I needed to write a regex that'll capture all three skills per line. Then the advanced challenges were including two worded skills in regex and finally including space combat 1.
Then the challenge was that whenever a line had less than 3 skills, (Usually in the end). I managed to overcome that, but I have failed to apply this into the list code.
Here is my regex code;
\s*(\w+|\w+[ -]\w+|\w+ \w+ \d)\s*\d*%\s*(\w+|\w+[ -]\w+|\w+ \w+ \d)\s*\d*%\s*(\w+|\w+[ -]\w+|\w+ \w+ \d)\s*\d*%|\s*(\w+|\w+[ -]\w+|\w+ \w+ \d)\s*\d*%\s*(\w+|\w+[ -]\w+|\w+ \w+ \d)\s*\d*%|\s*(\w+|\w+[ -]\w+|\w+ \w+ \d)\s*\d*%
Here is my table code;
table.insert(my_skills, matches [2])
table.insert(my_skills, matches [3])
My ultimate goal is to create a table that captures each skill with its name and the percentage. Then skills with less than 80% will be added into the Autoresearch pool, where the script will research them until they are above 80%.
However while fiddling with the regex code, I think I got really stupid. Because currently the code I wrote only acquires the name of the skills. Which is useless without its percentage.
I've been using Mudlet for a while now, I'm trying to better myself so if you guys could guide me, I'd really appreciate it.