Skip to content

Class map

This page lists every public RitnLib class, with for each one: its source file, access mode, inheritance and a short description. To understand how these classes stack up, see The 4-layer architecture.

How to access a class

Two access modes depending on the family:

Family Access mode Example
Runtime classes (RitnLib*) Globals — injected into _G by core/setup-classes.lua, no require local rPlayer = RitnLibPlayer(player)
Data / settings classes (RitnProto*, RitnIngredient, RitnLibSetting) require through the ritnlib.defines registry local Recipe = require(ritnlib.defines.class.prototype.recipe)
-- at the top of a data-stage file:
require("__RitnLib__.defines")          -- creates the ritnlib global (idempotent)
local Recipe = require(ritnlib.defines.class.prototype.recipe)

⚠ Runtime classes produce temporary wrappers: never store them in storage. See the golden rule.

Inheritance tree

RitnPrototype ──► every RitnProto* (except RitnProtoRecipeCategory, no inheritance)

RitnLibPlayer ──► RitnLibGui ──► RitnLibInformatron

Every class is built by the in-house factory ritnlib.classFactory (core/class.lua).

Runtime classes (control stage) — globals

Class File Wraps Description
RitnLibEvent classes/LuaClass/RitnEvent.lua any event Normalizes an event payload into ready-to-use fields (player, surface, force, entity, recipe…).
RitnLibPlayer classes/LuaClass/RitnPlayer.lua LuaPlayer Fast access to player info: force, surface, character, driving, admin status.
RitnLibSurface classes/LuaClass/RitnSurface.lua LuaSurface Entity search on a surface.
RitnLibForce classes/LuaClass/RitnForce.lua LuaForce A force's recipes, technologies, statistics and rocket launches.
RitnLibEntity classes/LuaClass/RitnEntity.lua LuaEntity Entity manipulation: vehicle driver/passenger, destruction.
RitnLibRecipe classes/LuaClass/RitnRecipe.lua LuaRecipe Enable/disable a recipe at runtime.
RitnLibTechnology classes/LuaClass/RitnTechnology.lua LuaTechnology Research-finished hook for a technology.
RitnLibGui classes/LuaClass/RitnGui.lua GUI event GUI event dispatcher by element-naming convention. Inherits from RitnLibPlayer.
RitnLibInformatron classes/RitnClass/RitnInformatron.lua Informatron event Informatron page integration. Inherits from RitnLibGui. Marked -- beta in defines.lua.
RitnLibInventory classes/RitnClass/RitnInventory.lua LuaPlayer + supplied table Player inventory snapshot & restore (the consumer mod supplies the storage table).
RitnLibGuiElement classes/RitnClass/gui/RitnGuiElement.lua add{...} payload Fluent builder for a LuaGuiElement creation payload.
RitnLibStyle classes/RitnClass/gui/RitnStyle.lua LuaStyle Style presets: stretch, alignment, visibility, colors.

These classes are also reachable via require (keys ritnlib.defines.class.luaClass.*, ritnClass.*, gui.*), but that is the internal loading path — in practice you use the globals.

Data classes (data stage) — via require

defines key = prefix with ritnlib.defines.class. in the require.

Class defines key Manipulates Description
RitnPrototype ritnClass.prototype data.raw[type][name] Base class of all manipulators: prototype copy + generic mutators (:changePrototype, :setPrototype, :update…).
RitnProtoEntity prototype.entity data.raw[<entity-type>] Entities, auto-detected type.
RitnProtoItem prototype.item data.raw[<item-type>] Items, auto-detected type.
RitnProtoRecipe prototype.recipe data.raw.recipe Recipes: ingredients, results, activation.
RitnProtoTech prototype.tech (alias technology) data.raw.technology Technologies: costs, science packs, prerequisites, recipe unlocks, cascade disable.
RitnProtoOre prototype.ore data.raw.resource + autoplace Ores and their autoplace control.
RitnProtoSprite prototype.sprite data.raw.sprite + utility-sprites Sprites.
RitnProtoStyle prototype.style data.raw["gui-style"].default Prototyped GUI styles.
RitnProtoItemGroup prototype.group data.raw["item-group"] Item groups (crafting tabs).
RitnProtoItemSubgroup prototype.subgroup data.raw["item-subgroup"] Item subgroups (crafting rows).
RitnProtoRecipeCategory prototype.category data.raw["recipe-category"] Recipe categories. ⚠ Declared without inheriting RitnPrototype: generic mutators are not available.
RitnProtoFuelCategory prototype.fuelCategory data.raw["fuel-category"] Fuel categories.
RitnProtoCustomInput prototype.customInput data.raw["custom-input"] Custom keyboard shortcuts.
RitnProtoUtilityConst prototype.utility.constants data.raw["utility-constants"].default Engine UI constants.
RitnIngredient ritnClass.ingredient ingredient table Recipe-ingredient normalization.

Note: the actual class name is RitnProtoTech (not RitnProtoTechnology) — that is what appears in object_name and in the LuaLS annotations.

Settings stage — via require

Class defines key Description
RitnLibSetting ritnClass.setting Fluent builder for a mod-setting prototype, registered via data:extend. ⚠ As it stands, only bool settings work (see known bugs).

Utility libraries (lualib/) — via require

Not classes, but function modules. Direct keys in ritnlib.defines:

Module defines key Description
other-functions other Custom type() (recognizes LuaPlayer, LuaEntity…), ifElse, tryCatch, uuid, freeplay helpers.
table-functions table Enriched table wrappers.
string-functions string Enriched string wrappers.
json-functions json JSON encode/decode — embeds rxi/json.lua (MIT).
entity-functions (direct require) Entity-prototype helpers.
gui-functions (direct require) GUI-prototype helpers.
LuaStyle-functions (direct require) ⚠ Deprecated — superseded by RitnLibStyle.

Foundation layer (core/)

File Description
core/class.lua The ritnlib.classFactory.newclass(super, init) factory that builds every class above. See ADR-0001.
core/constants.lua Science-pack tints, UI colors, string markers, enemy sizes.
core/eventListener.lua ⚠ Fork of event_handler, experimental status — not wired in by control.lua.
core/interfaces.lua remote.add_interface("RitnLib", {}) — empty interface today, reserved.

See also