A (long) MapTool macro tutorial

Doc requests, organization, and submissions

Moderators: dorpond, trevor, Azhrei

User avatar
trevor
Codeum Arcanum (RPTools Founder)
Posts: 11311
Joined: Mon Jan 09, 2006 4:16 pm
Location: Austin, Tx
Contact:

Post by trevor »

Moved to documentation forum and stickied
Dreaming of a 1.3 release

Elorebaen
Dragon
Posts: 365
Joined: Sat Dec 22, 2007 5:37 pm

Post by Elorebaen »

Hello,

I am rather new to macro programming. Can I have parts of a macro simply fulfill the function without giving output in the Chat window?

For example:
{token.name} takes {DamageValue} points of damage!
<br>Now {token.name} only has {HP = HP - DamageValue} hit points

If I wanted to place this on NPCs, I would not want the info after the BR to show in the Chat window.

Thanks for the help!
E

User avatar
jfrazierjr
Deity
Posts: 5176
Joined: Tue Sep 11, 2007 7:31 pm

Post by jfrazierjr »

Elorebaen wrote:Hello,

I am rather new to macro programming. Can I have parts of a macro simply fulfill the function without giving output in the Chat window?

For example:
{token.name} takes {DamageValue} points of damage!
<br>Now {token.name} only has {HP = HP - DamageValue} hit points

If I wanted to place this on NPCs, I would not want the info after the BR to show in the Chat window.

Thanks for the help!
E

No, you can use /self to only send to yourself or /gm to only send to you and he GM, but it's all or nothing within a macro.
I save all my Campaign Files to DropBox. Not only can I access a campaign file from pretty much any OS that will run Maptool(Win,OSX, linux), but each file is versioned, so if something goes crazy wild, I can always roll back to a previous version of the same file.

Get your Dropbox 2GB via my referral link, and as a bonus, I get an extra 250 MB of space. Even if you don't don't use my link, I still enthusiastically recommend Dropbox..

bobthedog
Cave Troll
Posts: 85
Joined: Sun Aug 03, 2008 7:17 pm

Post by bobthedog »

Elorebaen wrote:Hello,

I am rather new to macro programming. Can I have parts of a macro simply fulfill the function without giving output in the Chat window?

For example:
{token.name} takes {DamageValue} points of damage!
<br>Now {token.name} only has {HP = HP - DamageValue} hit points

If I wanted to place this on NPCs, I would not want the info after the BR to show in the Chat window.

Thanks for the help!
E
What I have done (not really macro related, but) is create a separate property set for monsters/NPCs. Then (among other stuff), I set this property in there:

*#HP

Every macro that changes HP works with it, because it's the same property name, but it'll only show the NPC's HP (on the statsheet) to the GM.

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

Post by knizia.fan »

Elorebaen wrote:Hello,

I am rather new to macro programming. Can I have parts of a macro simply fulfill the function without giving output in the Chat window?

For example:
{token.name} takes {DamageValue} points of damage!
<br>Now {token.name} only has {HP = HP - DamageValue} hit points

If I wanted to place this on NPCs, I would not want the info after the BR to show in the Chat window.

Thanks for the help!
E
As jfrazier said, you can't have players and GMs see different parts of the output. However, you can comment out the second line (using <!-- -->)so that the effect takes place but nothing is printed to the chat window.

Elorebaen
Dragon
Posts: 365
Joined: Sat Dec 22, 2007 5:37 pm

Post by Elorebaen »

Thank you for the responses!

Also, I forgot to mention, thank you for the tutorial!!

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

Post by Mr. Pokeylope »

jfrazierjr wrote:No, you can use /self to only send to yourself or /gm to only send to you and he GM, but it's all or nothing within a macro.
This is on my to-do list of things to fix (allowing multiple commands within a macro), but based on the evaluation I did while waiting on roll syntax feedback, it'll take a fair bit of effort to get it working

So, eventually, maybe.

User avatar
jfrazierjr
Deity
Posts: 5176
Joined: Tue Sep 11, 2007 7:31 pm

Post by jfrazierjr »

Mr. Pokeylope wrote:
jfrazierjr wrote:No, you can use /self to only send to yourself or /gm to only send to you and he GM, but it's all or nothing within a macro.
This is on my to-do list of things to fix (allowing multiple commands within a macro), but based on the evaluation I did while waiting on roll syntax feedback, it'll take a fair bit of effort to get it working

So, eventually, maybe.
Hmm... I wonder if you can hook into existing mechanics like what you are doing with tooltips. For example:

/me does super foo [/gm "I actually user super bar instead"]
I save all my Campaign Files to DropBox. Not only can I access a campaign file from pretty much any OS that will run Maptool(Win,OSX, linux), but each file is versioned, so if something goes crazy wild, I can always roll back to a previous version of the same file.

Get your Dropbox 2GB via my referral link, and as a bonus, I get an extra 250 MB of space. Even if you don't don't use my link, I still enthusiastically recommend Dropbox..

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

Post by Mr. Pokeylope »

jfrazierjr wrote:Hmm... I wonder if you can hook into existing mechanics like what you are doing with tooltips. For example:

/me does super foo [/gm "I actually user super bar instead"]
Nah, it'd just be done using the multi-line macro editor, and each line would be a separate command. In theory you're supposed to be able to use newlines to automatically insert <br> tags, but since there's a bug that prevents that from working at the moment, I don't feel too bad about changing the (intended) behavior.

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

Post by Plissken »

Hi, I'm trying to make it so that when a monster reaches its bloodied value, the bloodied state will show up. I tried this and variants of this but wouldn't work.

{ if (HP==30, [state.Bloodied = 1], [state.Bloodied = 0] ) }

What is the correct way to do this?

User avatar
jfrazierjr
Deity
Posts: 5176
Joined: Tue Sep 11, 2007 7:31 pm

Post by jfrazierjr »

Mr. Pokeylope wrote:
jfrazierjr wrote:Hmm... I wonder if you can hook into existing mechanics like what you are doing with tooltips. For example:

/me does super foo [/gm "I actually user super bar instead"]
Nah, it'd just be done using the multi-line macro editor, and each line would be a separate command. In theory you're supposed to be able to use newlines to automatically insert <br> tags, but since there's a bug that prevents that from working at the moment, I don't feel too bad about changing the (intended) behavior.


Ummm what? What bug are you talking about, cause it may not be a bug....
I save all my Campaign Files to DropBox. Not only can I access a campaign file from pretty much any OS that will run Maptool(Win,OSX, linux), but each file is versioned, so if something goes crazy wild, I can always roll back to a previous version of the same file.

Get your Dropbox 2GB via my referral link, and as a bonus, I get an extra 250 MB of space. Even if you don't don't use my link, I still enthusiastically recommend Dropbox..

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

Post by Mr. Pokeylope »

Plissken wrote:Hi, I'm trying to make it so that when a monster reaches its bloodied value, the bloodied state will show up. I tried this and variants of this but wouldn't work.

{ if (HP==30, [state.Bloodied = 1], [state.Bloodied = 0] ) }

What is the correct way to do this?
{state.Bloodied = if (HP==30, 1, 0) }

Although {state.Bloodied = if (HP <= MaxHP / 2, 1, 0) } would probably be a better way to do it? (Assuming you've got a MaxHP property set.) Using <= so that the monster doesn't have to be exactly at the bloodied value for it to be set.

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

Post by Mr. Pokeylope »

jfrazierjr wrote:Ummm what? What bug are you talking about, cause it may not be a bug....
If you have the following macro:

Code: Select all

foo
bar
the documented behavior is that it will replace the newline with a <br> tag. The code to do this exists, but there's a bug in it and the replacement doesn't actually happen. So instead of "foo<br>bar" you get "foo\nbar" (where "\n" represents a newline), which when rendered as HTML is printed as "foo bar".

User avatar
jfrazierjr
Deity
Posts: 5176
Joined: Tue Sep 11, 2007 7:31 pm

Post by jfrazierjr »

Mr. Pokeylope wrote:
jfrazierjr wrote:Ummm what? What bug are you talking about, cause it may not be a bug....
If you have the following macro:

Code: Select all

foo
bar
the documented behavior is that it will replace the newline with a <br> tag. The code to do this exists, but there's a bug in it and the replacement doesn't actually happen. So instead of "foo<br>bar" you get "foo\nbar" (where "\n" represents a newline), which when rendered as HTML is printed as "foo bar".
Pretty sure it's NOT a bug. Basically, if I remember corretly, this was changed to NOT insert a br automatically because that messes upformatting of tables when someone tries to "prettify" their HTML code. everywhere there is a br tag, the table gets another empty cell that's about 3 px wide...

Talk to Orchard who originally reported the problem (though I had noted it before and had just not tracked down the cause) to make sure what you are doing won't cause his tables to go haywire...
I save all my Campaign Files to DropBox. Not only can I access a campaign file from pretty much any OS that will run Maptool(Win,OSX, linux), but each file is versioned, so if something goes crazy wild, I can always roll back to a previous version of the same file.

Get your Dropbox 2GB via my referral link, and as a bonus, I get an extra 250 MB of space. Even if you don't don't use my link, I still enthusiastically recommend Dropbox..

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

Post by Lindharin »

I have to say that I really prefer newlines in the macro code to NOT cause automatic <br> tags. That will just make macros so much harder to read, if the macro commands have to be on one long line or have random <br> tags in them.

But I admit I'm biased because I don't do much typing in the chat window directly. It's all in the macro editor, and losing line breaks there will make that little text area that much harder to work with.

If people want that functionality back, at least consider some way to turn it off, maybe with some option/code at the start of the macro or something.

Post Reply

Return to “Documentation Requests/Discussion”