RPTools.net

Discussion and Support

Skip to content

It is currently Tue Oct 17, 2017 10:58 pm 






Reply to topic  [ 40 posts ]  Go to page 1, 2, 3  Next

Previous topic | Next topic 

  Print view

Author Message
User avatar  Offline
Demigod
 
Joined: Mon Jun 29, 2009 9:37 am
Posts: 3108
Location: Germany
 Post subject: Are you aware of this: onChangeSelection
PostPosted: Wed Mar 03, 2010 6:49 am 
I just found some nice jewel hidden deep in the googleDocs-doc for maptool (linked from some fixed thread...). I wasnt aware of it and I would wonder if it would be common knowledge.

Frames and dialogs can call macros on some events. :shock: To do this place a <link> in the html-header of your frame/dialog-content. There are three events, on impersonation, on selection and on changes made on a token. The latter is said to work not perfectly.

Code:
<link rel='onChangeImpersonated' type='macro' href='macroLink'>
<link rel='onChangeSelection' type='macro' href='macroLink'>
<link rel='onChangeToken' type='macro' href='macroLink'>


I have to play around with these more, but i build a simple example: frame showing the actual selected tokens and some information (in the sample its only pc/npc-status).

place these two macros on a lib:token. Click "openFrame". Select some macros.

openFrame
Code:
[frame("showSelected"): {
[
rmacro("frameContent@lib:token"):""]
}]
 


frameContent
Code:
<html>
<
head>
    <
link rel='onChangeSelection' type='macro' href='[r:macroLinkText("open frame@lib:token")]'
</
head>
<
body>
    [
hselection getSelected()]
    [
hodd 1]
    <
table width="100%">
    [
r, foreach( idselection,"" ), code: {
        <
tr style='background-color:[r:if(odd, "#ffffff;","#aaffaa;")]'>
            <
td><img src='[r, token(id): getTokenImage(50)]'></td>
            <
td><b>[r:getName(id)]</b></td>
            <
td>[r: if(isPC(id), "PC""NPC")]</td>
        </
tr>
        [
hodd = if(odd01)]
    }]
    </
table>
</
body>
</
html>
 

_________________
HELP: GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC.

most complete list of my maptool stuff


Top
 Profile  
 
 Offline
Great Wyrm
 
Joined: Sun Jun 22, 2008 6:53 pm
Posts: 2102
Location: Melbourne, Australia
 Post subject: Re: Are you aware of this: onChangeSelection
PostPosted: Wed Mar 03, 2010 8:40 am 
To answer your question
yes I am aware of this :)

Some things to keep in mind when using these
The impersonation event may be called when you run a macro with run on selected tokens checked and then again at the end when it reimpersonates the original token

The selection one may be fired by some token changes if they are made to a selected token, even if this occurs on another client. When you select a token it maybe fired twice, once for the selection change associated with the deselection of the previously selected token, and once for the new selection, under certain circumstances you could get it fired a third time (1 for deselect, 2 for new token)

The change token one is kinda tricky, it gets fired often even when it appers there has been no change to the token -- but MapTool has updated something internally that is not visible to either the user or macros -- this is why it is reccomended to have your macro update the dialog/frame when changing a token if possible, it will lead to the code being executed a lot less often

I have purposefully used the words can or may above as you should not rely on these side effects as they don't happen in all cases but you should be aware that they can happen so you write your macros accordingly

The othe thing you need to know is, you should not modify any tokens in macros fired off from these events, depending on what you try to do you can cause yourslef quite a lot of problems.


Top
 Profile  
 
User avatar  Offline
Demigod
 
Joined: Mon Jun 29, 2009 9:37 am
Posts: 3108
Location: Germany
 Post subject: Re: Are you aware of this: onChangeSelection
PostPosted: Wed Mar 03, 2010 8:44 am 
Thanks for that additional infos.

_________________
HELP: GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC.

most complete list of my maptool stuff


Top
 Profile  
 
User avatar  Offline
Great Wyrm
 
Joined: Sat Jun 21, 2008 12:07 am
Posts: 1950
 Post subject: Re: Are you aware of this: onChangeSelection
PostPosted: Wed Mar 03, 2010 11:21 am 
Yeah, as I recall DeviantNull uses this (the on change selection element) in his interactive character sheet.
And I purloined the technique and use it in my own. :)

Remember, if you do this, to have a check to see if the selected token has all the properties needed. In my case, I just fill the frame with "Not a character" in that event.

_________________
Drop-In Utilities:
My Spell Manager for D&D3.5 and PFRPG
My Inventory Manager for D&D and PFRPG, but more generally useable than that.
My Message Manager -- My Top-Down D&D Token Images
and my Custom Initiative & Status/Spell-Effect Tracker (work in progress, but functional).


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Tue Jul 01, 2008 6:48 pm
Posts: 6237
 Post subject: Re: Are you aware of this: onChangeSelection
PostPosted: Wed Mar 03, 2010 11:29 am 
I quickly fiddled with it, but couldn't get it to recognize the newly selected token (that is, when I changed selections, it threw a cloud of "Enter value for" prompts). I had configured the macroLink to send arguments and/or operate on the proper token (I think) but it was a bust.

It's not relevant to my framework (I don't use a character sheet) but it's nifty, nonetheless.

Edit - although, it would be excellent for my Dragon Age framework.

_________________

What I'm Working On

MapTool Tutorials:
Introduction to Tokens
Introduction to Properties
Introduction to Macro Writing
Introduction to Light and Sight


Last edited by Rumble on Wed Mar 03, 2010 11:35 am, edited 1 time in total.

Top
 Profile  
 
User avatar  Offline
Great Wyrm
 
Joined: Sat Jun 21, 2008 12:07 am
Posts: 1950
 Post subject: Re: Are you aware of this: onChangeSelection
PostPosted: Wed Mar 03, 2010 11:33 am 
If I ever get my framework to a place where it's worth posting (meaning two days before never), I can show it off. If you have a multi-page sheet, you can even have it save the page when you change tokens.

Pretty sure DeviantNull does this too.

_________________
Drop-In Utilities:
My Spell Manager for D&D3.5 and PFRPG
My Inventory Manager for D&D and PFRPG, but more generally useable than that.
My Message Manager -- My Top-Down D&D Token Images
and my Custom Initiative & Status/Spell-Effect Tracker (work in progress, but functional).


Top
 Profile  
 
User avatar  Offline
TheBard
 
Joined: Tue Mar 21, 2006 7:26 pm
Posts: 3482
Location: Austin, Tx
 Post subject: Re: Are you aware of this: onChangeSelection
PostPosted: Wed Mar 03, 2010 11:34 am 
Very good information. Thanks for sharing.

_________________
ImageImage ImageImageImageImage
Support RPTools by shopping
Image
Image


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Tue Nov 10, 2009 6:11 pm
Posts: 7883
Location: Bay Area
 Post subject: Re: Are you aware of this: onChangeSelection
PostPosted: Wed Mar 03, 2010 11:50 am 
I can probably use this in my newest project because it shows the currently selected tokens, but I fear it could interfere with other stuff so I get what I have going, then dink with this later.

_________________
Downloads:


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Tue Jul 01, 2008 6:48 pm
Posts: 6237
 Post subject: Re: Are you aware of this: onChangeSelection
PostPosted: Wed Mar 03, 2010 12:02 pm 
plothos wrote:
If I ever get my framework to a place where it's worth posting (meaning two days before never), I can show it off. If you have a multi-page sheet, you can even have it save the page when you change tokens.

Pretty sure DeviantNull does this too.



So how do you make it recognize the change in the current token? That seems to be what's tripping me up. If I launch my character sheet (there is one in my framework, but it's not particularly dynamic - however, this could make it so), the launching token is the current token, and it stays that way.

However, if I put in the onChangeSelected event link, and I select a new token (after the initial launch), it loses all context. I've tried sending arguments via the macro link, but that doesn't work. Do I need, instead, to have a quick "getSelected()" check in the macro that deploys the sheet - like "switchToken(getSelected())" right at the beginning?

I only had a few minutes to play around with it this morning, so I didn't explore all the options.

_________________

What I'm Working On

MapTool Tutorials:
Introduction to Tokens
Introduction to Properties
Introduction to Macro Writing
Introduction to Light and Sight


Top
 Profile  
 
User avatar  Offline
Great Wyrm
 
Joined: Sat Jun 21, 2008 12:07 am
Posts: 1950
 Post subject: Re: Are you aware of this: onChangeSelection
PostPosted: Wed Mar 03, 2010 12:43 pm 
If you have the link that executes on selection change run a macroLink() with 'selected' as the target, it should detect what ever got picked up. The key of course is making sure the frame doesn't go looking for property types on the wrong tokens.

Here's a stripped down campaign file with a couple tokens on it and the character sheet macros I use atm, and a pic showing some of the displays you get just selecting different tokens with the frame open.


Demo.jpg
Demo.jpg [ 124.48 KiB | Viewed 8712 times ]
Char Sheet Example.cmpgn [1.01 MiB]
Downloaded 230 times

_________________
Drop-In Utilities:
My Spell Manager for D&D3.5 and PFRPG
My Inventory Manager for D&D and PFRPG, but more generally useable than that.
My Message Manager -- My Top-Down D&D Token Images
and my Custom Initiative & Status/Spell-Effect Tracker (work in progress, but functional).


Last edited by plothos on Wed Mar 03, 2010 3:34 pm, edited 2 times in total.
Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Tue Jul 01, 2008 6:48 pm
Posts: 6237
 Post subject: Re: Are you aware of this: onChangeSelection
PostPosted: Wed Mar 03, 2010 1:59 pm 
plothos wrote:
If you have the link that executes on selection change run a macroLink() with 'selected' as the target, it should detect what ever got picked up. The key of course is making sure the frame doesn't go looking for property types on the wrong tokens.

Here's a stripped down campaign file with a couple tokens on it and the character sheet macros I use atm.



Oh, I didn't realize "selected" was a built-in option for the macroLinks! Well, that changes EVERYTHING!

(actually, it doesn't, but it does explain whassup with my problems!)

_________________

What I'm Working On

MapTool Tutorials:
Introduction to Tokens
Introduction to Properties
Introduction to Macro Writing
Introduction to Light and Sight


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Tue Jul 01, 2008 6:48 pm
Posts: 6237
 Post subject: Re: Are you aware of this: onChangeSelection
PostPosted: Wed Mar 03, 2010 2:05 pm 
Got it working; thanks!

I found out an interesting thing (I was using assert()'s to check a few things) - in my framework, the event fires four times every time you change selections.

_________________

What I'm Working On

MapTool Tutorials:
Introduction to Tokens
Introduction to Properties
Introduction to Macro Writing
Introduction to Light and Sight


Top
 Profile  
 
User avatar  Offline
Giant
 
Joined: Mon May 04, 2009 2:44 pm
Posts: 214
 Post subject: Re: Are you aware of this: onChangeSelection
PostPosted: Wed Mar 03, 2010 2:16 pm 
Oh, I am so using this!

Thank you very much!

skester


Top
 Profile  
 
 Offline
Dragon
 
Joined: Wed Oct 21, 2009 1:52 pm
Posts: 419
 Post subject: Re: Are you aware of this: onChangeSelection
PostPosted: Wed Mar 03, 2010 2:48 pm 
Probably not gonna play with this right now... but this has a number of potential uses. Character sheet and targeting are what come to mind first...

_________________
Loyalty is not blind, and it cannot be forced. It is a sincere bond formed out of respect and gratitude.


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Tue Jul 01, 2008 6:48 pm
Posts: 6237
 Post subject: Re: Are you aware of this: onChangeSelection
PostPosted: Wed Mar 03, 2010 2:57 pm 
Darinth wrote:
Probably not gonna play with this right now... but this has a number of potential uses. Character sheet and targeting are what come to mind first...



Targeting to some extent, although you'll need to account for multiple firings of the event (as I mentioned, it's been 3-4 firings of the event to select a token; plus, of course, the old "non-owned selection" issue is still a factor) - so however you do it, you need to run only one iteration of whatever happens next.

However, it's pretty cool. I've noticed it screwed up the CSS in one of my forms. It was a little better if I put the CSS link first, but still not perfect. Otherwise, though - really excellent for a dynamic, keeping up with your actions character sheet. A better tool for a GM than a player, almost.

_________________

What I'm Working On

MapTool Tutorials:
Introduction to Tokens
Introduction to Properties
Introduction to Macro Writing
Introduction to Light and Sight


Top
 Profile  
 
Display posts from previous:  Sort by  
Reply to topic  [ 40 posts ]  Go to page 1, 2, 3  Next

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:

Who is online

In total there are 4 users online :: 0 registered, 0 hidden and 4 guests (based on users active over the past 5 minutes)
Most users ever online was 243 on Sun Nov 04, 2012 6:14 am

Users browsing this forum: No registered users and 4 guests





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

Style based on Andreas08 by Andreas Viklund

Style by Elizabeth Shulman