Page 1 of 1
data.lua and control.lua
Posted: Sat Mar 09, 2019 11:51 pm
by sOvr9000
I generated a table in data.lua based on recipes of item prototypes. I want to be able to use that table in control.lua. How do I do that?
Re: data.lua and control.lua
Posted: Sun Mar 10, 2019 12:02 am
by SyncViews
The runtime control script is in a different context. You can access prototypes in the game/LuaGameScript object.
Re: data.lua and control.lua
Posted: Sun Mar 10, 2019 12:27 am
by sOvr9000
Okay, so I'm getting this error:
Code: Select all
control.lua:131: attempt to index global 'game' (a nil value)
I referred to
https://lua-api.factorio.com/latest/ and
https://lua-api.factorio.com/latest/LuaGameScript.html, which led me to believe that referencing "game" in control.lua should work. Why doesn't it?
EDIT: Oops, I missed this: "It is, however, not available inside handlers registered with LuaBootstrap::on_load." Thank you, SyncViews. I know what I can do now.