LUA warnings on older mods
Posted: Mon Jul 06, 2026 1:49 pm
I'm working to update older mods for 2.1, and have found a number of instances of warnings in luacheck like:
mutating non-standard global variable data
accessing undefined variable data
In both cases, the relevant lines look like:
data.raw["cargo-pod"]["cargo-pod"].created_effect = {
...
data:extend({
My understanding of Lua leads me to think that these mods are referencing the global variable "data", and changing the code to directly reference global variables clears the error:
_G.data.raw
...
_G.data.extend
But it feels incorrect to do everything in globals directly. I read https://lua-api.factorio.com/latest/aux ... orage.html and I'm wondering if I could instead shift these mods to use the storage variable instead? Would that be better? What would that look like?
mutating non-standard global variable data
accessing undefined variable data
In both cases, the relevant lines look like:
data.raw["cargo-pod"]["cargo-pod"].created_effect = {
...
data:extend({
My understanding of Lua leads me to think that these mods are referencing the global variable "data", and changing the code to directly reference global variables clears the error:
_G.data.raw
...
_G.data.extend
But it feels incorrect to do everything in globals directly. I read https://lua-api.factorio.com/latest/aux ... orage.html and I'm wondering if I could instead shift these mods to use the storage variable instead? Would that be better? What would that look like?