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!
Token ownership, based on 2nd token
Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice
Re: Token ownership, based on 2nd token
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 -->
...
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
Re: Token ownership, based on 2nd token
Let me show you what's happening, here's my exact code...
Also tried it like so...
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.
Code: Select all
[h : owners = getOwners("json", selectedToken)]
[broadcast(owners)]
[h : setOwner(owners, straightToken)]
Code: Select all
[h : owners = getOwners(",", selectedToken)]
[broadcast(owners)]
[h : setOwner(owners, straightToken)]
Instead, see image to what's getting set.
Re: Token ownership, based on 2nd token
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?
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
Re: Token ownership, based on 2nd token
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.
And yes, the straight and selected token contain token IDs. the "selected" token is the current player, the "straight" token is that "floating" token.