|
CuMorrigu Beginner
Joined: 29 Jul 2004 Posts: 19 Location: United States
|
Posted: Tue Mar 18, 2008 9:20 pm
Trouble with multiplication |
Okay,
I have the following script:
Code: |
#CLASS {Stocks}
#TRIGGER {Baker's Guild: %2 %3 %4 } {bascv = %2;basop = %3;basow = %4;#math bapsv @bascv*@basow}
#TRIGGER {Blacksmith's Guild: %2 %3 %4 } {blscv = %2;blsop = %3;blsow = %4;#math blpsv @blscv*@blsow}
#TRIGGER {Cityguard's Guild: %2 %3 %4 } {cgscv = %2;cgsop = %3;cgsow = %4;#math cgpsv @cgscv*@cgsow}
#TRIGGER {Banker's Guild: %2 %3 %4 } {bnscv = %2;bnsop = %3;bnsow = %4;#math bnpsv @bnscv*@bnsow}
#TRIGGER {Janitor's Guild: %2 %3 %4 } {jascv = %2;jasop = %3;jasow = %4;#math japsv @jascv*@jasow}
#TRIGGER {Wizard's Guild: %2 %3 %4 } {wiscv = %2;wisop = %3;wisow = %4;#math wipsv @wiscv*@wisow}
#TRIGGER {Assassin's Guild: %2 %3 %4 } {asscv = %2;assop = %3;assow = %4;#math aspsv @asscv*@assow}
#TRIGGER {Merc's Guild: %2 %3 %4 } {mescv = %2;mesop = %3;mesow = %4;#math mepsv @mescv*@mesow}
#TRIGGER {Seer's Guild: %2 %3 %4 } {sescv = %2;sesop = %3;sesow = %4;#math sepsv @sescv*@sesow}
#TRIGGER {svecho} {#echo The current value of your stock in the Baker's Guild is: ------ @bapsv;#echo The current value of your stock in the Blacksmith's Guild is: - @blpsv;#echo The current value of your stock in the Cityguard's Guild is --- @cgpsv;#echo The current value of your stock in the Banker's Guild is ------ @bnpsv;#echo The current value of your stock in the Janitor's Guild is ----- @japsv;#echo The current value of your stock in the Wizard's Guild is ------ @wipsv;#echo The current value of your stock in the Assassin's Guild is ---- @aspsv;#echo The current value of your stock in the Merc's Guild is -------- @mepsv;#echo The current value of your stock in the Seer's Guild is -------- @sepsv}
#CLASS 0 |
Now what I'm trying to do is calculate the value of the stocks I own in the mud, when I run the script all the results I get are negative and they aren't even the correct negative number
For a stock with a value of 9988322 in which I own 300 shares, the script returns a value of -1298470696, this SHOULD be 2996496600.
Also for ease of reading how would you tell zmud to return the results with a comma every three places?
I appreciate any help anyone could give me, thanks. |
|
|
|
Dharkael Enchanter
Joined: 05 Mar 2003 Posts: 593 Location: Canada
|
Posted: Tue Mar 18, 2008 9:51 pm |
in your math statements cast one of the operands to a float, looks like zmud has some limitations with integer math.
change
Code: |
#math blpsv @blscv*@blsow |
to
Code: |
#math blpsv %float(@blscv)*@blsow |
to have it return the numbers comma seperated use the format function.
Code: |
#echo %format("&n",@blpsv) |
Look at the help file for %format to get an idea of how to tweak the format to your liking.
Not absolutely necessary but maybe think about changing the %2 %3 %4 to (%d) (%d) (%d) and then use %1 %2 %3 to refer to the captured data.
I'm assuming the 2nd capture the one that gets fed to blsop or whatever is also a number. |
|
_________________ -Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style." |
|
|
|
CuMorrigu Beginner
Joined: 29 Jul 2004 Posts: 19 Location: United States
|
Posted: Tue Mar 18, 2008 10:11 pm |
You da' man, works like a charm, thx.
|
|
|
|
|
|