data.lua and control.lua

Place to get help with not working mods / modding interface.
Post Reply
sOvr9000
Burner Inserter
Burner Inserter
Posts: 14
Joined: Mon Jun 27, 2016 5:43 am
Contact:

data.lua and control.lua

Post 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?

SyncViews
Filter Inserter
Filter Inserter
Posts: 295
Joined: Thu Apr 21, 2016 3:17 pm
Contact:

Re: data.lua and control.lua

Post by SyncViews »

The runtime control script is in a different context. You can access prototypes in the game/LuaGameScript object.

sOvr9000
Burner Inserter
Burner Inserter
Posts: 14
Joined: Mon Jun 27, 2016 5:43 am
Contact:

Re: data.lua and control.lua

Post 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. :D

Post Reply

Return to “Modding help”