Kuxynators Final Fixes
This mod is used to fix compatibility issues with mods using there 'data-final-fixes' in an incompatible way.
For this reason, it is also not permitted to reference the mod as a dependency, as this would compromise the intended functionality and purpose, Instead, an API is made available to execute actions after all mods have been initialised.
Disclaimer
This mod does not change any data itself. However, mods using this API may change data.
The authors of these mods are instructed to change data in cases of legitimate interest only.
In case of abuse, mods can be excluded from using this API.
API
code for <pre>data.lua</pre>
require("__Kux-FinalFixes__/register_callback)(stage, your_callback_func, display_name)
stage = "data"|"data-updates"|"data-final-fixes"
display_name = display name for your callback function
more detailed code w/o require
local mod_name = "MyMod"
local interface_name = "Kux-FinalFixes"
-- prepare public interface (the first mod will do this)
_G[interface_name] = _G[interface_name] or {}
_G[interface_name].data_callbacks = _G[interface_name].data_callbacks or {}
_G[interface_name].data_update_callbacks = _G[interface_name].data_update_callbacks or {}
_G[interface_name].data_final_callbacks = _G[interface_name].data_final_callbacks or {}
-- register callbacks
table.insert(_G[interface_name].data_callbacks, {mod_name, function(stage)
print("Initializing data")
end})
table.insert(_G[interface_name].data_update_callbacks, {mod_name, function(stage)
print("Updating data")
end})
table.insert(_G[interface_name].data_final_callbacks, {mod_name, function(stage)
print("Finalizing data")
end})
The data
callback can be used to access all prototypes (e.g. as template) created by other mods (without the need of a dependency) so the next stage (data-update) does not need to be used to create new prototypes.
The data-updates
callback does the same for the data-updates stage.
And the data-final-fixes
callback zu guter letzt is the last change (w7o dependencies) to see changes by other mods.
As with the use of data.lua, data-updates.lua, data-final-fixes.lua, the callbacks should only be used for the purposes that are usual for this stage.
Each author is responsible for how errors are handled in the callback function. This mod will ignore all errors and only add an entry to the log file.
No Dependency License
Copyright (c) 2025 by Kuxynator
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to distribute copies of the Software.
This software may not be added as a dependency for any other mod without explicit authorization
This software must not be altered or redistributed under a different name without explicit permission from the copyright holder.
This software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, and non-infringement. In no event shall the authors or copyright holders be liable for any claim, damages, or other liability, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the software or the use or other dealings in the software.
The Data Stages
1. data.lua
data.lua is the first file loaded in the Data Phase. It is primarily responsible for defining all new prototypes in your mod. Prototypes include entities, items, recipes, tiles, fluids, and more. This file is strictly used for the initial creation of content and does not account for dependencies or modifications from other mods.
Key Characteristics of data.lua:
- This file runs before all other mods.
- It should focus on defining new prototypes (e.g., new machines, items, or recipes).
- Avoid modifying existing prototypes here, as other mods might not have loaded their definitions yet.
2. data-updates.lua
data-updates.lua is executed after all data.lua files from every mod have been loaded. Its purpose is to modify prototypes that were defined in data.lua, whether they originate from the base game or other mods. This step is ideal for adjustments, compatibility changes, or extending existing prototypes.
Key Characteristics of data-updates.lua:
- Runs after all data.lua files of every mod.
- Used to modify existing prototypes, either from the base game or other mods.
- Focus on compatibility changes or extensions, not on creating new prototypes.
3. data-final-fixes.lua
data-final-fixes.lua is the last file executed during the Data Phase. It runs after all data.lua and data-updates.lua files from every mod, allowing for final adjustments to prototypes. This step is critical for resolving conflicts between mods or making adjustments that depend on the final state of all loaded data.
Key Characteristics of data-final-fixes.lua:
- Runs after all other files in the Data Phase.
- Used for resolving mod conflicts or making final adjustments.
- Avoid creating new prototypes here—focus only on adjustments or fixes.
Special cases
generic mods that cannot have dependencies
One of these mods is base
witch creates barreling recipes in data-updates.lua. One of the reason why new protypes SHOULD be creted in data.lua. With base, however, this is only a minor problem because (almost) every mod references base
by default.
With my mod you can workaround the problem using the data callback, so in regular data-updates.lua
, ever other mods knows you prototypes.
I know if more mods use data callback the problem exists again, but at least with far fewer mods and the risk of conflicts is also lower.