Repository navigation
API Plugin settings
| Import | from proleak import settings |
Plugin settings: declared with add (or in plugin.yml), saved between sessions and editable from the plugin's Settings form in the Mods menu.
| Class | |
|---|---|
Settings |
Settings of one plugin (ctx.settings in on_load). |
Setting |
One setting the plugin declared with add. |
| Returns | Function | |
|---|---|---|
Setting |
add(key: str, default: bool | int | float | str | list[str], *, type: str | None = None, label: str | None = None, subtitle: str | None = None, help: str | None = None, min: float | None = None, max: float | None = None, choices: list[str] | None = None) |
Declare a setting of the calling plugin and return it as a Setting. |
object |
get(key: str, default: object = None) |
Value of key for the calling plugin. |
None |
set(key: str, value: object) |
Set key for the calling plugin. |
dict[str, object] |
as_dict() |
All settings of the calling plugin. |
Callable[[str, object], None] |
on_change(fn: Callable[[str, object], None]) |
Decorator: call fn(key, value) after one of the calling plugin's settings changes, from code or from the Mods menu. |
settings.<key> reads the calling plugin's value; settings.set(key, value)
validates and saves it.
add(key: str, default: bool | int | float | str | list[str], *, type: str | None = None, label: str | None = None, subtitle: str | None = None, help: str | None = None, min: float | None = None, max: float | None = None, choices: list[str] | None = None) -> Setting
Declare a setting of the calling plugin and return it as a Setting.
The type follows default (bool, int, float or text) unless type says one of:
-
"color": a color as"#rrggbb". -
"choice": one ofchoices. -
"multi": a list of any ofchoices(a list default withchoicesimplies it). The value lists the chosen items in the order ofchoices; a choice cannot contain a comma. -
"key": a key name as Unity spells it ("V","F12","PageUp"), set in the form by pressing the key.
min and max bound a number. subtitle is a short line the settings form shows under the
label; help is longer text shown in a "?" box beside it. The value saved in an earlier
session is kept when it is still valid. Declaring a setting gives the plugin a Settings form
in the Mods menu. Declare settings when the plugin loads (module body or on_load).
get(key: str, default: object = None) -> object
Value of key for the calling plugin.
set(key: str, value: object) -> None
Set key for the calling plugin.
as_dict() -> dict[str, object]
All settings of the calling plugin.
on_change(fn: Callable[[str, object], None]) -> Callable[[str, object], None]
Decorator: call fn(key, value) after one of the calling plugin's settings changes, from
code or from the Mods menu.
Settings of one plugin (ctx.settings in on_load).
| Returns | Method | |
|---|---|---|
object |
get(key: str, default: object = None) |
Value of key, or default when there is no such setting. |
None |
set(key: str, value: object) |
Validate against plugin.yml and save. |
dict[str, object] |
as_dict() |
All settings as a dict. |
get(key: str, default: object = None) -> object
Value of key, or default when there is no such setting.
set(key: str, value: object) -> None
Validate against plugin.yml and save. Raises ValueError when out of range.
as_dict() -> dict[str, object]
All settings as a dict.
One setting the plugin declared with add.
Inherits SettingBinding.
| Type | Property | |
|---|---|---|
object |
value read-only
|
The saved value; assigning one validates and saves it. |
| Returns | Method | |
|---|---|---|
Callable[[object], None] |
on_change(fn: Callable[[object], None]) |
Decorator: call fn(value) after this setting changes, from code or the Mods menu. |
value reads the saved value and, when assigned, validates and saves a new one. Pass the
setting itself where the UI takes a value, such as a widget's bind=, and the UI follows
every change.
value: object [read-only]
The saved value; assigning one validates and saves it.
on_change(fn: Callable[[object], None]) -> Callable[[object], None]
Decorator: call fn(value) after this setting changes, from code or the Mods menu.
Using ProLeak
Features
Tutorial
- Your first plugin
- Plugin basics
- Handling events
- Plugin settings
- User interface
- Players, units and game data
- Purchases, signals and pings
- Chat, camera, input and more
- Cosmetics
- Game modes
- Game updates
- Publishing plugins
Reference