Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Skrull
Newbie


Joined: 08 Jan 2022
Posts: 4

PostPosted: Sat Jan 08, 2022 4:08 pm   

Help with trigger and DB
 
Hello was hoping to get some assistance and I wasn't having the best of luck finding the solution. I originally had this working in zmud, but having issues with cmud hoping someone can quickly tell me what I have incorrect.

So one of the guilds my character in only progresses on levels for killing worthy monsters so I'm trying to track how many it takes.

My trigger is

You grin proudly as you slay (*)

I created a database named Grade19 with two columns - Column 1 = Monster Type = Text and Column 2 = Kills Type = Number

Script I currently have

#DBLOAD Grade19
#FIND "%1" All Monster 1
#IF %null(%rec) {#NEW All {Monster=%1|Kills=1}} {&Kills=%eval(&Kills+1)}
#DBRESET
say ********* Total Worthy = %sum( Kills)

I get the following ERROR: Trigger "You grin proudly as you slay (*)" fired but did not compile
Reply with quote
chaossdragon
Apprentice


Joined: 09 Apr 2008
Posts: 167

PostPosted: Sun Jan 09, 2022 12:29 am   
 
If you was to do...

#LOOPDB @Grade19 {#SHOW %key "=" %val}

what do you see?
Reply with quote
Skrull
Newbie


Joined: 08 Jan 2022
Posts: 4

PostPosted: Sun Jan 09, 2022 3:33 am   
 
So only having that line in the mud nothing happens, and below is what the debugger shows

0.0000 | You grin proudly as you slay Guardian of justice.
0.0000 | f DarkerRe | Pattern: You grin proudly as you slay (*) : (%1="Guardian of justice.")
0.0001 | c DarkerRe | exec : Pattern "You grin proudly as you slay (*)" : #LOOPDB @Gra...

Wasn't able to get it to show more on that last line.
Reply with quote
chaossdragon
Apprentice


Joined: 09 Apr 2008
Posts: 167

PostPosted: Sun Jan 09, 2022 4:38 pm   
 
looks like it's not writing to the dbvar. I'm not super well versed in that myself... i've tried to learn but it's just out of my pay grade.
hpoonis, shalamar and a few others would more or less instantly see the problem and how to fix it though. wish I was smarter lol.
Reply with quote
Skrull
Newbie


Joined: 08 Jan 2022
Posts: 4

PostPosted: Sun Jan 09, 2022 6:59 pm   
 
No worries, but thanks for the reply.
Reply with quote
hpoonis2010
Adept


Joined: 18 Jun 2019
Posts: 279

PostPosted: Mon Jan 10, 2022 10:16 am   
 
I have had problems with the database module. It serves little or no purpose really. A lot of the problems in cMud come from window handling (it is unstable) and the DB module is no exception. So you are best served avoiding it.

Using 'database' variables as Mr. Chaosd suggests is more practical, and quicker when referencing/performing lookups.

I will assume "monster type" is just the 'monster' name which is going to be a variable pattern. This is going to be your data 'key' and the count (number of times that monster has been killed) is going to be the value. Your dbvar (call it grade19/monsterKills) will be used to store all these items.

For convenience, you can just make a blank VAR (either in the editor or using #VAR). What I will say is this, when creating or writing to your dbvar, it is going to be preferable to quantify it (at least) to the parent class. This will prevent any confusion in case you have similar var names, or if you have imported a 3rd-party package and that creator has made vars which may have similar (or same) names.

We'll call your parent class MONSTERS. So to create your dbvar, in the editor, make a variable. The keys in your dbvar will be each monster pattern.

MONSTERS/grade19

You want to read in the kill count for a specific monster, increment the kill count, then write the 'record' back.

This should test if the monster key exists then add the monster count+1 to a local var. If the key doesn't exist the killCount is (effectively) set to 1. The data is then written back to the var.

Code:
#TR monsterKillTrig {You grin proudly as you slay ($monster:*)} {
   #LOCAL $killCount
   #IF (%iskey(@MONSTERS/grade19,$monster)) {
      $killCount=@MONSTERS/grade19.$monster.killed+1
      } {$killcount=$killCount+1}
   #ADDKEY MONSTERS/grade19 $monster $killCount
    }


You should end up with a variable containing (eg)


KEY                   VALUE
fred                  1
ginger                3
kelly                 2
jackson               6
Guardian of Justice   4


Getting data out for one 'record' is just as simple. Eg.,

$object=@MONSTER/grade19.jackson

or

$object=%db(@MONSTER/grade19,'Guardian of Justice')

but you can use %dbkeys(@MONSTERS/grade19) to create a stringlist of all the var's keys and loop through them all (#FORALL) or pluck each one out as you would for a regular string list.
Reply with quote
Vallick
Beginner


Joined: 18 Dec 2021
Posts: 11
Location: North Idaho

PostPosted: Sun Jan 16, 2022 5:33 am   
 
OK so at this point of my life I'm totally lost trying to grasp writing a trigger. Would someone be willing to help me out and write one?

The output Im trying to capture to a database changes based on items, but provided a few examples below. The database name is Lores. Fields I have set up so far that seemed to make sense (totally willing to edit as needed)
Lore type (set to text) True Name (Item's will show with one name in inventory/equiped, but show slightly different when lored, True name being the way item shows in inventory and on ground) Stat, multiple choice for Con, Str, Wis, INt, Dex, Con, CHa, then the fields in the lore's themselves, object, item type, Mat Class, Weight, Value, affects, Affects, item is, apply, wearable, stat, damage, other, material, class.

If anyone would be willing to take the time to assist I really appreciate it. My mind has not been the same since a accident years ago and I just can't seem to figure out this stuff anymore.

exa plate
The breastplate looks slightly tarnished, but sound. (90%)
You feel informed:
Object 'breastplate breast plate armor armour pearl onyx'
Item Type: ARMOR
Mat Class: metal Material: steel
Weight : 8 Value : 100

Affects : ARMOR by -5
Affects : DEX by 1
Item is : MAGIC
Apply : 7
A pearl and onyx breastplate is wearable: body.

exa jug
The jug is no longer beautiful because of the cracked surface. (37%)
You feel informed:
Object 'jug crystal enchanted eggnog'
Item Type: DRINKCON
Mat Class: crystal Material: crystal
Weight : 0 Value : 200

Item is : BLESS
Contains : 50
Capacity : 50
It's full of a creamy white liquid.


lore sword
You meticulously examine an electrum bastard sword.
You feel informed:
Object 'sword bastard electrum'
Item Type: WEAPON
Mat Class: metal Material: gold
Weight : 22 Value : 120

Affects : HITROLL by 3
Affects : DAMROLL by 3
Item is : MAGIC BLESS
Class : bastard_sword
Damage : 5D5
This weapon was made by Boras Trueforge.
Reply with quote
hpoonis2010
Adept


Joined: 18 Jun 2019
Posts: 279

PostPosted: Sun Jan 16, 2022 8:25 am   
 
Provide more examples of exam and lore.
How many different types of item exist? The type of data specific to an item type looks like it varies.

Your initial trigger(s) can be of type INPUT as you are going to identify according to TWO commands: exam, lore. However, you should be aware of any other mud commands which use (especially) exam. We will continue as if exam is only for equipment and anything which is to do with the contents of containers (bag, box, etc) has a different command.

You will want to contain all the triggers, aliases and any related functions within their own class which will be disabled until needed. This should prevent any unwanted actions. The important trigger is going to be the one which ends the data-collecting.

The process should run like

INPUT COMMAND
   ENABLE CLASS
   GATHER DATA
      TRIGGER PER LINE OF DATA
         WRITE DATA TO ITEM RECORD
   END DATA GATHERING
   WRITE DATA TO DB VAR
   DISABLE CLASS


Below is the XML for my equipment data gathering. I include it only as a guide. I store the collected data into a 'record' variable (EQ_VARS/itemRecord)which is in another class, as I re-use this variable again for all equipment-gathering processes (monster-kills, stores, inventory, found items), but this class of triggers collects any and all equipment data.

Code:
<class name="gatherEQdata" enabled="false" id="399">
  <onenable>#VAR EQ_VARS/itemRecord ""

//#WIN EQ "Starting ID  "%time("ss:zzz")</onenable>
  <trigger name="eqIDTrig" priority="10940" id="401">
    <pattern>~| Id%s: (%d)</pattern>
    <value>#ADDKEY EQ_VARS/itemRecord id %1</value>
  </trigger>
  <trigger name="eqDurationTrig" priority="7700" id="402">
    <pattern>~| Duration%s: (*)~|</pattern>
    <value>#ADDKEY EQ_VARS/itemRecord duration %trim(%1)</value>
  </trigger>
  <trigger name="eqEnchantsTrig" priority="10930" id="403">
    <pattern>~| Enchants:</pattern>
    <value>#VAR tempEQData/tempEnchants ""
#T+ enchantTrigs</value>
  </trigger>
  <trigger name="eqInflictsTrig" priority="10960" id="404">
    <pattern>~| Inflicts%s: (*)%sDamage</pattern>
    <value>#ADDKEY EQ_VARS/itemRecord inflicts %trim(%1)</value>
  </trigger>
  <trigger name="eqKeywordsTrig" priority="10990" id="405">
    <pattern>~| Keywords%s: (*)~|</pattern>
    <value>$keyWords=%list(%trim(%1)," ")
#ADDKEY EQ_VARS/itemRecord keywords $keyWords</value>
  </trigger>
  <trigger name="eqPortalDestTrig" priority="11000" id="406">
    <pattern>~| Leads to%s: (*)%s~|</pattern>
    <value>#ADDKEY EQ_VARS/itemRecord portexit %trim(%1)</value>
  </trigger>
  <trigger name="eqMaterialTrig" priority="11020" id="407">
    <pattern>~| Material%s: (%w)</pattern>
    <value>#ADDKEY EQ_VARS/itemRecord material %1</value>
  </trigger>
  <trigger name="eqNameTrig" priority="11050" id="408">
    <pattern>~| Name%s: ($itemName:*)%s~|</pattern>
    <value>$qt=%char(34)
$itemName=%trim($itemName)
//$itemName=%concat($qt,$itemName,$qt)
#ADDKEY EQ_VARS/itemRecord name $itemName</value>
    <arglist>$itemName</arglist>
  </trigger>
  <trigger name="eqScoreTrig" priority="11070" id="409">
    <pattern>~| Score%s: (%n)</pattern>
    <value>#ADDKEY EQ_VARS/itemRecord score %1</value>
  </trigger>
  <trigger name="eqSpecialsTrig" priority="11080" id="410">
    <pattern>~| Specials%s: (*)%s~|</pattern>
    <value>#ADDKEY EQ_VARS/itemRecord specials %trim(%1)</value>
  </trigger>
  <trigger name="eqRawMaterialTrig" priority="11110" id="411">
    <pattern>~| Type%s:{%s| Raw material:}($itemType:%w)%sLevel%s:%s($itemLevel:%d)</pattern>
    <value>#ADDKEY EQ_VARS/itemRecord type $itemType
#ADDKEY EQ_VARS/itemRecord level $itemLevel</value>
    <arglist>$itemType,$itemLevel</arglist>
  </trigger>
  <trigger name="eqWeapTypeTrig" priority="11120" id="412">
    <pattern>~| Weapon Type:%s($weapType:%w)%sAverage Dam :%s($aveDam:%d)%s~|</pattern>
    <value>#ADDKEY EQ_VARS/itemRecord weaptype $weapType
#ADDKEY EQ_VARS/itemRecord avedam $aveDam</value>
    <arglist>$weapType,$aveDam</arglist>
  </trigger>
  <trigger name="eqWearableTrig" priority="11150" id="413">
    <pattern>~| Wearable%s: (%w)</pattern>
    <value>#ADDKEY EQ_VARS/itemRecord wearable %1</value>
  </trigger>
  <trigger name="eqWorthTrig" priority="11160" id="414">
    <pattern>~| Worth%s:%s($itemWorth:%n)%sWeight%s:%s($itemWgt:%d)</pattern>
    <value>#ADDKEY EQ_VARS/itemRecord worth $itemWorth
#ADDKEY EQ_VARS/itemRecord weight $itemWgt</value>
    <arglist>$itemWorth,$itemWgt</arglist>
  </trigger>
  <trigger name="eqLocatedTrig" priority="11180" id="415">
    <pattern>~| {Found at|Clan Item}%s: (*)~|</pattern>
    <value>// Items "Found at" were either bought on auction or are quest/goal equipment.
#ADDKEY EQ_VARS/itemRecord located %trim(%1)</value>
  </trigger>
  <class name="tempEQData" id="416">
    <var name="tempFlags" id="252">glow|magic|V3</var>
    <var name="tempFood" type="StringList" id="270">
      <value>Will replenish hunger by 60%</value>
      <json>["Will replenish hunger by 60%"]</json>
    </var>
    <var name="tempDrink" type="StringList" id="271">
      <value>2 servings of dark-ale|Each serving replenishes thirst by 24%|Each serving replenishes hunger by 15%|This drink is 13 proof</value>
      <json>["2 servings of dark-ale","Each serving replenishes thirst by 24%","Each serving replenishes hunger by 15%","This drink is 13 proof"]</json>
    </var>
    <var name="tempSpells" type="StringList" id="272">
      <value>5 uses of level 100 'light arrow'</value>
      <json>["5 uses of level 100 'light arrow'"]</json>
    </var>
    <var name="tempResistMods" type="Record" id="284">
      <value>Pierce=4|All physical=5|Light=-4|All magic=4|Fire=-4|Bash=4|Acid=-8|Slash=8</value>
      <json>{"Pierce":4,"All physical":5,"Light":-4,"All magic":4,"Fire":-4,"Bash":4,"Acid":-8,"Slash":8}</json>
    </var>
    <var name="tempBagdata" type="Record" id="287">
      <json>{}</json>
    </var>
    <var name="tempEnchants" type="Record" id="310">
      <value>reson="Luck=3"</value>
      <json>{"reson":{"Luck":3}}</json>
    </var>
    <var name="tempStatMods" type="Record" id="311">
      <value>Strength=5|Mana=-50|Luck=2|Damage roll=6</value>
      <json>{"Strength":5,"Mana":-50,"Luck":2,"Damage roll":6}</json>
    </var>
    <var name="tempSkillmods" type="Record" id="312">
      <value>Trip=5</value>
      <json>{"Trip":5}</json>
    </var>
    <var name="tempBag" type="Record" id="505">
      <value>in_wgt=80% of their usual weight|bagcap=50|heaviest=5</value>
      <json>{"in_wgt":"80% of their usual weight","bagcap":50,"heaviest":5}</json>
    </var>
    <var name="tempAffectMods" id="523">Haste</var>
  </class>
  <class name="bagTrigs" enabled="false" id="417">
    <trigger name="end_bagdata" priority="11320" id="418">
      <pattern>+----</pattern>
      <value>#ADDKEY EQ_VARS/itemRecord container @tempBag
#T- bagTrigs</value>
    </trigger>
    <trigger name="inWgtTrig" priority="10290" id="419">
      <pattern>Items inside weigh (*)~|</pattern>
      <value>#ADDKEY tempEQData/tempBag in_wgt %trim(%1)</value>
    </trigger>
  </class>
  <trigger name="eqBagCapTrig" priority="10180" id="430">
    <pattern>~| Capacity%s:%s($bagCap:%d)%sHeaviest Item:%s($hvyItem:%d)%s~|</pattern>
    <value>#VAR tempEQData/tempBag ""
#T+ bagTrigs

#ADDKEY tempEQData/tempBag bagcap $bagCap
#ADDKEY tempEQData/tempBag heaviest $hvyItem</value>
    <arglist>$bagCap,$hvyItem</arglist>
  </trigger>
  <trigger name="eqDamTypeTrig" priority="10070" id="431">
    <pattern>%sDamage Type : (%w)</pattern>
    <value>#ADDKEY EQ_VARS/itemRecord damtype %1</value>
  </trigger>
  <trigger name="eqNotesTrig" priority="10120" id="432">
    <pattern>%sNotes%s: (*)~|</pattern>
    <value>#ADDKEY EQ_VARS/itemRecord notes %trim(%1)</value>
  </trigger>
  <trigger name="drinkTrig" priority="10240" id="433">
    <pattern>~| Drink%s: (*).%s~|</pattern>
    <value>#VAR tempEQData/tempDrink ""
#T+ drinkTrigs
#ADDITEM tempEQData/tempDrink %trim(%1)
</value>
  </trigger>
  <trigger name="endGatherEQData" priority="10760" id="435">
    <pattern>-----+</pattern>
    <trigger param="1">
      <pattern>^$</pattern>
      <value>#T- gatherEQData</value>
    </trigger>
  </trigger>
  <trigger name="eqFlagsTrig" priority="10090" id="437">
    <pattern>~| Flags%s: (*)~|</pattern>
    <value>#VAR tempEQData/tempFlags ""
#T+ flagTrigs

tempEQData/tempFlags=%replace(%replace(%concat(@tempFlags,%trim(%1))," ",""),",","|")</value>
  </trigger>
  <trigger name="eqFoodTrig" priority="10150" id="439">
    <pattern>~| Food%s: (*)~|</pattern>
    <value>#VAR tempEQData/tempFood ""
#T+ foodTrigs
#ADDITEM tempEQData/tempFood %trim(%1)</value>
  </trigger>
  <trigger name="resist1ItemTrig" priority="11270" id="441">
    <pattern>| Resist Mods: ({@resistModTypes})%s: (%n)%s~|</pattern>
    <value>tempEQData/tempResistMods=""
#T+ resistModTrigs

#ADDKEY tempEQData/tempResistMods %1 %2</value>
  </trigger>
  <trigger name="resist2ItemTrig" priority="10640" id="442">
    <pattern>~| Resist Mods: ({@resistModTypes})%s: (%n)%s({@resistModTypes})%s: (%n)%s~|</pattern>
    <value>tempEQData/tempResistMods=""
#T+ resistModTrigs

#ADDKEY tempEQData/tempResistMods %1 %2
#ADDKEY tempEQData/tempResistMods %3 %4

// ^~| Resist Mods: ({@resistModTypes})%s: (%n)%s({@resistModTypes})%s: (%n)%s~|</value>
  </trigger>
  <trigger name="skillModsTrig" priority="10020" id="443">
    <pattern>~| Skill Mods : Modifies (*) by (%n)%s~|</pattern>
    <value>tempEQData/tempSkillMods=""
#T+ skillModTrigs

#ADDKEY tempEQData/tempSkillmods %trim(%1) %2</value>
  </trigger>
  <trigger name="spellsTrig" priority="10200" id="445">
    <pattern>~| Spells%s: (*)~|</pattern>
    <value>tempEQData/tempSpells=""
#T+ spellTrigs

#ADDITEM tempEQData/tempSpells %trim(%1)</value>
  </trigger>
  <trigger name="stats1ItemTrig" priority="10880" id="447">
    <pattern>~| Stat Mods  : ({@statModTypes})%s: (%n)%s           ~|</pattern>
    <value>tempEQData/tempStatMods=""
#T+ statModTrigs

#ADDKEY tempEQData/tempStatMods %1 %2</value>
  </trigger>
  <trigger name="stats2ItemTrig" priority="10910" id="448">
    <pattern>~| Stat Mods  : ({@statModTypes})%s: (%n)%s({@statModTypes})%s: (%n)%s~|</pattern>
    <value>tempEQData/tempStatMods=""
#T+ statModTrigs

#ADDKEY tempEQData/tempStatMods %1 %2
#ADDKEY tempEQData/tempStatMods %3 %4</value>
  </trigger>
  <class name="drinkTrigs" enabled="false" id="473">
    <trigger name="moreDrinkTrig" param="1" priority="10260" id="434">
      <pattern>~|%s: (*).%s~|</pattern>
      <value>#ADDITEM tempEQData/tempDrink %trim(%1)</value>
    </trigger>
    <trigger name="endDrinkTrig" priority="5260" id="474">
      <pattern>+-----</pattern>
      <value>#ADDKEY EQ_VARS/itemRecord drink @tempDrink
#T- drinkTrigs</value>
    </trigger>
  </class>
  <class name="flagTrigs" enabled="false" id="475">
    <trigger name="moreFlagsTrig" param="1" priority="10100" id="438">
      <pattern>~|%s: (*)~|</pattern>
      <value>tempEQData/tempFlags=%replace(%replace(%concat(@tempFlags,%trim(%1))," ",""),",","|")
</value>
    </trigger>
    <trigger name="endFlagsTrig" priority="5300" id="476">
      <pattern>+-----</pattern>
      <value>#ADDKEY EQ_VARS/itemRecord flags @tempFlags
#T- flagTrigs</value>
    </trigger>
  </class>
  <class name="foodTrigs" enabled="false" id="477">
    <trigger name="moreFoodTrig" param="1" priority="10160" id="440">
      <pattern>~|%s: (*).~|</pattern>
      <value>#ADDITEM tempEQData/tempFood %trim(%1)</value>
    </trigger>
    <trigger name="endFoodTrig" priority="5290" id="478">
      <pattern>+-----</pattern>
      <value>#ADDKEY EQ_VARS/itemRecord food @tempFood
#T- foodTrigs</value>
    </trigger>
  </class>
  <class name="statModTrigs" enabled="false" id="479">
    <trigger name="endStatModsTrig" priority="10840" id="486">
      <pattern>+----</pattern>
      <value>#ADDKEY EQ_VARS/itemRecord statmods @tempStatMods

#T- statModTrigs</value>
    </trigger>
    <trigger name="moreStatMods1Trig" priority="10860" id="487">
      <pattern>~|%s({@statModTypes})%s: (%n)%s~|</pattern>
      <value>#ADDKEY tempEQData/tempStatMods %1 %2
</value>
    </trigger>
    <trigger name="moreStatMods2Trig" priority="10740" id="488">
      <pattern>~|%s({@statModTypes})%s: (%n)%s({@statModTypes})%s: (%n)%s~|</pattern>
      <value>#ADDKEY tempEQData/tempStatMods %1 %2
#ADDKEY tempEQData/tempStatMods %3 %4</value>
    </trigger>
  </class>
  <class name="resistModTrigs" enabled="false" id="480">
    <trigger name="endResistModTrig" priority="11200" id="481">
      <pattern>+----</pattern>
      <value>#ADDKEY EQ_VARS/itemRecord resists @tempEQData/tempResistMods

#T- resistModTrigs</value>
    </trigger>
    <trigger name="moreResist1ItemTrig" priority="11230" id="483">
      <pattern>|%s({@resistModTypes})%s: (%n)%s~|</pattern>
      <value>#ADDKEY tempEQData/tempResistMods %1 %2</value>
    </trigger>
    <trigger name="moreResist2ItemTrig" priority="11250" id="484">
      <pattern>~|%s({@resistModTypes})%s: (%n)%s({@resistModTypes})%s: (%n)%s~|</pattern>
      <value>#ADDKEY tempEQData/tempResistMods %1 %2
#ADDKEY tempEQData/tempResistMods %3 %4</value>
    </trigger>
  </class>
  <var name="resistModTypes" type="StringList" id="482">
    <value>Acid|Air|All magic|All physical|Bash|Cold|Disease|Earth|Electric|Energy|Fire|Holy|Light|Magic|Mental|Negative|Pierce|Poison|Shadow|Slash|Sonic|Water</value>
    <json>["Acid","Air","All magic","All physical","Bash","Cold","Disease","Earth","Electric","Energy","Fire","Holy","Light","Magic","Mental","Negative","Pierce","Poison","Shadow","Slash","Sonic","Water"]</json>
  </var>
  <var name="statModTypes" type="StringList" id="489">
    <value>Moves|Strength|Constitution|Dexterity|Hit points|Intelligence|Mana|Luck|Hit roll|Damage roll|Wisdom</value>
    <json>["Moves","Strength","Constitution","Dexterity","Hit points","Intelligence","Mana","Luck","Hit roll","Damage roll","Wisdom"]</json>
  </var>
  <class name="enchantTrigs" enabled="false" id="490">
    <trigger name="resonTrig" priority="10490" id="491">
      <pattern>^~| Resonate%s: ({@enchantTypes}) (%n)</pattern>
      <value>#ADDKEY $tempReson %1 %2
#ADDKEY tempEQData/tempEnchants reson $tempReson</value>
      <trigger param="1">
        <pattern>%s: (%w) (%n)</pattern>
        <value>#SWITCH (%1)
  (%pos("Luck",%1)) {#ADDKEY get_item_data/temp_enchants resLUCK %2}
  (%pos("Wisdom",%1)) {#ADDKEY get_item_data/temp_enchants resWIS %2}

#STATE 1</value>
      </trigger>
    </trigger>
    <trigger name="illumTrig" priority="10530" id="493">
      <pattern>^~| Illuminate :%s({@enchantTypes}) (%n)</pattern>
      <value>#ADDKEY $tempIllum %1 %2
#ADDKEY tempEQData/tempEnchants illum $tempIllum</value>
      <trigger param="1">
        <pattern>$s: (*) (%n)%s</pattern>
        <value>#SWITCH (%1)
  (%pos("Luck",%1)) {#ADDKEY tempEQData/tempEnchants illLUCK %2}
  (%pos("Wisdom",%1)) {#ADDKEY get_item_data/temp_enchants illnWIS %2}

#STATE 1</value>
      </trigger>
    </trigger>
    <trigger name="endEnchantTrig" priority="10570" id="495">
      <pattern>+-----</pattern>
      <value>#ADDKEY EQ_VARS/itemRecord enchants @tempEnchants

#T- enchantTrigs</value>
    </trigger>
    <trigger name="solidTrig" priority="10600" id="496">
      <pattern>^~| Solidify%s:%s(*) (%n)</pattern>
      <value>#ADDKEY $tempSolid %1 %2
#ADDKEY tempEQData/tempEnchants solid $tempSolid</value>
      <trigger param="1">
        <pattern>^%s: (*) (%n)%s</pattern>
        <value>#SWITCH (%trim(%1))
  (%pos("Hit roll",%1)) {#ADDKEY get_item_data/temp_enchants solidHR %2}
  (%pos("Damage roll",%1)) {#ADDKEY get_item_data/temp_enchants solidDR %2}
   
#STATE 1</value>
      </trigger>
    </trigger>
  </class>
  <var name="enchantTypes" type="StringList" id="498">
    <value>Hit roll|Damage roll|Wisdom|Luck</value>
    <json>["Hit roll","Damage roll","Wisdom","Luck"]</json>
  </var>
  <class name="skillModTrigs" enabled="false" id="499">
    <trigger name="moreSkillModsTrig" param="1" priority="10040" id="444">
      <pattern>~|%sModifies (*) by (%n)%s~|</pattern>
      <value>#ADDKEY tempEQData/tempSkillmods %trim(%1) %2
</value>
    </trigger>
    <trigger name="endSkillModsTrig" priority="5550" id="500">
      <pattern>+-----</pattern>
      <value>#ADDKEY EQ_VARS/itemRecord skillmods @tempSkillmods
#T- skillModTrigs</value>
    </trigger>
  </class>
  <class name="spellTrigs" enabled="false" id="501">
    <trigger name="moreSpellsTrig" param="1" priority="10220" id="446">
      <pattern>~|%s: (*)~|</pattern>
      <value>tempEQData/tempSpells=%additem(%trim(%1),@tempSpells)
</value>
    </trigger>
    <trigger name="endSpellsTrig" priority="5580" id="502">
      <pattern>+-----</pattern>
      <value>#ADDKEY EQ_VARS/itemRecord spells @tempSpells
#T- spellTrigs</value>
    </trigger>
  </class>
  <class name="affectModTrigs" enabled="false" id="520">
    <trigger name="endAffectModsTrig" priority="5550" id="521">
      <pattern>+-----</pattern>
      <value>#ADDKEY EQ_VARS/itemRecord affectmods @tempAffectMods
#T- affectModTrigs</value>
    </trigger>
    <trigger name="moreAffectsTrig" param="1" priority="10100" id="522">
      <pattern>~|%s: (*)~|</pattern>
      <value>tempEQData/tempAffectMods=%replace(%replace(%concat(@tempAffectMods,%trim(%1))," ",""),",","|")</value>
    </trigger>
  </class>
  <trigger name="affectsModTrig" priority="5240" id="524">
    <pattern>~| Affect Mods: (*)~|</pattern>
    <value>#VAR tempEQData/tempAffectMods ""
#T+ affectModTrigs

tempEQData/tempAffectMods=%replace(%replace(%concat(@tempAffectMods,%trim(%1))," ",""),",","|")</value>
  </trigger>
  <trigger priority="5250" id="525">
    <pattern>~| Heal Rate  : (%w) ~[(%n)~]%s{(%w) ~[(%n)~]%s|%s}~|</pattern>
    <value>#LOCAL $object
#IF (%numparam()=2) {
  #ADDKEY $object %1 %2
  #ADDKEY EQ_VARS/itemRecord hrate $object
  } {
    #ADDKEY $object %1 %2
    #ADDKEY $object %3 %4
    #ADDKEY EQ_VARS/itemRecord hrate $object
    }</value>
  </trigger>
</class>


ItemRecord
Code:
  <var name="itemRecord" type="Record" id="329">
    <value>material=light|mob=an Order of the Light soldier|avedam=215|weight=2|level=98|wearable=wield|located=The Yurgach Domain|specials=sharp|weaptype=dagger|inflicts=light|worth=766|id=2611235104|flags="glow|magic|V3"|damtype=Light|zone=Yurgach Domain|type=Weapon|room=29505|name=The Blade of Light|statmods="Strength=5|Mana=-50|Luck=2|Damage roll=6"|score=970|keywords="blade|light"</value>
    <json>{"material":"light","mob":"an Order of the Light soldier","avedam":215,"weight":2,"level":98,"wearable":"wield","located":"The Yurgach Domain","specials":"sharp","weaptype":"dagger","inflicts":"light","worth":766,"id":2611235104,"flags":["glow","magic","V3"],"damtype":"Light","zone":"Yurgach Domain","type":"Weapon","room":29505,"name":"The Blade of Light","statmods":{"Strength":5,"Mana":-50,"Luck":2,"Damage roll":6},"score":970,"keywords":["blade","light"]}</json>
  </var>
Reply with quote
Vallick
Beginner


Joined: 18 Dec 2021
Posts: 11
Location: North Idaho

PostPosted: Sun Jan 16, 2022 4:30 pm   
 
As far as number of different Item types, maybe 30 to 100? No way in advance I could anticipate all of the item types, and new item types are prone to be added at any time. Based on all the information you've been able to provide, you've confirmed for me this is well above my ability to figure out anymore. For that I appreciate you. It also looks like enough work it's probably not worth anyone else's trouble, however if anyone is feeling magnanimous, this will be a much loved, and shared tool. If anyone is motivated to help out, some more useful information: Exam item would actually be a command that either would need to be ignored, or trigger to collect data would have to be turned on and off (as suggested with the separate class). Reason is once a item has a Scroll of legend lore recited on it, those stats will show until the item decays (Item's decay due to use, Time, or damage). Maybe because of this a alias would be usefull to capture the information as the reciting of a scroll of legend lore is a unique event? THere is also a game skill barbarian class's have called lore that out puts partial and semi accurate lore, to a almost perfect lore like the scroll. Maybe the Barbarian lore that out puts as "meticulously examine" would be saved, but I have no problem doing that manually if I chose to settle with a Barb lore on a item vs actually using a scroll. Barb lore is mostly used to determine if It's worth purchasing the lore scroll in game on a item. Last, due to the formatting/coding of the website, positioning/spacing is not exact to the mud output due to truncated spaces. (just realized need to add more category's such as effects and restricts)

rec lore cloak
You stop using a clear crystal sceptre.
You grab a scroll of legend lore.
You recite a scroll of legend lore which dissolves.
You feel informed:
Object 'cloak multicolored'
Item Type: WORN
Mat Class: cloth Material: wool
Weight : 3 Value : 90

Effects : HIDE

rec lore Chasuble
You recite a scroll of legend lore which dissolves.
You feel informed:
Object 'chasuble flowing white'
Item Type: ARMOR
Mat Class: cloth Material: wool
Weight : 8 Value : 100

Affects : INT by 1
Item is : BLESS
Restricts: NOMAGE NOTHIEF NOPALADIN NODRUID NORANGER NOWARRIOR NODARK_KNIGHT NOBARBARIAN NOBLACK_ROBE NORED_ROBE NOWHITE_ROBE NOSHAMAN
Apply : 5


rec lore ivory.ring
You grab a scroll of legend lore.
You recite a scroll of legend lore which dissolves.
You feel informed:
Object 'ring ivory'
Item Type: WORN
Mat Class: natural Material: bone
Weight : 2 Value : 95

Affects : CON by -2
Affects : STR by -1
Effects : INVISIBLE DETECT_INVISIBLE
Item is : MAGIC BLESS

rec lore hammer
You grab a scroll of legend lore.
You recite a scroll of legend lore which dissolves.
You feel informed:
Object 'hammer crystal clear'
Item Type: WEAPON
Mat Class: natural Material: natural_crystal
Weight : 15 Value : 600

Affects : HITROLL by 3
Affects : spell slots by +1 at level 5
Item is : HUM BLESS
Class : hammer
Damage : 3D5
This object is part of a larger set.


rec lore ring
You grab a scroll of legend lore.
You recite a scroll of legend lore which dissolves.
You feel informed:
Object 'ring crystal clear'
Item Type: WORN
Mat Class: natural Material: natural_crystal
Weight : 1 Value : 300

Affects : WIS by 1
Item is : MAGIC
This object is part of a larger set.


rec lore ruby
You grab a scroll of legend lore.
You recite a scroll of legend lore which dissolves.
You feel informed:
Object 'necklace ruby diamond'
Item Type: WORN
Mat Class: metal Material: gold
Weight : 3 Value : 500

Affects : INT by 1
Item is : ANTI_EVIL
Restricts: NOMAGE NOTHIEF NOPALADIN NORANGER NOWARRIOR NODARK_KNIGHT NOBARBARIAN NOBLACK_ROBE NORED_ROBE NOWHITE_ROBE

rec lore helmet
You grab a scroll of legend lore.
You recite a scroll of legend lore which dissolves.
You feel informed:
Object 'helmet crystal clear'
Item Type: ARMOR
Mat Class: natural Material: natural_crystal
Weight : 14 Value : 300

Affects : WIS by 1
Item is : MAGIC BLESS
Apply : 2
This object is part of a larger set.

rec lore buckler
You grab a scroll of legend lore.
You recite a scroll of legend lore which dissolves.
You feel informed:
Object 'shield old green dragon buckler'
Item Type: WORN
Mat Class: wood Material: vallenwood
Weight : 16 Value : 150

Affects : HP_REGEN by 2
Affects : MOVE_REGEN by 2
Restricts: NOTHIEF NOPALADIN NORANGER NOWARRIOR NODARK_KNIGHT NOBARBARIAN




Barb lore vs Scroll lore: exceptional:

You meticulously examine ruby lined belt.
You feel informed:
Object 'belt ruby lined'
Item Type: CONTAINER
Mat Class: metal Material: silver
Weight : 8 Value : 100

You sense that this item affects abilities.
Affects : ARMOR by -4
Item is : MAGIC BLESS
Restricts: NOMAGE NOBLACK_ROBE NORED_ROBE NOWHITE_ROBE

You recite a scroll of legend lore which dissolves.
You feel informed:
Object 'belt ruby lined'
Item Type: CONTAINER
Mat Class: metal Material: silver
Weight : 8 Value : 100

Affects : DEX by 1
Affects : ARMOR by -4
Item is : MAGIC BLESS
Restricts: NOMAGE NOBLACK_ROBE NORED_ROBE NOWHITE_ROBE

(you can see why the Barbarian lore is usefull, but not the final lore that would want to be saved as it omits the Dex modifier)


rec lore sword
You stop using an electrum bastard sword.
You grab a scroll of legend lore.
You recite a scroll of legend lore which dissolves.
You feel informed:
Object 'sword bastard electrum'
Item Type: WEAPON
Mat Class: metal Material: gold
Weight : 22 Value : 120

Affects : HITROLL by 3
Affects : DAMROLL by 3
Item is : MAGIC BLESS
Class : bastard_sword
Damage : 5D5
This weapon was made by Boras Trueforge.


(You'll notice in this one the game output sobering up in the middle of loring as well as Tesla's (another player) finishing memorization)
rec lore boots
Tesla closes her spellbook with a content look on her face.
You are now sober.
You grab a scroll of legend lore.
You recite a scroll of legend lore which dissolves.
You feel informed:
Object 'boots remarkable crafted'
Item Type: ARMOR
Mat Class: cloth Material: wool
Weight : 5 Value : 600

Affects : DEX by 1
Apply : 10


rec lore cape
You grab a scroll of legend lore.
You recite a scroll of legend lore which dissolves.
You feel informed:
Object 'cape shining serpent scale barbarity'
Item Type: WORN
Mat Class: hide Material: rawhide
Weight : 4 Value : 120

Affects : MOVE by 11
Affects : STR by 1
Restricts: NOMAGE NOTHIEF NOPALADIN NODRUID NOCLERIC NORANGER NOWARRIOR NODARK_KNIGHT NOBLACK_ROBE NORED_ROBE NOWHITE_ROBE NOSHAMAN


rec lore chest
You grab a scroll of legend lore.
You recite a scroll of legend lore which dissolves.
You feel informed:
Object 'chest decayed'
Item Type: CONTAINER
Mat Class: wood Material: pine
Weight : 48 Value : 15
Reply with quote
hpoonis2010
Adept


Joined: 18 Jun 2019
Posts: 279

PostPosted: Sun Jan 16, 2022 6:10 pm   
 
Take heart, it is not really as bad as you may think.

The variation in item type: worn, armor (armour is worn...ask any mediaeval knight!), container, wand etc is nothing to be concerned about. What IS important are the variations in detail provided by each item type. That batch of code I pasted caters for every possible line that an identify, lore, appraise, etc throws up(that I am aware of) in aardwolf. Should anything come up in the future, I shall alter, or create, triggers to compensate.

The kind of thing you will be triggering on are the patterns occurring between the start of your line and after the ': '.

Object 'chasuble flowing white'
Item Type: ARMOR
Mat Class: cloth Material: wool
Weight : 8 Value : 100

Affects : INT by 1
Item is : BLESS
Restricts: NOMAGE NOTHIEF NOPALADIN NODRUID NORANGER NOWARRIOR NODARK_KNIGHT NOBARBARIAN NOBLACK_ROBE NORED_ROBE NOWHITE_ROBE NOSHAMAN
Apply : 5

So you will need a trigger for every possible variation between '^' and ': '

When you KNOW that some item data is fixed, eg,. 'Weight' is a positive integer from 0-150 then you can use (%d); Value is a value between -500 and 1500 then use (%n). Item type is a one-word identifier, so you can use (%w), and if you want to make things easier you can %upper or %lower the result for testing.

It seems that 'You feel informed' is your primary trigger for exam and lore. Thus your enabling trigger is simple enough. The finalising trigger is the other important one. For aardwolf I have to match the pattern "+----" and a following blank line, so I need a 2-stage trigger. This is probably going to be the case with you also.

The best advice I can give which will help immensely is:

For your triggers, write the exact capture back to the screen. Eg.,

...and it is always good practice to TRIM the capture as you don't really want leading/trailing space.

#TR {Restricts: (*)} {
#SH %trim(%1)
}

For one example it should display

NOMAGE NOBLACK_ROBE NORED_ROBE NOWHITE_ROBE

So regardless of whether the captured text is

NOMAGE NOBLACK_ROBE NORED_ROBE NOWHITE_ROBE

or

NOTHIEF NOPALADIN NORANGER NOWARRIOR NODARK_KNIGHT NOBARBARIAN

or

NOMAGE NOTHIEF NOPALADIN NODRUID NOCLERIC NORANGER NOWARRIOR NODARK_KNIGHT NOBLACK_ROBE NORED_ROBE NOWHITE_ROBE NOSHAMAN

you will get the full text, and if it is numerical data that should appear as is also. As you progress with refining your pattern-matching, or within the script you specify substrings or alterations of numbers by calculation, always drop a #SH for the $vars or calculation results so you can see what you are getting. Then, when you have whittled the data to that which you specifically want, write it away. I have spent hours writing code that does nothing permanently just to verify that I have what I want.

Begin small. Start with correctly opening and closing your capture. If you put all your data-capture code into a class this is simplicity itself, you can just test for the class status (enabled/disabled) and you can actually see the result in the editor as the class will be crossed out if disabled.

#TR {You feel informed:} {
#T+ grab_data_class
}

#TR {end_pattern}
#T- grab_data_class
}

Then you can begin triggering to capture everything after each pattern which marks an item's data.

Object '(*)'
Item type: (*)
Mat Class: (%w) Material: (%w)
Weight : (%d) Value : (%n)

etc.

Once you have the data then you can begin to manipulate it. For example, you can convert the RESTRICTS words to a stringlist with $var=%list(%trim(%1)," "), or $var=%replace(%trim(%1)," ","|"), and send the output to the screen again with #SH to see if you have it correct.

Where you have multiple lines you will have to drop each into a fixed var before writing away. If you examine my code you will see references to (eg) tempEnchants, or tempSkillMods as this data has multiple (and variable) keywords so I have to write these somewhere in an intermediate stage until the trigger pattern moves on.

All this may seem overwhelming but the biggest learning experience is by doing. You begin to understand the language more by getting things wrong (and restarting... you wouldn't believe the number of times I have re-started all this code), and by revisiting your code. Improvements are great once you realise that you understand more of the language and how you could make a thing more efficient...or more succinct.

Shalimar (not the 80s funk-soul trio) is a great one for coding. My scripts are less compact but still do the job. In the end, we can give you help and advice and even offer suggestions to get you through.

Go forth, young man, and do great things...if not, just do things then come back and seek further help but, in the end, it is best if you make start and show us after so we know what we are dealing with.
Reply with quote
Danlo
Magician


Joined: 28 Nov 2003
Posts: 313
Location: Australia

PostPosted: Sun Jan 23, 2022 6:59 am   Re: Help with trigger and DB
 
Skrull wrote:

You grin proudly as you slay (*)

I created a database named Grade19 with two columns - Column 1 = Monster Type = Text and Column 2 = Kills Type = Number

Script I currently have

#DBLOAD Grade19
#FIND "%1" All Monster 1
#IF %null(%rec) {#NEW All {Monster=%1|Kills=1}} {&Kills=%eval(&Kills+1)}
#DBRESET
say ********* Total Worthy = %sum( Kills)

I get the following ERROR: Trigger "You grin proudly as you slay (*)" fired but did not compile

I believe the issue is that #FIND does not set %rec to a matching record in the database. Please try the following script instead:

#DBLOAD Grade19
#if (%find(%1,,Monster)) {#DBGET %find(%1,,Monster);&Kills = %eval(&Kills+1)} {#NEW "" {Monster=%1|Kills=1}}
#DBRESET
say ********* Total Worthy = %sum( Kills)
#DBSAVE


Last edited by Danlo on Sun Jan 23, 2022 7:13 am; edited 2 times in total
Reply with quote
Danlo
Magician


Joined: 28 Nov 2003
Posts: 313
Location: Australia

PostPosted: Sun Jan 23, 2022 7:08 am   
 
chaossdragon wrote:
If you was to do...

#LOOPDB @Grade19 {#SHOW %key "=" %val}

what do you see?


He isn't writing to a dbvar, that's why your code did nothing.
You would use #LOOPVIEW {#SHOW %rec} to see what it contains.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net