Token
This is a global built in package that provides global interfaces to token specific activities.
Only tokens which are placed into token containers are handled by these functions. Image controls are currently the only valid token container objects.
addEventHandler
function addEventHandler( event, callback )
Add a general event handler callback function.
The handler function should have the following signature: [function name]([parameters]). The parameters will vary depending on the event the function is attached to, as follows.
[onAdd] parameters = (token, bLoadEvent)
[onClickDown] parameters = (token, nButton, imagecontrol)
[onClickRelease] parameters = (token, nButton, imagecontrol)
[onContainerChanged] parameters = (token, imagecontrolOld, idOld)
[onContainerChanging] parameters = (token)
[onDelete] parameters = (token)
[onDoubleClick] parameters = (token, imagecontrol)
[onDragStart] parameters = (token)
[onDrag] parameters = (token)
[onDragEnd] parameters = (token)
[onDrop] parameters = (token, dragdataDrop)
[onHover] parameters = (token, bHover)
[onHoverUpdate] parameters = (token, x, y)
[onMenuSelection] parameters = (token, nSelection, [nSelection, …])
[onMove] parameters = (token)
[onMovePathChanged] parameters = (token)
[onTargetUpdate] parameters = (token, tokenTarget, bTargeted)
[onWheel] parameters = (token, nNotches)
Parameters
event (string)
The event to be captured (see function details)
callback (function)
The function to be called when the event triggers
getDistanceBetween
function getDistanceBetween(token, token)
Returns the distance (in game system units) between two tokens. If the tokens specified are not in the same image value (i.e. map), then nil will be returned.
Parameters
token (tokeninstance)
A tokeninstance object on the current image control.
Return values
(number)
The distance between the two specified tokens in game system units,
or nil if the tokens are not on the same map.
getToken
function getToken(containernodename, containerid)
Gets the tokeninstance object referred to by the container node name and ID parameters.
Parameters
containernodename (string)
The database path identifier for the container node
containerid (number)
The ID of the token within the container node
Return values
(tokeninstance)
A tokeninstance object representing the requested token, or nil if the container does not exist or the ID is not valid.
getTokensWithinDistance
function getTokensWithinDistance(token, distance)
Returns a list of all tokens within the given game system unit distance from the specified token.
Parameters
token (tokeninstance)
A tokeninstance object on the current image control.
Return values
(table)
A table with integer index values containing references to tokeninstance objects contained in the control
removeEventHandler
function removeEventHandler( event, callback )
Remove a general event handler callback function.
Parameters should be the same as the event handler registration performed by addEventHandler API.
Parameters
event (string)
The event to be captured (see addEventHandler API)
callback (function)
The event handling function to be removed