-
Notifications
You must be signed in to change notification settings - Fork 0
Registry Facade.md
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.
modlib.Registry.RESOURCES
modlib.Registry.SCENES
modlib.Registry.SCRIPTS
modlib.Registry.SCENE_NODESThese are string constants:
resources
scenes
scripts
scene_nodes
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)modlib.register(registry, id, data)Adds a new entry. Returns false if the id is empty or already registered in that registry.
modlib.override(registry, id, data)Replaces the current entry and stores the previous value so revert() can restore it.
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.
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.
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.
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
}
}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"
)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.
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
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")OrcKit developer wiki for Sir, We Have an Orc Problem Playtest mods. These pages document OrcKit 1.0.0.