About RitnLib
From Factorio Mod PortalFunction library for Ritn Mod.
RitnLib
> FR — Bibliothèque pour mods Factorio : raccourcis sur data.raw, wrappers sur les classes runtime (LuaPlayer, LuaForce, LuaEntity…), constructeur de GUI, builder de mod settings, snapshot d'inventaires. > > EN — Library for Factorio mods: shortcuts over data.raw, wrappers for the runtime classes (LuaPlayer, LuaForce, LuaEntity…), GUI builder, mod settings builder, inventory snapshot.
🇬🇧 English
RitnLib is a library mod for Factorio 2.0. It doesn't add anything to the game — it serves as a dependency for other mods, shortening the Factorio patterns that come up in every non-trivial mod: mutating data.raw, handling entities, dispatching events, building a GUI, declaring mod settings, snapshotting an inventory…
What it looks like
Without RitnLib, snapshot and restore on respawn:
script.on_event(defines.events.on_player_died, function(event)
storage.snapshots = storage.snapshots or {}
local player = game.get_player(event.player_index)
if not storage.snapshots[player.name] then
storage.snapshots[player.name] = {
[defines.inventory.character_main] = game.create_inventory(65535),
[defines.inventory.character_guns] = game.create_inventory(65535),
[defines.inventory.character_ammo] = game.create_inventory(65535),
[defines.inventory.character_armor] = game.create_inventory(65535),
[defines.inventory.character_trash] = game.create_inventory(65535),
}
end
for define, snapshot in pairs(storage.snapshots[player.name]) do
local inv = player.get_inventory(define)
for i = 1, #inv do
if inv[i].valid then snapshot[i].swap_stack(inv[i]) end
end
end
end)
script.on_event(defines.events.on_player_respawned, function(event)
-- … mirror of the above, the other way around …
end)
With RitnLib:
script.on_event(defines.events.on_player_died, function(event)
storage.snapshots = storage.snapshots or {}
RitnLibInventory(game.get_player(event.player_index), storage.snapshots):save()
end)
script.on_event(defines.events.on_player_respawned, function(event)
RitnLibInventory(game.get_player(event.player_index), storage.snapshots):load()
end)
That's the idea across the whole library: you state what you want to do, RitnLib handles the Factorio plumbing.
What's inside
Data stage — mutating data.raw
RitnProtoRecipe— disable, hide, modify ingredients, retint science packs.RitnProtoTechnology— disable (with prerequisite purge), add/remove/replace science packs, managelab.inputs, unlock/remove recipes.RitnProtoEntity,RitnProtoItem,RitnProtoOre(with autoplace),RitnProtoSprite,RitnProtoStyle.RitnProtoItemGroup,RitnProtoItemSubgroup,RitnProtoRecipeCategory,RitnProtoFuelCategory,RitnProtoCustomInput,RitnProtoUtilityConst.- Ready-to-require fonts
ritn-default-{12..20}(normal + bold) and a set of GUI styles*-ritngui. - Helpers for
data.raw['gui-style'].defaultand a local fork of the engine'sutil.lua.
Control stage — runtime
- Wrappers:
RitnLibPlayer,RitnLibSurface,RitnLibForce,RitnLibEntity,RitnLibRecipe,RitnLibTechnology. RitnLibEvent(event)— normalizes any Factorio event and exposesevent.player,event.surface,event.force,event.entity,event.recipe,event.technology,event.inventory,event.element,event.area,event.position… without having to remember each event's structure.RitnLibInventory— snapshot/restore (main, guns, ammo, armor, trash, cursor) viagame.create_inventory.RitnLibGui+RitnLibGuiElement+RitnLibStyle— chained GUI construction, click dispatcher viaremote.call("<your-mod>", "gui_action_<gui_name>", …).
Settings stage
RitnLibSetting— builder fordata:extend({...})(bool-setting,int-setting,double-setting,string-setting,color-setting; scopestartup/runtime-global/runtime-per-user).
Integrations with other mods
- Ready
remote.calls for thefreeplayscenario:set_created_items,set_respawn_items,set_skip_intro,set_disable_crashsite. remote.call("silo_script", "set_no_victory", …).- Optional
DiscoScience.setIngredientColorhook for custom science packs. - Automatic detection of
gvv(global-state debugger) andzk-lib(optimized event_handler).
Status
Factorio 2.0 migration is in progress. A few methods still carry 1.x branches (recipe normal/expensive, force.items_launched, hr_version on sprites…). Code is being cleaned up version after version — see changelog.txt.
Installation
Subscribe via the in-game Mod Portal, or clone this repository into Factorio/mods/RitnLib/.
Then add "RitnLib" to your own mod's info.json dependencies:
{
"name": "my-mod",
"dependencies": [ "base", "RitnLib" ]
}
Documentation
- 📖 Documentation — guides and class reference (EN · FR)
- 🏗 Internal architecture (FR, maintainer-facing)
- 📜 Changelog
Source / Issues
License
The Lua source code is © 2021-2026 Ritn. Embedded third-party content is licensed individually — notably rxi/json.lua (MIT).
🇫🇷 Français
Highlights
From source dataGame versions
Built for Factorio 2.1.
Footprint
Rated a light load on a server.
License
Published under MIT.
RitnLib on Nxeon
From our catalogue- One-click install
- Supported on Nxeon Factorio servers. We download it from Factorio Mod Portal, place it, and restart the server.
- Server side
- Required on the server
- Server load
- light
- Smallest plan we suggest
- Factorio — 2 GB (2 GB RAM). This follows our own load rating above, not a benchmark.
- Latest build
- 0.10.7, released 2026-10-06
Recent builds
| Build | Released | Game versions | Loaders |
|---|---|---|---|
| 0.10.7 | 2026-10-06 | 2.1 | n/a |
| 0.10.5 | 2026-10-01 | 2.1 | n/a |
| 0.10.4 | 2026-09-12 | 2.1 | n/a |
Run RitnLib on a Factorio server
Pick a server or deploy a new one above; it is installed in one click.
What kind of mod it is
From the catalogLibraries & compatibility
Foundations and fixes other mods build on. Usually installed because something else needs it.
Runs on your server
From source side supportFactorio Mod Portal lists RitnLib as required on the server. Check its Factorio Mod Portal page to see whether players need it too.
Compatibility
- Game
- Factorio
- Runs on
- Serverrequired on the server
- Game versions
- 2.1
Verified at the source
- ✓Factorio Mod PortalOfficial listing, checked 2026-10-09Open ↗
- ✓AuthorRitn, as published on Factorio Mod Portal
- ✓LicenseMITFree
