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
nazradin
Apprentice


Joined: 23 Mar 2003
Posts: 114
Location: New Zealand

PostPosted: Thu Jul 01, 2004 11:30 am   

defining var
 
below is a script for keeping track of how well the trip verb works for me in GS4.

the script works fine except for in the alais triptotals , I am unable to define the xpercent vars


#CLASS {bardstuff|trip}
#ALIAS triptotals {
tripavoidpercent = %eval( @tripavoid/@totaltrip)
tripunbalancepercent = %eval( @tripunbalance/@totaltrip)
trippartialpercent = %eval( @trippartial/@totaltrip)
tripsstumblepercent = %eval( @tripsstumble/@totaltrip)
tripsuccesspercent = %eval( @tripsuccess/@totaltrip)
#echo harmlessly aside. -tripavoid- @tripavoid @tripavoidpercent
#echo Half-hearted attempt does little to unbalance -tripunbalance- @tripunbalance @tripunbalancepercent
#echo totally off balance! -trippartial- @trippartial @trippartialpercent
#echo stumbling to the ground! -tripsstumble- @tripsstumble @tripsstumblepercent
#echo swept cleanly from under it! -tripsuccess- @tripsuccess @tripsuccesspercent
#echo -totaltrip- @totaltrip
}
#ALIAS resettrip {
@tripavoid = 0
@tripunbalance = 0
@trippartial = 0
@tripsstumble = 0
@tripsuccess = 0
@totaltrip = 0
}
#VAR tripavoid {30}
#VAR tripunbalance {12}
#VAR trippartial {7}
#VAR tripsstumble {4}
#VAR tripsuccess {9}
#VAR totaltrip {62}
#VAR tripavoidpercent {0}
#VAR tripunbalancepercent {0}
#VAR trippartialpercent {0}
#VAR tripsstumblepercent {0}
#VAR tripsuccesspercent {0}
#TRIGGER {The sonic lance flies harmlessly aside.} {
tripavoid = %eval( @tripavoid +1)
totaltrip = %eval( @totaltrip +1)
}
#TRIGGER {* feet are swept cleanly from under it!} {
tripsuccess = %eval( @tripsuccess +1)
totaltrip = %eval( @totaltrip +1)
}
#TRIGGER {Lucky strike leaves * totally off balance!} {
trippartial = %eval( @trippartial +1)
totaltrip = %eval( @totaltrip +1)
}
#TRIGGER {Quick strike is rewarded with * stumbling to the ground!} {
tripsstumble = %eval( @tripsstumble +1)
totaltrip = %eval( @totaltrip +1)
}
#TRIGGER {Half-hearted attempt does little to unbalance *.} {
tripunbalance = %eval( @tripunbalance +1)
totaltrip = %eval( @totaltrip +1)
}
#CLASS 0



out put from triptotals alais is

harmlessly aside. -tripavoid- 30 0
Half-hearted attempt does little to unbalance -tripunbalance- 12 0
totally off balance! -trippartial- 7 0
stumbling to the ground! -tripsstumble- 4 0
swept cleanly from under it! -tripsuccess- 9 0
-totaltrip- 62


am i unable to define vars in an alais using %eval ?

Naz
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Thu Jul 01, 2004 4:12 pm   
 
These are all working correctly. All your dividends are smaller than your divisor, therefore all your quotients are 0. If you want percents, multiply by 100 BEFORE doing the division.

tripavoidpercent = %eval( (100 * @tripavoid)/@totaltrip)

30/62 = 0 (with 30 left over)
(100 * 30)/62 = 48 (with 24 left over)

zMUD uses integer arithmetic so the remainders are discarded.
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