Can't call my Lib Macro unless the Lib Token is Highlighted

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
callmedoug
Kobold
Posts: 5
Joined: Wed Feb 17, 2021 10:34 am

Can't call my Lib Macro unless the Lib Token is Highlighted

Post by callmedoug »

I am at a complete loss, I am positive I have everything right, but I cant call a Lib Macro unless I highlight the Lib and turn on "Apply to Selected Token"

Here is specifically what i have done.

1> created Lib.Buffs
2> added a Macro to it called BuffState
I turned off Allow Players to Edit
I turned off Apply to Selected Tokens

the code for that button is
[h: propNames = "Bardic Performance, Haste, Bless"]

[frame("Buff"): {
<html>
<head>
<link rel="stylesheet" type="text/css" href="CharSheet_css@[r: getMacroLocation()]">
<title>Current Party Buffs</title>
</head>
<body>
<table id="stats">
<tr>
<th>Buff</th>
<th>State</th>
</tr>
[h: class = "oddRow"]
[foreach(prop, propNames, ""), code: {
<tr class="[r:class]">
<td>[r: prop]</td>
<td>[r: getProperty(prop)]</td>
</tr>
[h: class = if(class=="oddRow", "evenRow", "oddRow")]
}]
</table>
</body>
</html>
}]

3) I created a Campaign Button called Buffs.
I turned off apply to Selected Tokens
I turned off Allow players to Edit

The code for the button is
[MACRO("BuffState@Lib:Buffs"): ""]

All I get is an error
Error executing "getProperty": there is no impersonated token.
Error trace : BuffState@Lib:Buffs <<< Buffs@campaign

From everything i read, and all the other macros from the Pathfinder Framework, I have setup everything exactly the same, but it simply wont work unless, I go to the Macro Button and turn on Apply to Select Tokens, and then highlight the Lib token, which defeats the entire purpose.

it works flawlessly if i highlight the Lib Token, or if i click the macro from the lib itself.

what the heck am i doing wrong, how do i change my Campaign Macro to not need to have the Lib token active to run the macro?

callmedoug
Kobold
Posts: 5
Joined: Wed Feb 17, 2021 10:34 am

Re: Can't call my Lib Macro unless the Lib Token is Highlighted

Post by callmedoug »

Found my error, it was in the BuffState, where i called getProperty - and hadn't set the token to use.

Changed
<td>[r: getProperty(prop)]</td>
to
<td>[r: getProperty(prop,"Lib:Buffs","_Title")]</td>
and it now works.

User avatar
Torlan
Kobold
Posts: 15
Joined: Fri Jan 07, 2022 8:12 am

Re: Can't call my Lib Macro unless the Lib Token is Highlighted

Post by Torlan »

I’m afraid the problem is this :

Code: Select all

getProperty(prop)
[EDIT]: this post came way too late :lol: [EDIT]

That function needs a target, which defaults to the current token. Otherwise a token id has to be provided for it to work.
From the wiki:
Usage
getProperty(property)
getProperty(property, id)
getProperty(property, id, mapname)
Parameter
property - The property that has its value returned. For referencing the literal name of the property (for instance, if you wish to get the property Constitution configured in Campaign Properties), enclose the property name in quotes. If using a variable whose value is the name of the property, do not enclose the variable name in quotes.
id - The token id or name of the token that has its property value returned, defaults to the Current Token.
Note: This parameter can only be used in a Trusted Macro.
mapname - The name of the map to find the token. Defaults to the current map.
Thus you might want to provide the ids of all the relevant tokens...or something on this line, depending on what’s your goal.

Hope this helps :wink:
Roses are grey, violets are grey...I'm dead and colorblind!

Post Reply

Return to “Macros”