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
ixy
Novice


Joined: 18 Mar 2007
Posts: 39

PostPosted: Tue Dec 15, 2009 7:37 pm   

dot notation alternate?
 
In zmud i used dot notation a lot, but it doesnt appear to work the same way in cmud, for example;

Code:

#trigger {^Beyonder, guardian of the source has been slain!} {#add kills.beyonder 1;#add kills.total 1}


i used to use triggers such as this to track boss kills i had made, and it added it up fine, now in cmud i cant seem to find an alternate way of doing it short of creating a new variable for every single boss and having a metric tonne of variables in my root folder.

Code:

#CLASS {database|equipment_database|equipment_database_capture}
#REGEX {\<(.+)hp (.+)sp (.+)st\>} {#t- equipment_database_capture;#dbload items;item.capture = %ansi( 16, 0)@item.capture;#IF (%numitems( %query( ((&name = @item.name) & (&keywords = @item.keywords)), All)) = 0) {#NEW items @item;#dbsave items;#dbclose items} {#echo "";#echo %ansi( 15, 0)@item.name %ansi( 16, 0)already in database.;#dbclose items}} "" {nocr|prompt}
#TRIGGER {(*)} {#var item.capture @item.capture%cr%TRIGGER}
#REGEX {^The minimum bid on this item is \[(.+)\] gp\.} {#t- equipment_database_capture;#dbload items;item.capture = %ansi( 16, 0)@item.capture;#IF (%numitems( %query( ((&name = @item.name) & (&keywords = @item.keywords)), All)) = 0) {#NEW items @item;#dbsave items;#dbclose items} {#echo "";#echo %ansi( 15, 0)@item.name %ansi( 16, 0)already in database.;#dbclose items}}
#REGEX {(.*) tells (you|you,) \'I can (sell|trade) you this item for (.*)\.\'} {#t- equipment_database_capture;#dbload items;item.capture = %ansi( 16, 0)@item.capture;#IF (%numitems( %query( ((&name = @item.name) & (&keywords = @item.keywords)), All)) = 0) {#NEW items @item;#dbsave items;#dbclose items} {#echo "";#echo %ansi( 15, 0)@item.name %ansi( 16, 0)already in database.;#dbclose items}}
#TRIGGER {This item is beyond your power to identify further.} {#t- equipment_database_capture;#dbload items;item.capture = %ansi( 16, 0)@item.capture;#IF (%numitems( %query( ((&name = @item.name) & (&keywords = @item.keywords)), All)) = 0) {#NEW items @item;#dbsave items;#dbclose items} {#echo "";#echo %ansi( 15, 0)@item.name %ansi( 16, 0)already in database.;#dbclose items}}
#CLASS 0
#CLASS {database|equipment_database|equipment_database_id}
#REGEX {^You focus your powers of observation on (.+):} {item = "";item.name = %1}
#COND {^Item '(.+)' is type (.+), (alignment (.+), made of (.+),|with keywords '(.+)'\.)} {item.zone = @current.zone;item.mob = @current.mob;item.keywords = %6;#t+ equipment_database_capture} {regex}
#COND {has keywords '%1'} {item.keywords = %1} {looppat}
#REGEX {^This item is up for auction from (.+)\.} {#t+ equipment_database_capture;item = ""}
#COND {^Item '%1' is type %2, alignment %3, made of %4,$} {item.zone = None;item.name = %1}
#COND {has keywords '%1'} {item.keywords = %1} {looppat}
#REGEX {^You ask (.+) for a description of one of (.+) wares\.} {item = "";item.mob = %1}
#COND {%1 tells you:} {#t+ equipment_database_capture}
#COND {^Item '%1' is type %2, alignment %3, made of %4,$} {item.zone = @current.zone;item.name = %1}
#COND {has keywords '%1'} {item.keywords = %1}
#CLASS 0


I used to use this part of a script to capture whole items from diffrent sources and a few other triggers to capture room, zone, mob, etc, and store it in one variable and add it to the db as 1 whole item, with a few set fields to aid for searching, but again i cant seem to get this to work either. One of my main reasons for finally upgrading to cmud was i hoped to have a more stable database, zmud didnt seem to like having 2 open at the same time and often crashed on me :(

Any help on this would be greatly appreciated, even just a quick example that i can work from!
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Tue Dec 15, 2009 8:27 pm   
 
Must be a 2.37 issue, I have no problems with that syntax in 3.12. Perhaps you need to cast the field value, as somehow CMud is treating it as a string (ie, #ADD = concatenation instead of addition)? You can force a string to be used as a number via the %number() function.

As for alternates, you can use the %db(). %db(@varname,fieldname) == @varname.fieldname.
_________________
EDIT: I didn't like my old signature
Reply with quote
Aerious
Wanderer


Joined: 21 Jan 2008
Posts: 62

PostPosted: Tue Dec 15, 2009 8:27 pm   
 
prots.greater = gPhys;prots.greater_start = @timer;party colour green;party say Greater Invlunerability Up!;party colour yellow

becomes something to the effect of

prots.greater_history = @timer-%db(@prots,greater_start)
prots.greater_name = %db(@prots,greater)
prots.greater = 0
party colour red
party say %db(@prots,greater_name) Off - %db(@prots,greater_history) s
party colour yellow


specifically, your #add, will need to become

kills.beyonder = %db(@kills,beyonder) + 1
kills.total = %db(@kills,total) + 1
etc
Reply with quote
ixy
Novice


Joined: 18 Mar 2007
Posts: 39

PostPosted: Tue Dec 15, 2009 9:01 pm   
 
Thank you very much! can finally start sorting out my scripts now :)
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