Mod changes in 0.13

Place to post guides, observations, things related to modding that are not mods themselves.
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 »

Nice news that I missed.

But can you confirm that there will be a on_player_connected event ?
I start a thread here, not to pollute this general thread :
viewtopic.php?f=33&t=25484
My mods on the Factorio Mod Portal :geek:

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 »

binbinhfr wrote:But can you confirm that there will be a on_player_connected event ?
I think he did: (last 2 events) :D
Rseding91 wrote: - Added several player related events: on_player_cursor_stack_changed, on_player_main_inventory_changed, on_player_quickbar_inventory_changed,
on_player_tool_inventory_changed, on_player_armor_inventory_changed, on_player_ammo_inventory_changed, on_player_gun_inventory_changed,
on_player_placed_equipment, on_player_removed_equipment, on_pre_player_died, on_player_died, on_player_respawned, on_player_joined_game, on_player_left_game

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 »

Yes, bob told me. As we say in France, I must have some shit in my eyes :D
My mods on the Factorio Mod Portal :geek:

seronis
Fast Inserter
Fast Inserter
Posts: 225
Joined: Fri Mar 04, 2016 8:04 pm
Contact:

Re: Mod changes in 0.13

Post by seronis »

Changes and Additions look great. One question though:
Removed game.regenerate_tiles().
I believe some of the mods like Train Outposts or RSO use this. Is there an alternative that they should have been using ?

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: And just so you're not discouraged by those breaking changes this is the list of additions/new things coming in 0.13 related to the mod API:
I'm more horrified by the vast possibility space opened by the second list.
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.

Simcra
Long Handed Inserter
Long Handed Inserter
Posts: 76
Joined: Wed Apr 06, 2016 6:05 am
Contact:

Re: Mod changes in 0.13

Post by Simcra »

Rseding91 wrote:- Added LuaGame::delete_surface. Deletes the surface passed in if the surface is deletable.
- Added LuaSurface::deconstruct_area() - deconstructs an area as if the player did it.
- Added LuaSurface::cancel_deconstruct_area() - cancels deconstruction over an area as if the player did it.
- Added events for tile building: on_player_built_tile, on_player_mined_tile, on_robot_built_tile, on_robot_mined_tile
- Added LuaEntity::player, returns the player connected to the character entity.
- Added LuaTilePrototype accessible from LuaTile::prototype and LuaGameScript::tile_prototypes.
Awesome, I will greatly benefit from these! Are we going to get more access to surface generation in future? It's impractical and inefficient to use the on_chunk_generated event to remove entities and replace tiles. It would make more sense to be able to define world generation in greater detail with MapGenSettings.

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 »

Simcra wrote:
Rseding91 wrote:- Added LuaGame::delete_surface. Deletes the surface passed in if the surface is deletable.
- Added LuaSurface::deconstruct_area() - deconstructs an area as if the player did it.
- Added LuaSurface::cancel_deconstruct_area() - cancels deconstruction over an area as if the player did it.
- Added events for tile building: on_player_built_tile, on_player_mined_tile, on_robot_built_tile, on_robot_mined_tile
- Added LuaEntity::player, returns the player connected to the character entity.
- Added LuaTilePrototype accessible from LuaTile::prototype and LuaGameScript::tile_prototypes.
Awesome, I will greatly benefit from these! Are we going to get more access to surface generation in future? It's impractical and inefficient to use the on_chunk_generated event to remove entities and replace tiles. It would make more sense to be able to define world generation in greater detail with MapGenSettings.
Can't you already do that? (I never have, but the api suggests it's possible)

http://lua-api.factorio.com/0.12.34/Lua ... te_surface

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 »

oh yes you can.
see this mod :
viewtopic.php?f=97&t=19178
My mods on the Factorio Mod Portal :geek:

Simcra
Long Handed Inserter
Long Handed Inserter
Posts: 76
Joined: Wed Apr 06, 2016 6:05 am
Contact:

Re: Mod changes in 0.13

Post by Simcra »

binbinhfr wrote:oh yes you can.
see this mod :
viewtopic.php?f=97&t=19178
TL;DR: It's not possible to specify terrain segmentation none, therefore you cannot create empty surfaces.

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

Re: Mod changes in 0.13

Post by sparr »

Rseding91 wrote:- Changed "defines" so they're available by default and removed the defines.lua file.
Why not leave an empty defines.lua, so that mods for which this is the only breaking change won't be broken?

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Mod changes in 0.13

Post by DaveMcW »

sparr wrote:Why not leave an empty defines.lua, so that mods for which this is the only breaking change won't be broken?
Because they care more about having a clean file system than supporting old mods. :P

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

Re: Mod changes in 0.13

Post by sparr »

DaveMcW wrote:
sparr wrote:Why not leave an empty defines.lua, so that mods for which this is the only breaking change won't be broken?
Because they care more about having a clean file system than supporting old mods. :P
If the filesystem itself is the concern, then the definition of require() could be changed to discard attempts to require "defines". This change could be removed in 0.14. Deprecating API features before removing them is common practice, it gives API users time to change their code without things breaking.

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

Re: Mod changes in 0.13

Post by Rseding91 »

sparr wrote:
DaveMcW wrote:
sparr wrote:Why not leave an empty defines.lua, so that mods for which this is the only breaking change won't be broken?
Because they care more about having a clean file system than supporting old mods. :P
If the filesystem itself is the concern, then the definition of require() could be changed to discard attempts to require "defines". This change could be removed in 0.14. Deprecating API features before removing them is common practice, it gives API users time to change their code without things breaking.
I've never seen that work. Everyone just keeps using the deprecated things until they're eventually removed and they're forced to fix it. It's a simple line deletion - even a "find and replace" will do.
If you want to get ahold of me I'm almost always on Discord.

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

Re: Mod changes in 0.13

Post by sparr »

Rseding91 wrote:Everyone just keeps using the deprecated things until they're eventually removed and they're forced to fix it. It's a simple line deletion - even a "find and replace" will do.
Not everyone. Just some. Responsible/active mod devs will make the change. By giving one version for the deprecation, you let responsible devs have mods that don't break. If a dev ignores the deprecation period then it's their fault when their mod breaks a version later. If you remove things with no deprecation period then any time players can't play because their mods are broken is your fault.

Even though I know the change is coming, I can't publish a fix right now because people would download it and get a broken-in-0.12 mod. So I've got to hope I'm awake with 0.13 releases and coordinate a release. That's silly.

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Mod changes in 0.13

Post by DaveMcW »

They do give you several months between the .0 release and stable. But then they spend a year hyping the next .0 release so everyone upgrades instantly. :P

User avatar
DaCyclops
Long Handed Inserter
Long Handed Inserter
Posts: 85
Joined: Mon Aug 25, 2014 12:37 am
Contact:

Re: Mod changes in 0.13

Post by DaCyclops »

sparr wrote:
Rseding91 wrote:Everyone just keeps using the deprecated things until they're eventually removed and they're forced to fix it. It's a simple line deletion - even a "find and replace" will do.
Not everyone. Just some. Responsible/active mod devs will make the change. By giving one version for the deprecation, you let responsible devs have mods that don't break. If a dev ignores the deprecation period then it's their fault when their mod breaks a version later. If you remove things with no deprecation period then any time players can't play because their mods are broken is your fault.

Even though I know the change is coming, I can't publish a fix right now because people would download it and get a broken-in-0.12 mod. So I've got to hope I'm awake with 0.13 releases and coordinate a release. That's silly.
But you will still need to be awake, because you are going to need to sign into the mod portal and create your mod in there.

Considering the number of large-scale changes they are making (next major release, introduction of Modportal, refactoring of legacy itemnames, removal of legacy functions, introduction of specialised functions) it doesnt seem like something that major. And if you use a CVS like Github, just have the release sitting there as a pre-release ready to set "live" the moment you get to it.

And worst case scenario, you could just do some code to say "If 0.13-only API code returns Null, get defines.LUA because its 0.12"

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 »

I simply added

Code: Select all

if not defines then
  require "defines"
  defines.trainstate = defines.train_state
end
(and applied the renaming changes in the code.)
That should at least make them load with 0.13 and 0.12

ratchetfreak
Filter Inserter
Filter Inserter
Posts: 952
Joined: Sat May 23, 2015 12:10 pm
Contact:

Re: Mod changes in 0.13

Post by ratchetfreak »

Rseding91 wrote:
sparr wrote:
DaveMcW wrote:
sparr wrote:Why not leave an empty defines.lua, so that mods for which this is the only breaking change won't be broken?
Because they care more about having a clean file system than supporting old mods. :P
If the filesystem itself is the concern, then the definition of require() could be changed to discard attempts to require "defines". This change could be removed in 0.14. Deprecating API features before removing them is common practice, it gives API users time to change their code without things breaking.
I've never seen that work. Everyone just keeps using the deprecated things until they're eventually removed and they're forced to fix it. It's a simple line deletion - even a "find and replace" will do.
Add a nag log entry (aka warning) for each use of require("defines") or include("defines")

That tends to help in the change over

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

Re: Mod changes in 0.13

Post by sparr »

Choumiko wrote:I simply added

Code: Select all

if not defines then
  require "defines"
  defines.trainstate = defines.train_state
end
(and applied the renaming changes in the code.)
That should at least make them load with 0.13 and 0.12
Great solution.

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 »

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 []?
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.

Post Reply

Return to “Modding discussion”