Interface BotScript
- All Known Implementing Classes:
TaskScript
public interface BotScript
Service Provider Interface for bot scripts.
Implementations are discovered at runtime via ServiceLoader.
Each script follows a lifecycle of onStart(ScriptContext) → onLoop() → onStop().
Annotate implementations with ScriptManifest to declare metadata.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault List<ConfigField> Returns the configurable fields this script exposes.default ScriptUIgetUI()Returns a custom UI for this script, rendered in the Script UI panel.default voidonConfigUpdate(ScriptConfig config) Called when the script's configuration is updated (at startup from persisted values, or at runtime from the config UI).intonLoop()Called repeatedly while the script is running.voidonStart(ScriptContext ctx) Called once when the script is started.voidonStop()Called once when the script is stopped, either by returning-1fromonLoop()or by an external stop request.
-
Method Details
-
onStart
Called once when the script is started. Use this to initialize state and cache references from the context.- Parameters:
ctx- the script context providing access to theGameAPIand event bus
-
onLoop
int onLoop()Called repeatedly while the script is running. The returned value controls the delay before the next invocation.- Returns:
- delay in milliseconds before the next loop iteration, or
-1to stop the script
-
onStop
void onStop()Called once when the script is stopped, either by returning-1fromonLoop()or by an external stop request. Use this to clean up resources. -
getConfigFields
Returns the configurable fields this script exposes. Override this to declare user-editable parameters. The default implementation returns an empty list (no config).- Returns:
- a list of config field descriptors
-
onConfigUpdate
Called when the script's configuration is updated (at startup from persisted values, or at runtime from the config UI). The default implementation does nothing.- Parameters:
config- the new configuration snapshot
-
getUI
Returns a custom UI for this script, rendered in the Script UI panel. Override this to provide interactive widgets, status displays, or controls beyond whatgetConfigFields()offers.The returned
ScriptUIis called every frame while its panel is showing; seeScriptUI.render()for where and how. Returnnull(the default) if this script has no custom UI.- Returns:
- a ScriptUI implementation, or null
-