putting a formula inside a table

Thoughts, Help, Feature Requests, Bug Reports, Developing code for...

Moderators: dorpond, trevor, Azhrei

Forum rules
PLEASE don't post images of your entire desktop, attach entire campaign files when only a single file is needed, or generally act in some other anti-social behavior. :)
Post Reply
User avatar
Sereptus
Giant
Posts: 123
Joined: Tue Jun 07, 2011 12:08 pm
Location: Canada

putting a formula inside a table

Post 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 1076 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?
OOOHH RegEx....YOU BITTER-SWEET BEAST!!!

User avatar
Full Bleed
Demigod
Posts: 4736
Joined: Sun Feb 25, 2007 11:53 am
Location: FL

Re: putting a formula inside a table

Post 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))]
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."

User avatar
JamzTheMan
Great Wyrm
Posts: 1872
Joined: Mon May 10, 2010 12:59 pm
Location: Chicagoland
Contact:

Re: putting a formula inside a table

Post 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.
-Jamz
____________________
Custom MapTool 1.4.x.x Fork: maptool.nerps.net
Custom TokenTool 2.0 Fork: tokentool.nerps.net
More information here: MapTool Nerps! Fork

User avatar
Sereptus
Giant
Posts: 123
Joined: Tue Jun 07, 2011 12:08 pm
Location: Canada

Re: putting a formula inside a table

Post 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:
OOOHH RegEx....YOU BITTER-SWEET BEAST!!!

User avatar
Full Bleed
Demigod
Posts: 4736
Joined: Sun Feb 25, 2007 11:53 am
Location: FL

Re: putting a formula inside a table

Post 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.
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."

User avatar
Sereptus
Giant
Posts: 123
Joined: Tue Jun 07, 2011 12:08 pm
Location: Canada

Re: putting a formula inside a table

Post 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 1031 times
My output to chat currently looks like this
Spoiler
Output.png
Output.png (16.95 KiB) Viewed 1031 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
OOOHH RegEx....YOU BITTER-SWEET BEAST!!!

User avatar
JamzTheMan
Great Wyrm
Posts: 1872
Joined: Mon May 10, 2010 12:59 pm
Location: Chicagoland
Contact:

Re: putting a formula inside a table

Post 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...
-Jamz
____________________
Custom MapTool 1.4.x.x Fork: maptool.nerps.net
Custom TokenTool 2.0 Fork: tokentool.nerps.net
More information here: MapTool Nerps! Fork

User avatar
aliasmask
RPTools Team
Posts: 9024
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: putting a formula inside a table

Post 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.

User avatar
JamzTheMan
Great Wyrm
Posts: 1872
Joined: Mon May 10, 2010 12:59 pm
Location: Chicagoland
Contact:

Re: putting a formula inside a table

Post 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))]
-Jamz
____________________
Custom MapTool 1.4.x.x Fork: maptool.nerps.net
Custom TokenTool 2.0 Fork: tokentool.nerps.net
More information here: MapTool Nerps! Fork

User avatar
Sereptus
Giant
Posts: 123
Joined: Tue Jun 07, 2011 12:08 pm
Location: Canada

Re: putting a formula inside a table

Post 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!
OOOHH RegEx....YOU BITTER-SWEET BEAST!!!

User avatar
JamzTheMan
Great Wyrm
Posts: 1872
Joined: Mon May 10, 2010 12:59 pm
Location: Chicagoland
Contact:

Re: putting a formula inside a table

Post 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).
-Jamz
____________________
Custom MapTool 1.4.x.x Fork: maptool.nerps.net
Custom TokenTool 2.0 Fork: tokentool.nerps.net
More information here: MapTool Nerps! Fork

Post Reply

Return to “MapTool”