Page 1 of 1

on_pre_player_built_tile

Posted: Tue Jan 09, 2018 9:43 am
by Trainwreck
I've got a landfill mod that allows players to place all the different terrain tiles as landfill. It also allows landfill to overwrite existing terrain. I'd like to give players a landfill refund if they overwrite terrain with a similar style, e.g. overwriting a sand-1 tile with sand-2.
If there was an on_pre_player_built_tile event that was called before the surface tiles were updated then I could use that event to store the current tile values. on_pre_player_built_tile would receive the same event arguments as on_player_built_tile. Then in on_player_built_tile I could compare the stored tiles with the current surface tiles and put the appropriate landfill back in the players inventory.

I've tried using on_put_item, but that doesn't seem to be called when placing landfill. Maybe it's only for entities. If it was called then I could probably use that, assuming it is called before the surface is updated.

Re: on_pre_player_built_tile

Posted: Tue Jan 09, 2018 11:36 am
by darkfrei
Here must be on_player_repleced_entity and on_player_replaced_tile
They are need event.old_entity, event.entity (new) and event.old_tile, event.tile (new) with unchanged properties of old ones.

Re: on_pre_player_built_tile

Posted: Wed Jan 10, 2018 11:50 am
by eradicator
Sounds like adding event.old_tile_name to on_player_built_tile would be sufficient?

Re: on_pre_player_built_tile

Posted: Thu Jan 11, 2018 5:07 am
by Rseding91
eradicator wrote:Sounds like adding event.old_tile_name to on_player_built_tile would be sufficient?
I did just that for the next version of 0.16.