• Please note: In an effort to ensure that all of our users feel welcome on our forums, we’ve updated our forum rules. You can review the updated rules here: http://forums.wolflair.com/showthread.php?t=5528.

    If a fellow Community member is not following the forum rules, please report the post by clicking the Report button (the red yield sign on the left) located on every post. This will notify the moderators directly. If you have any questions about these new rules, please contact support@wolflair.com.

    - The Lone Wolf Development Team

script issuse

tooley1chris

Well-known member
Can someone please help make this work?
Under the trait bonus field I want the value to equal CO+CO+EN divided by 3
Is there a part of forum dedicated to poor scripters who lack talent?

<!-- Health Trait -->
<thing
id="trHealth"
name="Health"
compset="Trait"
isunique="yes"
description="Description goes here">
<fieldval field="trtAbbrev" value="Hlth"/>
<tag group="explicit" tag="1"/>
<tag group="User" tag="Power"/>

<!-- Calculate the Health trait as appropriate -->
<eval value="1" phase="Traits" priority="4000">
<before name="Derived trtFinal"/>
<after name="Calc trtFinal"/><![CDATA[
field[trtBonus].value += #trait[attrPE] + #trait[attrCO] + #trait[attrCO] / 3
]]></eval>
</thing>
 
Code:
field[trtBonus].value += (#trait[attrPE] + #trait[attrCO] + #trait[attrCO]) / 3

It looks like what you had previously would only be dividing the second CO by 3, not the first CO or the PE.

Something else you should look at: at the top, you say that you want it to be EN + CO + CO, but your script appears to have PE + CO + CO.
 
Sorry but it IS PE. (Physical Endurance ) not so worried about abbreviation as formula. How SHOULD it look? Thanks!
EDIT: OK what you said helped me work it out by dividing Each attribute separatly. Thanks!
 
Last edited:
You don't need to divide each by 3 and sum them (though that does work more or less).... use Parenthesis (just like in Algebra) to control order of operations... as Mathias put above () around the addition will cause the values to add before they are divided.
 
Actually, you probably don't want 1/3's hanging around, either.

What direction is it supposed to round fractions?

This will give you round down:
Code:
field[trtBonus].value += round((#trait[attrPE] + #trait[attrCO] + #trait[attrCO]) / 3,0,-1)

This will give you round up:
Code:
field[trtBonus].value += round((#trait[attrPE] + #trait[attrCO] + #trait[attrCO]) / 3,0,1)
 
Just in case you have trouble with those (I've had trouble with parentheses inside round() before), here are versions of those that are more reliable:

round down:
Code:
var healthtot as number
healthtot = (#trait[attrPE] + #trait[attrCO] + #trait[attrCO]) / 3
field[trtBonus].value += round(healthtot,0,-1)

round up:

Code:
var healthtot as number
healthtot = (#trait[attrPE] + #trait[attrCO] + #trait[attrCO]) / 3
field[trtBonus].value += round(healthtot,0,1)
 
I'm trying to figure out how to spell that sound your lips make when you rapidly rub your finger up and down while humming. WOW but that's another language! Thanks for the rounding script. That's really helping with the extra points here and there! For those of you kind enough to answer my queries BEWARE! I now have you on speed dial for future reference! Haha
 
Back
Top