SANDBOX — this is a test environment. No servers are actually deployed and no real payments are charged.
Back to NxLabs

NxLabs / Factorio

Module category defaults

TBy thremtopod

Makes vanilla module categories the default allowed_module_categories for entity prototypes.

Description

foundrygg.com Discord Downloads) GitLab Bugs GitLab Critical Gitlab Pipeline Status

Module Category Defaults

This library mod sets the vanilla module categories as allowed_module_categories for all applicable entity prototypes that do not have that field already set by another mod. This allows blacklisting special modules when a mod needs to define its own rules for including them.

In effect, this mod inverts the engine's behavior for modded module categories: instead of being allowed for all entities by default, all modded module categories will be _disallowed for all entities by default_. Modded module categories can be added to this mod's list of default categories, which will cause them to be treated as if they were vanilla categories (i.e. enabled by default). The same can also be done for recipes; this is not done automatically, but only if another mod requires it.

Mod Support

In the data stage, the global table ModuleCategoryDefaults is made available. Most importantly, it contains a table default_categories that will be used to apply the defaults. Add or remove values to change the outcome of this mod. You probably want to add your custom category that you want to be available to all regular machines. ModuleCategoryDefaults also has a few additional tables and functions, which are explained in the examples.

This mod makes all its changes in data-final-fixes. Default categories should be added in your mod's data or data-updates. Any logic that depends on allowed_module_categories being set should be in your mod's data-final-fixes, and may require an additional step for compatibility safety (explained in the examples).

Example: My mod adds a module category for all buildings to use.

  1. Add module-category-defaults as a dependency to your mod.
  2. Add your module category to the defaults table: table.insert(ModuleCategoryDefaults.default_categories, 'my-module-category').

Done. The module(s) will be available the same as without this mod. This must be done in either data or data-updates.

Example: My mod adds a special module for a special building.

  1. Add module-category-defaults as a dependency to your mod.
  2. Add your special module category to the allowed_module_categories table for each of the special buildings, as you would normally do.

Done. No other buildings will be able to use the module. You do not need to touch ModuleCategoryDefaults or the allowed_module_categories table of any other entity prototypes. This must be done in either data or data-updates.

Example: My mod adds a special module that should be used in _no_ buildings.

  1. Add module-category-defaults as a dependency to your mod.
  2. Add your module category to the restricted categories table: table.insert(ModuleCategoryDefaults.restricted_categories, 'my-module-category').

Done. No buildings will be able to use the module. This must be done in either data or data-updates.

Exam

Ratings & reviews

No ratings yet

Sign in to leave a rating or comment.