Documentation
¶
Index ¶
- type CommandSchema
- type CommandWrapper
- type CustomCmd
- type DelayCmd
- type Executor
- func (e *Executor) Execute() (int, error)
- func (e *Executor) SetCustomFunc(f func(name, request string) error)
- func (e *Executor) SetInputFunc(f func(key, action string, durationTicks int64, async bool) error)
- func (e *Executor) SetMouseFunc(...)
- func (e *Executor) SetScreenshotFunc(f func(output string, b64, async bool) error)
- func (e *Executor) SetStateFunc(f func(name, path string) error)
- func (e *Executor) SetWaitFunc(f func(condition, timeout, interval string, verbose bool) error)
- func (e *Executor) SetWheelFunc(f func(x, y float64, async bool) error)
- type InputCmd
- type MouseCmd
- type RepeatCmd
- type RepeatSchema
- type ScreenshotCmd
- type Script
- type ScriptSchema
- type StateCmd
- type WaitCmd
- type WheelCmd
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CommandSchema ¶ added in v0.3.0
type CommandSchema struct {
// Input command - inject keyboard input
Input *InputCmd `json:"input,omitempty" jsonschema:"oneof_required=input,description=Inject keyboard input"`
// Mouse command - inject mouse input
Mouse *MouseCmd `json:"mouse,omitempty" jsonschema:"oneof_required=mouse,description=Inject mouse input"`
// Wheel command - inject wheel/scroll input
Wheel *WheelCmd `json:"wheel,omitempty" jsonschema:"oneof_required=wheel,description=Inject wheel/scroll input"`
// Screenshot command - capture game screenshot
Screenshot *ScreenshotCmd `json:"screenshot,omitempty" jsonschema:"oneof_required=screenshot,description=Capture game screenshot"`
// Delay command - pause execution
Delay *DelayCmd `json:"delay,omitempty" jsonschema:"oneof_required=delay,description=Pause execution for a duration"`
// Custom command - execute a registered custom command
Custom *CustomCmd `json:"custom,omitempty" jsonschema:"oneof_required=custom,description=Execute a registered custom command"`
// State command - query game state
State *StateCmd `json:"state,omitempty" jsonschema:"oneof_required=state,description=Query game state via registered exporter"`
// Wait command - wait for condition to be met
Wait *WaitCmd `json:"wait,omitempty" jsonschema:"oneof_required=wait,description=Wait for condition to be met"`
// Repeat command - repeat a block of commands
Repeat *RepeatSchema `json:"repeat,omitempty" jsonschema:"oneof_required=repeat,description=Repeat a block of commands"`
}
CommandSchema represents a command in the script format for schema generation. Only one field should be set at a time.
type CommandWrapper ¶ added in v0.3.0
type CommandWrapper interface {
// contains filtered or unexported methods
}
CommandWrapper is the interface for all command types.
func UnmarshalCommand ¶ added in v0.6.0
func UnmarshalCommand(data []byte) (CommandWrapper, error)
UnmarshalCommand unmarshals a single command from JSON. This is the public version that can be used by external packages.
type CustomCmd ¶ added in v0.3.0
type CustomCmd struct {
Name string `json:"name" jsonschema:"description=Name of the registered custom command"`
Request string `json:"request,omitempty" jsonschema:"description=Optional request data to pass to the custom command"`
}
CustomCmd represents a custom command.
type DelayCmd ¶
type DelayCmd struct {
Ms int64 `json:"ms" jsonschema:"minimum=0,description=Milliseconds to wait"`
}
DelayCmd represents a delay command.
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
Executor executes a script.
func (*Executor) SetCustomFunc ¶ added in v0.3.0
SetCustomFunc sets the function to call for custom commands.
func (*Executor) SetInputFunc ¶
SetInputFunc sets the function to call for input commands.
func (*Executor) SetMouseFunc ¶
func (e *Executor) SetMouseFunc(f func(action string, x, y int, button string, durationTicks int64, async bool) error)
SetMouseFunc sets the function to call for mouse commands.
func (*Executor) SetScreenshotFunc ¶
SetScreenshotFunc sets the function to call for screenshot commands.
func (*Executor) SetStateFunc ¶ added in v0.6.0
SetStateFunc sets the function to call for state commands.
func (*Executor) SetWaitFunc ¶ added in v0.6.0
SetWaitFunc sets the function to call for wait commands.
type InputCmd ¶
type InputCmd struct {
Action string `json:"action" jsonschema:"enum=press,enum=release,enum=hold,description=Action to perform"`
Key string `json:"key" jsonschema:"description=Key name (use 'autoebiten keys' to list all)"`
DurationTicks int64 `json:"duration_ticks" jsonschema:"default=6,description=Duration in game ticks for hold action"`
Async bool `json:"async" jsonschema:"default=false,description=Return immediately without waiting"`
}
InputCmd represents an input command.
type MouseCmd ¶
type MouseCmd struct {
Action string `` /* 154-byte string literal not displayed */
X int `json:"x" jsonschema:"default=0,description=X coordinate"`
Y int `json:"y" jsonschema:"default=0,description=Y coordinate"`
Button string `json:"button" jsonschema:"description=Mouse button (use 'autoebiten mouse_buttons' to list all)"`
DurationTicks int64 `json:"duration_ticks" jsonschema:"default=6,description=Duration in game ticks for hold action"`
Async bool `json:"async" jsonschema:"default=false,description=Return immediately without waiting"`
}
MouseCmd represents a mouse command.
type RepeatCmd ¶
type RepeatCmd struct {
Times int `json:"times"`
Commands []CommandWrapper `json:"commands"`
}
RepeatCmd represents a repeat block.
type RepeatSchema ¶ added in v0.3.0
type RepeatSchema struct {
Times int `json:"times" jsonschema:"minimum=1,description=Number of times to repeat"`
Commands []CommandSchema `json:"commands" jsonschema:"description=Commands to repeat"`
}
RepeatSchema represents a repeat block for schema generation.
type ScreenshotCmd ¶
type ScreenshotCmd struct {
Output string `json:"output" jsonschema:"description=Output file path (optional, auto-generated if not provided)"`
Base64 bool `` /* 131-byte string literal not displayed */
Async bool `json:"async" jsonschema:"default=false,description=Return immediately without waiting"`
}
ScreenshotCmd represents a screenshot command.
type Script ¶
type Script struct {
Version string `json:"version"`
Commands []CommandWrapper `json:"commands"`
}
Script is the root node of a script.
func ParseBytes ¶
ParseBytes parses a script from JSONC bytes (JSON with Comments).
func ParseString ¶
ParseString parses a script from a JSON string.
func (*Script) UnmarshalJSON ¶ added in v0.3.0
UnmarshalJSON implements custom JSON unmarshaling for CommandWrapper.
type ScriptSchema ¶ added in v0.3.0
type ScriptSchema struct {
// Schema is the JSON Schema URI for this document
Schema string `json:"$schema,omitempty" jsonschema:"type=string,format=uri-reference,description=JSON Schema URI for this document"`
Version string `json:"version" jsonschema:"enum=1.0,description=Script format version"`
// Commands to execute in order
Commands []CommandSchema `json:"commands" jsonschema:"description=List of commands to execute in order"`
}
ScriptSchema represents the root script structure for schema generation.
type StateCmd ¶ added in v0.6.0
type StateCmd struct {
Name string `json:"name" jsonschema:"required,description=State exporter name"`
Path string `json:"path" jsonschema:"required,description=Dot-notation path to query"`
}
StateCmd represents a state query command.
type WaitCmd ¶ added in v0.6.0
type WaitCmd struct {
Condition string `json:"condition" jsonschema:"required,description=Condition to poll for (e.g., state:gamestate:Player.Health == 100)"`
Timeout string `json:"timeout" jsonschema:"required,description=Maximum wait duration (e.g., 10s, 5m)"`
Interval string `json:"interval,omitempty" jsonschema:"description=Poll interval (default 100ms)"`
Verbose bool `json:"verbose,omitempty" jsonschema:"description=Print errors during polling"`
}
WaitCmd represents a wait-for condition command.
type WheelCmd ¶
type WheelCmd struct {
X float64 `json:"x" jsonschema:"default=0,description=Horizontal scroll"`
Y float64 `json:"y" jsonschema:"default=0,description=Vertical scroll"`
Async bool `json:"async" jsonschema:"default=false,description=Return immediately without waiting"`
}
WheelCmd represents a wheel command.