API and Hooks
Accessing the API
Section titled “Accessing the API”Use game.modules.get('travel-pace').api, or the global TRAVELPACE object.
Members
Section titled “Members”| Member | Description |
|---|---|
unit | Property. The world’s distance unit abbreviation. |
calculateTravel(data) | Calculate a journey without posting anything. |
submitCalculation(data) | Calculate a journey and post it to chat, firing travelPace.calculated. |
createChatMessage(result) | Post an already-calculated result to chat. |
durationToSeconds(totalMinutes) | Convert travel minutes to world-time seconds, following the Day Advance Mode setting. |
openCalculator() | Open the calculator, or bring the open one forward. |
The input payload
Section titled “The input payload”calculateTravel and submitCalculation take:
| Property | Description |
|---|---|
mode | 'distance' or 'time'. |
pace | 'slow', 'normal', or 'fast'. |
distance | Distance in the world’s travel unit. Required in distance mode. |
time | An object with days, hours, and minutes. Days are travel days. Required in time mode. |
mount | A creature, vehicle, or group actor to travel as, or null to travel on foot. |
The result
Section titled “The result”A result carries the mode it ran in, the original input, the output (totalMinutes plus either time/timeFormatted or distance), the pace’s mechanical-effect text, the traveller’s resolved speed, the list of applied modifiers, their combined multiplier, and the traveller’s UUID when one was used.
travelPace.preCalculate
Section titled “travelPace.preCalculate”Fires before every calculation, including each live update in the calculator window. Return false from a listener to cancel.
Receives an object with data, the input payload, and modifiers, a mutable array of {id, label, multiplier} entries that already holds any active weather modifiers. Push onto modifiers to apply your own multiplier. Each modifier gets its own line on the chat card.
travelPace.calculated
Section titled “travelPace.calculated”Fires after submitCalculation posts a chat message, including from the calculator’s Send to Chat button. Receives the result and the created ChatMessage.