Skip to content

Registry Facade.md

ESTONlA edited this page May 25, 2026 · 1 revision

Registry Facade

OrcKit includes a generic registry facade. It is useful for mods that want to share data with each other through a common loader-owned table.

Important limitation: this game's project-specific content registration helpers are not implemented yet. The registry is not currently a full native item/weapon/furniture registration system for this game.

Registry Names

modlib.Registry.RESOURCES
modlib.Registry.SCENES
modlib.Registry.SCRIPTS
modlib.Registry.SCENE_NODES

These are string constants:

resources
scenes
scripts
scene_nodes

Basic Register and Read

var modlib = Engine.get_meta("OrcmodLib")

var data := {
	"display_name": "Example Entry",
	"value": 10,
}

modlib.register(modlib.Registry.RESOURCES, "example_mod.entry", data)

var entry = modlib.get_entry(modlib.Registry.RESOURCES, "example_mod.entry")
print(entry)

register

modlib.register(registry, id, data)

Adds a new entry. Returns false if the id is empty or already registered in that registry.

override

modlib.override(registry, id, data)

Replaces the current entry and stores the previous value so revert() can restore it.

patch

modlib.patch(registry, id, {
	"damage": 20,
	"cooldown": 0.5,
})

patch() expects the existing entry to be an Object or Resource because it uses get() and set() on fields.

Array Helpers

modlib.append(registry, id, "tags", ["fire", "rare"])
modlib.prepend(registry, id, "tags", "starter")
modlib.remove_from(registry, id, "tags", "old")

These expect the target field to be an Array.

Remove and Revert

modlib.remove(registry, id)
modlib.revert(registry, id)
modlib.revert(registry, id, ["damage", "cooldown"])

revert() restores overridden entries or patched fields when OrcKit has a saved previous value.

Batch Helpers

modlib.register_many(registry, {
	"example.a": {"value": 1},
	"example.b": {"value": 2},
})

Other batch helpers:

modlib.override_many(registry, entries)
modlib.patch_many(registry, entries)
modlib.append_many(registry, field, entries)
modlib.prepend_many(registry, field, entries)
modlib.remove_from_many(registry, field, entries)
modlib.revert_many(registry, entries)
modlib.remove_many(registry, ids)

Batch helpers return:

{
	"ok": true,
	"results": {
		"id": true
	}
}

Query Helpers

modlib.has(registry, id)
modlib.keys(registry)
modlib.list(registry)
modlib.find(registry, predicate)

Example:

var matches = modlib.find(modlib.Registry.RESOURCES, func(entry):
	return entry is Dictionary and entry.get("category", "") == "example"
)

Unimplemented Game-Specific Helpers

These functions exist, but currently warn that they are not implemented for this game:

modlib.register_item(entries)
modlib.register_furniture(entries)
modlib.register_weapon(entries)
modlib.register_magazine(entries)
modlib.register_attachment(entries)
modlib.register_ai_loadout(entries)

Use hooks, autoloads, script overrides, or explicit resource replacement for real game integration.

When to Use the Registry

Good uses:

  • sharing compatibility flags between mods
  • exposing optional data for other mods
  • keeping a mod-owned lookup table
  • allowing other mods to patch your data through a known API

Avoid using it as:

  • a magic content registration layer
  • a substitute for understanding the game's resource structure
  • a replacement for explicit compatibility patches

Compatibility Pattern

Mod A:

modlib.register(modlib.Registry.RESOURCES, "mod_a.api", {
	"version": "1.0.0",
	"supports_extra_maps": true,
})

Mod B:

var api = modlib.get_entry(modlib.Registry.RESOURCES, "mod_a.api")
if api is Dictionary and api.get("supports_extra_maps", false):
	print("Enable Mod A compatibility")

Clone this wiki locally