Code: Select all
-- data.lua
require 'control'
Code: Select all
-- control.lua
print(game.local_player)
Code: Select all
__factorio-mod-template__/data.lua:1: __factorio-mod-template__/control.lua:1: attempt to index global 'game' (a nil value)
Code: Select all
-- data.lua
require 'control'
Code: Select all
-- control.lua
print(game.local_player)
Code: Select all
__factorio-mod-template__/data.lua:1: __factorio-mod-template__/control.lua:1: attempt to index global 'game' (a nil value)
Interesting! Thanks. So does any .lua file in the top-level directory of a mod folder get automatically run like that? Or is it just control.lua? And also, what's special about data.lua that causes it to be run at a different time? Is that just what happens to any file called data.lua?Arch666Angel wrote:You are running the control.lua in the data phase, when there is no game/player. Just delete the require 'control' from data.lua, control.lua is loaded automatically when a game loads/initializes.