Token ownership, based on 2nd token

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
xavram
Dragon
Posts: 891
Joined: Tue Apr 20, 2010 8:22 pm

Token ownership, based on 2nd token

Post by xavram »

I have a situation where there's a token that's used (on their turn) by each player. Ideally, when a player receives the initiative, this "floating" token would have its ownership set to the same ownership as the token that the player controls. I've set the "VisibleToOwnerOnly" flag on this floating token to true.

But, I can't seem to get this to work. If I call "GetOwners" on the player's token, it always returns back an empty list. If I open the token, I can see that its marked as having "so-and-so" as the owner...so why isn't that returned?

Furthermore, when playing with this, I found that if I call "setOwner("test", selectedId)", it doesn't set the owner to "test". Instead, it seems to be setting it to some GUID. Not sure what that's about.

As usual, any feedback is appreciated!

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

Re: Token ownership, based on 2nd token

Post by aliasmask »

I would use a lib token to store that communal data with a check to make sure that the current initiative token is owned by the player. Something like this:

Code: Select all

[H: initToken = getInitiativeToken()]
[H: initTokenOwners = getOwners("json",initToken)]
[H: currentPlayer = getPlayerName()]
[H: abort(json.contains(initTokenOwners,currentPlayer))]

<!-- current init token is owned by current player, do stuff -->
...

xavram
Dragon
Posts: 891
Joined: Tue Apr 20, 2010 8:22 pm

Re: Token ownership, based on 2nd token

Post by xavram »

Let me show you what's happening, here's my exact code...

Code: Select all

[h : owners = getOwners("json", selectedToken)]
[broadcast(owners)]
[h : setOwner(owners, straightToken)]
Also tried it like so...

Code: Select all

[h : owners = getOwners(",", selectedToken)]
[broadcast(owners)]
[h : setOwner(owners, straightToken)]
Pretty simple, right? And "jramirez" is what gets broadcast, so I would expect that "jramirez" would be set as the owner.

Instead, see image to what's getting set.

Image

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

Re: Token ownership, based on 2nd token

Post by aliasmask »

How and where is this macro running from? Is it on a lib token (because it needs to be). From what I can see, you're trying to use the macro on the floating token which won't work if the player can't see it and is not the owner already. Does the "straightToken" variable have the token id?

xavram
Dragon
Posts: 891
Joined: Tue Apr 20, 2010 8:22 pm

Re: Token ownership, based on 2nd token

Post by xavram »

Yes, running from a library token.

And yes, the straight and selected token contain token IDs. the "selected" token is the current player, the "straight" token is that "floating" token.

Post Reply

Return to “Macros”