Skip to content

sonolus.script.options

EmptyOptions

An option set with no options, used as the default when an engine declares none.

options(cls: type[T]) -> T | Options

Decorator to define options.

Note

A replay_fallback_option_names class attribute is excluded from the options list and is instead forwarded as replayFallbackOptionNames in the built engine configuration.

Usage
@options
class Options:
    slider_option: float = slider_option(
        name='Slider Option',
        standard=True,
        advanced=False,
        default=0.5,
        min=0,
        max=1,
        step=0.1,
        unit='unit',
        scope='scope',
    )
    toggle_option: bool = toggle_option(
        name='Toggle Option',
        standard=True,
        advanced=False,
        default=True,
        scope='scope',
    )
    select_option: int = select_option(
        name='Select Option',
        standard=True,
        advanced=False,
        default='value',
        values=['value'],
        scope='scope',
    )

select_option(*, name: str | None = None, title: AnyText | None = None, description: AnyText | None = None, standard: bool = False, advanced: bool = False, default: AnyText | int, values: list[AnyText], scope: str | None = None) -> Any

Define a select option.

Parameters:

Name Type Description Default
name str | None

The name of the option.

None
title AnyText | None

The display title of the option, as a plain string or an AnyText localization dict. If unset, the name is shown.

None
description AnyText | None

The description of the option, as a plain string or an AnyText localization dict.

None
standard bool

Whether the option is standard.

False
advanced bool

Whether the option is advanced.

False
default AnyText | int

The default value of the option, given as an entry of values or an index into it.

required
values list[AnyText]

The values of the option, each a plain string or an AnyText localization dict.

required
scope str | None

The scope of the option.

None

slider_option(*, name: str | None = None, title: AnyText | None = None, description: AnyText | None = None, standard: bool = False, advanced: bool = False, default: float, min: float, max: float, step: float, unit: AnyText | None = None, scope: str | None = None) -> Any

Define a slider option.

Parameters:

Name Type Description Default
name str | None

The name of the option.

None
title AnyText | None

The display title of the option, as a plain string or an AnyText localization dict. If unset, the name is shown.

None
description AnyText | None

The description of the option, as a plain string or an AnyText localization dict.

None
standard bool

Whether the option is standard.

False
advanced bool

Whether the option is advanced.

False
default float

The default value of the option.

required
min float

The minimum value of the option.

required
max float

The maximum value of the option.

required
step float

The step value of the option.

required
unit AnyText | None

The unit of the option, as a plain string or an AnyText localization dict.

None
scope str | None

The scope of the option.

None

toggle_option(*, name: str | None = None, title: AnyText | None = None, description: AnyText | None = None, standard: bool = False, advanced: bool = False, default: bool, scope: str | None = None) -> Any

Define a toggle option.

Parameters:

Name Type Description Default
name str | None

The name of the option.

None
title AnyText | None

The display title of the option, as a plain string or an AnyText localization dict. If unset, the name is shown.

None
description AnyText | None

The description of the option, as a plain string or an AnyText localization dict.

None
standard bool

Whether the option is standard.

False
advanced bool

Whether the option is advanced.

False
default bool

The default value of the option.

required
scope str | None

The scope of the option.

None