How to rename Macro by command

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
Darelius
Cave Troll
Posts: 44
Joined: Thu Aug 19, 2010 1:04 pm

How to rename Macro by command

Post by Darelius »

Hello, i guess, the solution is simple, but i didnt find it yet.

I have a Macro with name "Bite".
When i run it, there is a variable [h: AttackName="Punch"]
So, when the variable is different, the macro should be renamed in thenew name of the variable "AttackName".
But i dont know, how to to it?

i tried:

Code: Select all

[h: AttackName="Punch"]
[h: OldMacroName=getMacroName()]
[h, if (OldMacroName!=AttackName),CODE:
{
h: setMacroProps("label",AttackName)]
};
{}] 
I have no idea, how to use the setMacroProps, maybe the wrong way?
i used http://lmwcs.com/rptools/wiki/setMacroProps but didnt gat any idea how to make it work

Maptool Version: 1.6.1
Thanks for the help


...DX

User avatar
bubblobill
Giant
Posts: 167
Joined: Sun Jan 24, 2010 3:07 pm

Re: How to rename Macro by command

Post by bubblobill »

setMacroProps() needs the index of the macro to rename.
to get the index you would need to do something like

Code: Select all

[indices=getMacroIndexes(getMacroName(), 'json')]
[index=json.get(indices, 0)]
[setMacroProps(index, json.set('', 'label', AttackName))]
Bubblobill on the forum.
@Reverend on the MapTool Discord Server

Responsible for less atrocities than most... I do accept responsibility for these though: SmartDoors, Simple d20 Framework - barebones, Drop-in: All 3.5 SRD Monsters, Drop in: Simple Character Editor, Battletech Framework

Darelius
Cave Troll
Posts: 44
Joined: Thu Aug 19, 2010 1:04 pm

Re: How to rename Macro by command

Post by Darelius »

Thank you very much!


...DX

Phergus
Deity
Posts: 7132
Joined: Fri May 12, 2006 8:56 pm
Location: Middle of Nowhere, NM
Contact:

Re: How to rename Macro by command

Post by Phergus »

Wouldn't it be simpler to let the macro get the name of the button and use that to populate the AttackName variable.

Code: Select all

[h: AttackName = getMacroName()]
I attack with a [r: AttackName]

Darelius
Cave Troll
Posts: 44
Joined: Thu Aug 19, 2010 1:04 pm

Re: How to rename Macro by command

Post by Darelius »

Phergus wrote:
Thu May 28, 2020 1:24 pm
Wouldn't it be simpler to let the macro get the name of the button and use that to populate the AttackName variable.

Code: Select all

[h: AttackName = getMacroName()]
I attack with a [r: AttackName]
Normally yes.

But i have a "basic" macro set for many creatures.
In this macro the name of attack, attack bonus etc is set in the beginning as variables.
So i have to change the variables once for each creature, use it and dont need to rename makro and variable ;) only "laziness" macro *g*


...DX

Post Reply

Return to “Macros”