RoD Database zMud Trigger Set

Due to popular request, I've created a set of zMud settings that will read the output of an identify spell or auction list and parse it into a one-line RoD Database compatible line. The line is then echoed to the local screen so you can see it, and then added to the end of a file called RoD_Item-FromTriggers.txt in your zMud directory.

Click here to download the zMud script file itemgathertriggers-zmud705.zsc (9 KB)



Here is a explanation of how this 2-trigger and 2-alias zMud trigger set work:

Overview

There are two settings classes, named ITEMGATHER and ITEMPROCESS. ITEMGATHER is enabled when a incoming line from the mud starts with "Object '". ITEMGATHER then reads and stores every line from the mud for 4 seconds, after which it is disabled again. The ITEMPROCESS settings, which are always enabled, control monitoring for the "Object '" line, turning on and off the ITEMGATHER class, and then processing the captured mud text to attempt to build a RoD Database line from the data gathered. Once the data has been parsed, the resulting item database input line is written to a text file called RoD_Item-FromTriggers.txt in the zmud directory on the local machine. Part of the purpose of setting up the triggers in this manner is so that any Identify command, or any monitoring of the Auction channel will automatically result in the storing of RoD Database item lines for all items that cross the screen.

Logic Flow:

1. ITEMGATHER starts disabled, and ITEMPROCESS starts enabled.
2. The trigger in ITEMPROCESS waits for a line starting with "Object '" to come from the mud.
3. The itemlist is emptied, and then the first line (starting with "Object'") is stored in it.
4. The ITEMGATHER class is enabled, which turns on every-line capture.
5. A four-second temporary alarm is started, to call the ITEMPROCESSOR alias in four seconds.
6. The ITEMGATHER trigger captures each line, and puts it in the itemlist text list variable.
7. After four seconds expires, the ITEMPROCESSOR alias runs, which turns off the ITEMGATHER class.
8. Then it goes through the captured lines, one at a time, and parses what it finds into RoD Database Format.
9. Once parsed, the ITEMWRITE alias is called to write the itemdb database line to the RoD_Item-FromTriggers.txt file.

Expected Input / Output

The expected input is an item from Realms of Despair, from either Auction or Identify. For example, here is the input and output when a Sword of Legend comes across the mud:

Input:

Object 'Sword of Legend'...
It is a level 50 slashing weapon, weight 1.
Locations it can be worn: wield
Special properties: hum loyal magic metal
Alignments allowed: good
This weapon has a gold value of 200000.
Damage is 14 to 44 (average 29).
Affects hit roll by 13.
Affects damage roll by 13.
Affects hp by 75.
Affects mana by 125.
Affects affected_by by detect_evil protect
Affects luck by 2.
Affects dexterity by 2.
Affects strength by 2.
Affects constitution by 2.
Affects armor class by -20.

Output:

* | Sword of Legend | 50 | 0 | -20 | 14 | 44 | 13 | 13 | 75 | 125 | 2 | 2 | 2 | 0 | 0 | 2 | 0 | 0 | 1 | 200000 | hum loyal magic metal anti-neutral anti-evil | good affected_by detect_evil protect [L]

Errors:

You'll get the following error if you have square brackets set to evaluate:

ERROR!
The square brackets were stripped from the weapon types!
To fix this, please click VIEW, PREFERENCES, GENERAL, and under SCRIPT PARSER click on GENERAL PARSING
Then, on the right, uncheck "Allow [] for eval"

As the error indicates, the square braces are critical to the database, and the "Allow [] for eval" needs to be unchecked so that it is turned off for whatever character is going to be using this trigger set.

Code (in easy to read format):

#CLASS {ITEMGATHER} #TRIGGER {^*} {#var itemtoadd %trigger #additem itemlist @itemtoadd} #CLASS 0 #CLASS {ITEMPROCESS} #TRIGGER {^Object '} {#var itemlist {""} #t+ ITEMGATHER #var itemnum 0 #alarm +4 {ITEMPROCESSOR} #var itemtoadd %trigger #additem itemlist @itemtoadd} #ALIAS ITEMWRITE {#var namett {"RoD_Item-FromTriggers.txt"} #file 2 @namett #write 2 @itemdb #close 2} #ALIAS ITEMPROCESSOR { #t- ITEMGATHER #var itemnum %numwords( @itemlist, |) #noop num lines gathered - @itemnum - here are the lines gathered- #loo 1,@itemnum {#noop --- %word( @itemlist, %i, |)} #var istr1 {""} #var istr2 {""} #loo 3,21 {#var istr%i 0} #var istr22 {""} #var istr23 {""} #noop evaluating captured lines #loo 1,@itemnum { #if (%match( %word( @itemlist, %i, |), "Object '(%*)'(%*)", istr2, itemp) = 1) { #var istr2 %trim( @istr2) #noop @istr2 } #if (%match( %word( @itemlist, %i, |), "It is a level (%d) (%*), weight (%d)", istr3, istr1, istr20) = 1) { #var istr1 %trim( @istr1) #noop @istr3 @istr1 @istr20 } #if (%match( %word( @itemlist, %i, |), "Armor class is (%d) of (%d).", itemp, istr4) = 1) {#noop @istr4} #if (%match( %word( @itemlist, %i, |), "Locations it can be worn: (%*)", istr1) = 1) { #var istr1 %trim( @istr1) #noop @istr1 } #if (%match( %word( @itemlist, %i, |), "Special properties: (%*)", itemp) = 1) { #var istr22 %concat( @istr22, " ", %trim( @itemp)) #noop @istr22 } #if (%match( %word( @itemlist, %i, |), "Races allowed: (%*)", itemp) = 1) { #var istr23 %concat( @istr23, " ", %trim( @itemp)) #noop @istr23 } #if (%match( %word( @itemlist, %i, |), "Classes allowed: (%*)", itemp) = 1) { #var istr23 %concat( @istr23, " ", %trim( @itemp)) #noop @istr23 } #if (%match( %word( @itemlist, %i, |), "Genres allowed: (%*)", itemp) = 1) { #var istr23 %concat( @istr23, " ", %trim( @itemp)) #noop @istr23 #var iaso 1 #var iad 1 #var iar 1 #var iaf 1 #var iaa 1 #var iash 1 #if (%pos( "sorcerer", @itemp) > 0) {#var iaso 0} #if (%pos( "divinity", @itemp) > 0) {#var iad 0} #if (%pos( "rogue", @itemp) > 0) {#var iar 0} #if (%pos( "fighter", @itemp) > 0) {#var iaf 0} #if (%pos( "aberrant", @itemp) > 0) {#var iaa 0} #if (%pos( "shaman", @itemp) > 0) {#var iash 0} #if (@iaso = 1) {#var istr22 %concat( @istr22, " ", "anti-augurer anti-mage anti-nephandi")} #if (@iad = 1) {#var istr22 %concat( @istr22, " ", "anti-cleric")} #if (@iar = 1) {#var istr22 %concat( @istr22, " ", "anti-bladesinger anti-fathomer anti-thief")} #if (@iaf = 1) {#var istr22 %concat( @istr22, " ", "anti-paladin anti-ranger anti-warrior")} #if (@iaa = 1) {#var istr22 %concat( @istr22, " ", "anti-vampire")} #if (@iash = 1) {#var istr22 %concat( @istr22, " ", "anti-druid")} } #if (%match( %word( @itemlist, %i, |), "Alignments allowed: (%*)", itemp) = 1) { #var iag 1 #var ian 1 #var iae 1 #if (%pos( "good", @itemp) > 0) { #math iag @iag-1 #math iag @iag*-1 #var istr23 %concat( @istr23, " ", "good") } #if (%pos( "neutral", @itemp) > 0) { #math ian @ian-1 #math ian @ian*-1 #var istr23 %concat( @istr23, " ", "neutral") } #if (%pos( "evil", @itemp) > 0) { #math iae @iae-1 #math iae @iae*-1 #var istr23 %concat( @istr23, " ", "evil") } #if (@iag = 1) {#var istr22 %concat( @istr22, " ", "anti-good")} #if (@ian = 1) {#var istr22 %concat( @istr22, " ", "anti-neutral")} #if (@iae = 1) {#var istr22 %concat( @istr22, " ", "anti-evil")} } #if (%match( %word( @itemlist, %i, |), "This (%*) has a gold value of (%d)", itemp, istr21) = 1) {#noop gold : @istr21} #if (%match( %word( @itemlist, %i, |), "Damage is (%d) to (%d) ", istr6, istr7) = 1) {#noop damage : @istr6 @istr7} #if (%match( %word( @itemlist, %i, |), "Affects (%*) by (%*)", itemp, itemp2) = 1) { #var itemp2 %remove( ".", @itemp2) #var itemp3 0 #if (%pos( "armor class", @itemp) > 0) { #var istr5 @itemp2 #var itemp3 1 } #if (%pos( "hit roll", @itemp) > 0) { #math istr8 @istr8+@itemp2 #var itemp3 1 } #if (%pos( "damage roll", @itemp) > 0) { #math istr9 @istr9+@itemp2 #var itemp3 1 } #if (%pos( "hp", @itemp) > 0) { #math istr10 @istr10+@itemp2 #var itemp3 1 } #if (%pos( "mana", @itemp) > 0) { #math istr11 @istr11+@itemp2 #var itemp3 1 } #if (%pos( "strength", @itemp) > 0) { #math istr12 @istr12+@itemp2 #var itemp3 1 } #if (%pos( "dexterity", @itemp) > 0) { #math istr13 @istr13+@itemp2 #var itemp3 1 } #if (%pos( "constitution", @itemp) > 0) { #math istr14 @istr14+@itemp2 #var itemp3 1 } #if (%pos( "intelligence", @itemp) > 0) { #math istr15 @istr15+@itemp2 #var itemp3 1 } #if (%pos( "wisdom", @itemp) > 0) { #math istr16 @istr16+@itemp2 #var itemp3 1 } #if (%pos( "luck", @itemp) > 0) { #math istr17 @istr17+@itemp2 #var itemp3 1 } #if (%pos( "charisma", @itemp) > 0) { #math istr18 @istr18+@itemp2 #var itemp3 1 } #if (%pos( "moves", @itemp) > 0) { #math istr19 @istr19+@itemp2 #var itemp3 1 } #if (%pos( "save", @itemp) = 1) { #var itemp %trim( @itemp) #var itemp %concat( "Sv", %proper( %right( @itemp, 8))) #var itemp %concat( %left( @itemp, 4), @itemp2) #var istr23 %concat( %trim( @istr23), " ", @itemp) #var itemp3 1 } #if (%pos( "resistant", @itemp) = 1) { #var itemp %trim( @itemp) #var itemp %concat( "Res", %proper( %right( @itemp, 10))) #var istr23 %concat( %trim( @istr23), " ", @itemp, "(", @itemp2, ")") #var itemp3 1 } #if (@itemp3 = 0) {#var istr23 %concat( %trim( @istr23), " ", %trim( @itemp), " ", %trim( @itemp2))} #noop affects : @itemp @itemp2 } #if (%match( %word( @itemlist, %i, |), "(%*) appears to be of a (%*).", itemp, itemp2) = 1) { #var istr22 %concat( @istr22, " ", %trim( @itemp2)) #noop @itemp2 } #if (%match( %word( @itemlist, %i, |), "Casts spell (%*)", itemp) = 1) { #var istr22 %concat( @istr22, " Casts ", %trim( @itemp)) #noop @itemp } #if (%match( %word( @itemlist, %i, |), "Has (%*) of level (%*)", itemp, itemp2) = 1) { #var istr22 %concat( @istr22, " ", %trim( @itemp), " of level ", %trim( @itemp2), " ", %trim( %word( @itemlist, %i + 1, |))) #noop @istr22 } #if (%match( %word( @itemlist, %i, |), "Level (%d) spell(%*) of:", itemp, itemp2) = 1) { #var istr22 %concat( @istr22, " ", %trim( %word( @itemlist, %i, |)), " ", %trim( %word( @itemlist, %i + 1, |))) #noop @istr22 } } #noop processing formatting rules for individual fields #if (%pos( "a ", @istr2) = 1) {#var istr2 %right( @istr2, 2)} #if (%pos( "an ", @istr2) = 1) {#var istr2 %right( @istr2, 3)} #if (%pos( "the ", @istr2) = 1) {#var istr2 %right( @istr2, 4)} #if (%pos( "weapon", @istr1) > 1) { #var itemp %delete( @istr1, weapon) #noop istr1 @istr1 itemp @itemp #if (%pos( "pierce", @itemp) > 0) {#var istr23 %concat( @istr23, " [S]")} #if (%pos( "stab", @itemp) > 0) {#var istr23 %concat( @istr23, " [S]")} #if (%pos( "slash", @itemp) > 0) {#var istr23 %concat( @istr23, " [L]")} #if (%pos( "slice", @itemp) > 0) {#var istr23 %concat( @istr23, " [L]")} #if (%pos( "pound", @itemp) > 0) {#var istr23 %concat( @istr23, " [B]")} #if (%pos( "crush", @itemp) > 0) {#var istr23 %concat( @istr23, " [B]")} #if (%pos( "whip", @itemp) > 0) {#var istr23 %concat( @istr23, " [f]")} #if (%pos( "grep", @itemp) > 0) {#var istr23 %concat( @istr23, " [f]")} #if (%pos( "claw", @itemp) > 0) {#var istr23 %concat( @istr23, " [T]")} #if (%pos( "bite", @itemp) > 0) {#var istr23 %concat( @istr23, " [T]")} #if (%pos( "bolt", @itemp) > 0) {#var istr23 %concat( @istr23, " [M]")} #if (%pos( "arrow", @itemp) > 0) {#var istr23 %concat( @istr23, " [M]")} #if (%pos( "dart", @itemp) > 0) {#var istr23 %concat( @istr23, " [M]")} #if (%pos( "stone", @itemp) > 0) {#var istr23 %concat( @istr23, " [M]")} #if (%pos( "pea", @itemp) > 0) {#var istr23 %concat( @istr23, " [M]")} #if (%pos( "blast", @itemp) > 0) {#var istr23 %concat( @istr23, " [P]")} #if (%pos( "suction", @itemp) > 0) {#var istr23 %concat( @istr23, " [P]")} #if (%pos( "hitting", @itemp) > 0) {#var istr23 %concat( @istr23, " [P]")} #var istr1 {"*"} #var itemp {""} #if (%pos( "[", @istr23) = 0) { #show ERROR! #show The square brackets were stripped from the weapon types! #show To fix this, please click VIEW, PREFERENCES, GENERAL, and under SCRIPT PARSER click on GENERAL PARSING #show Then, on the right, uncheck "Allow [] for eval" } } #noop concatenating all 23 fields #var itemdb {" "} #loo 1,22 { #if ( @{istr%i} = 0) {#var istr%i {""}} #if (2 = %i) {#var itemdb %concat( @itemdb, %trim( @{istr%i}), " | ")} {#var itemdb %concat( @itemdb, %trim( @{istr%i}), " | ")} } #var itemdb %trim( %concat( @itemdb, %trim( @istr23))) #show @itemdb itemwrite #noop 'RoD Database Format: #noop ' 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 #noop 'Type | Name | Lv | AC | -AC| d1 | d2 | HR | DR | HP | MP | STR | DEX | CON | INT | WIS | LCK | CHA | MV | Wgt | Value | Properties | Other #noop note : need two spaces after item name in column 2} #CLASS 0 Thank you for your time! -Zistrosk, the Goody Two-Shoes-