What are h:,r:,t: and when do I use colons versus commas?

Discuss macro implementations, ask for macro help (to share your creations, see User Creations, probably either Campaign Frameworks or Drop-in Resources).

Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice

Post Reply
Ctesias
Kobold
Posts: 10
Joined: Fri Jun 20, 2014 9:59 am

What are h:,r:,t: and when do I use colons versus commas?

Post by Ctesias »

I am seeing inconsistent examples throughout the internet using maptools to write macros and I am having trouble finding answers to the questions in the title.

Whare are h:,r:, and t:? Are there any others?

When do I use commas with h,r,t,etc and when do I use colons?

Why doesn't this code work? this is a token macro. DexBonus is a property on the token, that's why it's not listed in the macro:

[h: FlurryPenalty = -2]
[h: FeatBonus = 1]
[h: NumFlurryAttacks = 2]

[h: ListOfRolls = " "]
[h, count(NumFlurryAttacks), code:
{
[h: r = roll(1, 20)]
[h: ListOfRolls = listAppend(ListOfRolls, r)]
}
]
Flurry of Blows:<br>
Roll + flurry penalty + dex + featbonus<br>
[h, foreach(roll, ListOfRolls), code:
{
[r: roll +"+"+ FlurryPenalty +"+"+ DexBonus +"+"+ FeatBonus +":"+ roll + FlurryPenalty + DexBonus + FeatBonus]
}
<br>
]


gets me:


Testad Venturer:
Flurry of Blows:
Roll + flurry penalty + dex + featbonus
[h, FOREACH(roll, ListOfRolls), code: { [r: roll +"+"+ FlurryPenalty +"+"+ DexBonus +"+"+ FeatBonus +":"+ roll + FlurryPenalty + DexBonus + FeatBonus }
]


and I'm not entirely sure why. Insight is appreciated.

User avatar
Jagged
Great Wyrm
Posts: 1306
Joined: Mon Sep 15, 2008 9:27 am
Location: Bristol, UK

Re: What are h:,r:,t: and when do I use colons versus commas

Post by Jagged »

Its all in the Wiki

"r" is short for result
"h" is hidden
"t" is tooltip

IF statements and other branching statements need a comma rather than a colon. Don't ask me why ;)

Ctesias
Kobold
Posts: 10
Joined: Fri Jun 20, 2014 9:59 am

Re: What are h:,r:,t: and when do I use colons versus commas

Post by Ctesias »

Could you add a little more information around what r: and t: actually do in terms of their use?

User avatar
Jagged
Great Wyrm
Posts: 1306
Joined: Mon Sep 15, 2008 9:27 am
Location: Bristol, UK

Re: What are h:,r:,t: and when do I use colons versus commas

Post by Jagged »

They control the output of the following function or code. R shows the results. H hides the results.

So typically you hide your variable statements and only show the last line for the result. The Wiki really explains this better than I can.

Code: Select all

[h:x=getTokenX(0)]
[h:y=getTokenY(0)]
Your token is at [r:x],[r:y]<br>


User avatar
JML
Dragon
Posts: 515
Joined: Mon May 31, 2010 7:03 am
Location: Blagnac, France

Re: What are h:,r:,t: and when do I use colons versus commas

Post by JML »

Ctesias wrote:Could you add a little more information around what r: and t: actually do in terms of their use?
Just read this:

MeMeMe
Dragon
Posts: 256
Joined: Tue Mar 31, 2009 7:44 pm

Re: What are h:,r:,t: and when do I use colons versus commas

Post by MeMeMe »

Given that you're already writing macros, I don't think RTFM manual posts are all that helpful. There are a lot of gotchas in maptool scripting, thing it's easy to trip up over, aqnd aren't well-explained anywhere. So I'll attempt to give you some genuine help.

[quote="Ctesias"]When do I use commas with h,r,t,etc and when do I use colons?[/code]

I don't think the linked articles explain this at all well, so:

There are two types of commands, let's call them "containers" and "commands".

Containers (the wiki calls the Roll Options, but the term is misleading, since they don't just affect rolls) contain one or more commands.
* Containers must ALWAYS be followed by a single colon, EXCEPT
* you may use several containers, but if so, you MUST separate them by commas, and the LAST one gets a colon.

Sometimes, they just contain a single command, like
[H: FlurryPenalty = -2]

Here's an example from your example, using multiple containers (h, count, code):

[h, count(NumFlurryAttacks), code:
{
[h: r = roll(1, 20)]
[h: ListOfRolls = listAppend(ListOfRolls, r)]
}
]


You also asked about R and T.

If you have code like this
[DieRoll = 1d20]
You will get output that is different, depending on the maptool user's preferences.
If they have "Use ToolTips for Inline Rolls" unchecked, they will see this:
Player: 13
The 13 will be shaded, and you can hover your mouse over it and will see a tooltip, showing some text about how the roll was generated. That will look something like (in this example):
« DieRoll = 1d20 = DieRoll = 13 = 13 »
Basically it shows how the result was built. In more complicated examples, like 3d6+d8+4, it helps you to see what the dice each rolled and check the roll was legal, or check for things like exploding dice, crit results, etc, if you haven't coded the macro to handle them automatically.

If they have that setting checked, the output will look like this (no tooltip)
Player: « DieRoll = 1d20 = DieRoll = 13 = 13 »
So the full working is printed out to chat with no mouseover needed to see it.

Some groups don't like to see the full working, it looks pretty ugly, so the GM has the option of setting that preference whenever they satart a server.

So, having explained that, the roll options r, t, e, h, etc allow the macro r=writer to control exaclty what is output.

[h] is very useful, as it allows to run commands, without outputting anything to chat.
[r] allows you to control exactly what appears in chat. If you have [R: 1d20+7] it will always print out a number like 10, 27, etc, and will have no tooltip, so there is no way to see what the working was. It's very handy, since you can combine it with if statements and so on, and use it to build part of a macro's output without distracting tooltips.
Like, I've used examples like this contrived one:
[H:NumAliens=1d6]There [R,IF(NumAliens>1):"are";"is"] [R:NumAliens] orc[R,IF(NumAliens>1):"s"].
I hide the roll, so it's not output to chat. I use an IF statement to choose the correct word choice for single orc vs multiple orcs, and use R to make sure there is no tooltip which would be inappropriate here.

[t} allows you to control what appears in the tooltip, though I have never used that so I'm not sure how to construct it.

=============
Regarding your macro, I haven't tested it but this jumps out at me:
[h: ListOfRolls = " "]

This should be
[h: ListOfRolls = ""]

Also, when a macro outputs some code from the macro itself, it usually means there's a quote that isn't closed properly. So maptool is interpreting everything in that section of code as a string.
MapTools Forks: Thread

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

Re: What are h:,r:,t: and when do I use colons versus commas

Post by Full Bleed »

MeMeMe wrote:Given that you're already writing macros, I don't think RTFM manual posts are all that helpful.
I've been writing macros for many years and I still need to RTFM manual (i.e. look at the wiki) every time I sit down to write more. Macroscript is quirky and there is no better substitute for figuring out how something needs to be done than looking at the wiki and *then* finding some recent code that actually works as intended.
There are a lot of gotchas in maptool scripting, thing it's easy to trip up over, aqnd aren't well-explained anywhere. So I'll attempt to give you some genuine help.
Better yet, I suggest that you might want to add examples and clarifications to the WIKI so you can help more than just this one guy if you believe what's there is insufficient. I'm certainly no stranger to pointing out holes in the wiki when I see them and imploring those in the know to provide clarification... but that doesn't change the fact that it's the best resource MT has going for it and if anyone wishes to write any kind of macroscript they should spend some quality time getting familiar with where common building-block information is located.
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."

Ctesias
Kobold
Posts: 10
Joined: Fri Jun 20, 2014 9:59 am

Re: What are h:,r:,t: and when do I use colons versus commas

Post by Ctesias »

the links and information were to pages I'd not discovered before. They've been very helpful, thanks.

User avatar
JML
Dragon
Posts: 515
Joined: Mon May 31, 2010 7:03 am
Location: Blagnac, France

Re: What are h:,r:,t: and when do I use colons versus commas

Post by JML »

You're welcome. Glad this was of some help.

@Full Bleed: +1

Post Reply

Return to “Macros”