VAM Scripter

Other

Provides a JavaScript-like scripting environment inside Virt-A-Mate for automating poses, animations, audio, interactions, and scene control with lifecycle a...

Install

openclaw skills install @nffdasilva/vam-scripter

VAM Scripter Skill

Virt-A-Mate Scripter v1.5.1 Language Support

Scripter is a JavaScript-inspired scripting language that runs inside Virt-A-Mate. It provides high-performance scripting without reflection, enabling automation of poses, animations, audio, and interactions.

gotolm

Scripter v1.5.1 - JavaScript-inspired VAM scripting language.

Syntax Overview

Scripter syntax closely resembles JavaScript with these characteristics:

Module System

import { module } from "vam-scripter";
export const name = value;

Variables

const name = value;  // immutable binding
let name = value;    // mutable binding
var name = value;    // mutable binding

Functions

function name(args) { body }
() => { body }       // arrow function syntax

Control Flow

if (condition) { ... } else { ... }
for (init; condition; update) { ... }
while (condition) { ... }
break; continue;

Exception Handling

try { ... } catch (e) { ... }
throw error;

Data Structures

[1, 2, 3]                        // array
{ key: value }                   // object

Core Modules

vam-scripter Module

The main module imported as "vam-scripter" exports:

ExportTypeDescription
scripterObjectMain plugin interface, lifecycle hooks
sceneObjectScene access (atoms, audio clips)
TimeObjectUnity Time properties
RandomObjectRandom number generation
DateTimeObjectDate/Time operations
playerObjectPlayer (VR/monitor status, hand/head transforms)
keybindingsObjectKeybinding management
InputObjectInput handling
fsObjectFile system operations

scripter Module

Provides lifecycle hooks and plugin management.

Property/MethodArgumentsReturnsDescription
scripter.onUpdate(fn)fn: () => voidFunctionLinkRun every frame
scripter.onLateUpdate(fn)fn: () => voidFunctionLinkRun after Update
scripter.onFixedUpdate(fn)fn: () => voidFunctionLinkRun on physics updates
scripter.onEnable(fn)fn: () => voidFunctionLinkRun when enabled
scripter.onDisable(fn)fn: () => voidFunctionLinkRun when disabled
scripter.onDestroy(fn)fn: () => voidFunctionLinkRun when destroyed
scripter.declareFloatParam(config)config: {name, default, min, max, constrain, onChange}FloatParamDeclarationCreate float parameter
scripter.declareStringParam(config)config: {name, default, onChange}StringParamDeclarationCreate string parameter
scripter.declareBoolParam(config)config: {name, default, onChange}BoolParamDeclarationCreate boolean parameter
scripter.declareAction(name, fn)name: string, fn: () => voidActionDeclarationCreate action
scripter.containingAtom-AtomReferenceReference to the atom housing the script

scene Module

Provides access to atoms and audio clips in the scene.

Property/MethodArgumentsReturnsDescription
scene.getAtom(name)name: stringAtomReferenceGet atom by name/UID
scene.getAtoms()-Array<AtomReference>Get all atoms
scene.getAtomIds()-Array<string>Get all atom UIDs
scene.getAudioClip(type, category, clip)type: "Embedded|URL", category: string, clip: stringNamedAudioClipReferenceGet audio clip

player Module

Provides access to player state and transforms.

PropertyTypeDescription
player.isVRbooleanTrue if in VR mode
player.lHandTransformReferenceLeft hand position/rotation
player.rHandTransformReferenceRight hand position/rotation
player.headTransformReferenceHead position/rotation

keybindings Module

Manages keybindings and commands.

Property/MethodArgumentsReturnsDescription
keybindings.invokeCommand(name)name: stringvoidInvoke a keybinding action
keybindings.declareCommand(name, fn)name: string, fn: () => voidKeybindingDeclarationDeclare a new keybinding

fs Module

File system operations for script persistence.

Property/MethodArgumentsReturnsDescription
fs.writeSceneFileSync(path, content)path: string, content: stringvoidWrite to scene-specific file
fs.readSceneFileSync(path)path: stringstring|undefinedRead scene-specific file
fs.unlinkSceneFileSync(path)path: stringvoidDelete scene-specific file

Time Module

Unity Time properties.

PropertyTypeDescription
Time.timefloatTime since level load
Time.deltaTimefloatTime since last frame
Time.fixedDeltaTimefloatFixed timestep for physics

Random Module

Random number generation.

Property/MethodArgumentsReturnsDescription
Random.value-floatRandom float 0.0-1.0
Random.range(min, max)min, max: int|floatint|floatRandom number in range

Math Module

Math utilities (available as Math).

MethodArgumentsReturnsDescription
Math.abs, Math.ceil, Math.floornumbernumberBasic math
Math.sin, Math.cos, Math.tannumbernumberTrigonometry
Math.sqrt, Math.pow(base, exp)numbernumberPowers/square root
Math.log, Math.log10numbernumberLogarithms
Math.max, Math.min(...args)numbersnumberMin/max
Math.random()-floatRandom 0-1
Math.lerp(start, end, t)numbersnumberLinear interpolation
Math.clamp(value, min, max)numbersnumberClamp value
Math.round, Math.signnumbernumberRounding/sign

Reference Types

AtomReference

Property/MethodArgumentsReturnsDescription
atom.name-stringAtom name
atom.type-stringAtom type
atom.on-booleanIs atom on
atom.getStorableIds()-Array<string>Get storable IDs
atom.getStorable(name)name: stringStorableReferenceGet storable
atom.getController(name)name: stringControllerReferenceGet controller
atom.distance(other)other: AtomReferencefloatDistance to another atom

TransformReference

Property/MethodArgumentsReturnsDescription
transform.position-Vector3Position
transform.rotation-QuaternionRotation
transform.forward-Vector3Forward direction
transform.up-Vector3Up direction
transform.right-Vector3Right direction
transform.lookAt(target)target: TransformReferencevoidRotate to face target
transform.lookAt(x, y, z)coords: Vector3voidRotate to face position

StorableReference

Property/MethodArgumentsReturnsDescription
storable.getId()-stringGet storable ID
storable.getType()-stringGet storable type
storable.getAudioAction(name)name: stringAudioActionReferenceGet audio action

ControllerReference

Property/MethodArgumentsReturnsDescription
controller.name-stringController name
controller.transform-TransformReferenceController transform

AudioActionReference

Property/MethodArgumentsReturnsDescription
audioAction.play(clip)clip: NamedAudioClipReferencevoidPlay audio clip
audioAction.stop()-voidStop audio

NamedAudioClipReference

Property/MethodArgumentsReturnsDescription
clip.name-stringClip name
clip.clip-AudioClipUnity audio clip

Common Patterns

Simple Update Loop

import { scripter, scene } from "vam-scripter";

const ball = scene.getAtom("Ball");
const person = scene.getAtom("Person");

scripter.onUpdate(() => {
    // Run every frame
});

Interaction Detection

import { scripter, scene } from "vam-scripter";

const ball = scene.getAtom("Ball");
const person = scene.getAtom("Person");
const personVoice = person.getStorable("HeadAudioSource").getAudioAction("PlayNow");
const surprisedSound = scene.getAudioClip("URL", "web", "surprised.wav");

scripter.onUpdate(() => {
    if (ball.distance(person) < 0.5) {
        personVoice.play(surprisedSound);
    }
});

Keybinding Handler

import { keybindings, scripter } from "vam-scripter";

const action = scripter.declareAction("MyAction", () => {
    // Handle action
});

keybindings.declareCommand("MyActionKey", () => {
    keybindings.invokeCommand("MyAction");
});

Parameter-Driven Animation

import { scripter, scene } from "vam-scripter";

const person = scene.getAtom("Person");
const head = person.getController("head");

const speedParam = scripter.declareFloatParam({
    name: "Animation Speed",
    default: 1.0,
    min: 0.1,
    max: 5.0,
    onChange: (value) => {
        // Parameter changed
    }
});

File Operations

import { fs, scripter } from "vam-scripter";

const state = JSON.parse(fs.readSceneFileSync("state.json") || "{}");

scripter.onUpdate(() => {
    // Use state
});

scripter.onDisable(() => {
    fs.writeSceneFileSync("state.json", JSON.stringify(state));
});

Date/Time Operations

const now = DateTime.now;
const year = now.year;
const month = now.month;
const day = now.day;

// DateTime properties: year, month, day, hour, minute, second, dayOfWeek

Development Notes

  • scripts must be loaded as index.js
  • Use import { ... } from "vam-scripter" to access modules
  • The language is case-sensitive (JavaScript-style)
  • Use // for single-line comments and /* */ for multi-line
  • All modules are singletons - each import gets the same reference

Files

  • SKILL.md - This documentation
  • scripts/ - Sample scripts and patterns
  • references/ - API reference details