Story Package

The Story package contains methods to control the interactive environment through programmable components.

1. get_context()

Methods that return the context of interactive environment.

Returns:

  • A StoryAsync object representing the context.

Example

import story

ctx = story.get_context()
Run

2.1. sleep_async(time: float)

Simulate an asynchronous delay to synchronize operations.

Parameters:

  • time (float): Delay duration in seconds.

Example

import story

ctx = story.get_context()

await ctx.sleep_async(10)
Run

2.2. text()

Returns an internal Text object for creating and managing interactive text elements.

Returns:

  • The Text object.

Example

import story

ctx = story.get_context()

text = ctx.text()
Run

2.2.1 init_async()

Initialize the Text component.

Returns:

  • The Text object.

Example

import story

ctx = story.get_context()

text = ctx.text()

text = await text.init_async()
Run

2.2.2 write(markdown: str)

Write text in component.

Parameters:

  • markdown (float): The KaTeX-compatible Markdown code to be rendered in the component.

Returns:

  • The Text object.

Example

import story

ctx = story.get_context()

text = ctx.text()

text = await text.init_async()

text = text.write("""
# Example

The example formula is as follows:

$$
E = mc^2
$$

You can also use mixed text with inline math, for example: "Einstein's famous equation $E = mc^2$ describes the relationship between energy and mass."
""")
Run