TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/pompom454/tea/llms.txt
Use this file to discover all available pages before exploring further.
LoadScreen API lets you keep Tea’s loading screen visible until your own asynchronous work is complete. Tea uses a lock-based system: any code that needs to delay story startup can acquire a lock, which forces the loading screen to remain displayed. When the work is finished, the lock is released. The loading screen hides automatically once all active locks have been released.
This is useful when your story depends on resources that take unpredictable amounts of time to load—for example, fetching data from an external API, preloading audio via the Web Audio API, or waiting for a Promise-based library to initialize.
If you only need to add a fixed delay to hide a flash of unstyled content (FOUC), you do not need this API. Use the
Config.loadDelay setting instead, which accepts a delay in milliseconds.LoadScreen.lock()
Acquires a loading screen lock. If the loading screen is not already visible, this also displays it.An integer lock ID. Store this value and pass it to
LoadScreen.unlock() when your work is complete.LoadScreen.unlock()
Releases a loading screen lock by its ID. If this was the last active lock, the loading screen is hidden and the story proceeds.The integer lock ID returned by
LoadScreen.lock().This method does not return a value.
The locking pattern
The standard way to useLoadScreen is to acquire a lock before starting async work, then release it in the callback or Promise resolution handler.
Multiple locks
You can hold multiple locks simultaneously. The loading screen stays visible until every lock has been released. This is useful when you have several independent async operations that must all complete before the story starts.Where to call LoadScreen.lock()
Where to call LoadScreen.lock()
Acquire locks in a
StoryInit special passage (using a <<run>> macro) or in JavaScript added to your story via Twine’s Edit Story JavaScript dialog. Locks acquired before Tea initializes the story will prevent the loading screen from dismissing until they are released.