OasisWManual 한국어
Section 9. Scripting

Scripting overview and the engine API

Scripts are JavaScript files that define your game's rules and movement. Rolling a ball with the keys, raising the score when you collect a star, ending the game when time runs out: all of this happens in scripts. This page explains where scripts live in OasisW, how they run, and where to find the engine API.

How OasisW scripts work

  • They are assets. A script file is an asset in ASSETS, shared by every scene in the project. If you edit a script in one scene, other scenes that use the script change too (What's per scene and what the project shares).
  • They run only when attached to an entity. A file on its own does nothing. Attach it to an entity's SCRIPT component, and when the game starts, one instance runs for each entity (Create and attach a new script).
  • Attributes expose values. Declare values such as speed or score text as script attributes, and you can change them in the SCRIPT component without opening the code (Define script attributes).
  • AI-written code uses the same format. Scripts that AI GAME BUILDER creates and scripts you create with + → Script share the same skeleton. That means you can read and edit the AI's code yourself (Read and edit AI-generated code).

Script format

An OasisW script creates a script type with ow.createScript('name') and adds functions to its prototype. A new file created with + → Script looks like this (checked on 2026-10-29).

var PlayHit = ow.createScript('playHit');

// initialize code runs once per entity
PlayHit.prototype.initialize = function () {};

// update code is called every frame (dt = seconds since the last frame)
PlayHit.prototype.update = function (dt) {};

// Uncomment swap below to hot-reload this script when you edit code while the game is launched
// In the body, move the state of the old instance (old) to the new instance
// PlayHit.prototype.swap = function (old) {};

swap at the end of the file lets you edit code while the launched game is running and swap in the new code without restarting the game. In a test on 2026-10-30, we kept a game whose script defines swap running in the Launch tab, added postUpdate to that file in the editor, and saved. Without refreshing the game tab, swap was called once and the new postUpdate ran (1 run). When each function is called is covered in Script structure and lifecycle.

Engine classes and constants start with ow, for example ow.Vec3, ow.StandardMaterial, ow.KEY_LEFT. Inside a script, this.entity is the entity the script is attached to, and this.app is the whole game.

Engine API

The OasisW engine API is compatible with the PlayCanvas engine. For the full list of classes, functions and events, see the PlayCanvas Engine API reference. Where the reference says pc., write ow. in OasisW scripts.

This manual doesn't document the whole API separately. Instead, each page includes only code that has been run in OasisW.

What you want to doPage with tested code
Detect collisionsReceive collision events
Change a colorReceive collision events (ow.StandardMaterial)
Play a soundAdd sound
Handle button pressesMake a button
Keyboard and mouse inputKeyboard, mouse, and touch input

Next steps

Source scripting/scripting-overview.html