VIBEGAMES
ALPHA
My ProjectsMy Games
Getting Started

Scripting OverviewAPI Reference
Scripting

Scripting Overview

How scripting works in Vibe Games.

How Scripts Work

Scripts bring your game to life. They run inside the game engine when you press Play and have access to the scene, input, physics, and more through the context object (ctx).

Lifecycle

  1. init(ctx) — Called once when the scene loads. Use it to set up initial state.
  2. update(ctx) — Called every frame. Use it for movement, input handling, and game logic.
  3. onMessage(ctx, message) — Called when another script sends a message to this object.

Context Object

The ctx parameter is your gateway to the engine. Key properties:

PropertyDescription
ctx.entityThe object this script is attached to
ctx.time.deltaTime since last frame (seconds)
ctx.time.elapsedTotal elapsed time (seconds)
ctx.input.keysCurrently pressed keyboard keys
ctx.input.mouseButtonsCurrently pressed mouse buttons
ctx.input.mousePositionCurrent mouse position
ctx.objectsAccess and modify all objects in the scene
ctx.variablesRead and write project-wide variables
ctx.activeSceneIdCurrent scene ID
ctx.activeCameraIdActive camera ID

Communicating Between Scripts

Use ctx.send(type, payload) to send messages to other scripts. Any script with an onMessage handler will receive it.

// Sender
ctx.send("player:hit", { damage: 10 });

// Receiver
export function onMessage(ctx, message) {
  if (message.type === "player:hit") {
    health -= message.payload.damage;
  }
}

Watching for Changes

React to property changes with watchers:

export function init(ctx) {
  ctx.watch(ctx.variables, (vars) => {
    console.log("Variables changed:", vars);
  });

  ctx.watchKey(ctx.variables, "score", (value) => {
    console.log("Score is now:", value);
  });
}

AI Assistant

Using the built-in AI assistant to build games.

API Reference

Complete scripting API reference.

On this page

How Scripts WorkLifecycleContext ObjectCommunicating Between ScriptsWatching for Changes

Vibe Games

© 2026 Vibe Games. All rights reserved.

Quick Links

  • Browse Games
  • Create Game
  • Documentation

Community

  • GitHub

Legal

  • Privacy Policy
  • Terms of Service