Page 1 of 1

[API bug?] surface_index of event is 0

Posted: Tue Oct 03, 2017 4:49 am
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)

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

Posted: Tue Oct 03, 2017 11:23 pm
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

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

Posted: Wed Oct 04, 2017 1:49 am
by Charidan
Thanks!