Wolph42's drop in onMouseOverEvent (advanced)

These are tools and utilities that make it easier to run games. This includes Lib: macro tokens dropped into MapTool to manage the game, a conversion file for CharacterTool to allow use in MapTool, or just about anything else you can think of -- except graphics with macros and anything specific to a particular campaign framework. Those are already covered by the Tilesets subforum and the Links and External Resources forum.

Moderators: Azhrei, dorpond, trevor, giliath, Gamerdude, jay, Mr.Ice

Post Reply
User avatar
wolph42
Deity
Posts: 9706
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Wolph42's drop in onMouseOverEvent (advanced)

Post by wolph42 »

Recently there was a discussion over the possible events in MT like onTokenMove, onSelectionChange, etc. These are officially supported by MT. There is however one event that is not officially supported but is available if you know how to implement: onMouseOver. The implementation is a pain and it has taken me about 4 hours of testing to get this right. The problem is not to trigger the event, the problem is to trigger the event AND you want to use the input() function. Using input() icw this trick will haywire MT, unless you do it right.

I've created a lib token with two types of events, one that runs only once after you drag a new token onto the map. And one event that triggers every time you mouseover a DIFFERENT token.

The below instructions can be found in the 'Notes' of the lib token attached. To get this working, download the token, drag/drop it into you campaign file, follow at least the first 5 lines of instructions (but do read the rest, cause there are some catches) and you're golden.

For each type of event there are two macro's, one which is triggered on that event and one that is called by the triggered macro. The latter ends its name with 'Macro' and these are the macros that you can edit with you own code.

[spoiler=INSTRUCTIONS]INSTRUCTIONS

Make sure that the 'Show stat sheet on mouse over' is turned on:
menu--> edit --> preferences --> Interactions --> 'tokens' box: at the bottom --> check the checkbox

Add the following two lines to the Basic property set:

*onMouseOverOnceVar:[macro("[email protected]:onMouseOver"):currentToken()]
*onMouseOverPermanentVar:[macro("[email protected]:onMouseOver"):currentToken()]

The property set can be set here:
menu--> edit --> Campaign Properties --> Token Properties --> Basic --> copy the lines --> Update --> OK

You can edit the two macro's that end with 'Macro'. Here you can put in code you like to have executed.

Note that:
- if you use a different set for your tokens that you need to set the properties for that set
- if you only want to use the 'run once event' (onMouseOverOnceVar) or the 'run every time I hover over event' (onMouseOverPermanentVar) or both, add the lines correspondingly.
- the 'run once event' has a selectTokens() command that will select the token hovered over. This can be removed
- the 'run every time event' doesn't have a selectTokens() command, but you can add it if you like.
- If you 'cancel' the 'run once event' it will be triggered a 2nd time. Not sure why. If you however click 'ok' then it will run only once.
- There are two optional macros on this lib token. These you can use to either fix an onMouseOver event for the 'every time' type if its broken. Or reset the 'run once event' to run again. To Use: Just drag the macros to the campaign panel, select the token and run the macro.
- If the permanent event is broken for ONE token, it won't work anymore for ANY token!!!
- One way to break this is by copying a selected token. The copied token won't trigger the onMouseOverEvent. This is because as soon as you hover over a token the macro call is deleted and only restored if you hover of another token (that has that macro call active). The token ID of the last token that activated the event is stored in the lib. The ID's of the copied tokens however are unknown to the library. The only way to get those working is by using the 'resetPermanentEvent' macro.[/spoiler](can be also found in the 'Notes' section of the library token)
[spoiler=Suggestions for changes]The macros will always send something to the chat when used. This might be useful or not. If not (so you want any output to chat ignored) then change the following line:

Code: Select all

[h: link = macroLinkText("[email protected]:onMouseOver", "self", me, "selected")]

into

Code: Select all

[h: link = macroLinkText("[email protected]:onMouseOver", "none", me, "selected")]

In both onMouseOverOnceEvent and onMouseOverPermanentEvent[/spoiler]
Attachments
lib-onMouseOver.rptok
(82.41 KiB) Downloaded 396 times
Last edited by wolph42 on Wed May 11, 2011 7:46 am, edited 2 times in total.

User avatar
CoveredInFish
Demigod
Posts: 3104
Joined: Mon Jun 29, 2009 10:37 am
Location: Germany
Contact:

Re: Wolph42's drop in onMouseOverEvent

Post by CoveredInFish »

Looks interesting, I hope I find time to toy around with it.

Thx for sharing

User avatar
wolph42
Deity
Posts: 9706
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: Wolph42's drop in onMouseOverEvent

Post by wolph42 »

Forgot to mention:
I've added a function that replaces the 'show dialog on new token', which allows the user a lot more versatility. This is also worth checking out. It makes use of one of the two events. Obviously you need to turn the show dialog off, this can also be found in the preferences.


Post Reply

Return to “Drop-In Macro Resources”