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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
rwfrk
Wanderer


Joined: 26 Feb 2002
Posts: 81
Location: USA

PostPosted: Tue Oct 29, 2002 2:46 am   

Adding things to a db record
 
Trying to pull a key from a db variable and then set it to its old value +Some new value..I dont want it as a list of values though..
--Using for a Lore thing that adds one spell at a time all into the key with some kind of seperator character ..but i cant figure out how to do it--
Its not always going to v4 ;) So I'd like to
#tri {~[v(%d)~] Spell: (*)$ and have it add it somehow..Adding to Varable item key spellof...thanks in advance
W95
Zmud 616
--Example Text Below--

[v1] Spell: protection evil
[v2] Spell: none
[v3] Spell: none
[v4] Spell: none
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Fri Nov 01, 2002 6:37 am   
 
You can use the %db function to get the current value and #ADDKEY to overwrite it with the new value. As long as you use the same variable and key, the existing value will be overwritten with the new one.

LightBulb
Senior Member
Reply with quote
rwfrk
Wanderer


Joined: 26 Feb 2002
Posts: 81
Location: USA

PostPosted: Fri Nov 01, 2002 6:39 am   
 
Thats the problem..I dont want it to overwrite..I want all of the Spells on 1 key ;)...(nones included) so..Chain Lightning|None|None}.etc ;)
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Fri Nov 01, 2002 6:51 am   
 
Sorry, you can't have your cake and eat it too. If you want to change the key, then you can't also not change the key. It MUST overwrite it to put something different there, even if all you are doing is appending or deleting.

LightBulb
Senior Member
Reply with quote
rwfrk
Wanderer


Joined: 26 Feb 2002
Posts: 81
Location: USA

PostPosted: Fri Nov 01, 2002 6:54 am   
 
Ok...Any way I can have that specific trigger bounce off of multiple aliases to do it?Perhaps store the current info in a temp variable..append it with the new info..and re-store(reset) the key *disclamer* *I DO NOT HAVE A CLUE HOW TO DO THIS*
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Fri Nov 01, 2002 9:30 am   
 
Okay, comma-separated values (you didn't want a list) and I'm assuming the spells will come in order. I used db as the name of the db variable, since you didn't provide a variable name:
#TR {~[v(%d)~] Spell: (*)$} {#IF (%1 = 1) {#ADDKEY db spellof {%2}} {#ADDKEY db spellof {%db(@db, spellof), %2}}}

LightBulb
Senior Member
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Fri Nov 01, 2002 6:11 pm   
 
Another thing that occurred to me later is that the commas could cause problems in the functions. To make sure they don't, add {} anywhere that gets a value from the variable.
#TR {~[v(%d)~] Spell: (*)$} {#IF (%1 = 1) {#ADDKEY db spellof {%2}} {#ADDKEY db spellof {%db({@db}, spellof), %2}}}

LightBulb
Senior Member
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD 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