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
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Sun Mar 18, 2007 6:48 am   

Variable Databases question...
 
I'm working on a script for Aardwolf. I know what I want to do and basically how to do it - there's just one problem.

I can't seem to add to an existing value in a variable database. If it were a simple numeric expression, then I'd have no problem. Let me show you what I mean.

This is the output I'm capturing:
Code:

22 Charneus     Stendarr's Child   111       323,330          0       122,110


My trigger thus far is:
Code:

Trigger: (%d)%s(%w)%s(*)%s(%d)%s(%x)%s(%x)%s(%x)
Action: #IF (%iskey(@donated,%2)) {#addkey donated %2 %eval(@donated.%2.1+%replace(%5,",",""))} {#addkey donated %2 %replace(%5,",","")}


Right now, that's just a basic code. Even so, it doesn't work. I need to remove the commas in the number in order to add a numerical value to it. But it doesn't seem to be working that way. Does anyone know a way I can change that 323,330 to 323330 so that I may add whatever I need to the value? Thanks! If this is too confusing, forgive me. It's currenty 1:45 a.m.... just let me know. Thanks in advance again.

Charneus
Reply with quote
ixy
Novice


Joined: 18 Mar 2007
Posts: 39

PostPosted: Sun Mar 18, 2007 12:52 pm   
 
i use a script for tracking gold i spend the method i use is this

Code:
^It will cost %1 gp to repair the damage to this ship.


As my trigger output im capturing

then...

Code:
@gold1 = %replace( "%1", ",")
#add outgoing @gold1
#add shipcost @gold1
#add balance -@gold1


Im not great with coding, but i use the variable @gold1 = %replace( "%1", ",") to strip the , out of the gold im capturing, before using the new data into my script.
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Sun Mar 18, 2007 2:26 pm   
 
It's possible that zMUD doesn't like this syntax:

%eval(@donated.%2.1+%replace(%5,",",""))

I assume the second . there is supposed to be a multiplication. zMUD probably doesn't know this (and if it does, it's possibly confused by the dot separating the variable name and the key). You also don't need the final parameter in replace if you're just deleting. Try one of these:

%eval(@{donated.%2}*1+%replace(%5,","))
%eval(%db(@donated,%2)*1+%replace(%5,","))
Reply with quote
Taz
GURU


Joined: 28 Sep 2000
Posts: 1395
Location: United Kingdom

PostPosted: Mon Mar 19, 2007 12:45 pm   
 
Use %n instead of %x and then there is no need for the %replace on %5 you can just do a %eval straight away on the %5.
_________________
Taz :)
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Mon Mar 19, 2007 11:31 pm   
 
Thanks, Taz. That is exactly what I was looking for!

Charneus

P.S. Other guys, thanks for the suggestion. By the way, there was no multiplication. If you read about it, using #var @donated.%2.1 indicates that the variable is referencing Database Donated, Key %2, record 1.
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