|
sav Wanderer
Joined: 09 Jan 2006 Posts: 86
|
Posted: Thu Jun 25, 2009 2:00 pm
Editing Variables |
Hi,
is there any command that i can use to edit a variable?
so i have this trigger, it picks up a bunch of stuff and stores it into 1 variable. it usually looks like
(N) (R) (G)
and if i'm fighting something, it'll be
(N) (R) (G) E: 50%
so i wanna remove the E: 50% from the variable value.
can anyone help?
i hope that makes sense. |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Thu Jun 25, 2009 9:55 pm |
If you want to remove the E: stuff, simply rewrite your trigger pattern so that it doesn't get included in the capture.
#trigger {^([NRG~(~)%s]) E: %d~%}...
If you want to do it your way, though, look into the use of the %left()/%right()/%leftback()/%rightback() and %remove() functions. The first group will help you get the position, the %remove() will let you cut it out. |
|
_________________ EDIT: I didn't like my old signature |
|
|
|
sav Wanderer
Joined: 09 Jan 2006 Posts: 86
|
Posted: Thu Jun 25, 2009 11:03 pm |
problem is, it can be (N) (R) or (R) (G) or (N) (G), or any other permutation.
so i use * to capture everything. and E: gets captured too.
also, is there anyway to %remove(all numbers, @string) ? |
|
|
|
charneus Wizard
Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Fri Jun 26, 2009 12:24 am |
That's where regex comes in handy!
#REGEX {^(?:\(N\))? (?:\(R\))? (?:\(G\))?} {whatever you want it to do}
If you need to capture individual parts, then do:
#REGEX {^((?:\(N\)))? ((?:\(R\)))? ((?:\(G\)))?} {whatever you want to do}
The N will always be %1, whether it's there or not, the R will be %2, and the G will be %3, whether they're there or not. Hope this helps!
Charneus |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Fri Jun 26, 2009 12:48 am |
The second regex can be simplified:
^(\(N\))? (\(R\))? (\(G\))?
but yes, that's a good way of going about it. You can test to see if each is present with:
#if %1 {n is present} {n isn't present}
#if %2 {r is present} {r isn't present}
#if %3 {g is present} {g isn't present} |
|
|
|
charneus Wizard
Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Fri Jun 26, 2009 12:54 am |
Sweet. Still a learning process with me and regexes. Always fun, though, and much easier to work with in trigger patterns sometimes.
Charneus |
|
|
|
sav Wanderer
Joined: 09 Jan 2006 Posts: 86
|
Posted: Fri Jun 26, 2009 8:57 am |
hmm, one slight problem.
(G) can be (G:a), (G:b) etc.
how do i capture that part? |
|
|
|
charneus Wizard
Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Fri Jun 26, 2009 5:12 pm |
Well, now that we know there's more information involved, can you give us what other possible outputs there are?
If it's JUST the G that changes, and it can be (G) or (G:a) or (G:b) or (G: and some lowercase letter), then that can be solved by doing:
#REGEX {^(\(N\) )?(\(R\) )?(\(G(?:\:[a-z])?\))?} {whatever}
I made a modification to the original one because I realized that it would always be looking for things like:
Note the spaces? Anyway, let us know if there are other things we need to account for, and if there are, please put them in one reply so we don't have to keep coming back and forth. ;)
Charneus |
|
|
|
sav Wanderer
Joined: 09 Jan 2006 Posts: 86
|
Posted: Fri Jun 26, 2009 11:12 pm |
heh, sorry. i'll try to condense it into one post.
ok, this is how it is.
(N) (R) (G:Arb) (FMR)
and like i said in my earlier post, the 4 different ones can be in any permutation. e.g. (N) (R) or (R) (G:Arb) or (N) (G:Arb) (FMR) etc. all could be present at the same time or none present too.
for (G:Arb), the Arb can be other things too. but its always a 2 or more letter word and the first letter is capitalized.
(N) (R) (FMR) don't change. they're either there or they're not. only the word after G: changes.
i'd also like to capture each individual part.
ok. i think that's it. at least till i think of something else.
thanks alot for your time/help. really appreciate it. =) |
|
|
|
charneus Wizard
Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Sat Jun 27, 2009 1:10 am |
Heh. You didn't even mention the FMR part, either.
Ok. Here is what you want:
Code: |
#REGEX {^(\(N\) )?(\(R\) )?(\(G(?:\:\w+)?\) )?(\(FMR\))?} {whatever} |
Like it was stated earlier, %1 is always going to be (N) or null, %2 is always going to be (R) or null, %3 is always going to be (G), (G:word), or null, and now %4 will always be (FMR) or null. If you're needing to capture the word after the G:, then use:
Code: |
#REGEX {^(\(N\) )?(\(R\) )?(\(G(?:\:(\w+))?\) )?(\(FMR\))?} (whatever} |
Everything will remain the same, except %4 is now going to be the word after G:, and %5 will be FMR.
Hope this does what you want/need it to...
Charneus |
|
|
|
sav Wanderer
Joined: 09 Jan 2006 Posts: 86
|
Posted: Sat Jun 27, 2009 9:32 am |
hmm, does it matter that these things that i wanna capture is right smack in the middle of a line of other data which i don't really need? (hence i didn't mention it)
H: 450/473 S: 348/390 FMR: 2/12% (N) (R) E: Pain
(N) (R) (G:Arb) (FMR) will appear between FMR: 2/12% and E: Pain. However, E: Pain may or may not be there. and the numbers after FMR: will change.
Sorry, i didn't want to capture the rest of the data so i didn't take it into account.
i keep on getting Fatal Trigger Error, Trigger loop detected. |
|
|
|
charneus Wizard
Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Sat Jun 27, 2009 10:33 am |
Ok. Let's do this. Tell me exactly what you want it to do, and what it can look like. That way, we can get this set up the way you want it to. That way, we don't have to keep going back and forth like this. :P A good example is:
My prompt looks like this:
123/123 hp 123/123 mp 123/123 mv gold: 12345 tnl: 12345
I want to capture my current hp, mp, mv, gold, and tnl and store them into individual variables. I also want them to be displayed on my status bar. The prompt never changes except for the numbers.
That way, we know what you want to do and the output that provides it.
Charneus |
|
|
|
sav Wanderer
Joined: 09 Jan 2006 Posts: 86
|
Posted: Sat Jun 27, 2009 9:43 pm |
Ok. Sorry, I'll restart from the top.
This is my prompt:
H: 475/475 S: 217/398 FMR: 1/30% (N) (R) (G:Abr) (FMR) Enemy: pain
"H:" "S:" "FMR:" "Enemy:" don't change. (N) (R) (G:Abr) (FMR) can be around in any permutation. "Abr" changes, but the first letter is always capitalized. There are 2 spaces after the % sign, and 1 space between Enemy and the last symbol of the (N) (R) (G:Abr) (FMR) regardless of which is present and which is not. I want to capture everything that changes. (N) (R) (G:Abr) (FMR) individually whether they're present or not, all the numbers and also what comes after "Enemy:" which can be a word or a number with a % sign. I will display them on my status bar, but i can do that once all the data is captured into variables.
and it looks like this when none of the (N) (R) (G:Abr) (FMR) are present:
H: 475/475 S: 398/398 FMR: 1/33% Enemy: pain
I think that's it. Sorry about that, and thanks for your help. |
|
|
|
oldguy2 Wizard
Joined: 17 Jun 2006 Posts: 1201
|
Posted: Sat Jun 27, 2009 11:38 pm |
Code: |
^H: \d+\/\d+ S: \d+\/\d+ FMR: \d+\/\d+\% (?:(\(N\))? (\(R\))? (\(G(?:\:[A-Z][a-z]*)?\))? (\(FMR\))? )?(?:Enemy: \w+)?$ |
You can can capture (N)|(R)|(G:Abr)|(FMR) out of that or they don't have to show up at all and neither does the Enemy part.
Will match:
H: 475/475 S: 217/398 FMR: 1/30% (N) (R) (G:Abr) (FMR) Enemy: pain
H: 475/475 S: 217/398 FMR: 1/30% Enemy: pain
H: 475/475 S: 217/398 FMR: 1/30% (N) (R) Enemy: pain
H: 475/475 S: 217/398 FMR: 1/30% (N) (R) (G:Abr) (FMR)
H: 475/475 S: 217/398 FMR: 1/30% (N) (R) (G) (FMR) Enemy: pain
And so on. |
|
|
|
charneus Wizard
Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Sun Jun 28, 2009 12:18 am |
Code: |
#REGEX {^H:\s+\d+\/\d+\s+S:\s+\d+\/\d+\s+FMR:\s+\d+\/\d+%\s+(\(N\) )?(\(R\) )?(\(G(?::(\w+))?\) )?(\(FMR\))?\s+Enemy: (\w+|\d+%)?} {#VAR NStatus %trim(%1);#VAR RStatus %trim(%2); #VAR GStatus %trim(%3);#VAR GWord %trim(%4);#VAR FMRStatus %trim(%5);#VAR EnemyStatus %trim(%6)} |
That should match everything you need. If you need anything else, let us know.
By the way, oldguy2, your matching for the G is extreme, since it's always going to be a word or nothing, and didn't allow for any other spaces (like one-digit numbers).
Charneus |
|
|
|
oldguy2 Wizard
Joined: 17 Jun 2006 Posts: 1201
|
Posted: Sun Jun 28, 2009 2:34 am |
Not sure what you are talking about. You put the same exact thing except yours will match a word with numbers in it. He said the first letter after G is always capitilized and I didn't know it could have numbers.
As far as spacing and everything he wanted captured I didn't see the part where he said it could have more than one space or where he said he wanted to capture the enemy status, so yeah you should put in the \s+ and capture the part after Enemy. |
|
|
|
charneus Wizard
Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Sun Jun 28, 2009 3:09 am |
Haha.. you're right, oldguy2. I'd forgotten that \w+ would include digits! See, still learning!
I just saw [A-Za-z] as a big mess when it could be shortened to \w+, anyway.
Speaking of which, I made a mistake in mine, too. And oldguy2, yours didn't account for the spaces after (N), (R), (G), and whatnot. If one of those isn't present, the space after it wouldn't be present, either. My mistake was not allowing for a space after (FMR).
Here...
Code: |
^H:\s+\d+\/\d+\s+S:\s+\d+\/\d+\s+FMR:\s+\d+\/\d+%\s+(\(N\) )?(\(R\) )?(\(G(?::(\w+))?\) )?(\(FMR\))?\s?Enemy: (\w+)? |
That should capture anything and everything that your prompt throws at you, sav. Hopefully, this is the final one we'll have to do! :D
Charneus |
|
|
|
oldguy2 Wizard
Joined: 17 Jun 2006 Posts: 1201
|
Posted: Sun Jun 28, 2009 3:54 am |
Quote: |
I just saw [A-Za-z] as a big mess when it could be shortened to \w+, anyway. |
That is not what I had. [A-Za-z]+ is not the same as [A-Z][a-z]+ because will match any word with or without caps like "aWordIs". [A-Z][a-z]+ will only match a word where the first letter is capitalized. [A-Z][a-z]* will match a word with the first letter in caps or just a capitalized letter by itself.
I had spaces in mine but only one space. You don't need the \s+ really unless you don't know how many spaces there are. All \s+ does is say there is at least one or more spaces. \s* would be one or zero spaces. Just putting a plain ol space " " is the same thing as \s and means it will match if there is one space between the word, numbers and so on but won't if there isn't. |
|
|
|
|
|