Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Help request: How to write a simple function?

Hi there, new Mentor here who's a bit out-of-date as a programmer, I'd like to ask a Question: I'm trying to Implement D&D3.0 (now called Pathfinder?) and as you know the Ability Score Modifiers increase by one for every two points of Ability Score, from average (no bonus, score of 10-11) up to +4 (ability score of 18 or 19), etc. I have the six Abilities defined on my Character Sheet, so if the ability in question were Charisma, then the formula that I am using would be: (floor(@{Charisma}/2-5)) . I'd like to write a global function for that... would that technically be a Macro, or an API script? How do I create a macro that works like a function: meaning, I pass it a Character's Attribute, and it returns a number that I can easily use in a /roll expression?
no need for macro, floor((@{stat}-10)/2)
1400894668

Edited 1400894809
Using the pathfinder character sheets you can use @{selected|CHA-mod} Doing this in the macro with something like /roll 1d20+@selected|STR-mod} will print out in chat with the formula. For this example with 18 str will look like this: rolling 1d20+(floor(((18 + 0 + 0 + 0)) / 2) - 5) The +0+0+0 are values of Enhance Misc Temp modifiers that you can assign to the character sheet.
1400905649
Sam M.
Pro
Sheet Author
I'm pretty confused about what's going on. Are you using the Pathfinder character sheet or creating one for yourself?
I am assuming the attr panel is what they are referencing from. Maynot be aware about them, or how to select them.
Oh that's right: the official HTML/CSS character sheets are coming out on the 28th. I forgot! Thus far I've only begun to play with it, using the character attributes and abilities under the Journal tab. I guess I should wait for the Data Delve before I get too far ahead of myself, the coder of the Pathfinder character sheet probably solved a lot of this for me... : Þ Thank you!
1400928418
Sam M.
Pro
Sheet Author
I did in fact, but it's not as useful in the API. But you'd be able to do this using macros and abilities no problem.