Weight as a variable
1. Current Weight
$weight = @eval($::char->{weight})
2. Max Weight
$mweight = @eval($::char->{weight_max})
3. Current weight percentage
$wpercent = @eval($weight/$mweight*100)
4. To get untill 95% weight from your current weight
$tryToGet = Unknown
do eval $::Macro::Data::varStack{tryToGet} = sprintf("%.0f", ($::char->{weight_max} - $::char->{weight}) * 95 / 100 )
5. To get how many items base on its weight untill 95% of your body weight from your current weight
$ItemCanGet = Unknown
$itemWeight = 15 #Let say Royal Jelly
do eval $::Macro::Data::varStack{ItemCanGet} = sprintf("%.0f", ($::char->{weight_max} - $::char->{weight}) * 95 / 100 / $itemWeight )
==============================
1. $weight = $::char->{weight} - Its perl eval and you shud used the @eval(...put perl here...)... pls take a look again at my last comments.
2. do eval $::Macro::Data::varStack{ItemCanGet} - Variables in Macro plugin (at least untill version 1.3.5) are stored in a global hash variable call %varStack (inside Macro::Data package) - taken from buggless comment. So, I did set the $ItemCanGet inside macro variable.. and later on, using perl eval to look inside those varStack (coz we need to do culculation using an eval not macro). Note: We cant simply create any macro variable using eval (as buggless said before XD), so we set macro variable 1st and then modify its value by using an eval. In this case, we modify the ItemCanGet that we set 1st inside macro variable.
3. sprintf("%.0f", - To get rid of the decimal point in our divide operations.
Quote:
"%.1f" is /10 --> ex: 0.1
"%.2f" is /100 --> ex: 0.01
"%.3f" is /1000 --> ex: 0.001

No comments:
Post a Comment