What's allowed/disallowed during migration?

Place to get help with not working mods / modding interface.
Post Reply
apriori
Filter Inserter
Filter Inserter
Posts: 259
Joined: Thu Feb 18, 2016 8:13 pm
Contact:

What's allowed/disallowed during migration?

Post by apriori »

What cannot be accessed through migration lua-scripts? Are "global" and "game" available? Are entities valid? Are entities (including hidden ones) without prototypes still accessible?
Any code or mods posted by me are WTFPL, unless otherwise copyrights are specified.

Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: What's allowed/disallowed during migration?

Post by Nexela »

migration/migrations.json -> Used to replace 1 prototype with another

migration/migrations.lua -> Full access to game NO access to global

on_configuration_change -> access to everything

on_load -> special case, No game, Read only global

on_init -> full access to everything

apriori
Filter Inserter
Filter Inserter
Posts: 259
Joined: Thu Feb 18, 2016 8:13 pm
Contact:

Re: What's allowed/disallowed during migration?

Post by apriori »

Nexela wrote:on_configuration_change -> access to everything
Looks like not to everything, or I'm wrong in my code:

Code: Select all

script.on_configuration_changed(Migrate())

function Migrate() 
  local version = game.active_mods["Teleportation"] -- attempt to index global 'game' (a nil value)
end
Any code or mods posted by me are WTFPL, unless otherwise copyrights are specified.

Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: What's allowed/disallowed during migration?

Post by Nexela »

2 Problems

script.on_configuration_changed(Migrate) --Remove the () your want to refrence the function not call it

Second, move the migrate function ABOVE the script.on_configuration_changed

Post Reply

Return to “Modding help”