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


Joined: 16 Dec 2003
Posts: 77
Location: USA

PostPosted: Fri Feb 06, 2004 9:53 am   

zMUD not capable of decimals in variables?
 
I'm using a set of triggers right now to keep track of how much weight I'm carrying. Each time I pick up an item, it adds the weight of that to a variable that is displayed on my status bar. Everything works fine except for the coins. Here's what I have:

Variable

Name: bit_weight
Value: 0.01

The same goes for each other type of coin. Now, when I pick up money, I have the following expression to add the weight to my total:

#TRIGGER {You take * (%d) copper Bit*} {#var weight_carried %eval((%1*@bit_weight)+@weight_carried)

Looking at it, I know that it should work, but it doesn't. When I highlight each variable in the Settings Editor to find out their value, it lists @bit_weight as being 0.00999999977648258. Any thoughts on why?
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Sat Feb 07, 2004 6:24 pm   
 
0.00999999977648258 is the normalized value of 0.01, as provided by the %norm function.

Since your trigger is specific to copper bits, you could use a specific formula.
#TR {You take * (%d) copper Bit*} {#MATH weight_carried ((@weight_carried * 100) + %1);#VAR weight_carried %insert( ".", @weight_carried, %len( @weight_carried) - 1)}

NOTE: This formula will fail in the unlikely event that you ever have a total weight of less than 0.10.
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