Page 1 of 1

Create a macro to quickly toggle mod-Sets

Posted: Sun May 30, 2010 3:22 pm
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 ) ]  

Re: Create a macro to quickly toggle mod-Sets

Posted: Mon Jun 14, 2010 5:43 pm
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.

Re: Create a macro to quickly toggle mod-Sets

Posted: Mon Jun 14, 2010 6:21 pm
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.

Re: Create a macro to quickly toggle mod-Sets

Posted: Mon Jun 14, 2010 10:05 pm
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.