[API bug?] surface_index of event is 0

Place to get help with not working mods / modding interface.
Post Reply
Charidan
Burner Inserter
Burner Inserter
Posts: 14
Joined: Tue Oct 03, 2017 4:44 am
Contact:

[API bug?] surface_index of event is 0

Post by Charidan »

I tried outputting the contents of some on_player_mine events, specifically on_player_mined_tile, and the surface_index is coming back as 0, which isn't a real surface. At first I thought this was because I had made water minable and was mining it off the map, but it was also true of stone paths.

Is this an intended behavior? Is this a bug in the API returning an incorrect index?

I have attached the test mod in question in case it's relevant. It's a very simple test mod adding a single item and recipe and making water minable, and altering the properties of fish; mostly it broadcasts a lot of information about mining events. I'm running with just this test mod and basemod. (Note: you need to be holding a stone brick in order to mine water because that's how tile mining works)
Attachments
test_0.0.2.zip
Mod file
(1.95 KiB) Downloaded 81 times

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

Re: [API bug?] surface_index of event is 0

Post by Nexela »

This is fixed for .16, It affects on_player_built_tile and on_player_mined_tile events, For now just add 1 to the surface index or get the surface from the player game.players[event.player_index].surface

Charidan
Burner Inserter
Burner Inserter
Posts: 14
Joined: Tue Oct 03, 2017 4:44 am
Contact:

Re: [API bug?] surface_index of event is 0

Post by Charidan »

Thanks!

Post Reply

Return to “Modding help”