Campaign Buttons vs. Token Buttons (Macro Issues)

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

User avatar
Kizan
Giant
Posts: 178
Joined: Sun Apr 01, 2007 2:09 pm
Location: Near Midville, OH

Campaign Buttons vs. Token Buttons (Macro Issues)

Post by Kizan »

I've come across something that I wasn't able to find (or didn't know what to look for) in the Wiki/Docs/Forums. So I'm posting my question here.

I've created a Lib token that I'm using to call a ToHit() function and a Damage() function. I've created Basic Attack buttons that call the functions to resolve the attack. I've got them working with one small oddity.

If I click on a PC/NPC Token and click on the basic attack button that is in the Campaign Window the macro runs correctly. It hides all of the variables, math showing only the result. Neatly stuffing all the vars and math into a tooltip.

If I then copy the button from the Campaign section to the PC/NPC token itself and run press the button. The function runs but does NOT hide the variables or the math or the result.

Why does it function this way and how can I get all my macros to function as if they were in the campaign window?

Screen shots and code snips below:

Code:

ToHit:

Code: Select all

[IF( argCount() <= 0 || argCount() > 1), CODE: {
[assert(0,'<b><font color="#FF0000">ToHitLib Function: Incorrect number of arguments to this function!</font></b><br>')]
};{}]

[H:StatBonus = arg(0)]

Using <b>{WeaponCName}</b>!<br>
[H:DiceRoll = 1d20]
[IF( DiceRoll == 20), CODE: {
<b><font color="#FF0000">Critical Hit!</font></b><br>
[H:macro.return = 2]
};{}]

[IF( DiceRoll == 1), CODE: {
<b><font color="#FF0000">feces! You rolled a 1! You miss.</font></b><br>
[H:macro.return = 1]
};{}]

Attack roll: <b>[DiceRoll + LevelBonus + WeaponCBonus +  StatBonus + MiscAttBonus]</b><br>
Damage:

Code: Select all

[IF( argCount() <= 0 || argCount() > 3), CODE: {
[assert(0,'<b><font color="#FF0000">DamageLib Function: Incorrect number of arguments to this function!</font></b><br>')]
};{}]

[H:CritFlag= arg(0)]
[H:NumW = arg(1)]
[H:DmgBonus = arg(2)]

Damage roll: <b>

[IF(CritFlag == 2), CODE:{
<b><font color="#FF0000"> [NumW * WeaponCMaxDamage + WeaponCDamBonus +  DmgBonus + MiscDamBonus + eval(WeaponCCrit)]</font></b>
};{
[NumW * eval(WeaponCDamage) + WeaponCDamBonus +  DmgBonus + MiscDamBonus]
}]
</b>
When run from Campaign Window - Screen Shot:
Image

When run from the Token Selection Window - Screen Shot:
Image

Thanx for any help or insight!

Kizan

Edit: Using MT1.3b54
Last edited by Kizan on Thu Apr 02, 2009 3:01 pm, edited 2 times in total.

User avatar
lmarkus001
Great Wyrm
Posts: 1867
Joined: Sat Mar 29, 2008 12:30 am
Location: Layfayette Hill, PA

Re: Campaign Buttons vs. Token Buttons (Macro Issues)

Post by lmarkus001 »

Which MT version?

If b53, try adding " " at the start and end of the macros you call in your library...

User avatar
zEal
Dragon
Posts: 944
Joined: Sun Mar 22, 2009 2:25 am

Re: Campaign Buttons vs. Token Buttons (Macro Issues)

Post by zEal »

This is not entirely related to your problem(although it might help), but the way you currently have it setup, it's relying on a Preference. If you want it to always appear as a tooltip, use the [t:] roll option.

Example:

Code: Select all

Attack roll: <b>[DiceRoll + LevelBonus + WeaponCBonus + StatBonus + MiscAttBonus]</b><br>
Should be:

Code: Select all

Attack roll: <b>[t: DiceRoll + LevelBonus + WeaponCBonus + StatBonus + MiscAttBonus]</b><br>
If you want to make sure it always displays as a tooltip, regardless of a user's preferences.

EDIT: The assert function supports its own conditions:

Code: Select all

[assert(argCount()==1,'<b><font color="#FF0000">ToHitLib Function: Incorrect number of arguments to this function!</font></b><br>')]
&

Code: Select all

[assert( (argCount() > 0 && argCount() < 4),'<b><font color="#FF0000">DamageLib Function: Incorrect number of arguments to this function!</font></b><br>')]
Last edited by zEal on Thu Apr 02, 2009 2:56 pm, edited 1 time in total.

User avatar
Kizan
Giant
Posts: 178
Joined: Sun Apr 01, 2007 2:09 pm
Location: Near Midville, OH

Re: Campaign Buttons vs. Token Buttons (Macro Issues)

Post by Kizan »

lmarkus001 wrote:Which MT version?

If b53, try adding " " at the start and end of the macros you call in your library...
Wups sorry. I edited my original post. I'm using MT 1.3b54

Kizan

User avatar
Kizan
Giant
Posts: 178
Joined: Sun Apr 01, 2007 2:09 pm
Location: Near Midville, OH

Re: Campaign Buttons vs. Token Buttons (Macro Issues)

Post by Kizan »

lmarkus001 wrote:Which MT version?

If b53, try adding " " at the start and end of the macros you call in your library...
I added the " " at begin and end, but didn't help. It did add the spaces, but didn't fix the problem.

Kizan

User avatar
Kizan
Giant
Posts: 178
Joined: Sun Apr 01, 2007 2:09 pm
Location: Near Midville, OH

Re: Campaign Buttons vs. Token Buttons (Macro Issues)

Post by Kizan »

zEal wrote: Example:

Code: Select all

Attack roll: <b>[DiceRoll + LevelBonus + WeaponCBonus + StatBonus + MiscAttBonus]</b><br>
Should be:

Code: Select all

Attack roll: <b>[t: DiceRoll + LevelBonus + WeaponCBonus + StatBonus + MiscAttBonus]</b><br>
If you want to make sure it always displays as a tooltip, regardless of a user's preferences.
I thought about it but decided that some DM's might want to be able to use the toggle. Thanx for the heads up though.
zEal wrote: EDIT: The assert function supports its own conditions:

Code: Select all

[assert(argCount()==1,'<b><font color="#FF0000">ToHitLib Function: Incorrect number of arguments to this function!</font></b><br>')]
&

Code: Select all

[assert( (argCount() > 0 && argCount() < 4),'<b><font color="#FF0000">DamageLib Function: Incorrect number of arguments to this function!</font></b><br>')]
Very neat and tidy. The only think I had to add the [H:] to the beginning or it will show the result.

Thanx for the help.

Kizan

User avatar
Kizan
Giant
Posts: 178
Joined: Sun Apr 01, 2007 2:09 pm
Location: Near Midville, OH

Re: Campaign Buttons vs. Token Buttons (Macro Issues)

Post by Kizan »

*Bump*

Anyone have any thought per the original question?

Please?

Thanx!

Craig
Great Wyrm
Posts: 2107
Joined: Sun Jun 22, 2008 7:53 pm
Location: Melbourne, Australia

Re: Campaign Buttons vs. Token Buttons (Macro Issues)

Post by Craig »

Kizan wrote:*Bump*

Anyone have any thought per the original question?

Please?

Thanx!
I am not sure. I am unable to reproduce it and I get the feeling no one else can either... Is it possible for you to put a cut down version of the campaign in question somewhere it can be downloaded?

User avatar
Kizan
Giant
Posts: 178
Joined: Sun Apr 01, 2007 2:09 pm
Location: Near Midville, OH

Re: Campaign Buttons vs. Token Buttons (Macro Issues)

Post by Kizan »

Craig wrote: I am not sure. I am unable to reproduce it and I get the feeling no one else can either... Is it possible for you to put a cut down version of the campaign in question somewhere it can be downloaded?
No problem. Here's the sandbox file that I've been using.

Thanx,

Kizan

User avatar
lmarkus001
Great Wyrm
Posts: 1867
Joined: Sat Mar 29, 2008 12:30 am
Location: Layfayette Hill, PA

Re: Campaign Buttons vs. Token Buttons (Macro Issues)

Post by lmarkus001 »

Code: Select all

[IF( argCount() <= 0 || argCount() > 1), CODE: {
[assert(0,'<b><font color="#FF0000">ToHitLib Function: Incorrect number of arguments to this function!</font></b><br>')]
};{}]

[H:StatBonus = arg(0)]
I thought arg() could only be used for a user defined function. So in effect these macros would need to be on a Lib: token?

User avatar
zEal
Dragon
Posts: 944
Joined: Sun Mar 22, 2009 2:25 am

Re: Campaign Buttons vs. Token Buttons (Macro Issues)

Post by zEal »

lmarkus001 wrote:I thought arg() could only be used for a user defined function. So in effect these macros would need to be on a Lib: token?
They are on a lib:token(see first post); the problem he's running into is having different results if the user defined functions are called from a campaign macro or a token macro.

EDIT: Not sure why it'd work this way, but if I change the Basic Melee Attack macro on Copy Me 2 so player's can't edit it, the tooltips work.

EDIT2: On an unrelated note, you should never assume the background color of the client(MapTool's chat panel in this case), I for one don't have a white chat panel background; I'd suggest explicitly making the background of the power white where you want it to be white.
Last edited by zEal on Mon Apr 06, 2009 11:00 am, edited 1 time in total.

User avatar
Kizan
Giant
Posts: 178
Joined: Sun Apr 01, 2007 2:09 pm
Location: Near Midville, OH

Re: Campaign Buttons vs. Token Buttons (Macro Issues)

Post by Kizan »

zEal wrote:
lmarkus001 wrote:I thought arg() could only be used for a user defined function. So in effect these macros would need to be on a Lib: token?
They are on a lib:token(see first post); the problem he's running into is having different results if the user defined functions are called from a campaign macro or a token macro.

EDIT: Not sure why it'd work this way, but if I change the Basic Melee Attack macro on Copy Me 2 so player's can't edit it, the tooltips work.

zEal,

Were you able to duplicate the problem?

Thanx,

Kizan

Edit: Wow I hit submit about the time you put up your edit. Thanx for trying it out.

User avatar
Kizan
Giant
Posts: 178
Joined: Sun Apr 01, 2007 2:09 pm
Location: Near Midville, OH

Re: Campaign Buttons vs. Token Buttons (Macro Issues)

Post by Kizan »

zEal,

I hadn't tried that because I wanted the players to be able to build macro buttons by pulling the power description from the Lib:TKText and the math would then be done in my Lib:KZCombat. As you have probably guessed I want the players to be able to build own their macro buttons.

Thanx for poking at this. I wonder if it has something to do with the code the requires Lib tokens to not be editable by players. I don't know much about "trusted" tokens, but I remember reading something about them. That if you wanted it to be a trusted token you should setup the Lib token so that no one has ownership or something like that.

Kizan

User avatar
Kizan
Giant
Posts: 178
Joined: Sun Apr 01, 2007 2:09 pm
Location: Near Midville, OH

Re: Campaign Buttons vs. Token Buttons (Macro Issues)

Post by Kizan »

zEal wrote:
lmarkus001 wrote: EDIT2: On an unrelated note, you should never assume the background color of the client(MapTool's chat panel in this case), I for one don't have a white chat panel background; I'd suggest explicitly making the background of the power white where you want it to be white.
zEal,

Unfortunately I didn't write most of the text in the description. It's created by TK. I'll put up a post in his forum with your suggestion.

Thanx,
Kizan

User avatar
zEal
Dragon
Posts: 944
Joined: Sun Mar 22, 2009 2:25 am

Re: Campaign Buttons vs. Token Buttons (Macro Issues)

Post by zEal »

I don't see any trusted functions in your code, which makes this behaviour seem a bit odd; but I haven't poked that deeply into it.


As for the client background, as you can see it looks a little odd:
Image

Post Reply

Return to “Macros”