OnlyWorlds is an open standard for world data: a world's characters, places, events and lore as elements of 22 types, linked by id, that any tool can read. This addon brings such a world into your Godot game: written outside the engine, then read at run time over the onlyworlds.com API, or shipped with the game as a folder.
A GDScript addon, with a class for each of the 22 element types. It reads and writes worlds through the API, and on
disk as world folders and .owworld files. It runs on the standard Godot build; no .NET is needed.
The map demo of this repository (demo/world_map.tscn) on a folder of Moppetopia, a public sample world: the
world's Map image, each of its Pins where the world places it, and each Pin's name. The folder itself is not in this
repository; the demo opens on a smaller example world that is.
Godot 4.7, the standard build. Earlier 4.x versions are untested, and so are exports other than Windows desktop (the web and mobile among them).
- Godot's Asset Library: OnlyWorlds SDK, also found from the
editor's AssetLib tab by searching for OnlyWorlds. Download it and install with the installer's defaults ("Ignore
Asset Root" stays ticked), and it lands at
addons/onlyworlds/. The Library carries a release, so it can be a step behind this repository. - The release zip:
onlyworlds-godot-0.17.0.zip, from this repository's Releases page. Unpack it into your project folder: it holdsaddons/onlyworlds/, which joins your project'saddons/folder. - A clone of this repository: copy its
addons/onlyworlds/folder into your project'saddons/folder.
Then open the project in the editor once (or run godot --headless --path . --import), so Godot registers the OW…
classes. Enabling the plugin under Project Settings → Plugins is optional: the classes work without it.
Versions. A patch release fixes and a minor release adds; neither removes nor renames a public name, and the addon keeps to this while it is 0.x. A name that will go is marked deprecated first, saying since which release, what to use instead and the release it leaves in; it stays at least six months after that release and goes only in 1.0. It is the same promise as on the docs' Stability page, and a check in CI holds the public names to it on every change; it reads names, not a call's parameters or what it does. The CHANGELOG lists what each version changed.
This reads Moppetopia, a public sample world, with its demo key. No account needed.
extends Node
func _ready() -> void:
var client := OWClient.new({"api_key": "0000000001"}) # demo key: Moppetopia, read-only
var world := await client.get_world()
if not world.ok:
print(world.error) # no connection, or the server said why
return
print(world.value["name"])
var found := await client.list("character", {"name_contains": "fluffington"})
print(found.value.data[0].name)Attach it to any node and run the scene. The Output panel shows Moppetopia, then Admiral Fluffington.
await client.list_all("character") pages through every character. In this repository the same script is
demo/first_run.tscn.
Without the editor. godot --headless --script runs only a script that extends SceneTree (a Node script is
refused: "doesn't inherit from SceneTree or MainLoop"). The same first run as one:
extends SceneTree
func _init() -> void:
await process_frame # TLS starts with the first frame: an https request before it gets no answer
var client := OWClient.new({"api_key": "0000000001"}) # demo key: Moppetopia, read-only
var world := await client.get_world()
if not world.ok:
print(world.error)
quit(1)
return
print(world.value["name"])
var found := await client.list("character", {"name_contains": "fluffington"})
print(found.value.data[0].name)
quit()From your project's folder, after the import: godot --headless --script res://first_run_headless.gd. It prints
Moppetopia, then Admiral Fluffington. In this repository it is demo/first_run_headless.gd.
Create a world at onlyworlds.com; its keys are on the world's page. A new key is shown once, so copy it then.
ow_r_reads, with no PIN. This is the key to ship in a game.ow_w_reads and writes. Writes also send your PIN, asapi_pin.
var client := OWClient.new({"api_key": world_key, "api_pin": pin}) # ow_w_…, your PIN
var made := await client.create("character", {"name": "The Brine Cartographer", "location": harbour_id})
await client.patch("character", made.value.id, {"description": "Maps the tide lines."})
await client.edit_links("character", made.value.id, "friends", {"add": [friend_id]})A link field takes the linked element's id ("location": harbour_id); a list of links (friends) is changed with
edit_links, which adds or removes ids without touching the others. patch sends only the fields you pass; delete("character", id) removes one. Every call answers a reply with
value on success, else error (an OWApiError that says why). Keep write keys out of games you ship: a key written
in a script, a scene or an exported variable is packed into the export, where anyone with the build can read it, so
read write credentials at runtime.
An AI agent that writes to your world takes a seat of its own instead, an
agent seat: its own key and secret (ow_s_…), for one world,
which the world's owner can remove at any time.
A world on disk, with no server at all. OWWorld.read_folder(path) reads a world folder,
OWWorldArchive.read_file(path) an .owworld file (one zip that holds a folder), and OWWorldExport.read_file(path)
the file a world's page on onlyworlds.com downloads (Export world); each gives the same typed elements (to_world()
on the last two). await OWFolderExport.export(client, path) goes the other way: it reads the world a key reaches
and writes it as a world folder, an offline copy a game can ship, with where it came from in its world.json. A
world you never edited is written back byte for byte. A pack (OWWorldArchive.pack, OWWorld.pack) is
a copy by default: every element file travels whole, hidden ones included, as you would back up or move your own
world. With include_hidden false it is a share, a file to hand to someone else: an element marked hidden is left
out, and so is every file under elements/ the reader could not read as one element; the result names each, hidden
apart from unread (hidden_left_out, unread_left_out). Either way a pack leaves out who wrote each one: the five
author fields (created_by, changed_by, changed_via, changed_client, doors) are left out of every element
file that is one JSON object, since a .owworld is a file handed on. Pass include_author_fields for a byte copy of
your own folder. This repository carries a
small example world, Hyperion, at codegen/schema-dist/example/hyperion; demo/world_map.tscn, the project's main
scene, draws its Map with its Pin.
A player link (https://www.onlyworlds.com/join#ow_j_…, made by a world's owner for one Character) needs no
account. Redeem it once for that player's read key; the server then shows the key only what that Character may see.
var code := OWJoin.parse_link(pasted) # "" when the text holds no code
var joined := await OWJoin.redeem(code) # the code is spent: keep joined.value.key
var client := OWClient.new({"api_key": joined.value.key})OWJoin.preview(code) says who invites, to which world, without spending the code.
Sign in with OnlyWorlds lets a player read their own worlds: the game opens their browser, they press Continue on onlyworlds.com, and the game holds a token that reads their worlds for 30 days. Start it only when the player presses your Sign in button, never on a timer, an error or the game's start. The page on onlyworlds.com cannot tell which game is asking, and tells the player to press Cancel on a sign-in they did not start; a game that opens it unasked teaches players to press Continue anyway.
var r := await OWSignIn.sign_in({"on_listening": func(url): show_address(url)}) # shown in case no browser opens
if r.ok:
var signed: OWSignIn.Result = r.value
save_sign_in(signed.token, signed.token_id, signed.expires_at_unix) # yours to keep: the SDK keeps nothing
var me := OWClient.new({"api_key": signed.token})
var worlds := await me.list_account_worlds() # rows: id, name, role
var reader := OWClient.new({"api_key": signed.token, "world": worlds.value[0].id})
elif r.error.reason == OWSignIn.CANCELLED:
show("Sign-in cancelled. Nothing was shared.")- What it reads: the list of the player's worlds, and in a world it names with
world, the world and its elements. It writes nothing. The roster (members()) answers 403, the rows oflist_account_worlds()carry no keys, and the change feed (OWSync) needs a world key: a signed-in game reads a world and reads it again later. To write, a game still takes a key: an agent seat's invite, or a key and PIN the player gives. - Keep the token as you keep a password, and revoke it on sign-out with
OWClient.new({"api_key": token}).revoke_account_token(token_id), or tokens named "A game" pile up on the player's account page. The SDK writes no file. Keep it out of logs and of anything you export, and never pass aResultor anOWSignIn.Beguntovar_to_str, which prints every member, the token and the PKCE verifier included (str()leaves them out). - When it ends: after 30 days, or when the player disconnects it. Before using a kept token, check
signed.is_expired(int(Time.get_unix_time_from_system())); on any reply,r.error.needs_sign_in()says the token is over. Either way, show the Sign in button again ("Your OnlyWorlds sign-in has ended"); there is no refresh, and the browser opens only on the player's press. What the game already read stays. - How it ends otherwise, by
r.error.reason:cancelled(the player pressed Cancel),timed_out(5 minutes by default,timeout_sec),stopped(your Cancel button:on_startedhands you theOWSignIn.Session, andsession.stop()ends it),no_browser(no browser could be opened and noon_listeningshowed the address; with one,on_browser_failedis called and the sign-in waits for the address opened by hand),rate_limited(retry_afterseconds),offline,invalid_grant, andno_listeneron the web, Android and iOS, where a game cannot take the browser's return this way. A web game signs in through the TypeScript SDK in its page instead. - What it holds to: it listens on 127.0.0.1 only, on a port the system picks, and answers nothing but the
browser's return carrying this sign-in's state; the code is exchanged once. If onlyworlds.com ever answered a token
that is not read-only, the call refuses it (
not_read_only) and asks onlyworlds.com to end it, waiting 10 seconds for that at most; one that does not end then lasts until its own 30 days. Another program on the same computer can make a sign-in fail by answering on the same port first, but it cannot get the token: the code is useless without the secret the game keeps. demo/sign_in.gdwalks a whole sign-in against onlyworlds.com from the command line (dry unless-- --live).
A world kept current. OWWorldCache holds a world in the game, and OWSync keeps it current from the world's
change feed: the first call reads every element, each later one only what changed. The cache keeps itself between
launches in one file.
var client := OWClient.new({"api_key": "ow_r_..."})
var world := OWWorldCache.read_file("user://world.owcache") # empty the first time
var r := await OWSync.incremental(client, world) # the first call walks the whole world, later ones the changes
if r.ok: world.write_file("user://world.owcache")
for c: OWCharacter in world.of_type("character"): print(c.name)await OWSync.has_changes(client, world) asks with one cheap request whether a sync would do anything, so a game can
poll it on a timer.
Links clicked outside the game (Windows). With OWLinkListener, an ow:// link clicked in a browser or a notes
app can reach your game while it runs:
var listener := OWLinkListener.new(47616, func(link: OWAddress.Reading): show_element(link.world, link.type, link.id))
var refusal := listener.start() # "" when listening; "port_taken" when another game or the editor holds the portIt listens on 127.0.0.1 only. It reads one line per connection, at most 4096 bytes, and can do nothing but hand your
callback an OWAddress.Reading, on the main thread at the end of a frame. A line the address profile refuses is
answered with the refusal and goes no further. While the main loop is a SceneTree, the listener polls itself every
frame. Keep a reference to it: once the last reference goes, it stops. A second callback argument gets the link as it
was received. A dispatch that returns false turns a link down for now, and the sender is told nobody took it.
For a click to arrive, Windows needs a handler for ow://. The addon carries one in addons/onlyworlds/ow-link/
(its README), and nothing is registered until you run its installer. These are
yours to do as the game's maker:
- pick the port, and start and stop the listener;
- write the config: the ports to try and the game to start when none answers;
- run
install.ps1on your own machine, or have your installer run it; - when the game was started for a link, read the link from the command line. It arrives as written in the config's
args; with the example's["--ow-link", "{link}"]it is the item after--ow-linkinOS.get_cmdline_args().
Anyone with a program running on the same machine can send the listener a link, as a click can, and a program that takes the port before your game does receives the links meant for it. Treat a link like an address the player typed.
| Part | Classes | What it does |
|---|---|---|
| Client | OWClient, OWJoin, OWSignIn, OWProposal |
The API: a player signed in through their browser to read their own worlds, read a world, list and page through its elements, the change feed, writes (create, upsert, patch, delete, link edits, bulk), proposed changes (propose, the world's queue, accept, decline, withdraw, review a proposed new element), joining by invite link, images (upload one for an element's picture, remove it) and files on elements (attach, list, download, remove). |
| Held world | OWWorldCache, OWSync |
A world held in the game and kept current from the API's change feed: a first walk, then only what changed, with the server's resets, rewinds and deletes applied; kept between launches in one file. |
| Models | OWCharacter, OWLocation, … (all 22), OWElement |
One class per element type, generated from the schema; OWTypes.make(type, body) builds the right one. |
| On disk | OWWorld, OWWorldArchive, OWWorldExport, OWFolderExport, OWJson |
World folders and .owworld files, read and written in the folder format's own bytes; the one-file download from a world's page on onlyworlds.com, read; a world on onlyworlds.com written as a folder. |
| Readers | OWLens, OWGraph, OWLanding, OWMapSpace, OWCharter, OWStrand, OWRecord, OWReport, OWMessage, OWNames, OWViews, OWNameFinder |
Answers worked out from elements you already hold, with no request of their own: what one reader may see of a world, the world as nodes and edges, its most-linked Characters and the most linked of each type, its maps as points and outlines and which of their Pins one reader knows, the rules and the story a world shows first, a Character's record of game runs, in-world messages and reports, how an element is shown, which element names a text mentions. |
| Helpers | OWCalendar, OWAddress, OWLinkListener, OWOpeners, OWTools, OWId, OWUnicode |
A world's own calendar, ow:// links, and links clicked outside the game reaching it while it runs (with a Windows handler to register), an "Open with" menu of OnlyWorlds tools, ids, name comparison. |
Every call, with what it answers and what it refuses: docs/reference.md.
The 22 classes are generated from one pinned release of the
schema distribution, the standard's published form (codegen/PIN;
OWSchemaPin names it at run time), vendored unchanged in codegen/schema-dist/. Each reader gives the same answers
as the TypeScript, Python and Unity SDKs on a shared set of test cases, and every request the client makes is checked
against the API's own description of itself (tests/data/keel-wire.json). The reference opens with the few words of
the standard it uses.
Open this repository as a Godot project. Its main scene is the map demo.
godot --headless --path . --import # once per clone, and after a pull that adds a class
godot --headless --path . --script res://tests/run.gd # the suite: exits 0 only when every test passes
python codegen/generate.py --check # the schema pin holds, the generated files are current
python codegen/generate_tools.py --check # the tools list's pin holds, ow_tools.gd is current
python codegen/generate_layout.py --check # the layout tables and their bits are current
python codegen/generate_layout_3d.py --check
python codegen/generate_frame_bits.py --check
python codegen/test_generate_views.py # generate.py refuses a views.json that breaks a rule
python tools/verify_promise.py --godot godot # the written promise: no public name gone, each one listed
python tools/mutants_promise.py --godot godot # the promise check, watched failing once per rule
godot --path . res://demo/world_map.tscn -- --world=<folder | file.owworld> # the map demo on another worldThe tests need no network and no key: the client's tests run against a fake transport. A few tests read two large
real worlds when their folders are named by OW_SIKELIA and OW_MOPPETOPIA; without them those tests are skipped,
never passed. The .owworld conformance set is the vendored copy, or a draft copy when OW_OWWORLD_FIXTURES names
a folder holding its verdicts.json. A stale class cache shows as Could not find type "OW…" parse errors, and a test file that fails to
parse drops out of the total rather than counting as failed: import again and rerun.
tools/ holds pack.gd and extract.gd (shell tools for .owworld files), check_writer.py (an .owworld file
judged by the fixture set's reference checker, which is not part of this repository: --run-py DIR),
verify_promise.py and mutants_promise.py (below), release_zip.py and prove_zip.py (the release zip made from a tag or a commit into dist/, then unpacked into an
empty project that reads a world through it: python tools/release_zip.py v0.13.1, then
python tools/prove_zip.py dist/onlyworlds-godot-0.13.1.zip --godot <binary>), and two probes.
Deprecating a name. Write ## @deprecated: Since X.Y.Z. Leaves in 1.0. Use Y. in its doc comment, with X.Y.Z the
release that first carries the mark; a deprecated function also calls push_warning() with the same words, since
GDScript does not warn at a call by itself. Then run python tools/verify_promise.py --godot <binary> --write and
commit tools/public-names.json, which lists every public name and its mark as Godot's doctool reads them. CI runs
verify_promise.py on every push and pull request, and python tools/mutants_promise.py --godot <binary> watches the
check fail once for each rule.
The schema lives at OnlyWorlds/OnlyWorlds. Other clients: the TypeScript SDK, the Python SDK, the Unity SDK and the Unreal SDK.
The code is MIT (LICENSE). Issues are welcome: a bug, a wrong word, a thing you could not do in Godot. Pull requests are read; a small fix is usually taken as is, and a change to what the addon does is better opened as an issue first, since it may already be built or ruled out. A pull request runs two checks by itself: the words of its commit messages, and the test suite on Linux. A reply can take a few days. A security problem goes through private vulnerability reporting, not an issue (SECURITY.md). What we ask at the door, and what you can expect: the code of conduct.
Maintained by Quillon, an AI agent working for Titus. Issues and pull requests are read and answered here.
