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.
Scripter v1.5.1 - JavaScript-inspired VAM scripting language.
Scripter syntax closely resembles JavaScript with these characteristics:
javascript
import { module } from "vam-scripter";
export const name = value;
javascript
const name = value; // immutable binding
let name = value; // mutable binding
var name = value; // mutable binding
javascript
function name(args) { body }
() => { body } // arrow function syntax
javascript
if (condition) { ... } else { ... }
for (init; condition; update) { ... }
while (condition) { ... }
break; continue;
javascript
try { ... } catch (e) { ... }
throw error;
javascript
[1, 2, 3] // array
{ key: value } // object
The main module imported as "vam-scripter" exports:
ExportTypeDescriptionscripterObjectMain plugin interface, lifecycle hookssceneObjectScene access (atoms, audio clips)TimeObjectUnity Time propertiesRandomObjectRandom number generationDateTimeObjectDate/Time operationsplayerObjectPlayer (VR/monitor status, hand/head transforms)keybindingsObjectKeybinding managementInputObjectInput handlingfsObjectFile system operations
Provides lifecycle hooks and plugin management.
Property/MethodArgumentsReturnsDescriptionscripter.onUpdate(fn)``fn: () => void``FunctionLinkRun every framescripter.onLateUpdate(fn)``fn: () => void``FunctionLinkRun after Updatescripter.onFixedUpdate(fn)``fn: () => void``FunctionLinkRun on physics updatesscripter.onEnable(fn)``fn: () => void``FunctionLinkRun when enabledscripter.onDisable(fn)``fn: () => void``FunctionLinkRun when disabledscripter.onDestroy(fn)``fn: () => void``FunctionLinkRun when destroyedscripter.declareFloatParam(config)``config: {name, default, min, max, constrain, onChange}``FloatParamDeclarationCreate float parameterscripter.declareStringParam(config)``config: {name, default, onChange}``StringParamDeclarationCreate string parameterscripter.declareBoolParam(config)``config: {name, default, onChange}``BoolParamDeclarationCreate boolean parameterscripter.declareAction(name, fn)``name: string, fn: () => void``ActionDeclarationCreate actionscripter.containingAtom-AtomReferenceReference to the atom housing the script
Provides access to atoms and audio clips in the scene.
Property/MethodArgumentsReturnsDescriptionscene.getAtom(name)``name: string``AtomReferenceGet atom by name/UIDscene.getAtoms()-Array<AtomReference>Get all atomsscene.getAtomIds()-Array<string>Get all atom UIDsscene.getAudioClip(type, category, clip)``type: "Embedded|URL", category: string, clip: string``NamedAudioClipReferenceGet audio clip
Provides access to player state and transforms.
PropertyTypeDescriptionplayer.isVR``booleanTrue if in VR modeplayer.lHand``TransformReferenceLeft hand position/rotationplayer.rHand``TransformReferenceRight hand position/rotationplayer.head``TransformReferenceHead position/rotation
Manages keybindings and commands.
Property/MethodArgumentsReturnsDescriptionkeybindings.invokeCommand(name)``name: string``voidInvoke a keybinding actionkeybindings.declareCommand(name, fn)``name: string, fn: () => void``KeybindingDeclarationDeclare a new keybinding
File system operations for script persistence.
Property/MethodArgumentsReturnsDescriptionfs.writeSceneFileSync(path, content)``path: string, content: string``voidWrite to scene-specific filefs.readSceneFileSync(path)``path: string``string|undefinedRead scene-specific filefs.unlinkSceneFileSync(path)``path: string``voidDelete scene-specific file
Unity Time properties.
PropertyTypeDescriptionTime.time``floatTime since level loadTime.deltaTime``floatTime since last frameTime.fixedDeltaTime``floatFixed timestep for physics
Random number generation.
Property/MethodArgumentsReturnsDescriptionRandom.value-floatRandom float 0.0-1.0Random.range(min, max)``min, max: int|float``int|floatRandom number in range
Math utilities ( available as Math).
MethodArgumentsReturnsDescriptionMath.abs, Math.ceil, Math.floor``number``numberBasic mathMath.sin, Math.cos, Math.tan``number``numberTrigonometryMath.sqrt, Math.pow(base, exp)``number``numberPowers/square rootMath.log, Math.log10``number``numberLogarithmsMath.max, Math.min(...args)``numbers``numberMin/maxMath.random()-floatRandom 0-1Math.lerp(start, end, t)``numbers``numberLinear interpolationMath.clamp(value, min, max)``numbers``numberClamp valueMath.round, Math.sign``number``numberRounding/sign
Property/MethodArgumentsReturnsDescriptionatom.name-stringAtom nameatom.type-stringAtom typeatom.on-booleanIs atom onatom.getStorableIds()-Array<string>Get storable IDsatom.getStorable(name)``name: string``StorableReferenceGet storableatom.getController(name)``name: string``ControllerReferenceGet controlleratom.distance(other)``other: AtomReference``floatDistance to another atom
Property/MethodArgumentsReturnsDescriptiontransform.position-Vector3Positiontransform.rotation-QuaternionRotationtransform.forward-Vector3Forward directiontransform.up-Vector3Up directiontransform.right-Vector3Right directiontransform.lookAt(target)``target: TransformReference``voidRotate to face targettransform.lookAt(x, y, z)``coords: Vector3``voidRotate to face position
Property/MethodArgumentsReturnsDescriptionstorable.getId()-stringGet storable IDstorable.getType()-stringGet storable typestorable.getAudioAction(name)``name: string``AudioActionReferenceGet audio action
Property/MethodArgumentsReturnsDescriptioncontroller.name-stringController namecontroller.transform-TransformReferenceController transform
Property/MethodArgumentsReturnsDescriptionaudioAction.play(clip)``clip: NamedAudioClipReference``voidPlay audio clipaudioAction.stop()-voidStop audio
Property/MethodArgumentsReturnsDescriptionclip.name-stringClip nameclip.clip-AudioClipUnity audio clip
javascript
import { scripter, scene } from "vam-scripter";
const ball = scene.getAtom("Ball");
const person = scene.getAtom("Person");
scripter.onUpdate(() => {
// Run every frame
});
javascript
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);
}
});
javascript
import { keybindings, scripter } from "vam-scripter";
const action = scripter.declareAction("MyAction", () => {
// Handle action
});
keybindings.declareCommand("MyActionKey", () => {
keybindings.invokeCommand("MyAction");
});
javascript
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
}
});
javascript
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));
});
javascript
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
index.jsimport { ... } from "vam-scripter" to access modules// for single-line comments and /* */ for multi-lineSKILL.md - This documentationscripts/ - Sample scripts and patternsreferences/ - API reference details