Grab Token Property from different Token for Players

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
Netsky
Cave Troll
Posts: 25
Joined: Sat Feb 14, 2015 4:35 am

Grab Token Property from different Token for Players

Post by Netsky »

Good day!

I'm running a Black Crusade Campaign where the players are able to get Minions. One of those Minions stats (Loyalty) are related to a property of the player (Fellowship).
So if this stat was to change, I would like to change it only on the player token instead of his/her minions, which is why I added a default Property to the Loyalty property:

Code: Select all

Loyalty : {getProperty("Fellowship", "TokenID")}
where TokenID is the name of the player owning that minion.

From a GM perspective everything looks fine. However logged in as player this just won't work (trusted macro rules I guess). All I can see is the unevaluated string.

Now to the main question: How do I get this to work, or which alternative solution would you suggest?

Thanks for your effort,
Netsky

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

Re: Grab Token Property from different Token for Players

Post by aliasmask »

Try this:

Code: Select all

Loyalty:[r: getProperty("Fellowship")]
When setting defaults for a token property the current token is always assumed. You could also replace "TokenID" with currentToken(). As a rule of thumb, I try to avoid using {}, but in this case there's nothing wrong with it, I just prefer using a statement format.
Netsky wrote:Good day!

I'm running a Black Crusade Campaign where the players are able to get Minions. One of those Minions stats (Loyalty) are related to a property of the player (Fellowship).
So if this stat was to change, I would like to change it only on the player token instead of his/her minions, which is why I added a default Property to the Loyalty property:

Code: Select all

Loyalty : {getProperty("Fellowship", "TokenID")}
where TokenID is the name of the player owning that minion.

From a GM perspective everything looks fine. However logged in as player this just won't work (trusted macro rules I guess). All I can see is the unevaluated string.

Now to the main question: How do I get this to work, or which alternative solution would you suggest?

Thanks for your effort,
Netsky

Netsky
Cave Troll
Posts: 25
Joined: Sat Feb 14, 2015 4:35 am

Re: Grab Token Property from different Token for Players

Post by Netsky »

thanks for your reply, but I think you got me wrong.

Minions are different tokens from the player character token. the "code snippet" is to be found in my campaign properties for the token type "Minion" (thus the {} )
So I can't use the current token, since that would not reflect it's master's Fellowship.

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

Re: Grab Token Property from different Token for Players

Post by aliasmask »

{getProperty("Fellowship")} is the same as [r: getProperty("Fellowship")] except in syntax.

Since you're wanting to get a property not on the current token how do you think you're going to determine, for all tokens of this type the default token to get the Fellowship from? I would suggest by ownership and any other PCs tokens on current map. Also, this should really be a 1 time calculation. We also want to avoid the GM from setting the property if this is for players only.

Code: Select all

*@Loyalty:[H: pcTokens = json.intersection(getPC("json"),getOwned(getPlayerName(),"json"))][R, if(!isGM() && json.length(pcTokens) == 1): getProperty("Fellowship",json.get(pcTokens,0));""]
This is totally legal, but as you can see it's more than just a simple property assignment and should probably be done as a user defined function call to a lib token.

It may be simpler to have one property have the name of the token who is the leader and the leader token have a list of all the tokens in his fellowship. Then it would look like this:

Code: Select all

*@Loyalty:[R, if(!json.isEmpty(Leader)): getProperty("Fellowship",Leader);""]

Netsky
Cave Troll
Posts: 25
Joined: Sat Feb 14, 2015 4:35 am

Re: Grab Token Property from different Token for Players

Post by Netsky »

aliasmask wrote: It may be simpler to have one property have the name of the token who is the leader and the leader token have a list of all the tokens in his fellowship. Then it would look like this:

Code: Select all

*@Loyalty:[R, if(!json.isEmpty(Leader)): getProperty("Fellowship",Leader);""]
this is indeed a good idea to solve it - added that Property, thanks!. The initial Problem still remains - I want the players to be able to see this property on the statsheet. While for the GM it works fine, for the player it looks like this: Image.
Any suggestions here?
aliasmask wrote:{getProperty("Fellowship")} is the same as [r: getProperty("Fellowship")] except in syntax.
that's good to know, I was under the impression only {} works for setting default properties. I have been proven wrong :)

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

Re: Grab Token Property from different Token for Players

Post by aliasmask »

For a property to be displayed you have to put * before the property name.

Netsky
Cave Troll
Posts: 25
Joined: Sat Feb 14, 2015 4:35 am

Re: Grab Token Property from different Token for Players

Post by Netsky »

which is the case.

let me paste screenshots of everything relevant:

Token Type Properties: http://puu.sh/fVdrP/74222fb8e9.png and if you are wondering were the * is: http://puu.sh/fVduJ/96e13a09bf.png
GM View: http://puu.sh/fVdQz/935b690687.jpg
Player View: http://puu.sh/fVdSH/a741b430ee.jpg

Changed nothing between both last screenshots, only started the server as player.

As you can see the GM view grabs the data as intended (Fellowship is 31 on Xyn Nissassa), whereas the players only get to see the unevaluated property. My guess is because of the Trusted Macro rules, the players don't get the data right?

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

Re: Grab Token Property from different Token for Players

Post by aliasmask »

Ah yes. This is a permissions problem. Remember I mentioned this should be on a lib token, well this is the case. A player can't get a property of another token they don't own unless the macro is run from a lib token.

Netsky
Cave Troll
Posts: 25
Joined: Sat Feb 14, 2015 4:35 am

Re: Grab Token Property from different Token for Players

Post by Netsky »

thanks for your help, got it working now!

Post Reply

Return to “Macros”