editor › Globals › ScriptInterface
Class: ScriptInterface
The ScriptInterface allows for simulating user input and simple editor interaction
Hierarchy
- ScriptInterface
Index
Constructors
Properties
- canvasReplayDevice
- deviceInputEventQueue
- interactionManager
- menuActionDispatcher
- scriptStepEventEmitter
- toolLibrary
Methods
- _addEvent
- _deRegisterScriptableEvents
- _determineKeypoints
- _onDeviceInputContinue
- _onDeviceInputEnd
- _onDeviceInputStart
- _onDispatchMenuAction
- _onToolSelected
- _processDeviceInputQueue
- _registerScriptableEvents
- _simplifyDrag
- disableIncomingEventProcessing
- doAction
- dragRay
- enableIncomingEventProcessing
- enter
- getActionTimeoutSeconds
- getScriptStepEventEmitter
- injectRay
- performModuleAction
- replayFromData
- replayFromName
- resetConfigValue
- selectTool
- setAssemblyHint
- setConfigValue
- tap
- tapRay
Constructors
constructor
+ new ScriptInterface(canvasReplayDevice: CanvasReplayInputDevice, toolLibrary: ToolLibrary, menuActionDispatcher: MenuActionDispatcher, interactionManager: InteractionManager): ScriptInterface
Defined in src/scripting/ScriptInterface.ts:73
Parameters:
| Name | Type |
|---|---|
canvasReplayDevice |
CanvasReplayInputDevice |
toolLibrary |
ToolLibrary |
menuActionDispatcher |
MenuActionDispatcher |
interactionManager |
InteractionManager |
Returns: ScriptInterface
Properties
Private canvasReplayDevice
• canvasReplayDevice: CanvasReplayInputDevice
Defined in src/scripting/ScriptInterface.ts:68
Private deviceInputEventQueue
• deviceInputEventQueue: IDeviceInputEventQueueElement[] | null = null
Defined in src/scripting/ScriptInterface.ts:72
Private interactionManager
• interactionManager: InteractionManager
Defined in src/scripting/ScriptInterface.ts:71
Private menuActionDispatcher
• menuActionDispatcher: MenuActionDispatcher
Defined in src/scripting/ScriptInterface.ts:70
Private Readonly scriptStepEventEmitter
• scriptStepEventEmitter: EventEmitter‹IScriptStep› = new EventEmitter
Defined in src/scripting/ScriptInterface.ts:73
Private toolLibrary
• toolLibrary: ToolLibrary
Defined in src/scripting/ScriptInterface.ts:69
Methods
Private _addEvent
▸ _addEvent(inputEvent: IInputEvent): void
Defined in src/scripting/ScriptInterface.ts:418
Parameters:
| Name | Type |
|---|---|
inputEvent |
IInputEvent |
Returns: void
Private _deRegisterScriptableEvents
▸ _deRegisterScriptableEvents(): void
Defined in src/scripting/ScriptInterface.ts:410
Returns: void
Private _determineKeypoints
▸ _determineKeypoints(vectors: Vector3[], maxInterpolationError: number): number[]
Defined in src/scripting/ScriptInterface.ts:547
Calculates the indices of vectors so that linearly interpolating these selected points will produce an error not greater than specified compared to the original vectors array
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
vectors |
Vector3[] | - | Original vectors |
maxInterpolationError |
number | 0.2 | Maximum absolute (distance) interpolation error |
Returns: number[]
Vector indices
Private _onDeviceInputContinue
▸ _onDeviceInputContinue(inputEvent: IInputEvent): void
Defined in src/scripting/ScriptInterface.ts:432
Parameters:
| Name | Type |
|---|---|
inputEvent |
IInputEvent |
Returns: void
Private _onDeviceInputEnd
▸ _onDeviceInputEnd(inputEvent: IInputEvent): void
Defined in src/scripting/ScriptInterface.ts:441
Parameters:
| Name | Type |
|---|---|
inputEvent |
IInputEvent |
Returns: void
Private _onDeviceInputStart
▸ _onDeviceInputStart(inputEvent: IInputEvent): void
Defined in src/scripting/ScriptInterface.ts:426
Parameters:
| Name | Type |
|---|---|
inputEvent |
IInputEvent |
Returns: void
Private _onDispatchMenuAction
▸ _onDispatchMenuAction(__namedParameters: object): void
Defined in src/scripting/ScriptInterface.ts:457
Parameters:
▪ __namedParameters: object
| Name | Type |
|---|---|
action |
string |
moduleName |
string |
parameters |
any |
value |
any |
Returns: void
Private _onToolSelected
▸ _onToolSelected(event: IToolSelectionEvent): void
Defined in src/scripting/ScriptInterface.ts:449
Parameters:
| Name | Type |
|---|---|
event |
IToolSelectionEvent |
Returns: void
Private _processDeviceInputQueue
▸ _processDeviceInputQueue(): void
Defined in src/scripting/ScriptInterface.ts:465
Returns: void
Private _registerScriptableEvents
▸ _registerScriptableEvents(): void
Defined in src/scripting/ScriptInterface.ts:402
Returns: void
Private _simplifyDrag
▸ _simplifyDrag(inputEvents: IDeviceInputEventQueueElement[]): object[]
Defined in src/scripting/ScriptInterface.ts:501
Simplifies a row of input events by determining keypoints
Parameters:
| Name | Type |
|---|---|
inputEvents |
IDeviceInputEventQueueElement[] |
Returns: object[]
disableIncomingEventProcessing
▸ disableIncomingEventProcessing(): void
Defined in src/scripting/ScriptInterface.ts:106
Returns: void
doAction
▸ doAction(scriptStep: IScriptStep, compositeModel: CompositeModel): Promise‹void›
Defined in src/scripting/ScriptInterface.ts:190
Parameters:
| Name | Type |
|---|---|
scriptStep |
IScriptStep |
compositeModel |
CompositeModel |
Returns: Promise‹void›
dragRay
▸ dragRay(events: ISimplifiedDeviceInputEvent[]): Promise‹unknown›
Defined in src/scripting/ScriptInterface.ts:339
Parameters:
| Name | Type |
|---|---|
events |
ISimplifiedDeviceInputEvent[] |
Returns: Promise‹unknown›
enableIncomingEventProcessing
▸ enableIncomingEventProcessing(): void
Defined in src/scripting/ScriptInterface.ts:91
Enables listening for events and processing them into "scriptStepEvents" that are emitted (has to be enabled explicitly due to performance overhead)
Returns: void
enter
▸ enter(): void
Defined in src/scripting/ScriptInterface.ts:311
Mimics an enter key press
Returns: void
getActionTimeoutSeconds
▸ getActionTimeoutSeconds(scriptStep: IScriptStep): number
Defined in src/scripting/ScriptInterface.ts:174
Given an event to perform, after which time should it absolutely be done? If it takes longer, script execution will nevertheless continue.
Parameters:
| Name | Type |
|---|---|
scriptStep |
IScriptStep |
Returns: number
getScriptStepEventEmitter
▸ getScriptStepEventEmitter(): IPublicEventEmitterInterface‹IScriptStep›
Defined in src/scripting/ScriptInterface.ts:115
Returns: IPublicEventEmitterInterface‹IScriptStep›
injectRay
▸ injectRay(type: InputEventType, event: ISimplifiedDeviceInputEvent): void
Defined in src/scripting/ScriptInterface.ts:395
Parameters:
| Name | Type |
|---|---|
type |
InputEventType |
event |
ISimplifiedDeviceInputEvent |
Returns: void
performModuleAction
▸ performModuleAction(module: string, action: string, parameters?: any, value?: any): Promise‹boolean›
Defined in src/scripting/ScriptInterface.ts:286
Performs an action on a module
Parameters:
| Name | Type | Description |
|---|---|---|
module |
string | Name of the module |
action |
string | Name of the action |
parameters? |
any | (optional) Menu item parameters |
value? |
any | Menu item value |
Returns: Promise‹boolean›
replayFromData
▸ replayFromData(scriptData: IScriptStep[], compositeModel?: CompositeModel): Promise‹void›
Defined in src/scripting/ScriptInterface.ts:137
Replays a script defined by a JSON object with the individual steps
Parameters:
| Name | Type | Description |
|---|---|---|
scriptData |
IScriptStep[] | - Array of steps. Each step consists out of an action, args for that action and an optional delay in ms (default value is 10ms) after executing that step |
compositeModel? |
CompositeModel | - |
Returns: Promise‹void›
Promise that resolves when all steps are executed
replayFromName
▸ replayFromName(scriptName: string, compositeModel?: CompositeModel): Promise‹void›
Defined in src/scripting/ScriptInterface.ts:123
Replays a script by name (loads the JSON from the server).
Parameters:
| Name | Type |
|---|---|
scriptName |
string |
compositeModel? |
CompositeModel |
Returns: Promise‹void›
Promise that will resolve once the replay has been finished
resetConfigValue
▸ resetConfigValue(key: string): void
Defined in src/scripting/ScriptInterface.ts:330
Parameters:
| Name | Type |
|---|---|
key |
string |
Returns: void
selectTool
▸ selectTool(name: string, isPersistent: boolean, parameters: any): Promise‹void›
Defined in src/scripting/ScriptInterface.ts:251
Selects a tool
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
name |
string | - | Name of the tool to be selected |
isPersistent |
boolean | false | Flag whether the tool selection should be persistent (default: false) |
parameters |
any | - | (optional) Parameters supplied to this tool (usually defined by the menu item) |
Returns: Promise‹void›
setAssemblyHint
▸ setAssemblyHint(compositeModel: CompositeModel, hint: string, value: string): void
Defined in src/scripting/ScriptInterface.ts:320
Sets a hint on the most recently added Assembly.
Parameters:
| Name | Type | Description |
|---|---|---|
compositeModel |
CompositeModel | - |
hint |
string | Name of the hint |
value |
string | Value of the hint |
Returns: void
setConfigValue
▸ setConfigValue(key: string, value: any): void
Defined in src/scripting/ScriptInterface.ts:326
Parameters:
| Name | Type |
|---|---|
key |
string |
value |
any |
Returns: void
tap
▸ tap(relativeX: number, relativeY: number): void
Defined in src/scripting/ScriptInterface.ts:302
Issues a pointerDown + pointerUp event on the given relative (0.0-1.0) position on the screen
Parameters:
| Name | Type | Description |
|---|---|---|
relativeX |
number | X position of the tap relative to the screen |
relativeY |
number | Y position of the tap relative to the screen |
Returns: void
tapRay
▸ tapRay(event: ISimplifiedDeviceInputEvent): void
Defined in src/scripting/ScriptInterface.ts:334
Parameters:
| Name | Type |
|---|---|
event |
ISimplifiedDeviceInputEvent |
Returns: void