Lone Wolf Development Forums  

Go Back   Lone Wolf Development Forums > Hero Lab Forums > HL - Authoring Kit
Register FAQ Community Today's Posts Search

Notices

Reply
 
Thread Tools Display Modes
tooley1chris
Member
 
Join Date: Jun 2012
Posts: 65

Old June 21st, 2012, 05:46 AM
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>
tooley1chris is offline   #1 Reply With Quote
Mathias
Senior Member
Lone Wolf Staff
 
Join Date: May 2005
Posts: 13,214

Old June 21st, 2012, 08:56 AM
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.
Mathias is offline   #2 Reply With Quote
tooley1chris
Member
 
Join Date: Jun 2012
Posts: 65

Old June 21st, 2012, 09:17 AM
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 by tooley1chris; June 21st, 2012 at 09:21 AM.
tooley1chris is offline   #3 Reply With Quote
cryptoknight
Senior Member
Volunteer Data File Contributor
 
Join Date: Dec 2008
Posts: 523

Old June 21st, 2012, 09:44 AM
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.
cryptoknight is offline   #4 Reply With Quote
Mathias
Senior Member
Lone Wolf Staff
 
Join Date: May 2005
Posts: 13,214

Old June 21st, 2012, 10:03 AM
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)
Mathias is offline   #5 Reply With Quote
Mathias
Senior Member
Lone Wolf Staff
 
Join Date: May 2005
Posts: 13,214

Old June 21st, 2012, 10:16 AM
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)
Mathias is offline   #6 Reply With Quote
tooley1chris
Member
 
Join Date: Jun 2012
Posts: 65

Old June 21st, 2012, 11:05 AM
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
tooley1chris is offline   #7 Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 03:51 AM.


Powered by vBulletin® - Copyright ©2000 - 2024, vBulletin Solutions, Inc.
wolflair.com copyright ©1998-2016 Lone Wolf Development, Inc. View our Privacy Policy here.