API and Hooks
Accessing the API
Section titled “Accessing the API”Reach the API through game.modules.get('travel-pace').api, or the global TRAVELPACE object once the module initializes.
Methods
Section titled “Methods”| Method | Description |
|---|---|
unit | The world’s distance unit abbreviation. |
calculateTravel(data) | Calculate a journey without posting anything. Returns the result, or null when a travelPace.preCalculate listener cancelled it. |
submitCalculation(data) | Calculate a journey and post it to chat, firing travelPace.calculated. Returns the result, or null when cancelled. |
createChatMessage(result) | Post an already-calculated result to chat. |
durationToSeconds(totalMinutes) | Convert travel minutes to world-time seconds, following the Day Advance Mode setting. See Settings. |
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 | A travel pace id: 'slow', 'normal', or 'fast'. |
distance | Distance in the world’s travel unit. Required in distance mode. |
time | An object with days, hours, and minutes. Required in time mode. |
mount | A resolved 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 a calculation runs. To cancel it, return false from a listener.
Passed a single object with data, the input payload, and modifiers, a mutable array of {id, label, multiplier} entries seeded with any active weather modifiers. To contribute your own multiplier alongside weather’s, push onto modifiers. See Weather and Conditions.
travelPace.calculated
Section titled “travelPace.calculated”Fires after submitCalculation posts a chat message. Passed the result and the created ChatMessage.