#[SOLVED] Reload a Frame for a specific Player

1 messages · Page 1 of 1 (latest)

trim tartan
#

I use PC sheets (Frames) in my framework. When it opens, it loads only data saved in tokens or libraries.
What I would like to do is force the player(s) I choose to call a macro that makes their PC Sheet load if it is already open right after I change some data (like current HP).

All my testing with execLink, execFunction, etc., has not produced the results I want.
execLink only works if I make the link appear in the chat (it'd be fine if only I could hide that).
execFunction requires a json ARRAY in the args and then using it errors out on the target Player's MT side.

Sorry if this is basic, I'm probably using something wrong.

rustic iron
#

You may have to send the link to chat, but it does not have to appear in chat.

#

For example; this is the macro/UDF in lib:weather that is used to run macros on player clients.

[h: macroName = arg(0)]
[h, if(argCount()>1): args=arg(1); args=""]
[h, if(argCount()>2): runWhen=arg(2); runWhen=1]
[h, if(argCount()>3): playerNames=arg(3); playerNames=json.append("", "all")]
[h: macroToRun = macroLinkText(macroName + "@" + getMacroLocation(),"none", args)]
[h: execLink(macroToRun, runWhen, playerNames, "json")]```
And execLink with a hidden result still works.
mystic dragon
#

You'll want to use isFrameVisible() to check if already open, but it would be in the macro called by execLink with the target of the player.

<!-- Campaign Window Macro: Refresh Char -->
[H: link = macroLinkText("loadChar@"+getMacroLocation(),"none",json.append("","Character Sheet"),currentToken())]
[H: execLink(link,1,getPlayerName()]```

<!-- loadChar -->
[H: abort(isFrameVisible(arg(0))]

<!-- redraw character sheet -->

"Character Sheet" is the name of the frame and is passed to loadChar. loadChar assumes current token was the one selected when campaign window macro was run.

But if the player is clicking the macro, you don't need execLink, imo. Only loadChar. execLink is for when the gm want to  run the macro on the player computers. In order to refresh another players character sheet, then you should check the owners of token, then passed that instead of current player.
trim tartan
#

Thank you both, I will test the suggestions. I also edited the original post for a bit clarity, fyi.

trim tartan
#

Tests complete. Working as intended.

Allow me to jot down where I went wrong:
Didn't use macroLinkText (I was using it wrong when learning it, got errors, gave up on it, thx to both for putting me back on that)
Didn't add the currentToken() in macroLinkText (thx aliasmask)
Didn't test properly. I was getting hidden results, making me think I was getting none. My bad there.
But, "Yay!". I have wanted this little feature for a long time. Thank you again.