pub struct Effects { /* private fields */ }Expand description
The anvil-script.effects service.
Implementations§
Source§impl Effects
impl Effects
Sourcepub fn get(host: &Host) -> Option<Self>
pub fn get(host: &Host) -> Option<Self>
The service; None without anvil-script or on an Anvil older than
1.16.
Sourcepub fn c_api(&self) -> Table<AnvilScriptEffectsService>
pub fn c_api(&self) -> Table<AnvilScriptEffectsService>
The C table, for what this crate does not wrap.
Sourcepub fn register<E>(&self, host: &Host, key: &str, execute: E) -> Result<()>
pub fn register<E>(&self, host: &Host, key: &str, execute: E) -> Result<()>
Registers the effect key with no line of its own in tooltips.
execute runs each time the game runs the effect. Results, in the order
anvil-script checks them: WrongKind for a plugin with
affects_gameplay = false; WrongPhase for a plugin that is not early,
or once the game has parsed an effect; InvalidArgument for a key that
is not <owner>_<name> (or holds a NUL); AlreadyExists for a taken
key; OutOfMemory past 256 keys. The handler is kept for the process;
a panic in it is logged once and the game’s command goes on.
Sourcepub fn register_with_tooltip<E, D>(
&self,
host: &Host,
key: &str,
execute: E,
describe: D,
) -> Result<()>
pub fn register_with_tooltip<E, D>( &self, host: &Host, key: &str, execute: E, describe: D, ) -> Result<()>
Registers the effect key as register does, with
a tooltip line: describe gives the line (UTF-8, its first line only)
or None for none, for the scope the tooltip is built for. Text past
anvil-script’s buffer is cut at a whole character.