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
Logic
Beginner


Joined: 30 May 2002
Posts: 17
Location: Denmark

PostPosted: Sat Jul 17, 2004 9:56 pm   

Data Record
 
Hi

I have made this script to see how many potion I quaff:

#trigger {You quaff (*).} {#IF %iskey( @AllPotion, "%1") {#ADDKEY AllPotion {%1} {%eval( %db( @AllPotion, "%1") + 1)}} {#ADDKEY AllPotion {%1} {1}}}
#VAR AllPotion {Potion One|61|ManaPotion|9}

And I have this data record holds the cost of each potion:
#VAR AllPotionCost {Potion One|960|ManaPotion|2400}

Now how can I math how mush I have spend on Potion One like 61*960 and put that i a new record like:
#VAR TotalPotionCost {Potion One|58560}
_________________
Logic
Denmark
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Sun Jul 18, 2004 2:25 am   
 
It's just simple multiplication.
#ADDK TotalPotionCost {%1} {%eval( %db( @Allpotion, "%1") * %db( @AllPotionCost, "%1"))}
_________________
LightBulb
Senior member

Most scripts in this forum are written for Command Line entry.
Don't even open the Settings Editor unless its use is specified or obvious.
Reply with quote
Logic
Beginner


Joined: 30 May 2002
Posts: 17
Location: Denmark

PostPosted: Sun Jul 18, 2004 4:57 pm   
 
hmmm I can get it to work with this:

#ADDK TotalPotionCost {Potion One} {%eval( %db( @Allpotion, "Potion One") * %db( @AllPotionCost, "Potion One"))}

But not this:

#FORALL @AllPotion {#ADDK TotalPotionCost {%1} {%eval( %db( @Allpotion, "%1") * %db( @AllPotionCost, "%1"))}}

I find this on the forum:
#FORALL @players {#ECHO %word( "%i", 1)%repeat( " ", 25-%len( %word( "%i", 1)))%word( "%i", 2)}
But how can I get it to work with my script that has a 2 word in it, I have try to play with the %format with no luck.

And how many items can a record holds, I only need max 100, is that ok.
_________________
Logic
Denmark
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Sun Jul 18, 2004 8:58 pm   
 
1. #FORALL is for lists. Use #LOOPDB for records.
2. Subtract the number of characters in the first word from 25. Put that many spaces between the first word and the second word.
3. I'm not aware of any limit. I've had more than 100 key-value pairs in a record.
_________________
LightBulb
Senior member

Most scripts in this forum are written for Command Line entry.
Don't even open the Settings Editor unless its use is specified or obvious.
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