Is this possible?

Thoughts, Help, Feature Requests, Bug Reports, Developing code for...

Moderators: dorpond, trevor, Azhrei

Forum rules
PLEASE don't post images of your entire desktop, attach entire campaign files when only a single file is needed, or generally act in some other anti-social behavior. :)
Post Reply
xavram
Dragon
Posts: 891
Joined: Tue Apr 20, 2010 8:22 pm

Is this possible?

Post by xavram »

I have a "Done with Turn" macro that when the players are done, advances the initiative and handle a bunch of stuff (state checks, damage from bleeding, advances spell duration, etc, etc). Works just fine, except for one thing. I call switchToken during it but that means the players end up NOT having their token selected. And of course, that irritates them, since we use strict token ownership. So each time it goes from one of their turns to someone else's, that player has to re-select his token.

But, from a DM perspective, its great that it switches to the token with initiative because then I'm all set to perform the action for the next NPC.

So my question is...is there some way to switchToken for the DM...but for the players, keep selection on the token they're already on?

This is probably very wishful thinking but I thought I'd ask.

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: Is this possible?

Post by wolph42 »

first of all switchtoken() is a temporary function that only applies to the macro its run in. It has nothing to do with selection of a token.

now just to be clear: you want a macro that does stuff and when it ends it:
1. selects the token of the user that pressed the button and
2. on the GM client it selects the token that is next in initiative?

is that correct?

that is possible. but not really easy.

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

Re: Is this possible?

Post by aliasmask »

Which tokens other players select are not effected by another players actions. Each client keeps a record of their own selections. But it's possible to force a selected token with Wiki: selectTokens(), but it has to be run from that client, not the person who ran the macro. This can be done by sending a link to chat to that client that makes the select command. You'll end up with some whitespace or you can someone incorporate it in to your end of turn macro.

pseudo-code:
player A selects end of turn
macro runs updating various things for that players token
link sent to player who controls token next in initiative with autoexecute on
macro runs beginning of turn functions including setting the currently token to be selected

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

Re: Is this possible?

Post by xavram »

Maybe I need to look at my "Done with Turn" macro and see if I'm forcing the "selection" issue due to an error on my part. I had thought the "switchToken" was doing it but if that's not the case, then it must be something I'm doing in the code.

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

Re: Is this possible?

Post by xavram »

I did have a "selectToken" in there!

Okay, so I took that out and at the end of my "Done with Turn" macro, I added this...

[h, if(isNPC()), code : {
[h: selectText = macroLink("", "SelectInitNpc@Lib:PC_CombatMacros")]
[broadcast(selectText, "gm")]
}]

The "SelectInitNPC" is pretty simple just...

[h : selectTokens(getInitiativeToken())]

...however, nothing happens. I put in a broadcast in "SelectInitNPC", before the selectTokens, but that never displays either. So I must be doing something incorrect and I'd assume its in the macroLink stuff since I have limited experience with that.

Any ideas?

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

Re: Is this possible?

Post by aliasmask »

Make sure SelectInitNpc has autorun on. Also, you can't autorun your own macros. You can only autorun for other clients. If the player is the same then use execLink rather than broadcasting it to chat.

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

Re: Is this possible?

Post by xavram »

So, tried it like...

[h, if(isNPC()), code : {
[h: selectText = macroLink("", "SelectInitNpc@Lib:PC_CombatMacros")]
[h : execLink(selectText)]
}]

No luck, nothing happens.

And when you say, "Make sure SelectInitNpc has autorun on", I assume you're talking about the "Auto Execute" checkbox. With it checked or unchecked, doesn't work.

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

Re: Is this possible?

Post by aliasmask »

Here's what I did:

Code: Select all

@@ @Next

<!-- advance the initiative to the next token and change the selection to that token for the owner of that token -->

[H: nextInitiative()]
[H: id = getInitiativeToken()]
[H: owners = getOwners("json",id)]
[H, if(json.isEmpty(owners)): owner = json.get(getInfo("server"),"gm"); owner = owners]
[H, if(json.isEmpty(owner)): owner = getPlayerName(); owner = json.get(owner,0)]

[H, if(owner == getPlayerName()): selectTokens(id); broadcast("Select Token" + macroLink("","SelectNext@"+getMacroLocation(),"none",json.append("[]",id),id) + "...",owner)]


!!
@@ @SelectNext

[H: id = arg(0)]
[H: selectTokens(id)]

!!
 
It doesn't check all the possible situations like an owner that doesn't exist, but it works for me.

The test campaign allow you to check the owner of the token and it will change the selection when it's their turn. Defaults to the first gm of campaign if no owner selected. Does nothing if owner of token not in game.
Attachments
test next select.cmpgn
(422.45 KiB) Downloaded 99 times

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

Re: Is this possible?

Post by xavram »

I'll play around with this tonight, thanks!

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

Re: Is this possible?

Post by xavram »

You the man AM! Minor tweak and its working like a charm!

Thanks!

Post Reply

Return to “MapTool”