A (long) MapTool macro tutorial

Doc requests, organization, and submissions

Moderators: dorpond, trevor, Azhrei

User avatar
Mr. Pokeylope
Giant
Posts: 118
Joined: Mon Aug 11, 2008 9:24 pm

Post by Mr. Pokeylope »

Okay, well, as it stands there is code that tries to do the replacement but it's slightly wrong, so it doesn't work. I'm fine with it not doing it, it just looks like its supposed to.
Last edited by Mr. Pokeylope on Thu Aug 28, 2008 1:07 am, edited 1 time in total.

User avatar
Norwolf
Kobold
Posts: 8
Joined: Thu Jul 24, 2008 12:53 am
Location: Calgary, AB

Post by Norwolf »

This might be useful to someone... I like files :)

http://gallery.rptools.net/v/contrib/No ... l.pdf.html

User avatar
Plissken
Giant
Posts: 116
Joined: Mon Jan 07, 2008 10:44 pm

Post by Plissken »

Are nested if statements possible?

knizia.fan
Giant
Posts: 197
Joined: Wed Jul 30, 2008 3:43 pm

Post by knizia.fan »

Plissken wrote:Are nested if statements possible?
Yes, they are. For example, here's a way to convert a number from 1-3 into the matching ordinal number.

Code: Select all

[h: Num = Enter_Your_Number]
[if(Num==1, "first", if(Num==2, "second", if(Num==3, "third", "Number too big!")))]
You can carry on embedding if() functions like that until you get bored, or until your code becomes an unreadable black hole :)

User avatar
FdL
Giant
Posts: 201
Joined: Thu Feb 28, 2008 5:21 pm

Post by FdL »

I love this macro in the explanation, it's what I was looking for to use in maptool.

But I see it doesn't work unless you make it as a token macro.

I'd prefer to have it as a campaign macro, for me to use with any token I select at that time.

I think it would require some major tweaking along the lines of using setting and reading token properties, but I haven't been able to do that succesfully (I'm new to scripting).

What I mean is so that I don't have to manually enter the macro in each token I make. I see there's no way to default this.

Also I'd prefer to have separate "Heal" and "Hurt" buttons.

Any pointers as to how to do these?

Edit: It makes a lot more sense to me to have positive numbers entered be interpreted as Healing, where negative ones would Hurt. It's more intuitive.

So I tweaked it into this (I don't use TempHP for now):

(hmm, can't post Code correctly, this eats some lines where I use color format)

Anyway, what I changed was pretty basic. Now positive numbers heal, negative numbers hurt.

Lindharin
Dragon
Posts: 668
Joined: Sat Apr 21, 2007 4:51 pm

Post by Lindharin »

FdL wrote:But I see it doesn't work unless you make it as a token macro. I'd prefer to have it as a campaign macro, for me to use with any token I select at that time.
You can do this now, though it is slightly annoying. Put the macro in a campaign button. Then select the token or tokens. Then RIGHT CLICK on the campaign macro button and in the pop-up context menu choose the option "Run as each selected". That will loop through all the selected tokens and run the macro as if it were a token macro. It is a little annoying but feasible. CAVEAT: Be VERY careful! The option right next to "Run as each selected" is DELETE, if I recall correctly. I've deleted a number of campaign macros by mistake by misplacing my mouse when I was trying to click on "Run as each selected."

In the next release, b42, this will no longer be necessary. There will be a new checkbox on the campaign and global macro config panels that will let you automatically apply the macro to selected tokens. If you check that checkbox, then you can just normally click the button and it will do the exact same thing as the current "Run as each selected".

User avatar
FdL
Giant
Posts: 201
Joined: Thu Feb 28, 2008 5:21 pm

Post by FdL »

That sounds awesome. I'll be waiting for b42! Thanks!

Crunchem
Kobold
Posts: 19
Joined: Sat Sep 20, 2008 9:02 pm

Post by Crunchem »

Just wanted to give props to the author of this. I spent waaay too many hours trying to parse macros to figure it out, and this has saved me a whole lot of time.

Thanks again!

User avatar
fuleng6021
Cave Troll
Posts: 29
Joined: Wed Oct 01, 2008 3:45 pm

Post by fuleng6021 »

Hello
I discovered maptool some time ago and also i had some difficulties inthe beginning now it seams at most is working. I also started to use macros. with them i have a problem, which is maybe too simple, but i did not find anyt solution on the forum.
a macro in [] like the one in the tutorial

Simple HTML example:
Code:
<b>Initiative roll:</b>
<br>My initiative is <span>[1d20+3]</span>.

should be output in the chat as:
Image

but my output only shows the
My initiative is = "final sum"
the only differents to a code with {} is the light blue backround.

Did i set some basic properties wrong or why is my [] macro output like the {}?

the_meek
Cave Troll
Posts: 99
Joined: Fri Aug 01, 2008 9:18 am

Post by the_meek »

The rolls were changed somewhat a few builds back. If you mouseover your shaded output in the chat window, you'll get a tooltip showing the expanded roll. If you want the roll expanded in chat, you need to specify that in the roll, like this:

<b>Initiative Roll:</b><br>
My initiative is [E: 1d20+3].

to get:

Initiative Roll:
My initiative is « d20+3 = 13 + 3 = 16 ».

User avatar
FdL
Giant
Posts: 201
Joined: Thu Feb 28, 2008 5:21 pm

Post by FdL »

I think there should be an option to set the default mode of display for rolls to solve that. I mean, it's hard for me as a DM to tell when the roll was a critical.

But anyway, I wanted some basic help or links to threads where I can learn to manipulate the health bar with scripts like the "Heal/Hurt" one I got.

Edit:

For criticals this seems to work (as pointed here http://forums.rptools.net/viewtopic.php?p=62405#62405)

My example application of this:

Code: Select all

[h: myroll=d20]

<b><span>Heavy Mace: [if(myroll>=threatrange, 'CRITICAL', myroll+5)]</span></b>, damage: <b><span>[1d8+1]</b></span>
This has the disadvantage that I can't get to see the result of the roll, nor I can add the bonus to it. I just tried this, I'm not great at scripting so it should be something dumb I'm not doing. (I don't remember how to output the roll AND a bit of text together for example :s I tried [something] & "text" but doesn't work)

User avatar
fuleng6021
Cave Troll
Posts: 29
Joined: Wed Oct 01, 2008 3:45 pm

Post by fuleng6021 »

the_meek wrote:The rolls were changed somewhat a few builds back. If you mouseover your shaded output in the chat window, you'll get a tooltip showing the expanded roll. If you want the roll expanded in chat, you need to specify that in the roll, like this:

<b>Initiative Roll:</b><br>
My initiative is [E: 1d20+3].

to get:

Initiative Roll:
My initiative is « d20+3 = 13 + 3 = 16 ».
Thank you

Mr_Rose
Kobold
Posts: 4
Joined: Fri Nov 28, 2008 8:37 pm

Post by Mr_Rose »

FdL wrote:I think there should be an option to set the default mode of display for rolls to solve that. I mean, it's hard for me as a DM to tell when the roll was a critical.

But anyway, I wanted some basic help or links to threads where I can learn to manipulate the health bar with scripts like the "Heal/Hurt" one I got.

Edit:

For criticals this seems to work (as pointed here *no linky for a poor n00b*)

My example application of this:

Code: Select all

[h: myroll=d20]

<b><span>Heavy Mace: [if(myroll>=threatrange, 'CRITICAL', myroll+5)]</span></b>, damage: <b><span>[1d8+1]</b></span>
This has the disadvantage that I can't get to see the result of the roll, nor I can add the bonus to it. I just tried this, I'm not great at scripting so it should be something dumb I'm not doing. (I don't remember how to output the roll AND a bit of text together for example :s I tried [something] & "text" but doesn't work)
So, I've been looking to create something like this, then I spot your work here and am inspired:
I still can't get the "if()" statement to take combinations of dicerolls easily, but it will accept variables as arguments.
The following seems to get most of the way there, but I am still new to maptool and macros in general, so it probably needs some refinement.

Code: Select all

[h: critbonus=d6]
[h: mydamage=d10+1]
[h: roll=d20]
<b>Longbow +1:</b> [myroll=roll+9] [if(roll>=20, 'CRITICAL HIT! Deals 11 damage +' +critbonus , 'damage:' +mydamage )]
This shows what you rolled (unexpanded unfortunately) and tells you the weapon's max damage plus any bonus it gets from crits (for being magic etc.) on a critical roll, or just rolls damage if it's a non-crit.

I expect that a lot of the variables could be altered to include token properties too...

Hope this helps.

Lyve1
Kobold
Posts: 4
Joined: Sun Jul 27, 2008 9:59 am

Re: A (long) MapTool macro tutorial

Post by Lyve1 »

I have a question. I notice that when you mouse over the calculation results of a macro that is set in a field in the token properties menu. The results of the calculation are show in edition to the numbers added together. I realize that simply mousing over the single digit number will briefly display the same calculation so it seems kinda redundant to have it all display in the chat window. I simply want to see My attack rolls end results and damage displayed. Not necessarily the entire calculation.

How can I code my macro ...say my wp damage [1d8]+ whatever code is in my macro for the given ability combat bonuses ect... in my token property so it doesn't display the entire calculation in the chat window?

ddrewitz
Kobold
Posts: 11
Joined: Wed Nov 19, 2008 10:10 pm

Re: A (long) MapTool macro tutorial

Post by ddrewitz »

i believe you have to put the ! before and after the code to not print it.

Post Reply

Return to “Documentation Requests/Discussion”