0xDocs 0x.limo

Docs / Scripting

Scripting with @x1/script

Partly live

TypeScript scripting with @x1/script — one scripting API for OG worlds, native runtime games and hosted web games, in a sandboxed VM on every 0x host. Creators publish packages into OG Earth today.

Publishing is open

Creators publish TypeScript packages into OG Earth: see Publishing scripts to worlds. @x1/script 0.2.0 and the 0x CLI 0.1.7 (0x script publish) are in the 0x registry. Sign in with 0x login, or use a publish token from Developer › Tokens in CI. What a package can ask for is in Capabilities.

#What it is

@x1/script lets you write game logic in TypeScript once and run it on every 0x host: OG worlds (the Minecraft-stack worlds), games on the native runtime, and hosted web games. The API, its names and its semantics follow the Luau-style scripting model (Players.PlayerAdded, task.wait, DataStore, signals with Connect). Methods that wait for the host return promises.

ts
import { Players, Messaging, task } from "@x1/script";

Players.PlayerAdded.Connect(async (p) => {
  p.SendMessage(`Welcome, ${p.DisplayName}`);
  await task.wait(1);
  await Messaging.PublishAsync("players.joined", { player: p.UserId });
});

#Design, as it stands

  • One API, every host: OG worlds (Paper), games on the 0x engine (sg-runtime), hosted web games, and the links between them.
  • Roblox-style API: Players.PlayerAdded.Connect(...), Chat and World events; DataStore.GetStore(name).UpdateAsync(...); Messaging.PublishAsync / SubscribeAsync across experiences (with grants); Teleport.TeleportAsync(player, destination, data); task.wait / spawn / delay; RunService.Heartbeat. Anything that waits on the host returns a promise.
  • Compiler: x1-script build (pinned) turns each script into one ES module with a source map, so errors point at your .ts lines.
  • Runtime: scripts run in x1script.wasm (QuickJS-ng compiled to WebAssembly). The same module runs on every host: wasmtime in worlds and games, the browser in web games.
  • Capabilities: sensitive calls need a capability the host grants (chat, kick, world, teleport, kv, messaging, items, …). A script can check one with Host.Supports(capability).
  • Sandbox: each script gets its own sandbox: frozen built-ins, no eval or new Function(string), imports from @x1/script only, and per-handler time and step budgets plus a memory cap that try/catch can't escape.
  • Script bus: experiences talk to each other through the 0x script bus. Unmodified Steam games appear on it as events through the Steamworks compatibility bridge.

#Status

  • Live (2026-10-17): OG Earth runs X1Script (wasmtime) as the experience earth on the production script bus. Its first script only publishes events: players.joined, players.left and items.picked.
  • Live (2026-10-23): publishing packages into worlds, reviewed and approved per version, each in its own sandbox: see Publishing scripts to worlds.
  • Live (2026-10-23): @x1/script 0.2.0 (typings, the pinned compiler and x1-script pack/submit/status/withdraw) and @x1/script-runtime 0.2.0 in the 0x registry (https://0x.limo/npm/); 0x script publish in the 0x CLI 0.1.7.
  • Live (2026-10-24): publish tokens for CI at Developer › Tokens.
  • Public: the bus answers GET https://api.0x.limo/v1/scriptbus/info ({"api":0,"universe":"earth"}).
  • Not open yet: direct third-party access to the script bus from your own servers or clients (experience keys and bus grants). Packages reach the bus through their sandbox's messaging and kv capabilities.

Next: Publishing scripts to worlds · Capabilities · Sandboxes.