RitnLib

by Ritn

Function library for Ritn Mod.

Internal
15 days ago
0.17 - 2.1
125K

Changelog

Version: 0.10.7
Date: 06.10.2026
  Features:
    - RitnProtoTech: added setUnit(unit) to replace the whole research cost and remove research_trigger
      (turns a Factorio 2.x trigger technology back into a science pack technology).
    - RitnProtoTech: added setTrigger(trigger) to replace the research trigger and remove unit (turns a
      science pack technology into a trigger technology).
    - RitnProtoTech: added getUnlockMode() ("unit", "trigger" or nil), isUnit() and isTrigger().
    - RitnProtoTech: added getTrigger(), setTriggerTarget(target) (item, fluid, entity or entities
      depending on the trigger type) and setTriggerCount(count) (count or amount) for trigger technologies.
  Changes:
    - RitnProtoTech: addPack(), replacePack(), addPackLab() and removePackLab() accept a science pack
      defined as "tool" or "item" (Factorio 2.1 vanilla science packs are plain items).
  Bugfixes:
    - RitnProtoTech: setTime(), setIngredients(), removePack(), replacePack() and multipliedPack() no
      longer crash on a technology without "unit" (research trigger): they are now no-op, like setCount()
      and addPack().
    - RitnProtoRecipe: setEnabled() did nothing on a recipe without an "enabled" key (default true, most
      vanilla Factorio 2.x recipes); the key is now always written.
  Info:
    - Documentation: RitnProtoTech reference (FR + EN) updated with the unlock mode and research trigger
      methods.
Version: 0.10.6
Date: 01.10.2026
  Features:
    - RitnPrototype: added getIconLayers(scale, shift), inherited by every RitnProto* class. Returns a
      copy of the prototype's icon layers whether it uses icon or icons; optional scale/shift are
      applied to every layer (overlays). Returns an empty table if the prototype does not exist.
    - RitnLibSetting: added static getStartup(name), returns the value of a startup setting or nil if
      it does not exist (data and control stages).
    - table-functions: added normalizePosition(value) ({x, y} or {x =, y =} -> {x =, y =}) and
      offsetPosition(position, offset).
    - RitnProtoTech: added addEffect(effect) to append any modifier (ammo-damage, gun-speed,
      turret-attack...) to a technology.
    - RitnProtoTech: added setPrerequisites(prerequisites) to replace the whole prerequisite list
      (unknown technologies are ignored).
  Changes:
    - RitnProtoTech:setCount() now removes unit.count_formula and is a no-op on a technology without
      "unit" (research trigger).
Version: 0.10.5
Date: 01.10.2026
  Features:
    - Added RitnProtoTile (classes/prototypes/Tile.lua, ritnlib.defines.class.prototype.tile) with
      setBlueprintable(value) to set can_be_part_of_blueprint.
    - RitnProtoRecipe: added setCategories(categories) and addCategory(category) for the Factorio 2.1
      RecipePrototype::categories property (replaces the removed category / additional_categories).
    - RitnProtoRecipe: added addResult(), removeResult(), setResult() to manage recipe results.
    - RitnProtoRecipe: added replaceIngredient(old_name, new_ingredient). With a string, the old amount
      is kept and the type is detected from the new name.
    - RitnProtoRecipe: added setProductivity(value) to set allow_productivity (replaces the module
      limitation lists removed in Factorio 2.0).
    - RitnProtoItem: added setFuelEmissionsMultiplier(value) (no-op if the item is not a fuel).
    - RitnPrototype: added getEquipmentType() (uses the new lualib/vanilla/types_equipment.lua list).
    - RitnProtoOre.active(): new optional 4th parameter "planets" (default {"nauvis"}): the ore is now
      added to the map_gen_settings of those planets, otherwise it never spawned in Factorio 2.x.
  Changes:
    - Updated lualib/vanilla/types_item.lua: added space-platform-starter-pack, removed mining-tool,
      "tool" moved up the list.
    - Updated lualib/vanilla/types_entity.lua to the Factorio 2.x entity types.
    - RitnIngredient: uses independent_probability (Factorio 2.1, renamed from probability). The legacy
      "probability" key is still accepted as input, only independent_probability is written.
    - RitnIngredient: every other field of an entry (temperature, ignored_by_productivity,
      extra_count_fraction, percent_spoiled...) is now kept by add/addNew/set. When two entries are
      combined, the extra fields come from the entry already present in the recipe.
    - util.product_amount(): aligned with the Factorio 2.1 core util (independent_probability,
      shared_probability, extra_count_fraction).
    - RitnProtoRecipe:disable() hides the result item with hidden = true instead of flags = {"hidden"}.
  Bugfixes:
    - Fixed RitnPrototype:getItemType() / getEntityType() crashing when an item/entity type of the list
      has no prototype in data.raw (e.g. item-with-label in Factorio 2.1).
    - Fixed RitnProtoOre:remove() leaving the ore in the planets' map_gen_settings, which crashed the
      game at planet setup ("<ore> is not a valid autoplace control name").
    - Fixed RitnProtoOre.active() with bStandard = true calling a string: the local resource() helper
      was shadowed by the "resource" parameter (helper renamed make_resource()).
    - Fixed RitnIngredient getItem() reading ingredient.inputs.probability (undefined sub-table).
    - Fixed RitnIngredient getItem() crashing on an item entry defined with amount_min/amount_max only.
    - Fixed util.product_amount() crashing when a product has no probability.
    - Fixed lualib/vanilla/ores.lua crude-oil result using the removed "probability" key.
    - RitnProtoTech:addPack() no longer errors on a technology without a "unit" (research trigger).
  Info:
    - Documentation: new reference page RitnProtoTile (FR + EN), added to the navigation, the index,
      the class map, the architecture layers and the ritnlib.defines registry page.
    - Documentation: RitnProtoRecipe reference updated: setCategories, addCategory, replaceIngredient,
      addResult, removeResult, setResult, setProductivity; disable() now sets hidden = true on the item;
      setHidden() "stats" parameter flagged as inert (hide_from_player_stats is not a valid key).
    - Documentation: RitnProtoItem (setFuelEmissionsMultiplier), RitnPrototype (getEquipmentType,
      missing data.raw types skipped), RitnProtoOre (active() "planets" parameter, remove() also
      cleans the planets' map_gen_settings) and RitnIngredient (independent_probability, extra fields
      kept) reference pages updated.
    - Documentation: vanilla util / types reference pages updated (product_amount 2.1, new types_item
      list, types_equipment). RitnLibRecipe:getProperties() example uses "categories" (the "category"
      read was removed in Factorio 2.1).
    - Documentation: known bugs and Factorio 2.1 migration pages updated: the probability /
      independent_probability items are now marked as fixed.
    - Documentation: filled the 1.x API leftovers debt page (icon_mipmaps, hr_version,
      hide_from_player_stats, hardness, LuaStyle.visible). Renamed api-1.x-residuelle.md (FR) /
      api-1.x-leftover.md (EN) to api-1.x-leftover.md / api-1.x-leftover.en.md (suffix convention).
    - Documentation: new bilingual page migration-2.1.
    - Documentation: fixed 72 in-page anchor links that never matched on the MkDocs site (GitHub-style
      double-dash slugs) and the broken RitnLibSetting link in the settings-builder guide.
Version: 0.10.4
Date: 12.09.2026
  Bugfixes:
    - RitnLibEntity:setMinable() no longer errors on Factorio 2.1: LuaEntity::minable became
      read-only in 2.1.7, the write now targets LuaEntity::minable_flag.
Version: 0.10.3
Date: 12.09.2026
  Changes:
    - Updated to Factorio 2.1: factorio_version bumped from 2.0 to 2.1.
Version: 0.10.2
Date: 02.07.2026
  Info:
    - Documentation: written all 7 task-oriented guides in FR and EN (installation,
      first-prototype, first-handler, gui-pattern, inventory-snapshot,
      settings-builder, remote-interfaces).
    - Documentation: corrected life-cycle concept (settings stage runs before data
      stage; "runtime stage" replaces "control stage" throughout).
    - Documentation: corrected remote-contract concept and gui-pattern guide to
      match the real RitnLibGui extension contract: self.gui[1] is the container
      (not the root frame), gui_action is a table, remote interface signature is
      function(action, event).
    - Documentation: unified guide file names to English base names
      (first-prototype.md, first-handler.md).
Version: 0.10.1
Date: 21.06.2026
  Bugfixes:
    - Fixed minor code errors RitnSetting type constants.
Version: 0.10.0
Date: 14.06.2026
  Info:
    - Documentation: restructured docs/ for MkDocs i18n plugin (suffix strategy, FR default + EN alternate). Added GitHub Pages workflow (.github/workflows/docs.yml) with mkdocs-material + mkdocs-static-i18n. All 100+ docs files migrated from docs/fr/ + docs/en/ to docs/**/*.md + docs/**/*.en.md. Fixed all internal links. Added stubs for planned guides, concepts, ADRs, and debt pages.
    - Updated README: documentation links now point to https://ritndev.github.io/RitnLib/
Version: 0.9.14
Date: 14.06.2026
  Info:
    - Documentation: added bilingual (EN/FR) reference pages for all utility modules: lualib (json, string, table, other, entity, gui, LuaStyle functions), core layer (class-factory, constants, event-listener, interfaces), ritnlib.defines registry, vanilla helpers (util, crash-site, ores, types), and a beta stub for RitnLibInformatron.
Version: 0.9.13
Date: 14.06.2026
  Info:
    - Documentation: added the full bilingual (EN/FR) Tier 1 class reference (~27 classes), styled like the Factorio runtime API docs (attributes, methods, parameters, return values, real usage examples from consumer mods). Covers the runtime wrappers (Event, Player, Surface, Force, Recipe, Technology, Entity, Gui, Inventory), the GUI builders (GuiElement, Style), the data-stage prototype manipulators (RitnPrototype base, RitnIngredient and every RitnProto* class), and a work-in-progress stub for RitnLibSetting.
    - Fixed dead links in the documentation index (RitnProtoTechnology -> RitnProtoTech).
Version: 0.9.12
Date: 14.06.2026
  Info:
    - Documentation: added bilingual (EN/FR) class : RitnLibEvent, RitnLibForce, RitnLibGui and RitnLibPlayer.
  Scripting:
    - Delete: saveLogistic() and loadLogistic() on RitnInventory class.
Version: 0.9.11
Date: 14.06.2026
  Info:
    - Documentation: added bilingual (EN/FR) class reference map (reference/overview), known-bugs and Factorio 2.0 migration debt pages, and the first ADR (0001 - in-house class factory).
  Scripting:
    - LuaLS annotations: corrected false "broken/P0" notes carried over from the audit, verified against the consumer mods (comments only, no behaviour change). RitnLibGui methods are documented as an extension contract; RitnLibForce getStats* reframed as the 1.x statistics API pending the 2.0 migration; dropped the wrong "removed in 2.0" note on LuaForce.items_launched/rockets_launched (still present in 2.0); RitnLibEvent created_entity flagged as a 1.x residue (on_trigger_created_entity).
Version: 0.9.10
Date: 12.06.2026
  Scripting:
    - Added LuaLS (EmmyLua) annotations to every class and module: typed fields, params, returns and call signatures, with bilingual EN/FR descriptions shown in IDE tooltips.
    - Added types/ritnlib-globals.lua meta file (shipped in the mod zip). Consumer mod developers can add the RitnLib/types folder to their .luarc.json workspace.library to get full autocomplete on RitnLib globals (RitnLibPlayer, RitnLibEvent, ...).
  Bugfixes:
    - Fixed minor code errors found during the annotation pass (RitnIngredient.getItem, RitnSetting type constants).
  Info:
    - Added .luarc.json (LuaLS workspace config, dev only - excluded from the mod zip).
    - Updated .gitattributes: dev-only files excluded from releases; types/ folder now shipped.
Version: 0.9.9
Date: 11.06.2026
  Info:
    - Added : /docs
    - Initial documentation files added: architecture, index, getting-started, concepts...
  Changes:
    - Updated README.md
Version: 0.9.8
Date: 09.06.2026
  Changes:
    - Updated release workflow (GitHub Actions: tag-driven publish to Factorio Mod Portal).
Version: 0.9.7
  Changes:
    - Renamed player/surface getters to get_player() and get_surface() on RitnLibEvent.
Version: 0.9.6
  Features:
    - Added self.isPresent property on all wrapper classes (e.g. RitnSurface, RitnPlayer, RitnForce, RitnEntity, RitnRecipe, RitnTechnology). Lets consumers test wrapper validity without nil-checking every field.