[0.12.15] Cannot index game.force on script.on_load

Bugs that are actually features.
Post Reply
User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5152
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

[0.12.15] Cannot index game.force on script.on_load

Post by Klonan »

As title
Screenshot
im not sure if its a bug or something deliberate, but this worked no problem in 0.12.0-0.12.10

User avatar
Adil
Filter Inserter
Filter Inserter
Posts: 945
Joined: Fri Aug 15, 2014 8:36 pm
Contact:

Re: [0.12.15] Cannot index game.force on script.on_load

Post by Adil »

Well, remember the release notes
FactorioBot wrote: The callback registered in on_load function doesn't have access to the game API.
It's that.
You can only now work with your mod data during the event. Event if there are references to game objects in that your data, I believe you cannot use their api anyway.
I do mods. Modding wiki is friend, it teaches how to mod. Api docs is friend too...
I also update mods, some of them even work.
Recently I did a mod tutorial.

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5152
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: [0.12.15] Cannot index game.force on script.on_load

Post by Klonan »

Adil wrote:Well, remember the release notes
FactorioBot wrote: The callback registered in on_load function doesn't have access to the game API.
It's that.
You can only now work with your mod data during the event. Event if there are references to game objects in that your data, I believe you cannot use their api anyway.
Ahh right, I must've glossed over that one, thanks for pointing it out

kovarex
Factorio Staff
Factorio Staff
Posts: 8078
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: [0.12.15] Cannot index game.force on script.on_load

Post by kovarex »

Klonan wrote:
Adil wrote:Well, remember the release notes
FactorioBot wrote: The callback registered in on_load function doesn't have access to the game API.
It's that.
You can only now work with your mod data during the event. Event if there are references to game objects in that your data, I believe you cannot use their api anyway.
Ahh right, I must've glossed over that one, thanks for pointing it out
By using the on_init and on_configuration_changed (https://forums.factorio.com/wiki/inde ... on_changed), you should be able to do all you need.

on_init is for starting the game, on_configuration_changed is for updating when your mod is added, or some mod version changed (including your mod).

Post Reply

Return to “Not a bug”