Guide to onTokenMove

From RPTools Wiki
Revision as of 19:27, 19 November 2010 by Coveredinfish (talk | contribs) (New page: =Guide to onTokenMove and all related stuff= Recently a great new feature has been added to MapTool. This guide shall aide you to use it. Every time a token is moved (by the user) a spec...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Guide to onTokenMove and all related stuff

Recently a great new feature has been added to MapTool. This guide shall aide you to use it. Every time a token is moved (by the user) a specific macro is called. This macro can even cancel that move.


Events

Just like onCampaignLoad the new events are macros on a lib:token that have to be named like the event. Note that these events should be only defined once - otherwise can lead to unexpected behaviour.


onTokenMove gets called whenever a token is moved. The token gets its moved path as macro.args. The moved token is the token in context.


onMultipleTokenMoves is called when multiple tokens are moved at once. The macro.args contain a json array with all moved token ids. The is no token context.


Note that, before onMultipleTokenMoves is actually called, onTokenMove is called for each single token.


Paths

In context of these events there will sometimes be specified or returen a path or a list of coordinates. These all follow this specific format.


It is a json array containing json objects for each points. Each json object defines the keys x and y with the map coordinates.

[h: samplePath = json.append("",
	json.set("", "x", 50, "y", 50), 
	json.set("", "x", 0, "y", 0)
)]

Related Functions

Examples

Traps

Movement cost tracking

Exposure of Fog on gridless maps