Scripting
Scripts are the heart of interactivity in OasisW. They're reusable pieces of code that you attach to Entities to define behaviors, handle user input, manage game logic, and bring your projects to life.
Scripting Systems
OasisW supports scripting approaches:
- Classic Scripts (
.js
files) - The original OasisW scripting system using prototype-based syntax.
Quick Example
Here's a simple script that rotates an entity:
- Classic
var Rotate = pc.createScript('rotate');
Rotate.attributes.add('speed', { type: 'number', default: 10 });
Rotate.prototype.update = function(dt) {
this.entity.rotate(0, this.speed * dt, 0);
};
What You'll Learn
Fundamentals
Core concepts that apply to all OasisW scripts:
- Getting Started - Basic script structure and syntax
- Script Lifecycle - When and how script methods are called
- Script Attributes - Exposing configurable properties
- Calling the Engine API - Key classes and patterns
- Events - Communication between scripts