Macro Memory

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

Raktus
Giant
Posts: 200
Joined: Fri Nov 26, 2010 10:18 pm

Re: Macro Memory

Post by Raktus »

Right, I've been using these macro's from the Campaign window.

So, what I thought you said was to create the macro on the lib token and then link it to the macro in the Campaign window so that the properties would be from the lib token but applied to the selected tokens... of course I tried that and failed, lol.

User avatar
aliasmask
RPTools Team
Posts: 9029
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Macro Memory

Post by aliasmask »

I'll post some code for you to make life easier. It'll include onCampainLoad that will make all your macros functions and a generic output function to use instead of posting directly to chat. Then I'll post the changes to your macro to make it work from the campaign window.

Raktus
Giant
Posts: 200
Joined: Fri Nov 26, 2010 10:18 pm

Re: Macro Memory

Post by Raktus »

I greatly appreciate your help :-)

Raktus
Giant
Posts: 200
Joined: Fri Nov 26, 2010 10:18 pm

Re: Macro Memory

Post by Raktus »

*hip bumps*

User avatar
aliasmask
RPTools Team
Posts: 9029
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Macro Memory

Post by aliasmask »

I'll be able to show you tomorrow.

edit: Ack, sorry. I meant to post stuff today but got distracted with other issues one being npp decided to lose all my settings. If someone else wants to take a crack at this don't let me stop you.

User avatar
aliasmask
RPTools Team
Posts: 9029
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Macro Memory

Post by aliasmask »

Let me try to understand what you're trying to do.

You want to roll damage for multiple tokens, but you only want to enter damage dice only once? What if different tokens have different damage? Or do you want to set the new damage dice if you select more than 1 token?

Btw, I included some tools for new coders: http://forums.rptools.net/viewtopic.php?f=20&t=25531

I got about this far before I realized I may be doing it wrong:

Code: Select all

<!-- Define constants used in function -->
[H: rollTypes = "Advantage,Normal,Disadvantage"]
[H: dieSidesList = "d4,d6,d8,d10,d12,d20"]
[H: numDiceList = "1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20"]

<!-- Get Property Data used in function -->
[H: tokenNames = getSelectedNames()]
[H: lastRollType = getLibProperty("lastRollType")]
[H: lastDieSides = getLibProperty("lastDieSides")]
[H: lastNumDices = getLibProperty("lastNumDice")]

<!-- Set defaults for user input -->
[H, if(! json.isEmpty(lastRollType)): rollTypeSelect = listFind(rollTypes,lastRollType); rollTypeSelect = 1]
[H, if(! json.isEmpty(lastDieSides)): dieSidesSelect = listFind(dieSidesList,lastDieSides); dieSidesSelect = 5]
[H, if(! json.isEmpty(lastNumDices)): numDiceSelect = lastNumDices -1; numDiceSelect = 0]

<!-- Get user input -->
[h: abort(input(
    strformat("rollType|%{rollTypes}|Roll Type|RADIO|SELECT=%{rollTypeSelect} VALUE=STRING ORIENT=H"),
    strformat("dieSides|%{dieSidesList}|Die Sides|LIST|SELECT=%{dieSidesSelect} VALUE=STRING"),
    strformat("numDice|%{numDiceList}|Number of Dice|LIST|SELECT=%{numDiceSelect} VALUE=STRING")
))]

<!-- Process Rolls for Each Selected Token -->
[H, foreach(token,tokenNames), code: {
    [H: switchToken(token)] 

Raktus
Giant
Posts: 200
Joined: Fri Nov 26, 2010 10:18 pm

Re: Macro Memory

Post by Raktus »

The desired end result, that has so far only worked on single tokens and not on a group of selected ones, is thus:

Select a single token OR a group of tokens
Press macro
Input a die roll and/or damage
Roll the die with any particular mods thrown in (d20+d4+4 for example)
Roll damage if any, if 0 or blank then do nothing with it
Next time macro is pressed, retain all previous inputs from last press

User avatar
aliasmask
RPTools Team
Posts: 9029
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Macro Memory

Post by aliasmask »

Input a die roll and/or damage
...
Roll damage if any, if 0 or blank then do nothing with it
How do you know you're rolling damage and how do you know if it 0 or blank. Where is this data coming from?

Raktus
Giant
Posts: 200
Joined: Fri Nov 26, 2010 10:18 pm

Re: Macro Memory

Post by Raktus »

Well, I was handling it with code like this before:

Code: Select all

[h: abort(input(
  "rollType|Advantage, Normal, Disadvantage|Roll Type|RADIO|SELECT=1 VALUE=STRING",
 "roll2|d20|enter dice",
 "roll5|0|damage dice"))]
...
[h: roll6=eval(string(roll5))]
...
[r, if(roll6== 0), code:{ 
   [H: output = json.append(output,strformat("<b>%{tokenName}</b> <b>rolls:</b> %{d20roll}"))]
};{}] 
[r, if(roll6>= 1), code:{ 
 [H: output = json.append(output,strformat("<b>%{tokenName}</b> <b>rolls:</b> %{d20roll}  - Damage roll: %{roll6}"))]
};{}] 

Raktus
Giant
Posts: 200
Joined: Fri Nov 26, 2010 10:18 pm

Re: Macro Memory

Post by Raktus »

Also, playing with the code you had so far I keep getting this back...

Code: Select all

Error in body of roll.
Statement options (if any): H       
Statement Body : lastRollType = getLibProperty("lastRollType")

Post Reply

Return to “Macros”