|
Stowslee Wanderer
Joined: 20 Apr 2008 Posts: 69 Location: Watervliet, NY
|
Posted: Wed Jan 28, 2009 4:50 am
Catching a difficult set of triggers.... |
For me at least figuring out how to capture and store the following is proving extremely difficult.
[ 73] bladder slice [ 28] blue ink [ 26] bone
It presents itself on the screen as shown. And it just the first of many lines like it. I am trying to capture each value individually and store them as a variable.
[ 73] bladder slice would be stored in a single variable and so on.
My issue is catching the numbers inside the [ ]
Also if the value is 0 then it will not appear in the list.
Any ideas on how to catch these lines? |
|
|
|
Scirkhan Apprentice
Joined: 14 Sep 2007 Posts: 167 Location: aztx
|
Posted: Wed Jan 28, 2009 5:05 am |
#TRIGGER {~[ (%d)~] (*) ~[ (%d)~] (*) ~[ (%d)~] (*) } {#additem VarStowslees {~[ %1~] %2};#additem VarStowslees {~[ %3~] %4};#additem VarStowslees {~[ %5~] %6}}
Well I guess that's one way. |
|
|
|
Stowslee Wanderer
Joined: 20 Apr 2008 Posts: 69 Location: Watervliet, NY
|
Posted: Wed Jan 28, 2009 5:08 am |
I will give it a try thanks
Input the code...
Trigger reads
~[ (%d)~] (*) ~[ (%d)~] (*) ~[ (%d)~] (*)
and the command it executes
#additem Cache {~[ %1~] %2}
#additem Cache {~[ %3~] %4}
#additem Cache {~[ %5~] %6}
Doing this it stores nothing to the @Cache string.
Also... quick question. In doing this will I be able to refer to each items Number specifically?
[ 73] bladder slice
@bladderslice = 73 is my intent. If at all possible, or at least some way of referring to its value. |
|
|
|
Scirkhan Apprentice
Joined: 14 Sep 2007 Posts: 167 Location: aztx
|
Posted: Wed Jan 28, 2009 5:52 am |
Funny, I tested it and it worked.
#TRIGGER {~[ (%d)~] (*) ~[ (%d)~] (*) ~[ (%d)~] (*) } {#ADDKEY Cache {%2=%1|%4=%3|%6=%5}}
How's that? |
|
|
|
Stowslee Wanderer
Joined: 20 Apr 2008 Posts: 69 Location: Watervliet, NY
|
Posted: Wed Jan 28, 2009 6:05 am |
When using the full version it doesn't seem to catch anything, could it have to do with there being the possibility of two words?
When using ~[ (%d)~] (*) I get
bone slice [ 18] castorite [ 139] castorite slice =158
as the value... it copies the entire line. |
|
|
|
Scirkhan Apprentice
Joined: 14 Sep 2007 Posts: 167 Location: aztx
|
Posted: Wed Jan 28, 2009 6:20 am |
Using that trigger you just gave will capture the entire line.
So if you did #show @Cache you would Not get:
bladder slice73blue ink28bone26
Is this the entire line? [ 73] bladder slice [ 28] blue ink [ 26] bone
Or does it show more? |
|
|
|
Stowslee Wanderer
Joined: 20 Apr 2008 Posts: 69 Location: Watervliet, NY
|
Posted: Wed Jan 28, 2009 6:23 am |
It shows nothing when I use the #TRIGGER {~[ (%d)~] (*) ~[ (%d)~] (*) ~[ (%d)~] (*) } {#ADDKEY Cache {%2=%1|%4=%3|%6=%5}}
And this is everything I am attempting to capture... though it looks a lot prettier on the MUD screen to be sure.
Glancing into the cache, you see:
Code: |
[ 73] bladder slice [ 28] blue ink [ 26] bone
[ 158] bone slice [ 18] castorite [ 139] castorite slice
[ 685] cloth [ 48] eyeball [ 48] eyeball slice
[ 119] green ink [ 50] heart [ 53] heart slice
[ 5] iron [ 5] kidney [ 2] kidney slice
[ 31] leather [ 387] liver [ 568] liver slice
[ 50] lung [ 52] lung slice [ 165] ovary
[ 58] ovary slice [ 61] pineal [ 26] pineal slice
[ 107] purple ink [ 180] red ink [ 6] sileris
[ 87] spleen [ 89] spleen slice [ 79] stomach
[ 9] stomach slice [ 27] sulphurite slice [ 69] testis
[ 306] testis slice [ 10] tongue [ 53] tongue slice
[ 32] tumor [ 9] tumor slice [ 172] yellow ink
H:100% M:100% E:100% B:84% XP:35% [db eb] [Vote] <---- Prompt Line |
Spacing is way off on this... but this is absolutely everything exactly the way I receive it.
EDIT: Taz inserted code tags to show proper layout |
|
|
|
Scirkhan Apprentice
Joined: 14 Sep 2007 Posts: 167 Location: aztx
|
Posted: Wed Jan 28, 2009 6:52 am |
the type of trigger you asked for and what you asked it to do: ~[ (%d)~] (*)
Are a lot different and I can't do that right now.
However,
#TRIGGER {~[(*)~] (*) ~[(*)~] (*) ~[(*)~] (*)} {#ADDKEY Cache {%2=%1|%4=%3|%6=%5};#show 1}
Works for me.
You will probably still need a regex? trigger to fire off likes like
[ 306] testis slice [ 10] tongue, hopefully someone else can get you one.
I might be able to days later. |
|
|
|
Stowslee Wanderer
Joined: 20 Apr 2008 Posts: 69 Location: Watervliet, NY
|
Posted: Wed Jan 28, 2009 7:01 am |
I really appreciate your time and help... and I did actually learn quite a bit from what you showed me. I will be able to use what you showed me in other places. Thank you again.
And just tested the code you gave me above... worked perfectly. I should be able to work with that. |
|
|
|
Stowslee Wanderer
Joined: 20 Apr 2008 Posts: 69 Location: Watervliet, NY
|
Posted: Tue Feb 03, 2009 3:56 am |
Hopefully my last shot on this topic... I was able to create a set of triggers that will capture everything in the code listed above with a few exceptions and have no idea why.
I use the triggers
~[%s(%d)~] (%w)
Command - #var %2 %1
And
~[%s(%d)~] (%w) (%w)
Command #var %2%3 %1
Problem it it catches the first instance of the trigger on the line and each contains multiple instances. Is there a way to make it so the trigger fires on each instance on each line? |
|
|
|
Leitia Adept
Joined: 04 May 2007 Posts: 292 Location: Boston
|
Posted: Thu Feb 05, 2009 4:33 pm |
I worked on those problems for days some time ago. I don't play Iron Realms games lately, so I don't know how portable or valid this code is. I do remember a lot particular bugs with tracking names in my rift, but discovered it was totally reliable to just trigger on adding and removing from the rift. So the easy answer is to remove all from the cache, then enable your tracking triggers. In the hope of being portable, I tried a multistate trig to capture what was already in the rift. Something here might interest you.
Code: |
#TRIGGER "riftseeker1" {Glancing into the Rift, you see:} {#var Rifted "" {_nodef} {Pouring|TheRift};#t+ More1Run;#alarm +3 {#state riftseeker1 0;#T- More1Run;#T- Pouring|TheRift|Riftrig;#sh Rifting Closed;#co salmon}} "Pouring|TheRift|Riftrig"
#COND {%s ~[(%s%d)~] (*)%s ~[(%s%d)~] (*)%s ~[(%s%d)~] (*)} {#var rifted %additem( %1, @rifted);#var rifted %additem( %2, @rifted);#var rifted %additem( %3, @rifted);#var rifted %additem( %4, @rifted);#var rifted %additem( %5, @rifted);#var rifted %additem( %6, @rifted)} {looplines|param=99}
#TRIGGER "riftseeker3" {^%s ~[(%s%d)~] ({%w|%w %w})$} {#var rifted %additem( %1"|"2, @rifted)} "Pouring|TheRift|Riftrig" |
I included the interaction to my alchemy scripts. They were in that folder and may have some bearing on application
Code: |
#ALIAS CheckStock {#sh "~CheckStock code should be run once ingredient based and not rift content based.";#var PRH_DBName "";#var PRH_WarnFail "" {_nodef} {Pouring|DataGroup};#var PRH_Toss1 "";#var PRH_Toss2 "";#var PRH_GoGet "";#var PRH_HerbCrit "";#var PRH_PotCrit "";#func PRH_IGots %db( @AllRift, @PRH_DBName);#var PRH_PForFill "";#var PRH_PForNum "";#var RiftCost "" {_nodef} {Pouring|DataGroup};#loopdb @FillDB {#var PRH_PForFill %key;#var PRH_PForNum %val;GetHerbReq};#if (%null( @HerbByNames)) {MakeHNDB};#loopdb @RiftCost {#var PRH_DBName %db( @HerbByNames, %key);#if (@PRH_IGots < %val) {#addkey PRH_WarnFail %key %val|@PRH_IGots}};#if (@PRH_WarnFail) {#loopdb @PRH_WarnFail {#addi PRH_HerbCrit %key;#var PRH_Toss1 %item( %val, 1);#var PRH_Toss2 %item( %val, 2);#var PRH_GOGet %eval( @PRH_Toss1 - @PRH_Toss2);#sh " "%format( "&-20s &-9s &-7.0f &-6s &-7.0f &-6s &-7.0f", For %proper( %key)~- , Required: , @PRH_Toss1, Rifted: , @PRH_Toss2, Need:, @PRH_GoGet);#co firebrick};#loopdb @FillDB {#forall @PRH_HerbCrit {#if (%pos( %i, %db( @Ingredients, %key))) {#addi PotCrit %key}}};#sh " ";#sh "Potions Effected:";#co firebrick;#forall @PRH_PotCrit {#sh " "%i;#co firebrick};#sh " "};#unvar PRH_PForFill;#unvar PRH_PForNum;#unvar PRH_DBName;#unvar PRH_IGots;#unvar PRH_Toss1;#unvar PRH_Toss2;#unvar PRH_GoGet;#unvar PRH_HerbCrit;#unvar PRH_PotCrit;#unvar PRH_WarnFail {Pouring|DataGroup};#unvar RiftCost {Pouring|DataGroup}} "Pouring|TheRift"
#ALIAS IR {#T+ Pouring|TheRift|Riftrig;~IR} "Pouring|TheRift"
#ALIAS riftout {#loopdb @HerbByNames {#if (!%pos( "gold", %val)) {#add acount 1;#add bcount 1;#var oneitem %val;#var twoitem %db( @AllRift, @oneitem);#var oneitem %replace( @oneitem, "_", " ");#var oneitem %replace( @oneitem, "qqq", "'");#if (@acount = 1) {#var disp1 {@oneitem};#var dispn1 {@twoitem}};#if (@acount = 2) {#var disp2 {@oneitem};#var dispn2 {@twoitem}};#if (@acount = 3) {#var disp3 {@oneitem};#var dispn3 {@twoitem}};#if (@acount = 3 or @bcount = %numkeys( @herbbynames)) {#if (@disp1 and @dispn1 and @disp2 and @dispn2 and @disp3 and @dispn3) {#sh %format( "&-18s &-5.0f &-18s &-5.0f &-18s &-5.0f", @disp1, @dispn1, @disp2, @dispn2, @disp3, @dispn3)} {#if (@disp1 and @dispn1 and @disp2 and @dispn2) {#sh %format( "&-18s &-5.0f &-18s &-5.0f", @disp1, @dispn1, @disp2, @dispn2)} {#if (@disp1 and @dispn1) {#sh %format( "&-18s &-5.0f", @disp1, @dispn1)}}};#add acount -3;#co orange}}}} "Pouring|TheRift"
#ALIAS UsableRift {#var AllRift "" {_nodef} {Pouring|TheRift};#var testrifted @rifted {_nodef} {Pouring|Potions};#var xritem "";#var rcount 0;#var ncount "";#var instock "" {_nodef} {Pouring|Potions};#var nonstock "" {_nodef} {Pouring|Potions};#var testrifted %replace( @rifted, "'", "qqq");#var testrifted %replace( @testrifted, " ", "_");#func longn %i;#forall @testrifted {#if (@xritem) {#sh abc;#sh Item added %db( @AllRift, @longn) @longn;#co beige;#sh Item now is @longn @xritem;#co palegreen;#addkey AllRift @longn @xritem;#sh Item added @longn %db( @AllRift, @longn);#co palegreen;#var xritem ""} {#var xritem @longn}};MakeHNDB;#unvar testrifted {Pouring|Potions};#unvar rifted {Pouring};#unvar xritem;#unvar rcount;#unvar ncount;#unvar instock "" {_nodef} {Pouring|Potions};#unvar nonstock "" {_nodef} {Pouring|Potions};#unvar longn %i} "Pouring|TheRift"
#VAR AllRift {bayberry_bark616bellwort_flower329black_cohosh651bloodroot_leaf510blue_ink37blueberry2diamond_dust110eagleqqqs_feather23echinacea835ginger_root1371ginseng_root1158gold_ink2goldenseal_root749green_ink24hawthorn_berry355irid_moss581kelp240kola_nut430kuzu_root441ladyqqqs_slipper725lobelia_seed1163myrrh_gum1331obsidian1prickly_ash_bark572prickly_pear695purple_ink20red_ink31sidewinder_skin145sileris315skullcap336slippery_elm705valerian823venom_sac92yellow_ink34ladyqqqs_slipper_root749weed40} {_nodef} "Pouring|TheRift"
#VAR Rifted {616|bayberry bark|329|bellwort flower|651|black cohosh|422|bloodroot leaf|37|blue ink|2|blueberry|110|diamond dust|23|eagle's feather|786|echinacea|763|goldenseal root|24|green ink|356|hawthorn berry|576|irid moss|346|kelp|432|kola nut|695|prickly pear|20|purple ink|31|red ink|131|sidewinder skin|315|sileris|336|skullcap|686|slippery elm|827|valerian|82|venom sac} {_nodef} "Pouring|TheRift"
#TRIGGER {You remove %d (*)~, bringing the total in the Rift to (%d).} {#co rosybrown;#var RiftInny "%1" {_nodef} {Pouring};#var RiftInnyN "%2" {_nodef} {Pouring};#var RiftInny %replace( "%1", "'", "qqq");#var RiftInny %replace( @RiftInny , " ", "_");#addkey AllRift @RiftInny @RiftInnyN;#unvar riftinny Pouring;#unvar riftinnyn Pouring} "Pouring|TheRift"
#TRIGGER {^You store %d (*)~, bringing the total to (%d).$} {#var RiftInny "%1" {_nodef} {Pouring};#var RiftInnyN "%2" {_nodef} {Pouring};#var RiftInny %replace( "%1", "'", "qqq");#var RiftInny %replace( @RiftInny , " ", "_");#if (%iskey( @Allrift, @RiftInny)) {#addkey AllRift @RiftInny @RiftInnyN} {#addkey AllRift @RiftInny @RiftInnyN;MakeHNDB};#unvar riftinny Pouring;#unvar riftinnyn Pouring} "Pouring|TheRift" |
I made notes to myself in the above code. I am just offering how I was working out that problem, not finished scripts. I am not very experienced at this.
Damn, I have a lot of ginseng
EDIT:
Here is a referenced alias MakeHNDB. I have to quit looking at this. I feel drawn into this behemoth and see the above had been more developed and is quite dated.
Code: |
#var HerbByNames "" {_nodef} {Pouring|Datagroup}
#var PRH_GBNames ""
#var PRH_CKDude ""
#loopdb @AllRift {
#var PRH_CKDude %replace( %key, "_", "|")
#addkey PRH_GBNames %key @PRH_CKDude
}
#loopdb @PRH_GBNames {#forall %val {#if (%iskey( @pricelist, %i)) {#addkey HerbByNames %i %key}}}
#addkey HerbByNames gold "Available_GP"
#delkey HerbByNames venom
#unvar PRH_GBNames
#unvar PRH_CKDude |
|
|
Last edited by Leitia on Thu Feb 05, 2009 6:00 pm; edited 1 time in total |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Thu Feb 05, 2009 5:57 pm |
Damn, you guys like making this stuff more complex than it is.
Code: |
#trig {Glancing into the cache, you see:} {rift="";#t+ riftcap}
#cond {prompt} {#t- riftcap}
#regex "riftcap" {^\s+\[\s*(\d+)\] ([\w+ ']+?)(?:\s+\[\s*(\d+)\] ([\w+ ']+?))?(?:\s+\[\s*(\d+)\] ([\w+ ']+?))?$} {#addkey rift {%2} {%1};#if (%4) {#addkey rift {%4} {%3}};#if (%6) {#addkey rift {%6} {%5}}} "" {disable} |
Tested (in CMUD, but should still be fine), working, job done. It even works for lines with fewer than three items.
Also, I see your ginseng and raise you 2000 toadstool in the rift and another 1500 in pocketbelts :)
EDIT: Getting an item back out, btw, in case you don't know how to do that, is just %db(@rift,"exactnameusedincache"). You need to use %db rather than the simpler @rift.itemname syntax because some of them have spaces and apostrophes. |
|
|
|
Leitia Adept
Joined: 04 May 2007 Posts: 292 Location: Boston
|
Posted: Thu Feb 05, 2009 6:09 pm |
*snuggle fang
Cool, I know I had finally gotten my trigger to work for cases of one or two items as well as the three, just not sure when now. I think that one up there (mine) does that though. Saving the page for reference. |
|
|
|
Leitia Adept
Joined: 04 May 2007 Posts: 292 Location: Boston
|
Posted: Thu Feb 05, 2009 6:17 pm |
I replaced spaces because I wanted predictable keys for future scripts, I replace apostrophes because I have no clue how all the functions define them. I did see Larkin use keys with spaces, but was not sure how I would process keys. Personally, spaces seem wrong. I don't know why. My ex told me the Romans didn't use them in Latin
|
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Thu Feb 05, 2009 7:14 pm |
The trouble with replacing them is that it only really helps when you yourself are interacting with the data. Any script that's working with it can be set to use a name with spaces just as easily as it can to use one without, and scripts that're using some data from the game will need to do the replacing every time. And the actual help it'll give you as a user is dubious, anyway, since you'll have to remember to replace the stuff you got rid of every time.
|
|
|
|
Leitia Adept
Joined: 04 May 2007 Posts: 292 Location: Boston
|
Posted: Thu Feb 05, 2009 8:19 pm |
I had found #IF (whatever==%i) while looping and looping dbs unmanageable with spaced data, at least as I recall. My scripts were horrendous though, the output was beautiful, but the logic was interminable. I am sure I can find examples of why I needed to replace, only I would be afraid my methods were clunky and everyone else would have done something simple instead to the same results
|
|
|
|
Stowslee Wanderer
Joined: 20 Apr 2008 Posts: 69 Location: Watervliet, NY
|
Posted: Sun Feb 08, 2009 1:59 am |
Thank you guys very much, and the script you wrote up Fang worked incredibly well. I really appreciate the assistance.
|
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Sun Feb 08, 2009 3:00 am |
In retrospect, I probably should've made the #trig {prompt} a #cond {prompt} instead. You may wish to delete the first two triggers and make that change. I've edited the post above.
|
|
|
|
|
|