Page 1 of 2

Mod changes in 0.12

Posted: Sun Jul 05, 2015 4:19 pm
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 515 times
can be used to cover the majority of the renames required "findentities" -> "find_entities".

Re: Mod changes in 0.12

Posted: Mon Jul 06, 2015 7:40 pm
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 ...

Re: Mod changes in 0.12

Posted: Mon Jul 06, 2015 9:02 pm
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.

Re: Mod changes in 0.12

Posted: Mon Jul 06, 2015 11:49 pm
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

Re: Mod changes in 0.12

Posted: Tue Jul 07, 2015 2:19 am
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.

Re: Mod changes in 0.12

Posted: Tue Jul 07, 2015 8:38 am
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.

Re: Mod changes in 0.12

Posted: Tue Jul 07, 2015 5:03 pm
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.

Re: Mod changes in 0.12

Posted: Tue Jul 07, 2015 5:52 pm
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?

Re: Mod changes in 0.12

Posted: Tue Jul 07, 2015 10:03 pm
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.

Re: Mod changes in 0.12

Posted: Wed Jul 08, 2015 1:00 am
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.

Re: Mod changes in 0.12

Posted: Wed Jul 08, 2015 4:21 pm
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.

Re: Mod changes in 0.12

Posted: Fri Jul 17, 2015 4:57 pm
by GotLag
game.alwaysday=true no longer works in console, is there a new way to do this or has it been disabled?

Re: Mod changes in 0.12

Posted: Fri Jul 17, 2015 5:00 pm
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.

Re: Mod changes in 0.12

Posted: Fri Jul 17, 2015 5:19 pm
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.

Re: Mod changes in 0.12

Posted: Fri Jul 17, 2015 5:28 pm
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?

Re: Mod changes in 0.12

Posted: Fri Jul 17, 2015 5:55 pm
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).

Re: Mod changes in 0.12

Posted: Fri Jul 17, 2015 8:21 pm
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

Re: Mod changes in 0.12

Posted: Fri Jul 17, 2015 8:55 pm
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.

Re: Mod changes in 0.12

Posted: Sat Jul 18, 2015 9:37 am
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.

Re: Mod changes in 0.12

Posted: Tue Jul 28, 2015 4:32 pm
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.