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.
on_pre_player_built_tile
-
- Fast Inserter
- Posts: 110
- Joined: Wed Apr 05, 2017 2:17 am
- Contact:
Re: on_pre_player_built_tile
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.
They are need event.old_entity, event.entity (new) and event.old_tile, event.tile (new) with unchanged properties of old ones.
- eradicator
- Smart Inserter
- Posts: 5211
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: on_pre_player_built_tile
Sounds like adding event.old_tile_name to on_player_built_tile would be sufficient?
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Re: on_pre_player_built_tile
I did just that for the next version of 0.16.eradicator wrote:Sounds like adding event.old_tile_name to on_player_built_tile would be sufficient?
If you want to get ahold of me I'm almost always on Discord.