A (long) MapTool macro tutorial

Doc requests, organization, and submissions

Moderators: dorpond, trevor, Azhrei

User avatar
Azhrei
Site Admin
Posts: 12086
Joined: Mon Jun 12, 2006 1:20 pm
Location: Tampa, FL

Re: A (long) MapTool macro tutorial

Post by Azhrei »

Lyve1 wrote: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?
Read the first post again, in the section under What Macros Can Do. Note that some functions are built in and other functions might require you to write HTML that produces the effect you're looking for.

Klandaghi
Kobold
Posts: 2
Joined: Sat Feb 24, 2007 5:37 am

Re: A (long) MapTool macro tutorial

Post by Klandaghi »

I know that other scripting and programming languages support labels and or functions, is that a possibility with Macros? I.E.

Code: Select all

<!-- Reset Variables to be safe. -->
     [DiceRolled=0]
     [Successes=0]
     [Botch=0]

<!-- Get number of Dice to Roll [LoopControlVariable=Dice_to_roll] -->

<!-- Get the Difficulty or number to beat [Difficulty=What_is_the_difficulty] -->

<!-- Have label at start of code where you would like everything that follows to be able to be repeated by being called. -->
     [Label:MyLabel]

<!-- Start Loop -->
     if(LoopControlVariable>0, <!-- Increment DiceRolled [DiceRolled = DiceRolled + 1] -->, <!-- Do nothing if false -->)

<!-- Display Roll and save it to a variable for comparisions -->
     if(LoopControlVariable>0, "Die " + {DiceRolled} " = " + [RollVal=1d10], <!-- Do nothing if false -->)

<!-- What is the roll, success, failure, one, or ten? -->
     if(RollVal>=Difficulty,[Successes=Successes+1], if(RollVal==1 [Successes=Successes-1], <!-- Do Nothing -->))

<!-- Is it a success and thus canceled out all botching? -->
     if(RollVal>=Difficulty,[Botch=Botch+1], <!-- Do Nothing -->)
     if(RollVal==10,[Successes=Successes+1], if(RollVal==1,[LoopControlVariable = LoopControlVariable + 1]))

<!-- Decrement LoopControlVariable -->
      [LoopControlVariable = LoopControlVariable - 1]

<!-- Go back up to MyLabel -->
      [Goto MyLabel]

<!-- Comma Delineating False Code -->
     ,
      [Insert Code that outputs all that stuff here])
[Move on to more code since the Loop has finished]
Most of my experience comes from PASCAL so my thoughts and ideas on scripting might be a little bit off. I'm just looking for a way to cut down on macro code and not have to copy and paste and repeat. My ideal usage would be for an Old World of Darkness game like Werewolf: The Apocalypse. You could have one roll die function that would repeat for the number of dice you had (prompted for number of dice at the beginning and the difficulty) and that would keep track of the number of dice rolled then spew the information out at the end of it all.

I kind of lost concentration on what i was writing, and I don't need to put all the code up there that I was thinking of for this post to get the idea across I don't think. I'll save us all the headache hehehe.

Craig
Great Wyrm
Posts: 2107
Joined: Sun Jun 22, 2008 7:53 pm
Location: Melbourne, Australia

Re: A (long) MapTool macro tutorial

Post by Craig »

There is no Label/goto Label like functionality. But there is looping
http://lmwcs.com/maptool/index.php?titl ... nd_Looping
There are while/for/foreach/count loops. Unfortunately there are no continue/break analogues so you must go through the whole loop, but in a lot of cases that is not that big a problem.

stealthbaz
Kobold
Posts: 12
Joined: Thu Feb 19, 2009 4:07 pm

Re: A (long) MapTool macro tutorial

Post by stealthbaz »

Is there a way to alter the token's health bar via script?

I.e. is there a token variable to access that health bar setting?

stealthbaz
Kobold
Posts: 12
Joined: Thu Feb 19, 2009 4:07 pm

Re: A (long) MapTool macro tutorial

Post by stealthbaz »

Oop.. .posted too soon. I found it:

setBar(name, percentage)

http://lmwcs.com/maptool/index.php?titl ... ons:setBar

chrono21791
Kobold
Posts: 1
Joined: Tue Aug 03, 2010 10:43 pm

Re: A (long) MapTool macro tutorial

Post by chrono21791 »

I'm trying to make a simple macro that will detect critical hits. I think I can do that on my own, but I've been running into major problems trying to make everything simple. Basically, I use {} for my roll commands because I don't want to see the whole thing, and I want it to be able to detect critical hits because I cant see the entire result.

I am trying to modify this macro, and once I do that, I can adapt it to all other attack macro commands.

Serraziel tries to capture her opponent in her jaws!
<br>She rolls: <b>{1d20+4}</b>

This makes it simple and easy to read, but unfortunately, if left like this, I would have to remember the attack bonus and manually subtract it from each result to see if it is a critical hit. Can anyone help? I have looked in many tutorials on how to use critical hits but most of them either give me a box asking me to enter the roll result, or simply give me an error, saying I have invalid commands.

LarryHunsaker
Kobold
Posts: 24
Joined: Wed Oct 06, 2010 10:35 am

Re: A (long) MapTool macro tutorial

Post by LarryHunsaker »

You can detect critical hits pretty easily.
Just use this to make your d20 roll and set an Attack Bonus:

[h: Roll=d20]
[h: AttackBonus=4]

Then you use this to set the Critical Hit threshold, I will assume a natural 20 for this:

[h: CriticalHit = 20]

Then use this:

[if(Roll>=CriticalHit),CODE:{Critical Hit ([Roll+AttackBonus])!};{[Roll+AttackBonus]}]

That should do it for you. So your example would go from this:

Serraziel tries to capture her opponent in her jaws!
<br>She rolls: <b>{1d20+4}</b>

To this:

Serraziel tries to capture her opponent in her jaws!
[h: Roll=d20]
[h: CriticalHit = 20]
[h: AttackBonus=4]
<br>She rolls: <b>[if(Roll>=CriticalHit),CODE:{Critical Hit ([Roll+4])!};{[Roll+4]}]</b>

Hope that helps.

DrnkBstrd
Kobold
Posts: 13
Joined: Thu Mar 31, 2011 4:17 pm

Re: A (long) MapTool macro tutorial

Post by DrnkBstrd »

Hello Everybody

I am totaly new to all this, I started to work Image and Pog files into the Gametable app. a couple of months ago and ran across Maptool app. about a month ago, and have to say it's alot better, but alot more advanced. I love the idea of Macros to play out commands but don't have the first idea about scripting.I have begun by looking into these Macro Scripts and it dosn't seem too difficult,and even got the couple I've found running, but rather than "Reinvent the Wheel" I was wondering where I might find a comprehensive list of basic and/or general Macros Scrips that could be copied and pasted. As this can be quite time consuming and I want to start Playing as soon as possible.

I Have tried a couple of the frameworks and they seem great but I'm unsure of how to apply the existing Macros to the tokens, or which do what exactally.

Exellent tutorial, It really gave a good grasp on What Macros are and what they an do. Thank You for making such resources available.

imneuromancer
Kobold
Posts: 1
Joined: Sun Jul 24, 2011 11:47 pm

Re: A (long) MapTool macro tutorial

Post by imneuromancer »

I am confused as to how you can macro out one token doing something to another token. For example, Alice wants to hit Bill with a sword. How does one macro out Alice's attack roll and damage, then compare it to Bill's AC and subtract the damage from his hit points if it succeeds?

Once I grok that, I have a feeling that maptools is going to find its way to even my tabletop games (not just my internet games!) because it will be so incredibly handy!

User avatar
Azhrei
Site Admin
Posts: 12086
Joined: Mon Jun 12, 2006 1:20 pm
Location: Tampa, FL

Re: A (long) MapTool macro tutorial

Post by Azhrei »

You want something called "Library tokens". Macros on a Lib: token can be executed in a trusted mode if everything is set up correctly. In that mode they can modify properties on other tokens, not just the token that invoked the Lib: macro in the first place.

Start at the Main Page of the wiki.

J0fSpades
Kobold
Posts: 2
Joined: Mon Apr 22, 2013 1:56 pm

Re: A (long) MapTool macro tutorial

Post by J0fSpades »

So, I just want a simple macro that displays damage and attack rating. However, this seems to be the most difficult thing I've ever had to do in my life. I type in this in the command section of the macro:

I make an attack roll!<br>
<b>Attack</b>: [1d20+7]<br>
<b>Damage</b>: [1d8+5]

I get this as a display:
I make an attack roll!
Attack: 23 Damage:Attack: 23
Damage:: 23
Damage:Damage:: 12

Even worse, I enter this:
I attack [1d20] and deal [1d8] damage.

And I see this:
I attack 16 and dealand deal 5 damage.

Forgive me if this has been addressed, but I can't seem to find an answer anywhere.

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: A (long) MapTool macro tutorial

Post by wolph42 »

J0fSpades wrote:So, I just want a simple macro that displays damage and attack rating. However, this seems to be the most difficult thing I've ever had to do in my life....
this is really asking for some snappy comments now is it :mrgreen:
I make an attack roll!<br>
<b>Attack</b>: [1d20+7]<br>
<b>Damage</b>: [1d8+5]
please use the 'code' tags, which you can find at the top of the post edit window.

ok to help you out:
first of all you've encountered a bug thats currently active in b89 of MT. turn off the smileys in the settings and you won't get the 'double post' 'double post' anymore :wink:
second, start reading theroll options in the wiki. Especially: r,s,h and g. These used most.
your example then becomes (per example):

Code: Select all

I make an attack roll!<br>
 <b>Attack</b>: [r:1d20+7]<br>
 <b>Damage</b>: [r:1d8+5]
or

Code: Select all

I make an attack roll!<br>
 <b>Attack</b>: [r,g:1d20+7]<br>
 <b>Damage</b>: [r,g:1d8+5]
or

Code: Select all

I make an attack roll!<br>
 <b>Attack</b>: [r,s:1d20+7]<br>
 <b>Damage</b>: [r,s:1d8+5]
or you can leave it as you did (but then turn off the smiley in the settings).

Post Reply

Return to “Documentation Requests/Discussion”