Packages
 Input
 Module
 User
 DB
 Interface

Objects
 bitmapwidget
 databasenode
 dragdata
 textwidget
 tokeninstance
 widget
 widgetcontainer

Elements
 buttoncontrol
 categoryselectioncontrol
 chatentry
 chatwindow
 databasecontrol
 diecontrol
 diefield
 genericcontrol
 imagecontrol
 numbercontrol
 numberfield
 portraitselectioncontrol
 script
 scrollercontrol
 stringcontrol
 stringfield
 subwindow
 textbasecontrol
 tokenbag
 tokencontrol
 tokenfield
 windowclass
 windowcontrol
 windowinstance
 windowlist
 windowreferencecontrol
 windowreferencefield

Components
 categoryselectionsettings
 customdie
 die
 font
 framedef
 desktopframe
 hotkeybar
 icon
 imageupdatefolder
 importinfo
 includefile
 panel
 portraitset
 template
 tokenroot
 tooltip
addUnderlay
delete
getContainerNode
getId
getName
getPosition
getScale
getTargetingIdentities
isActivable
isActive
isModifiable
isTargetable
isTargeted
isTargetedByIdentity
isVisible
onActivation
onDelete
onMove
onTargetUpdate
removeAllUnderlays
setActivable
setActive
setModifiable
setName
setPosition
setScale
setTarget
setTargetable
setVisible



This object represents a token instance placed in a token container. Token instances are based on token prototypes that define the bitmap used for the token. A token container can contain several instances of one prototype.

By default, token instances can be manipulated by the host and all clients. The token container may be locked, in which case vectors may be drawn out from the token by the clients to indicate movement requests. Tokens can also be toggled non-modifiable which disallows client interaction altogether.

Tokens flagged targetable can be clicked by players to indicate they are targeting the corresponding token. Several clients can target one token.

Token instances do not have direct scripting function definitions, but use a handler based notification scheme. Care should be taken to unregister handlers whenever the objects containing the handler script are destroyed.



Interface

addUnderlay

function addUnderlay( size, color, [mode] )

Add an underlay to the token. Underlays are colored areas drawn based on the grid squares below the token. The size of underlays is given in squares and is measured as a radius from the token centre to the grid square centres. Thus, an equal value as the underlay size will result in a different sized overlay area based on whether the token is situated at a grid square centre or a grid line intersection.

Only scripts running on the session host can set this property.

Parameters

size   (number)   
The size of the underlay in grid squares
color   (string)   
The color of the underlay, in the form '#aarrggbb' where 'aa' represents the transparency (alpha) of the desired color
mode   (string)   [optional]
If this string contains the substring "gmonly", this overlay will be displayed on the host only. If the string contains the substring "hover", the overlay will only be drawn when the mouse cursor is hovering over the token. The flags can be combined.

delete

function delete( )

Destroy the token instance, removing it from the token container.


getContainerNode

function getContainerNode( )

Returns a reference to a databasenode object representing the data for the image containing the token instance. The node name and the token id number (see getId) can be used together to identify the specific token in a saved session.

Return values

(databasenode)
The databasenode representing the image containing the token

getId

function getId( )

Returns the id number of the token in the image database node representing the image containing the token instance. See getContainerNode for more information.

Return values

(number)
The identifier number for this token instance

getName

function getName( )

Return a string containing the name of the token instance, as displayed in the tool tip drawn when the mouse cursor hovers over the token.

Return values

(string)
The name of the token instance

getPosition

function getPosition( )

Return the coordinates the token is located at, relative to the origin of the token container.

Return values

(number)
The horizontal position of the token
(number)
The vertical position of the token

getScale

function getScale( )

Return the size scaling value used for rendering the token in the image control. Any token specific scaling is applied in addition to any global token scaling value in the image control.

Return values

(number)
The size scale factor used for rendering the token

getTargetingIdentities

function getTargetingIdentities( )

Returns a list of all the identities that are targeting this token.

Return values

(table)
An integer indexed table containing a list of all the identity names targeting this token

isActivable

function isActivable( )

Indicates whether the token can be activated. See setActive for more information.

Only scripts running on the session host can set this property.

Return values

(boolean)
Returns true if the token is activable, false otherwise.

isActive

function isActive( )

Determine if the token is currently active. See setActive for more information.

Return values

(boolean)
Returns true if the token is active, false otherwise.

isModifiable

function isModifiable( )

Returns the modifiability flag status.

Return values

(boolean)
Returns true if the token can be interacted with by the clients, false otherwise

isTargetable

function isTargetable( )

Returns the targetability flag status.

Return values

(boolean)
Returns true if the token is targetable, false otherwise

isTargeted

function isTargeted( )

Determines if the token is targeted by one or more identities.

Return values

(boolean)
If true, one or more identities are targeting this token. If no identity is targeting this token, returns false.

isTargetedByIdentity

function isTargetedByIdentity( [targetedby] )

Determines if the token is targeted by the specified identity.

Parameters

targetedby   (string)   [optional]
The name of the identity whose target flag is to be set. If this parameter is omitted, the users currently active identity is used.

Return values

(boolean)
If true, the specified ideneity is targeting this token, false otherwise.

isVisible

function isVisible( )

Get the visibility status of the token instance.

Return values

(boolean)
Returns true if the token is visible, false otherwise

onActivation

handler function onActivation( target )

This handler is called when the target token is activated.

Parameters

target   (tokeninstance)   
The tokeninstance triggering the event

onDelete

handler function onDelete( target )

This handler is called when the target token is deleted.

Parameters

target   (tokeninstance)   
The tokeninstance triggering the event

onMove

handler function onMove( target )

This handler is called when the target token is moved.

Parameters

target   (tokeninstance)   
The tokeninstance triggering the event

onTargetUpdate

handler function onTargetUpdate( target )

This handler is called when the targeting information for the target token is changed.

Parameters

target   (tokeninstance)   
The tokeninstance triggering the event

removeAllUnderlays

function removeAllUnderlays( )

Removes all underlays from the token.


setActivable

function setActivable( state )

Determine whether the token can be activated. See setActive for more information.

Parameters

state   (boolean)   
A value of true to enable activation, false to disable it

setActive

function setActive( state )

Determines whether the token is currently marked active. Active markers can be used by the host to indicate a single token in a container, e.g. to represent it is currently active in a turn sequence.

Parameters

state   (boolean)   
Returns true if this token is presently marked active, false otherwise.

setModifiable

function setModifiable( state )

Flags the token modifiability status. Non-modifiable tokens can't be interacted with by the clients.

Only scripts running on the session host can set this property.

Parameters

state   (boolean)   
A value of false to disable client interactions with the token, or true to allow them.

setName

function setName( name )

Sets the name string used as the tooltip for the token.

Parameters

name   (string)   
A string containing the value to use as the token name and tooltip

setPosition

function setPosition( x, y )

Sets the coordinates the token is located at in the token container.

Parameters

x   (number)   
The horizontal position the token is placed at
y   (number)   
The vertical position the token is placed at

setScale

function setScale( scale )

Sets the size scaling factor used in rendering the token instance in the image control. A token specific scaling value is applied in addition to any global token scaling used in the image control.

Parameters

scale   (number)   
The requested non-negative scaling factor

setTarget

function setTarget( state, [targetedby] )

Sets a target flag on the token. Targeting flags are identity specific, i.e. each token may be targeted by more than one identity.

Parameters

state   (boolean)   
The state of the targeting flag. A value of true to set the target for the specified identity or false to reset it.
targetedby   (string)   [optional]
The name of the identity whose target flag is to be set. If this parameter is omitted, the users currently active identity is used.

setTargetable

function setTargetable( state )

Sets the targetablility flag for the token.

Only scripts running on the session host can set this property.

Parameters

state   (boolean)   
The value true to enable targeting, false otherwise

setVisible

function setVisible( state )

Set the client visibility for the token. A hidden token will not be displayed to the clients, and will be drawn with 50% transparency on the host.

Parameters

state   (boolean)   
Set to true to show the token, false to hide it


'Fantasy Grounds' is a trademark of SmiteWorks Ltd.
'd20 System' and the d20 System logo are trademarks of Wizards of the Coast, Inc. in the United States and other countries and are used with permission.
© 2004-2008 SmiteWorks Ltd. ALL RIGHTS RESERVED.
Privacy policy