PDA

View Full Version : Help with rounding numbers



chillybilly
May 9th, 2015, 13:58
I am trying to create a homemade ruleset for Blade of the Iron Throne. I'm definitely not a programmer but I'm taking baby steps.

Someof the attributes take other attributes and then divide them by two. This yields fractions on my character sheet. Is there any way to code it so it rounds the fractions (up if equal to or great than .5 and down if less than .5)? Thank for any help! I'll also share the ruleset when it's functional (assuming that is allowed).

Here's the code:

<stringcontrol name="knockdowntitle"> <!--Knockdown-->
<anchored to="aimtitle" position="insidetopleft" offset="0,20"
width="100" height="20" />
<font>sheettext</font>
<static>Knockdown</static>
</stringcontrol>
<number_targetroll name="knockdown" source="abilities.knockdown">
<anchored to="knockdowntitle" position="insidetopleft" offset="105,0" width="30" height="20" />
<script>
function onInit()
setValue((window.strengthtot.getValue()+window.coo rdinationtot.getValue())/2);
end
</script>
<readonly />
<skill>Knockdown</skill>
</number_targetroll>

Nylanfs
May 9th, 2015, 14:31
Can you use (floor) or (ceiling)?

dulux-oz
May 9th, 2015, 14:47
I am trying to create a homemade ruleset for Blade of the Iron Throne. I'm definitely not a programmer but I'm taking baby steps.

Someof the attributes take other attributes and then divide them by two. This yields fractions on my character sheet. Is there any way to code it so it rounds the fractions (up if equal to or great than .5 and down if less than .5)? Thank for any help! I'll also share the ruleset when it's functional (assuming that is allowed).

Add 0.5 and then use the math.floor() function.

ie math.floor(x+0.5) where x is the final number to round-off.

damned
May 9th, 2015, 15:53
I am trying to create a homemade ruleset for Blade of the Iron Throne. I'm definitely not a programmer but I'm taking baby steps.

Someof the attributes take other attributes and then divide them by two. This yields fractions on my character sheet. Is there any way to code it so it rounds the fractions (up if equal to or great than .5 and down if less than .5)? Thank for any help! I'll also share the ruleset when it's functional (assuming that is allowed).

Here's the code:

<stringcontrol name="knockdowntitle"> <!--Knockdown-->
<anchored to="aimtitle" position="insidetopleft" offset="0,20"
width="100" height="20" />
<font>sheettext</font>
<static>Knockdown</static>
</stringcontrol>
<number_targetroll name="knockdown" source="abilities.knockdown">
<anchored to="knockdowntitle" position="insidetopleft" offset="105,0" width="30" height="20" />
<script>
function onInit()
setValue((window.strengthtot.getValue()+window.coo rdinationtot.getValue())/2);
end
</script>
<readonly />
<skill>Knockdown</skill>
</number_targetroll>

Sharing rulesets is allowed. sharing content is usually not.

chillybilly
May 9th, 2015, 16:03
It worked! Thank-you!