Create a macro to quickly toggle mod-Sets

Discussion concerning lmarkus' campaign framework for D&D3.x and Pathfinder.

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

Forum rules
Discussion regarding lmarkus001's framework only. Other posts deleted without notice! :)
Post Reply
neofax
Great Wyrm
Posts: 1694
Joined: Tue May 26, 2009 8:51 pm
Location: Philadelphia, PA
Contact:

Create a macro to quickly toggle mod-Sets

Post by neofax »

aliasmask wrote:I wish there was an easily programmable way to call your code to activate/deactivate mod sets.
This will toggle a mod set.

Code: Select all

[MACRO("subModToggle@Lib:libDnD35Pathfinder"): json.set( json.set( json.set( "{}", "tokenID", tToken ), "setID", tmID ), "setType", 0 ) ]  
  • tToken = Token ID of the token you want to toggle the mod-set on.
  • setID = The "name" of the mod-set (for example: "Bulls Strength" ).
  • setType = 0 for mod-set; 1 for item.
If you want to set it one way or the other, you must first discover if it is set, and if so, then you know if you should toggle it or not. Here is a code snippit to determine if a mod-set is active.

Code: Select all

[H: tModSet = "Bulls Strength" ]

[H: aTMS = json.get( PrivateJSON, "ActiveTempModSets" ) ]
[H, IF( json.type( aTMS ) == "UNKNOWN" ), CODE: {
   [ PrivateJSON = json.set( PrivateJSON, "ActiveTempModSets", "[]" ) ]
   [ aTMS = "[]" ]
}]

[H: msIsActive = if( json.contains( aTMS, tModSet ), 1, 0 ) ]  

apwhite
Cave Troll
Posts: 33
Joined: Mon Sep 10, 2007 11:49 am

Re: Create a macro to quickly toggle mod-Sets

Post by apwhite »

I just upgraded to this version of the framework with the new toggle mod-sets. I am so grateful for the framework and the support here.

I am having trouble connecting the dots with these code snippets. Could you provide a full sample macro for toggling the mod? I am not seeing how I can pass through the selected tokens or arguments into the appropriate macro. If you can provide one example, then I can set up all my other spells/states. I just need that first complete example.

neofax
Great Wyrm
Posts: 1694
Joined: Tue May 26, 2009 8:51 pm
Location: Philadelphia, PA
Contact:

Re: Create a macro to quickly toggle mod-Sets

Post by neofax »

Most Conditions/Spell/DR-ER are already provided. The above is for creating a button that allows the GM to turn on a particular mod with just a button. So, if your PC's use Bless alot, it would be easier to make a macro that does a foreach grabbing the token ids, checks if the mod is already applied and set the mod, instead of a three step manual process. I haven't used the above yet.

apwhite
Cave Troll
Posts: 33
Joined: Mon Sep 10, 2007 11:49 am

Re: Create a macro to quickly toggle mod-Sets

Post by apwhite »

neofax wrote:Most Conditions/Spell/DR-ER are already provided. The above is for creating a button that allows the GM to turn on a particular mod with just a button. So, if your PC's use Bless alot, it would be easier to make a macro that does a foreach grabbing the token ids, checks if the mod is already applied and set the mod, instead of a three step manual process. I haven't used the above yet.
Right, that is exactly what I am trying to accomplish. I want a macro button on my campaign pane which will toggle the mod. I currently have the button in the campaign pane which will call the macro stored in a library and it will toggle the mod just fine.

But I can only get it to toggle a single token. I cannot select more than one token and have it apply the macro to each one. I'd like help with the loop. How do I get the macro to run for each of the selected tokens.

Here is the macro for the campaign pane:

Code: Select all

[MACRO("BullsStrength@Lib:PathfinderSpells"):""]
And the macro for the library is:

Code: Select all

[H: tmID = "Bulls Strength"]
[H: tToken = getSelected()]

[H: numTList = listCount(tToken)]
[H: abort(numTList)]

[MACRO("subModToggle@Lib:libDnD35Pathfinder"): json.set( json.set( json.set( "{}", "tokenID", tToken ), "setID", tmID ), "setType", 0 ) ]  
Can anyone help with having it sort through all the selected tokens?

Also this routine takes about 9 seconds to run on my computer. Using my old macros and not the mod-set was nearly instantaneous.

Post Reply

Return to “D&D 3.5/Pathfinder 1e Campaign Macros”