Mod changes in 0.13

Place to post guides, observations, things related to modding that are not mods themselves.
User avatar
DedlySpyder
Filter Inserter
Filter Inserter
Posts: 253
Joined: Fri Jun 20, 2014 11:42 am
Contact:

Re: Mod changes in 0.13

Post by DedlySpyder »

Adil wrote:I can't comprehend these:
Rseding91 wrote: - Changed game.players, game.surfaces, game.entity_prototypes, game.item_prototypes, game.fluid_prototypes, force.recipes, force,technologies
to use custom access + iterator objects for improved performance.
Weren't game.entity_prototypes and such already indexable by []?
They were indexed by a number (so [1], etc), but now, from what I understand, they are indexed by something else (so ["name-or-something"]).

sparr
Smart Inserter
Smart Inserter
Posts: 1426
Joined: Fri Feb 14, 2014 5:52 pm
Contact:

Re: Mod changes in 0.13

Post by sparr »

Adil wrote:Weren't game.entity_prototypes and such already indexable by []?
Previously, when you asked for game.entity_prototypes["foo"], the API would produce the entire entity_prototypes table for you to index, which is a huge waste of time and memory if you just want one index from it. Now it works like a generator, and only the indices you request will be instanciated. There are some new limitations on how you access them other than [], such as not supporting ipairs(), and you can't simply save a copy of this object in your global (although a shallow or deep copy is still possible), but the limitations will be well worth the performance increases.

details: http://lua-api.factorio.com/0.13.0-prev ... Table.html

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

Re: Mod changes in 0.13

Post by Adil »

So what old code will break due to this?
I don't recall seeing ipairs used on any of the
game.players, game.surfaces, game.entity_prototypes, game.item_prototypes, game.fluid_prototypes, force.recipes, force,technologies
ever.
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.

sparr
Smart Inserter
Smart Inserter
Posts: 1426
Joined: Fri Feb 14, 2014 5:52 pm
Contact:

Re: Mod changes in 0.13

Post by sparr »

Adil wrote: I don't recall seeing ipairs used on any of the
game.players, game.surfaces, game.entity_prototypes, game.item_prototypes, game.fluid_prototypes, force.recipes, force,technologies
ever.
https://www.google.com/search?q=site:gi ... +%22ipairs(game%22
Adil wrote:So what old code will break due to this?
In addition to the above... any attempts to leave a reference to one of those tables in your global table (the one that gets saved in the game state) will result in an error and/or mp desync. You'll have to deep copy the parts of the table you want to keep.

Choumiko
Smart Inserter
Smart Inserter
Posts: 1352
Joined: Fri Mar 21, 2014 10:51 pm
Contact:

Re: Mod changes in 0.13

Post by Choumiko »

sparr wrote:In addition to the above... any attempts to leave a reference to one of those tables in your global table (the one that gets saved in the game state) will result in an error and/or mp desync. You'll have to deep copy the parts of the table you want to keep.
If i understand the change correctly it should only be an issue if you did something like global.players = game.players. Stuff like global.first_player = game.players[1] should still be fine?

Rseding91
Factorio Staff
Factorio Staff
Posts: 14138
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Mod changes in 0.13

Post by Rseding91 »

Choumiko wrote:
sparr wrote:In addition to the above... any attempts to leave a reference to one of those tables in your global table (the one that gets saved in the game state) will result in an error and/or mp desync. You'll have to deep copy the parts of the table you want to keep.
If i understand the change correctly it should only be an issue if you did something like global.players = game.players. Stuff like global.first_player = game.players[1] should still be fine?
Correct.
If you want to get ahold of me I'm almost always on Discord.

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

Re: Mod changes in 0.13

Post by Adil »

Rseding91 wrote:Unified prototype names to be consistant with ingame names.
Will the same named technologies be renamed as well?
For example: basic-laser-defense-equipment and basic-exoskeleton-equipment?
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
binbinhfr
Smart Inserter
Smart Inserter
Posts: 1524
Joined: Sat Feb 27, 2016 7:37 pm
Contact:

Re: Mod changes in 0.13

Post by binbinhfr »

About on_player_joined_game event :

at the first player creation, we already have event on_player_created.
Will the creation also trigger on_player_joined_game once ?
If yes, I suppose that it will be after the creation event ?
My mods on the Factorio Mod Portal :geek:

User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: Mod changes in 0.13

Post by bobingabout »

Question:

what is the correct way to access the new version of game.daytime?
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

orzelek
Smart Inserter
Smart Inserter
Posts: 3922
Joined: Fri Apr 03, 2015 10:20 am
Contact:

Re: Mod changes in 0.13

Post by orzelek »

Another question:
Any idea why game is playing silly with me and writes that my mod is meant for factorio 12?

It shows below it that dependency is set for base > 0.13.0. And it loads the control.lua part but data.lua or data-updates.lua will not be read (no log entry for them, checksum of mod says 0). Running mod as directory.

Solution:
There is a new required value factorio_version to make the mod work.

orzelek
Smart Inserter
Smart Inserter
Posts: 3922
Joined: Fri Apr 03, 2015 10:20 am
Contact:

Re: Mod changes in 0.13

Post by orzelek »

bobingabout wrote:Question:

what is the correct way to access the new version of game.daytime?
You need to have access to surface and find it there:
http://lua-api.factorio.com/0.13.0/LuaS ... ce.daytime

You can grab default surface like this:

Code: Select all

local surface = game.surfaces['nauvis']

User avatar
Schorty
Fast Inserter
Fast Inserter
Posts: 185
Joined: Tue Aug 12, 2014 10:29 am
Contact:

Re: Mod changes in 0.13

Post by Schorty »

Why are my Mods saying, that they are for Version 0.12 and therefor not compatible with the current version of the game? I get this message in the mods menu ingame. What do I have to do, to change this?
Tired of not being able to reduce the pollution? Try the Air-Filter-Mod
With this, you are able to use the pollution levels in your circuit network: Pollution detector

Rseding91
Factorio Staff
Factorio Staff
Posts: 14138
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Mod changes in 0.13

Post by Rseding91 »

Schorty wrote:Why are my Mods saying, that they are for Version 0.12 and therefor not compatible with the current version of the game? I get this message in the mods menu ingame. What do I have to do, to change this?
Add the tag to the info.json: "factorio_version":"0.13" indicating the mod works with that version.
If you want to get ahold of me I'm almost always on Discord.

orzelek
Smart Inserter
Smart Inserter
Posts: 3922
Joined: Fri Apr 03, 2015 10:20 am
Contact:

Re: Mod changes in 0.13

Post by orzelek »

Rseding91 wrote:
Schorty wrote:Why are my Mods saying, that they are for Version 0.12 and therefor not compatible with the current version of the game? I get this message in the mods menu ingame. What do I have to do, to change this?
Add the tag to the info.json: "factorio_version":"0.13" indicating the mod works with that version.
And be careful - mods disabled in this way that fullfill the base requirement are still running their control.lua - lots of fun to be had there.

User avatar
Schorty
Fast Inserter
Fast Inserter
Posts: 185
Joined: Tue Aug 12, 2014 10:29 am
Contact:

Re: Mod changes in 0.13

Post by Schorty »

orzelek wrote:And be careful - mods disabled in this way that fullfill the base requirement are still running their control.lua - lots of fun to be had there.
Why shouldn't they? Did I miss something important? I read, that the 'require "defines"' is not longer needed, but other than that? Could you explain this a bit further, please? :)
Tired of not being able to reduce the pollution? Try the Air-Filter-Mod
With this, you are able to use the pollution levels in your circuit network: Pollution detector

orzelek
Smart Inserter
Smart Inserter
Posts: 3922
Joined: Fri Apr 03, 2015 10:20 am
Contact:

Re: Mod changes in 0.13

Post by orzelek »

Schorty wrote:
orzelek wrote:And be careful - mods disabled in this way that fullfill the base requirement are still running their control.lua - lots of fun to be had there.
Why shouldn't they? Did I miss something important? I read, that the 'require "defines"' is not longer needed, but other than that? Could you explain this a bit further, please? :)
I was updating RSO, fixed control file and only then realized that mod is disabled. So control.lua of mod was loaded for disabled mod.

User avatar
DRY411S
Filter Inserter
Filter Inserter
Posts: 731
Joined: Sun Mar 13, 2016 9:48 am
Contact:

Re: Mod changes in 0.13

Post by DRY411S »

orzelek wrote:
Schorty wrote:
orzelek wrote:And be careful - mods disabled in this way that fullfill the base requirement are still running their control.lua - lots of fun to be had there.
Why shouldn't they? Did I miss something important? I read, that the 'require "defines"' is not longer needed, but other than that? Could you explain this a bit further, please? :)
I was updating RSO, fixed control file and only then realized that mod is disabled. So control.lua of mod was loaded for disabled mod.
Confirmed. Same for me and Recycling Machines. I have the Test Mode and EvoGUI mods installed too. All failing with control.lua errors because of the use of require("defines")

Strictly though they weren't disabled (i.e. not grey). They were red, i.e. enabled but Factorio was saying they weren't compatible. But on that basis, Factorio shouldn't have let control.luas run. Disabling them (by toggling to make them grey) stopped control.lua.

BloodForce
Manual Inserter
Manual Inserter
Posts: 1
Joined: Tue Jun 28, 2016 12:47 am
Contact:

Re: Mod changes in 0.13

Post by BloodForce »

how now turn on/off peaceful mode?

Rseding91
Factorio Staff
Factorio Staff
Posts: 14138
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Mod changes in 0.13

Post by Rseding91 »

BloodForce wrote:how now turn on/off peaceful mode?
/c game.player.surface.peaceful_mode = true/false
If you want to get ahold of me I'm almost always on Discord.

leffe108
Burner Inserter
Burner Inserter
Posts: 9
Joined: Mon Jun 27, 2016 7:16 pm
Contact:

Re: Mod changes in 0.13

Post by leffe108 »

You can find a list of some name changes in
C:\Program Files\Factorio\data\base\migrations\*.json

It may still be the same as in the original post, but in (in my opinion) more readable format. And you can grep through it easily.


Still, there are some changes that I cannot find. It may be because they are older than 0.12 => 0.13 because I try to update an old mod I didn't write. It would be welcome if 0.11 mod API could be available or older migration logs to look through for this purpose. Maybe those are archived at some other place than lua-apis.factorio.com? I'm very new to the Factorio specific part of modding for Factorio.

I'll just drop a list here of some changes I couldn't find in the migrations that could be older changes. Feel free to point me to the docs where my answers can be found if you don't like to do my homework.
  • AutoplaceSpecification::peaks::noise_persistence => noisePersistence (this doesn't even confirm with the naming standard of all other attributes)
  • AutoplaceSpecification::peaks::starting_area_weight_optimal is missing and I cannot see what it has been renamed to.
  • AutoplaceSpecification::peaks::starting_area_weight_range is missing and I cannot see what it has been renamed to.
  • AutoplaceSpecification::peaks::starting_area_weight_max_rang is missing and I cannot see what it has been renamed to.

Post Reply

Return to “Modding discussion”