Scripting
Scripts are the heart of interactivity in OasisW. They are reusable pieces of code that you attach to entities to define behavior, handle user input, manage game logic, and bring life to your project.
Scripting Systems
OasisW supports the following scripting approaches:
- Classic Scripts (
.jsfiles) - 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 to 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 - Script communication