Skip to content

Debugging

Material Foundry edited this page Feb 17, 2024 · 2 revisions

This wiki is deprecated, new documentation here.

You can enable debugging through the browser console (also works with the Foundry application).

Opening the console

  1. Press F12 to open 'Developer Tools'
  2. Open the 'Console' tab

Enabling debugging

Send the following code in the console:

Hooks.call('MPdebug', options}

Where you can configure which part of the debugging you want to enable:

let options = {
  'touchDetect': true,
  'nearestToken': true,
  'updateMovement': true,
  'moveToken': true,
  'dropToken': true,
  'tapDetect': true
}

Each of the options is optional, so if you only want to enable 'nearestToken' and 'updateMovement', send:

Hooks.call('MPdebug', {
  'nearestToken': true,
  'updateMovement': true
}}

Alternatively, you can enable one or more options by setting it to false.
After sending the command, a confirmation will be printed in the console with all the currently enabled options.
Refreshing will disable debugging.

touchDetect (touch devices only)

This can be used to check if your touch device is detected.
When touching the screen, it will print:
[touch type], [id], [coordinates], [scaled coordinates]

touch type is either start, move or end.
id is the touch id, where the first touch is assigned 0, and each extra touch get an incrementing value
coordinates is the screen coordinates (top-left should be 0,0).
scaled coordinates is the coordinates scaled to the canvas (so the canvas coordinates)

nearestToken

This can be used to check if the detected touch or base is at the correct location
When touching the screen, or moving a base, it will print:
[nearest token], [token position], [distance to token], [minimum distance], [will be controlled]

nearest token is the name of the token that's nearest to the touch or base
token position are the canvas coordinates of the token
distance to token distance between the scaled coordinates and the token
minimum distance the minimum distance to control a token. If distance to token <= minimum distance, the token will be controlled
will be controlled returns a true or false. If true, this means that distance to token <= minimum distance, and the token will be controlled

If it can't control a token, take a close look at the Distance parameter. Does it get lower when you move closer to the token? Compare the scaled coordinates from touchDetect with the token position, as the distance between these gives the Distance parameter.

updateMovement

If a token is controllable, it will check if the user can move the token.

If no token was close enough, it will print No token found
If the user can't control the token, it will print User can't control token [token name]
If a token can be controlled, it will print Found token [token name]

moveToken

If the user can move the token, it will check if there is a wall collision, otherwise it'll move the token
If there is, it will print Can't move due to a wall collision
Otherwise it will print Token: [token name], Move to: [coordinates]

dropToken

If the token is dropped, it will print
Token [token name], Dropping at [coordinates]
If Non-Owned Movement is enabled in the configuration, and the user is not the owner of the token, it will print
Token [token name], Non-owned token, requesting GM client to be dropped at [coordinates]

touchDetect (touch devices only)

This will print the following related to taps:
If 'Tap Timeout' has passed: Tap Timeout passed, allowing token movement
If 'Touch Timeout' has passed: Touch timeout passed, dropping token
If a door was tapped: Door tapped
If the canvas was tapped (so no door or other active element): Tapped on canvas, releasing all tokens

Clone this wiki locally