Registry API - Skirlez/nubbys-forgery GitHub Wiki

Registries

Nubby's Forgery has two registries. A registry holds a connection between mod resources like items, perks, supervisors, etc, and an identifier of some sort.

The identifier, whatever it may be, is referred to as the left. The resource struct is referred to as the right.

But why should I care????????

These data structures allow you to obtain a resource from its string ID and vice-versa, and to obtain a resource from its index and vice-versa.

global.registry

This registry connects resources to string ids. For example, it may hold a connection between an item struct and an ID like "my_cool_mod:my_cool_item"

global.index_registry

This registry connects resources to Nubby indices. For example, it may hold a connection between a perk struct and index 34.

(See more on indices: Gameplay Loading/Indexing)

Due to the nature of Nubby's Indices (the objects that hold the arrays the indices are for don't exist outside of gameplay), this registry will either be empty outside of gameplay or filled with an older run's data.

Resource types

0 - Item

1 - Perk

2 - Supervisor

(This will probably be some enum in the future...)

Functions

mod_registry_get_left(registry, type, right)

Gets the left of a registry by supplying the right.

Example usage: Get a string ID or index of an item by supplying its item struct:

let item = ...
let string_id = mod_registry_get_left(global.registry, 0, item_struct)
let index = mod_registry_get_left(global.index_registry, 0, item_struct)

mod_registry_get_right(registry, type, left)

Gets the right of a registry by supplying the left.

Example usage: Get a perk struct by supplying a string ID:

let perk = mod_registry_get_right(global.registry, 1, "my_cool_mod":"my_cool_perk")

mod_registries_exchange(from, to, type, left)

Gets the left of one registry by supplying the left of another.

Example usage: Get an item index by supplying an item ID:

let index = mod_registries_exchange(global.registry, global.index_registry, 0, "my_cool_mod:my_cool_item")