on_pre_player_built_tile

Trainwreck
Fast Inserter
Fast Inserter
Posts: 110
Joined: Wed Apr 05, 2017 2:17 am
Contact:

on_pre_player_built_tile

Post 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.
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: on_pre_player_built_tile

Post 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.
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: on_pre_player_built_tile

Post by eradicator »

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.
Rseding91
Factorio Staff
Factorio Staff
Posts: 14912
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: on_pre_player_built_tile

Post 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.
If you want to get ahold of me I'm almost always on Discord.
Post Reply

Return to “Implemented mod requests”