Page 1 of 1

putting a formula inside a table

Posted: Fri Feb 03, 2017 10:06 pm
by Sereptus
Is it possible to put code/formula inside the value section of a table? I've looked everywhere on the forums with no luck. (maybe I was asking the wrong thing in the search bar) :?
Spoiler
Table_coding.png
Table_coding.png (21.36 KiB) Viewed 1077 times
I realize the above doesn't work but is there a way to put something like "You take (1d4) dexterity damage!" but have the 1d4 calculated?

Re: putting a formula inside a table

Posted: Sat Feb 04, 2017 1:23 am
by Full Bleed
Sereptus wrote:Is it possible to put code/formula inside the value section of a table? I've looked everywhere on the forums with no luck. (maybe I was asking the wrong thing in the search bar) :?
Spoiler
Table_coding.png
I realize the above doesn't work but is there a way to put something like "You take (1d4) dexterity damage!" but have the 1d4 calculated?
Why don't you just eval the table value in the macro?

Range would be 1-52. Value would be 1d4.

Code: Select all

[eval(table("table name", 1))]

Re: putting a formula inside a table

Posted: Sun Feb 05, 2017 2:53 am
by JamzTheMan
I suppose he may have just wanted to double click the table for a random table result with random effect for each table entry.

But I don't believe that's possible and you will have to create a macro to do it as Full Bleed suggests.

Re: putting a formula inside a table

Posted: Sun Feb 05, 2017 11:41 pm
by Sereptus
Yes Jamz, that's what I was looking for. I suppose I'll just have to use the switch() CASE: for all the outputs if I want things calculated inside of text. Ugh! :? Thats a lot of writing for fumble and crit charts! LOL!! I'll post the macro when I find the time but for now this campaign is keeping me too busy. Thanks for the input guys! I also wanted the output of the charts in <font color=red size=+2> to make sure I wouldn't miss a fumble but haven't figured out how to do that either! :oops: Anyway! Back to the Orcs! :twisted:

P.S. Jamz, I switched over to your awesome NERPS version and am pretty impressed by certain functionality, although I have Herolab and Syrinscape I've been unable to get Herolab working at all, although I suspect it's because I'm using 5E. message me if you have any tips. :wink:

Re: putting a formula inside a table

Posted: Mon Feb 06, 2017 4:04 am
by Full Bleed
Sereptus wrote:Yes Jamz, that's what I was looking for.
You wanted to just click on the table from the table window and not use a macro for output?

Your example did not show a table that would display the output in the text you illustrated...

And why would just clicking on the table be easier/better than having a table macro? Guess I'm not seeing the problem here.

Re: putting a formula inside a table

Posted: Mon Feb 06, 2017 7:12 am
by Sereptus
Sorry Full Bleed, I wasn't being very specific or clear. I do use a macro to call crit and fumble charts that I got from a Pathfinder campaign file, I don't know who did all the work for the original charts.
Spoiler
Piercing_chart.png
Piercing_chart.png (147.41 KiB) Viewed 1032 times
My output to chat currently looks like this
Spoiler
Output.png
Output.png (16.95 KiB) Viewed 1032 times
I just was wondering if there was any way to have the expression evaluated when sending to chat,( GUT SLASH: Double damage and 3 bleed. Target cannot swallow whole.) also I wanted to make the text in BOLD RED for the fumble chart just to make sure I didn't miss that if I was busy looking something else up up when the player rolled. It seems this kind of functionality is not supported or maybe it is with the right coding when I call the macro?

Thanks again

Re: putting a formula inside a table

Posted: Mon Feb 06, 2017 4:04 pm
by JamzTheMan
I believe you will have to grab the table value and then parse it and format it. The easiest way may be to use regular expression to find "[0-9]+d[0-9]+" to find dice expressions and eval those and then put it together and format the string. Otherwise eval will try and evaluate the whole string in the table...

Re: putting a formula inside a table

Posted: Mon Feb 06, 2017 4:31 pm
by aliasmask
For the tables, if you surround the random values with [r: XX ] then when you get the string you can use evalMacro. I like that better than eval because if there is no code, it just returns it as a string. Basically, it looks for any [] and runs it with in the string. Also, there is no confusion as to what is code and what is not unlike with the eval function.

Re: putting a formula inside a table

Posted: Mon Feb 06, 2017 4:44 pm
by JamzTheMan
Ah, forgot about evalMacro. Man, it seemed like there would have been an easy way but it wasn't coming to me either.

Alias, can you also use {1d4} instead of [r: 1d4] ? Just curious.

Edit: Tested and yea, that works perfectly!

Table Test Entry 1: Double damage and {1d4} bleed!
[r: evalMacro(table("Test", 1))]

Re: putting a formula inside a table

Posted: Tue Feb 07, 2017 7:20 am
by Sereptus
Awesome! :mrgreen: Thanks guys! Now to edit all the tables to reflect this! :roll: BTW, who wrote all those fumble/crit tables for the Pathfinder framework?
Thanks again guys!

Re: putting a formula inside a table

Posted: Tue Feb 07, 2017 10:27 pm
by JamzTheMan
Sereptus wrote:Awesome! :mrgreen: Thanks guys! Now to edit all the tables to reflect this! :roll: BTW, who wrote all those fumble/crit tables for the Pathfinder framework?
Thanks again guys!
If they are the ones I'm thinking of, they were taking from the Critial Hit/Fumble decks from paizo. They are pretty fun, we use them at our table (physical cards).