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


Joined: 20 Apr 2008
Posts: 69
Location: Watervliet, NY

PostPosted: Sat Oct 01, 2011 4:24 pm   

Addition in Database Records
 
I am trying to increment values within a database variable each time a specific trigger fires. I've tried everything I can think of to get the values inside to change, however I always end up with either a static value of 1.

Code:

<trigger priority="22770" id="2277">
  <pattern>^You have slain (*).</pattern>
  <value>#ADDKEY slain {%1}  %eval(  %db(  @slain, "%1")+1)</value>
</trigger>


I am sure it is something simple I am missing, but can't for the life of me figure out what it is.
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Sat Oct 01, 2011 5:45 pm   
 
You'll want to take %1 out of quotes. In CMUD, whenever you put something in quotes it interprets it as a string literal, so it's actually looking for the key %1 in your database, not the contents of %1, and obviously that doesn't exist so it's adding 1 to null. See this page from the Changes for zMUD users section of the CMUD manual for more info. Also, you can get rid of the %eval - in general, putting expressions in parentheses is enough to evaluate them in CMUD (more info here). So the corrected code would be:
Code:
<trigger priority="22770" id="2277">
  <pattern>^You have slain (*).</pattern>
  <value>#ADDKEY slain {%1}  (%db(  @slain, %1)+1)</value>
</trigger>
Reply with quote
Stowslee
Wanderer


Joined: 20 Apr 2008
Posts: 69
Location: Watervliet, NY

PostPosted: Sun Oct 02, 2011 3:24 am   
 
Works perfectly now, this answers a lot of questions about some various bugs I had when switching over to CMud.
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