Skip to content

Scripts ​

Want an object to spin, hop, or flap? The Scripts workspace is where you write that. Start here even for tiny behaviors — that is the point.

This chapter is the User Manual page. The Scripting API splits a high-level track (copy-paste classes, then a complete flyer) and a low-level track, then lists every class.

Scripts live on the project. Ordinary objects, scenes, prefabs, animation, and UI do not need a script to exist — but a script is a perfectly normal way to make them do something.

Two authored surfaces ​

They share one component registry, Save & Apply, last-known-good recovery, and the shipped player.

SurfaceYou writeStart here
OpalScriptclass Foo : Component { … }High-level scripting
Behavior Componentexport default opal.component("Spinner", { … })Behavior Components

OpalScript looks like C#. It is not C# or .NET, and it cannot reach the browser or JavaScript.

First five minutes ​

High-level scripting is a spinner, a hopper, and a coin you tap. Your first component walks the spinner slowly. Flap is the advanced lesson on that track: gravity, one button, scrolling gaps, score, crash.

Built-in Health, Inventory, RigidBody2D, and Motion are there to call. A flap game does not need a Health bar; a combat game should not rebuild HP in a script.

Script Studio ​

Open Scripts in the workspace tabs. New Behavior starts an OpalScript class with empty Start and Update. Typing keeps a local draft; Save & Apply (Cmd/Ctrl+S or Cmd/Ctrl+Enter) commits it. A bad edit does not replace a last-known-good build.

Full layout, commands, docs drawer, and .ops / .opal-script names: Script Studio.

Script safety habits ​

  1. Keep scripts short.
  2. Name inputs and outputs clearly.
  3. Avoid hidden global state.
  4. Prefer component methods for gameplay state changes.
  5. Test in Play after every apply.

Expert track ​

Language, collisions, tasks, unions and maps, events, native APIs, tests, and frame budgets live on the low-level track. Every method is on the class index.

How-tos that keep their URLs: typed gameplay, HUD bindings, direct UI actions, spawning, time groups, gameplay time, Flow tasks, Health commands.