Mod changes in 0.12

Place to post guides, observations, things related to modding that are not mods themselves.
Rseding91
Factorio Staff
Factorio Staff
Posts: 14328
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Mod changes in 0.12

Post by Rseding91 »

As you may have read (or may not - I can't read minds yet) - most mods will break in 0.12 due to API name changes.

For those wanting to attempt to update your mods before 0.12 hits this is the 0.12 mod related change log as of July 4 2015:
Mod related changes
It's by no means 100% final and we may have missed a thing or two but that should cover a majority of the changes required. If anyone has questions about a specific change feel free to post and I'll do my best to explain them (since I wrote most of the changes).

We'll be updating the wiki after 0.12 has been released with the new information but as the wiki is now it contains none of the 0.12 mod changes.

EDIT: this python script:
renamer.zip
(2.61 KiB) Downloaded 532 times
can be used to cover the majority of the renames required "findentities" -> "find_entities".
If you want to get ahold of me I'm almost always on Discord.
YuokiTani
Smart Inserter
Smart Inserter
Posts: 1037
Joined: Thu May 08, 2014 7:57 pm
Contact:

Re: Mod changes in 0.12

Post by YuokiTani »

- Turrets change to 2x2 tiles ... will graphics without player overlay work ? (if this overlay-animation-sheet missing)
- and will this player-color-overlay-sheets possible work on all graphics like assemblys or walls ?
- will it possible to change player-animation-directions- and framecount (sheet) without crashing the game ?
- will some entity/items - methods such as energy_source, horizontal_animation, filename, width, production etc. renamed or restructed ?

questions over questions ... as always modders are alone and need reverse engineering to find out whats changed by trying their mods and looking at endless not useful error-messages.
but hey thats is modding fun ... or maybe not.

i hope i'am the only one with this impression and other modders have a better experience ...
Rseding91
Factorio Staff
Factorio Staff
Posts: 14328
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Mod changes in 0.12

Post by Rseding91 »

YuokiTani wrote:- Turrets change to 2x2 tiles ... will graphics without player overlay work ? (if this overlay-animation-sheet missing)
- and will this player-color-overlay-sheets possible work on all graphics like assemblys or walls ?
- will it possible to change player-animation-directions- and framecount (sheet) without crashing the game ?
- will some entity/items - methods such as energy_source, horizontal_animation, filename, width, production etc. renamed or restructed ?

questions over questions ... as always modders are alone and need reverse engineering to find out whats changed by trying their mods and looking at endless not useful error-messages.
but hey thats is modding fun ... or maybe not.

i hope i'am the only one with this impression and other modders have a better experience ...
I'm a mod creator myself so I'm well aware of the frustration updating mods to work between versions. I've actually updated your mod, tree farm, part of dytech and all of mine to work in 0.12 so I could test my save file as I made API changes. I have a plan to make the error messages far more helpful and not like they are now "Expected node 'width'" - 100% useless error message you can get now.

#1: I'm not sure I understand the question?
#2: the player color overlay is only applied to a few specific entities right now (turrets, gates, tanks, cars, players) - things that are specific to players. Stuff like assembling machines have no concept of an owner so it wouldn't make sense to have them use the players color that placed them.
#3: Sort of, it has to be a specific count - if it's not the specific count it gives an error message on startup stating how many directions are required and forces the count to be that.
#4: We made a script that (should) contain all of the simple name changes - I'll edit the post and include it.
If you want to get ahold of me I'm almost always on Discord.
ljdp
Long Handed Inserter
Long Handed Inserter
Posts: 96
Joined: Wed Jul 01, 2015 12:33 am
Contact:

Re: Mod changes in 0.12

Post by ljdp »

Added the ability to compare LuaObjects using "==" as in: "if game.player == game.players[1]" for all LuaObjects.
Removed all LuaObject::equals(): the == operator can be used in its place.
Does this mean LuaObjects can be properly used as keys?

Code: Select all

local entity = some_LuaEntity
local tbl = {}
tbl[entity] = true
if tbl[entity] then
   print("true")
end
Rseding91
Factorio Staff
Factorio Staff
Posts: 14328
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Mod changes in 0.12

Post by Rseding91 »

ljdp wrote:
Added the ability to compare LuaObjects using "==" as in: "if game.player == game.players[1]" for all LuaObjects.
Removed all LuaObject::equals(): the == operator can be used in its place.
Does this mean LuaObjects can be properly used as keys?

Code: Select all

local entity = some_LuaEntity
local tbl = {}
tbl[entity] = true
if tbl[entity] then
   print("true")
end
LuaObjects can already be used as keys. The issue comes from save/load stability in that using a LuaObject (a Lua table) as a key uses the address of the table which is random from when the Lua state is created and won't be the same address of the LuaObject when you save, exit, and load the game.
If you want to get ahold of me I'm almost always on Discord.
ljdp
Long Handed Inserter
Long Handed Inserter
Posts: 96
Joined: Wed Jul 01, 2015 12:33 am
Contact:

Re: Mod changes in 0.12

Post by ljdp »

I hadn't thought of that. What would be useful then is a unique ID for each entity. I've added an interface request.
YuokiTani
Smart Inserter
Smart Inserter
Posts: 1037
Joined: Thu May 08, 2014 7:57 pm
Contact:

Re: Mod changes in 0.12

Post by YuokiTani »

Rseding91 wrote:
YuokiTani wrote:- Turrets change to 2x2 tiles ... will graphics without player overlay work ? (if this overlay-animation-sheet missing)
#1: I'm not sure I understand the question?
#2: the player color overlay is only applied to a few specific entities right now (turrets, gates, tanks, cars, players) - things that are specific to players. Stuff like assembling machines have no concept of an owner so it wouldn't make sense to have them use the players color that placed them.
#3: Sort of, it has to be a specific count - if it's not the specific count it gives an error message on startup stating how many directions are required and forces the count to be that.
1) is the player-overlay optional or a needed graphic in next version ?
2) sure in friendly Co-Op Multiplayer not, but in a Player vs. Player Scenario - and if is not planed it's good until it appears in a future version
3) the game crashs after using the graphic and switching gfx in play ... looks like some hardcoded values and lua-code ignored/passed the code-check ... but i aim for changeing the gfx ... make the lua-values useless in this case.
orzelek
Smart Inserter
Smart Inserter
Posts: 3924
Joined: Fri Apr 03, 2015 10:20 am
Contact:

Re: Mod changes in 0.12

Post by orzelek »

Could we get some explanation whats behind the LuaSurface objects?

It's stated in the changes that it will be a read property of player or entity. This leaves me with question how to get LuaSurface for arbitrary location to spawn ores in RSO. Entity creation function will be now in the surface so I need to get that surface from somewhere thats position not entity related.

There is also a note in RSO thread about absolute coordinates going away - is that tied to LuaSurfaces and what consequence it will have on spawning ore? Especially if the spawning can happen on currently generated chunk and it's neighbors?
Oxyd
Former Staff
Former Staff
Posts: 1428
Joined: Thu May 07, 2015 8:42 am
Contact:

Re: Mod changes in 0.12

Post by Oxyd »

A surface is like a dimension. Surfaces aren't on locations; it's the other way around: Locations are on surfaces.

If you want to iterate through all surfaces, you can simply do

Code: Select all

for _, s in pairs(game.surfaces) do 
  whatever_you_want(s); 
end
Or you can simply limit yourself to only doing things to the default surface, game.surfaces['nauvis']. That will be the only surface in the game anyway unless a player (through the console) or a mod creates a new surface.

The read-only properties of player and entity simply give you the surface the player or entity is currently located on.
Rseding91
Factorio Staff
Factorio Staff
Posts: 14328
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Mod changes in 0.12

Post by Rseding91 »

To expand on what Oxyd said:

The event "on_chunk_generated" will pass "surface" - the surface of the chunk generated
Player has property "surface" - the surface the player is on
Entity has a property "surface" - the surface the entity is on (all events that pass entity can use this)
game.surfaces can be iterated to get all surfaces
game.get_surface can be used to get a specific surface by index or name (names can't be changed once a surface is created) - the default surface name is provided by Oxyd above

In all other events that pass player or entity information the player/entity "surface" property can be used.
If you want to get ahold of me I'm almost always on Discord.
orzelek
Smart Inserter
Smart Inserter
Posts: 3924
Joined: Fri Apr 03, 2015 10:20 am
Contact:

Re: Mod changes in 0.12

Post by orzelek »

Thanks for the explanation - seems that safest way to go is to use event provided surface. Later might need to make sure I'm not generating ore on surface that represents the space platform I guess.
GotLag
Filter Inserter
Filter Inserter
Posts: 532
Joined: Sat May 03, 2014 3:32 pm
Contact:

Re: Mod changes in 0.12

Post by GotLag »

game.alwaysday=true no longer works in console, is there a new way to do this or has it been disabled?
orzelek
Smart Inserter
Smart Inserter
Posts: 3924
Joined: Fri Apr 03, 2015 10:20 am
Contact:

Re: Mod changes in 0.12

Post by orzelek »

GotLag wrote:game.alwaysday=true no longer works in console, is there a new way to do this or has it been disabled?
Try game.always_day=true - global change to add separator.
GotLag
Filter Inserter
Filter Inserter
Posts: 532
Joined: Sat May 03, 2014 3:32 pm
Contact:

Re: Mod changes in 0.12

Post by GotLag »

Cheers, it works. Hadn't thought to try that.

A more serious problem: the changes to belt mechanics have completely broken my lane splitters. I was spawning invisible decoration entities to block half of each output belt, but the new belts seem to ignore collisions entirely.
ratchetfreak
Filter Inserter
Filter Inserter
Posts: 952
Joined: Sat May 23, 2015 12:10 pm
Contact:

Re: Mod changes in 0.12

Post by ratchetfreak »

GotLag wrote:Cheers, it works. Hadn't thought to try that.

A more serious problem: the changes to belt mechanics have completely broken my lane splitters. I was spawning invisible decoration entities to block half of each output belt, but the new belts seem to ignore collisions entirely.
isn't that kinda the point of the new belt system.

can you rearrange the "rails" of the belts instead?
GotLag
Filter Inserter
Filter Inserter
Posts: 532
Joined: Sat May 03, 2014 3:32 pm
Contact:

Re: Mod changes in 0.12

Post by GotLag »

Oh no doubt it's more efficient the new way. It's just that the old way let me tinker with belt outputs without having to add any real event handling (other than placement and removal of the modified splitters).
yeganer
Long Handed Inserter
Long Handed Inserter
Posts: 74
Joined: Mon Jul 06, 2015 12:07 pm
Contact:

Re: Mod changes in 0.12

Post by yeganer »

I may be wrongt but it seems that LuaTrain.locomotives is broken. At least i'm failing to access locomotives.frontmovers and locomotives.backmovers
orzelek
Smart Inserter
Smart Inserter
Posts: 3924
Joined: Fri Apr 03, 2015 10:20 am
Contact:

Re: Mod changes in 0.12

Post by orzelek »

yeganer wrote:I may be wrongt but it seems that LuaTrain.locomotives is broken. At least i'm failing to access locomotives.frontmovers and locomotives.backmovers
You need underscores - front_movers and back_movers will work most likely.
Choumiko
Smart Inserter
Smart Inserter
Posts: 1352
Joined: Fri Mar 21, 2014 10:51 pm
Contact:

Re: Mod changes in 0.12

Post by Choumiko »

Rseding91 wrote:
  • Added on_player_driving_changed_state event - passes the player_index who's driving state changed.
So, my quick test revealed that this event triggers whenever a player enters or leaves a vehicle right? Would it be possible to pass the entity that was entered/left too? For entered it's not that important as it's just player.vehicle, when leaving it's not that clean.
Also, the same thing for opening/closing a GUI/inventory of an entity would be awesome.
Ty94
Burner Inserter
Burner Inserter
Posts: 10
Joined: Fri Apr 24, 2015 6:58 pm
Contact:

Re: Mod changes in 0.12

Post by Ty94 »

New object LuaTransportLine, accessible from entity as read method get_transport_line(index) - an interface to the items on transport belts.
Can someone explain what methods and properties the LuaTransportLine object has. Because when I run get_transport_line, all I get is an empty table.
Post Reply

Return to “Modding discussion”