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
Troublemag
Wanderer


Joined: 14 Jul 2004
Posts: 83

PostPosted: Tue Feb 20, 2007 8:00 am   

db question converting from zmud to cmud 1.24
 
I've tried to read up on the changes, but I'm not a programmer and I don't know perl. I was able to piece together things in Zmud to get them to do what I wanted, more or less, and most of them converted over to Cmud fine. My item database triggers, however, did not.

Code:
#TRIGGER {Object '(*)' is type &{item.type}, extra flags &{item.flags}.} {#VARIABLE ItemKeywords "%1";#ADDKEY item {Keywords="%1"}} "eqdb"
#TRIGGER {You study the (*) very carefully} {#VARIABLE ItemName "%1";#ADDKEY Item {Name="%1"}} "eqdb"
#TRIGGER {Weight is &{item.weight}, value is &{item.value}, level is &{item.level}} {} "eqdb"
#TRIGGER {Armor class is &{item.acpierce} pierce, &{item.acbash} bash, &{item.acslash} slash, and &{item.acweaves} vs. weaves.} {} "eqdb"
#TRIGGER {Weapon type is &{item.weapontype}.} {} "eqdb"
#TRIGGER {Damage is &{item.damdice} ~(average &{item.damavg}~).} {} "eqdb"
#TRIGGER {Affects endurance by &{Item.EndBonus}.} {} "eqdb"
#TRIGGER {Affects hp by &{Item.HPBonus}.} {} "eqdb"
#TRIGGER {Affects strength by &{Item.StrBonus}.} {} "eqdb"
#TRIGGER {Affects intelligence by &{Item.IntBonus}.} {} "eqdb"
#TRIGGER {Affects wisdom by &{Item.WisBonus}.} {} "eqdb"
#TRIGGER {Affects dexterity by &{Item.DexBonus}.} {} "eqdb"
#TRIGGER {Affects constitution by &{Item.ConBonus}.} {} "eqdb"
#TRIGGER {Affects damage roll by &{Item.Dambonus}.} {} "eqdb"
#TRIGGER {Affects hit roll by &{Item.hitbonus}.} {} "eqdb"
#TRIGGER {$} {#IF (%numitems( %query( (&Name=Itemname)&&(&Keywords=ItemKeywords)&&(&Level=ItemLevel)), All) = 0) {#NEW @ItemType @Item} {gt already in there};#VARIABLE item {};#VARIABLE itemname {};#VARIABLE itemkeywords {};#VARIABLE itemlevel {};#T- eqdb} "eqdb"


These are the triggers I've got set. The last one is the one that generates an error stating that the trigger fired but did not compile or, if I put " around the eqdb when trying to execute the #T-, it will turn off that specific trigger but not the entire class. Any ideas, suggestions, corrections?
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Tue Feb 20, 2007 8:14 am   
 
Firstly, your first two triggers are using the syntax "%1" - this is wrong now, that'll make the value literally %1 rather than the first wildcard. Use %1 without the quotes.

As for the final trigger, I believe your #if statement's expression is wrong. You have this:

(%numitems(%query((&Name=Itemname) && (&Keywords=ItemKeywords) && (&Level=ItemLevel)), All) = 0)

when I think you mean this:

(%numitems(%query((&Name=Itemname) && (&Keywords=ItemKeywords) && (&Level=ItemLevel), All)) = 0)

EDIT: Though weirdly enough, the second doesn't compile either complaining about unmatched parenthesis. These are the only parenthesis there and they're all matched, so what's cooking?

Removing the parenthesis around the individual query items fixes the error, but that might not return the correct results. Adding an extra set of parenthesis around the whole query expression as in the example in the help files doesn't fix the problem.
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Tue Feb 20, 2007 8:15 pm   
 
One more recommendation is to convert this into a conditional trigger although you may find it a bit more complex.

Here's what I do.

Code:
#CLASS {identify}
#ALIAS ADDtoDB {   #DBLOAD Equipment;   #IF (%query( ( &Name==@CurItem.Name ) && ( &Level==@CurItem.Level)&&( &Value==@CurItem.Value))) { #NOOP  }   {  #NEW @CurItem.Kind {@CurItem}  };   #DBSAVE Equipment;   #UNVAR CurItem }
#VAR AffectKey {hit rollHitdamage rollDamarmor classAChpHealthmanaManamovesMovessave vs spellSpellSavestrengthStrengthintelligenceIntelligencewisdomWisdom}
#VAR DBCompare {}
#VAR AlignList {good|neutral|evil|anti-good|anti-neutral|anti-evil}
#VAR FlagList {rare|magic|glow|hum|nodisarm|nodrop}
#VAR FlagsKey {nosacNo SacrificenolootNo Lootno_auctionNo AuctionnodisarmNo DisarmnosaveNo SavenodropNo Drop}
#VAR CurItem {} {}
#TRIGGER "identify" {You recite Scroll of Identify.|Your hands briefly glow magically!} {#VAR CurItem {} {} identify}
#COND {Object '(*)' is type (%w), extra flags (*).} {#ADDKEY CurItem Name {%1};#ADDKEY CurItem Kind {%2};#IF (%trim( %3) <> "none") {#FORALL %replace( %3, " ", "|") {#IF (%ismember( %i, @AlignList)) {#ADDITEM Align %i} {#IF (%ismember( %i, @FlagList)) {#ADDITEM Flags %i} {#ADDITEM Flags %db( @FlagsKey, %i)}}};#ADDKEY CurItem Alignment %replace( @Align, "|", ",");#ADDKEY CurItem Flags %replace( @Flags, "|", ",");#UNVAR Align;#UNVAR Flags}}
#COND {^Worn: (*), Weight: (%d), value: (*), level: (%d).} {#ADDKEY CurItem Wear {%replace( %1, ".", {})};#ADDKEY CurITem Weight %2;calculate %3;#ADDKEY CurItem Value @CalcTemp;#CLASS Money 0;#ADDKEY CurItem Level %4;#T+ AffectsCheck}
#COND {^({Damage|Armor class}) is (*)} {#IF (%1 == "Damage") {#NOOP %regex( %2, "(\d+) to (\d+) \(average (\d+)\)", @CurItem.MinDamage, @CurItem.MaxDamage, @CurItem.AvgDamage)} {#ADDKEY CurItem Armor %2}}
#TRIGGER {$} {#T- AffectsCheck;#IF (@Debug) {#STWIN + %expanddb( @CurItem, %cr, ": ");#STWIN + @align l;#STWIN + @flags l};ADDToDB;#CLASS identify 0;#STATE identify 0}
#TRIGGER {^{You do not have that scroll.|You lost your concentration.}} {#STATE identify 0;#STATE idenitfy2 0;#CLASS identify 0}
#TRIGGER "AffectsCheck" {Affects (*) by (%n)} {#ADDKEY CurItem %db( @AffectKey, %1) %2} {} {disable}
#CLASS 0


I have a CMUD optimized version floating around but I found this one firsts. Note that I have what affects trigger which fires multiple times and it's sets the appropriate property based on the @AffectKey DB variable. Just an idea.
_________________
Asati di tempari!
Reply with quote
Troublemag
Wanderer


Joined: 14 Jul 2004
Posts: 83

PostPosted: Wed Feb 21, 2007 2:33 am   re: db question converting from zmud to cmud 1.24
 
I made the suggested changes to the existing triggers (I don't feel quite ready to dive into conditional triggers just yet, thanks) and while I'm not getting the error about the trigger firing but not compiling, it's not writing anything to the database either and it's still turning off just that one trigger and not the class.

The trigger now reads:
Code:
#IF (%numitems( %query( &Name=Itemname && &Keywords=ItemKeywords && &Level=ItemLevel), All) = 0) {#NEW @ItemType @Item} {gt already in there}
#VARIABLE item {}
#VARIABLE itemname {}
#VARIABLE itemkeywords {}
#VARIABLE itemlevel {}
#T- eqdb


I've tried appending the last trigger with class to force it to look at turning off a class of triggers, but that doesn't change how it is working, or rather not working.

Thanks for the suggestions though!
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Wed Feb 21, 2007 6:48 pm   
 
I know other users have ran into some quirks with using #T- to disable non-trigger items.

I personally use
Code:
#CLASS eqdb 0
to disable my classes.
_________________
Asati di tempari!
Reply with quote
Troublemag
Wanderer


Joined: 14 Jul 2004
Posts: 83

PostPosted: Thu Feb 22, 2007 2:02 am   
 
That did it! Changing it to #class eqdb 0 not only turned off the trigger class, it got the triggers to enter information in the database! Thanks!
_________________
CMUDPro 3.22
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Thu Feb 22, 2007 2:40 am   
 
Glad I could help, now go forth and conquer.
_________________
Asati di tempari!
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