@gwigz/slua

Documentation

Push SLua in-world through the Second Life viewer's external editor connection

Work in progress

This package is new and the viewer's external editing protocol is still changing. Expect rough edges, and pin the version once a deploy depends on it.

The Second Life viewer ships a JSON-RPC 2.0 WebSocket server on localhost:9020 for external script editing. @gwigz/slua-viewer-client is a typed client for that protocol, plus a CLI so a build can deploy itself:

bun run build && bunx @gwigz/slua-viewer-client push dist/main.slua

Compile errors come back with the file and line of your TypeScript source, as long as a source map sits beside the pushed file, and a failed compile exits non-zero, so a broken build fails your deploy script instead of shipping.

Requirements

A viewer with external script editing enabled (ExternalWebsocketSyncEnable). The object you are targeting must be published to the editor first, which is a button in the viewer rather than a side effect of selecting it, see Publishing an object.

Quick start

npx @gwigz/slua-viewer-client objects

Pair the object with a name once. Run this first, then press "Explore in IDE" under Content in the object's Build window, which is what publishes it:

bunx @gwigz/slua-viewer-client link main --wait

That stamps a slua:main key into the object's description and records the target in slua.json, so later deploys find the object again even after it has been taken and rezzed. See Targets.

Working on a script

Deploying a script and working on one want different things. Runtime output reaches whatever connections are open the moment a script speaks and nothing else, and most of what a script says follows a touch or a timer rather than anything you typed. connect holds one connection open the whole time you are working, rebuilds, pushes when the output changes, and prints what your scripts say as you poke at them:

bunx @gwigz/slua-viewer-client connect --exec "bun run build:watch"

Scaffolded projects wire that up as bun run dev. See connect.

As part of a build

Add it as a devDependency and pin it. Package scripts have node_modules/.bin on PATH, so slua-viewer is callable by name there:

npm install --save-dev @gwigz/slua-viewer-client
package.json
{
  "scripts": {
    "deploy": "bun run build && slua-viewer push --all",
  },
}

LSL support

push, pull, reset, set-running and logs all work on LSL scripts, so a project that mixes hand-written LSL with compiled SLua needs no special handling. It is not an LSL toolchain though. No preprocessor, no #include expansion, no linting. It deploys LSL, it does not build it.

On this page