PDA

View Full Version : Math in Multi-Column tables in Story Templates



dearestleader
February 16th, 2022, 06:51
Hello all,

I am attempting to automate some math using Story Templates. I'm using the 5e ruleset but attempting to replicate some tables from the 3e Races of Faerūn. I want to take a base number in one column and do math to it using another column. Examples from the RoF: Col1+Col2 = Height (HeightResultCol2xCol4)+Col3=Weight

Table Name: ShieldDwarfMalePhysical

Col1 BaseHt: 50
Col2 Mod: [2d4]
Col3 BaseWt: 145
Col4 Mod: [2d6]

I am testing
[ShieldDwarfMalePhysical]
Calc Height: [#ShieldDwarfMalePhysical|1#+#ShieldDwarfMalePhysic al|2#]
Calc Weight: [#ShieldDwarfMalePhysical|3#+#ShieldDwarfMalePhysic al|2#*#ShieldDwarfMalePhysical|4#]
Sanity Test: [2+2]=4

Output is
50 5 145 5
Calc Height: 50+5
Calc Weight: 145+5*5
Sanity Test: 4=4

That doesn't perform the calculations, but it's close! Is there a way to do that with the column layout I have or is there a better approach?

I can as a workaround just add another column that does the math like [50+2d4] and call that using #|x# in the Story Template as an extra step.

Zacchaeus
February 16th, 2022, 08:55
Someone asked a fairly similar question the other day and I referred them here https://www.fantasygrounds.com/forums/showthread.php?63527-Story-Template-PRO-(Extension-for-Unity)/page8 since I've not been able to get my head around most of the stuff in the updated story templates. The guy that did the code answered the query with a possible solution but I don't know if it worked or not.

dearestleader
February 16th, 2022, 15:48
Hi Zacchaeus, thanks for pointing out that other thread. I echo that the documentation could use an update. I'm still not clear on when one would want to use {} instead of or in addition to []. Here are the results of my test.

{:ShieldDwarfMalePhysical:Test}
Calc Height: [{#Test|1#}+{#Test|2#}]
Calc Weight: [{#Test|3#}+{#Test|2#}*{#Test|4#}]

Output
50 5 145 9
Calc Height: 55
Calc Weight: 190

This is exactly what I wanted without having separate columns that perform the calculations! Hopefully this will help others out too.

Nylanfs
February 16th, 2022, 17:02
Documentation, the bane of all programmers. :D