My First Macro! Next Step help, please

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
venger
Giant
Posts: 144
Joined: Tue Apr 17, 2007 11:37 am

My First Macro! Next Step help, please

Post by venger »

Hello!
My first macro. I'm digging in to learn some macro coding to better understand things like BOT and Frameworks. I looked at the code in BOT and a D&D5e framework and it's daunting for me atm.

To get my feet wet I started coding from scratch.
Started out to be simple combat roll calculator, with both hard-coded and prompted inputs, with an output to CHAT, which evolved to this rather verbose macro, to be trimmed down later as I gain confidence.

So I did the following;
In Campaign Properties I created a new Token Type named CHARACTER (shown below).

Then, created a new Token and on the SELECTED panel wrote a macro named THE WHITE SPEAR (shown below).

It works nicely, but now I realize I'd have to code every different Token, so I want to eventually make this macro more generic.
Been googling, but not stumbled onto just what I need yet.

For now I want just the weapon values, and the ProfBonus value within the token itself, or other data source.
I'm sure a common task, but for me atm, daunting!
I'll tackle searching for and choosing enemy tokens to query Armor Class and other stuff later.

So please, advise me. I'm not asking you to code it, I want to learn this, so snippets, links to code examples etc. would be very much appreciated.

PS: Wondering if I should delve into Library Tokens for storing data? idk if that's necessary unless its best practice. I dont plan on doing the entire Players Handbook, just the stuff we need to semi automate our F2F game.
tyvm!
----------------------------------------------
I created a Token Type named CHARACTER with these properties;

Code: Select all

*LEVEL 
*HP
*MaxHP
*AC
*INIT
*STR
*DEX
*CON
*INT
*WIS
*CHA
*SPEED
*PROFBONUS
*PASSIVE WIS
*Weap1
*WepAtt1Bonus
*WepAtt1Damage
*Weap2
*WeapAtt2Bonus
*WepAtt2Damage
And Here is the macro I've written in the SELECTED panel.
Name: THE WHITE SPEAR

Code: Select all

<b><font color="teal">
Roars: "I BEAR THE WHITE SPEAR!"<br>
------------------------<br>
<b><font color="red">
TAKES AN ATTACK ACTION USING;
<b><font color="green">
(THE WHITE SPEAR), Spear-Long,(Versitile), Reach(10ft)
<br>
Speartip:1d6 Pierce, Butt:1d4 Bludgeoning
<br>
Attack Bonus +2 (Proficiency Bonus)
<br>
[h:dice=0]
[h:ProfBonus=2]
[h:DamageTip=0]
[h:DamageButt=0]
[h:RageBonus=0]
[h:AttackRoll=0]
[h:TargetNumber=0]
<br>
<b><font color="black">
[h: dice=1d20]
Your Attack Roll: d20=[dice] + Prof Bonus:[ProfBonus]- Total:[dice + ProfBonus]
[h: AttackRoll = dice + ProfBonus]
<br>
Attack Roll: [AttackRoll]
[h: input("RageCheck | 0 | Raging? | CHECK")]
[h,if(RageCheck==1): RageBonus = 2; RageBonus = 0]
[h:input("TargetNumber | 10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30 |Enemy Armor Class| LIST |SELECT=0 VALUE=STRING")] <br>
Enemy Armor Class: [Targetnumber] 
<br><br>
[if(AttackRoll >= TargetNumber), code:
{
  <b><font color="blue">
  ---------- YOUR ATTACK HITS ----------<br>
  PRIMARY DAMAGE ROLLED 1d6= [DamageTip = 1d6] <br>
  SECONDARY DAMAGE ROLLED 1d4= [DamageButt= 1d4]<br>
  Rage Bonus: [RageBonus]<br>
  GRAND TOTAL DAMAGE from this Attack=[DamageTip + DamageButt + RageBonus]<br>
};
{
  <b><font color="blue">
  "Your Attack MISSES"<br>
}]
 <b><font color="teal">
--------------------------------

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

Re: My First Macro! Next Step help, please

Post by jfrazierjr »

Library tokens should be for things that apply to multiple tokens. One example would be "sleep"(as a generic term) that changes and updates multiple pc tokens in its code at once vs each player having to have their own "sleep" macro.


They are also good for stopping common things such as spell descriptions that multiple players tokens have access to.
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..

venger
Giant
Posts: 144
Joined: Tue Apr 17, 2007 11:37 am

Re: My First Macro! Next Step help, please

Post by venger »

Library tokens should be for things that apply to multiple tokens. One example would be "sleep"(as a generic term) that changes and updates multiple pc tokens in its code at once vs each player having to have their own "sleep" macro.


They are also good for stopping common things such as spell descriptions that multiple players tokens have access to
Thank you for replying
I understand the first part of your reply, but not the latter. Is "stopping" meant to be "showing"? ty

venger
Giant
Posts: 144
Joined: Tue Apr 17, 2007 11:37 am

Re: My First Macro! Next Step help, please

Post by venger »

I found what I needed for accessing fields within the tokens. getproperty is the ticket. Finding that command also lead to getspeech and a couple other things

Maptools is so awesome

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

Re: My First Macro! Next Step help, please

Post by jfrazierjr »

venger wrote:
Tue Sep 10, 2019 7:58 am
Library tokens should be for things that apply to multiple tokens. One example would be "sleep"(as a generic term) that changes and updates multiple pc tokens in its code at once vs each player having to have their own "sleep" macro.


They are also good for stopping common things such as spell descriptions that multiple players tokens have access to
Thank you for replying
I understand the first part of your reply, but not the latter. Is "stopping" meant to be "showing"? ty
Yes, showing... phone autocorrect...

Basically, a storage location for anything that you might want to affect multiple tokens or be a common pool, though you have to be careful about concurrency so it's best used for "pulls of data" but not push of date(where the push may come from two or more clients at a time, and thus last one in wins and probably a big "bug" headache for you to try to figure out later.
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
jfrazierjr
Deity
Posts: 5176
Joined: Tue Sep 11, 2007 7:31 pm

Re: My First Macro! Next Step help, please

Post by jfrazierjr »

venger wrote:
Tue Sep 10, 2019 8:01 am
I found what I needed for accessing fields within the tokens. getproperty is the ticket. Finding that command also lead to getspeech and a couple other things

Maptools is so awesome
Yes, yes it is... to be honest, i recognize your name from when I was doing a lot of coding on MT and that was 10 years ago or so.. I am a bit surpised you are just now delving into macros. Is that because there is a game system no one else has done or because you dont like the frameworks others have for game X? or just ready to learn something new?
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..

venger
Giant
Posts: 144
Joined: Tue Apr 17, 2007 11:37 am

Re: My First Macro! Next Step help, please

Post by venger »

Tes, yes it is... to be honest, i recognize your name from when I was doing a lot of coding on MT and that was 10 years ago or so.. I am a bit surpised you are just now delving into macros. Is that because there is a game system no one else has done or because you dont like the frameworks others have for game X? or just ready to learn something new?
Indeed I've used maptool a long time, I want to say like since before Versioning numbers lol. And Never needed any other VTT.
Yes and Something new too. And a good bit of wanting to FInally take time to learn to write macros in maptool.

Also, I want to use a framework, but Im paranoid, and want to become proficient enough to understand some of the nitty gritty behind the buttons and ultimatley be able to customize an existing framework, AND more importantly, fix something that might go wrong. go wrong. go wrong lol

But all those years back, nearly 20 years, we were playing F2F with maptool, and didnt need much in the way of automation at the time.
The One Ring for the last 5 years, MERP for 12 before that and didnt have a Framework available to my knowledge for those systems, though MERP could have realll, really used it.

I was very busy at work when times were good, used macros only as far as a convenient way to display impersonated text in chat.
A big plus...One of my players has a hearing disorder, and he LOVES it, one of the games he attends that he can really follow the story, because of maptool's text display capabilities.

so I showed all the text using macros in their simplest form and didnt have the time and energy to learn deeper coding methods. then several years ago the economy around here went south.
I am nearing retirement, and quit work and find myself with... *sings* "Too much time on my hands", Styx lol.

So now we are transitioning into D&D 5e, and I want to reduce work on the DMing sessions me and a friend will be running, and yeah, I like coding, I find it relaxing and satisfying.

I write Visual Basic proggys for gaming that handle a variety of game related random generation tasks, and always was curious about coding maptool, so here I am delving in now, just for fun and maptool will be even more useful to my group.

Progress- The above macro has already been amended to query the token properties. so freaking awesome

My next thing is, I found some code that does simple Hit Point damage and healing, and want to expand on it to replace the portrait with "State" graphics when HP is low or state is dead like I saw in that 5e Framework I grabbed by cubeblue I think.
It looks like a nice Framework, does a LOT with characters, though something buggy with one part, or that I don't understand yet, with one of the Weapon macros that throws an error

I can't just steal his code to use in mine, it references a lot of tables stored someplace, stuff I haven't figured out yet.

So along the way learning to macro I will learn that too, basically experiencing the joy by figuring out how it works on my own.
Its just a thing I have lol, bitten by the code bug, nothing personal to framework writers, they are awesome guys for doing all that work, just the token's campaign properties looks like full programs lol

BOT is the holy grail for me tho, and is actually what lead me here. I play with it often, but still learning stuff, and not quite ready for prime time, but making progress!

btw, thanks for asking :)

Post Reply

Return to “Macros”