All events

Every event contains at least the name and tick attributes. Other events may include some additional attributes, specific to the event.

Contains
name :: defines.events: Identifier of the event
tick :: uint: Tick the event was generated.
on_tick

It is fired once every tick. Since this event is fired every tick, its handler shouldn't include performance heavy code.

on_biter_base_built

Called when a biter migration builds a base.

Contains
entity :: LuaEntity: The built entity.
Note: This will be called multiple times as each biter in a given migration is sacraficed and builds part of the base.
on_built_entity

Called when player builds something.

Contains
created_entity :: LuaEntity
player_index :: uint
item :: string (optional)
tags :: dictionary stringAny (optional)
on_canceled_deconstruction

Called when the deconstruction of an entity is canceled.

Contains
entity :: LuaEntity
player_index :: uint (optional)
on_chunk_generated

Called when a chunk is generated.

Contains
area :: BoundingBox: Area of the chunk
surface :: LuaSurface: The surface the chunk is on
on_difficulty_settings_changed

Called when the map difficulty settings are changed.

Contains
old_recipe_difficulty :: uint
old_technology_difficulty :: uint
Note: It's not guarenteed that both settings are changed - just that at least one has been changed.
on_entity_died

Called when an entity dies.

Contains
entity :: LuaEntity
cause :: LuaEntity (optional): The entity that did the killing if available.
force :: LuaForce (optional): The force that did the killing if any.
on_entity_renamed

Called after an entity has been renamed either by the player or through script.

Contains
player_index :: uint (optional): If by_script is true this will not be included
by_script :: boolean
entity :: LuaEntity
old_name :: string
on_entity_settings_pasted

Called after entity copy-paste is done.

Contains
player_index :: uint
source :: LuaEntity: The source entity settings have been copied from.
destination :: LuaEntity: The destination entity settings have been copied to.
on_force_created

Called when a new force is created using game.create_force()

Contains
force :: LuaForce: The newly created force.
on_forces_merging

Called when two forces are merged using game.merge_forces().

Contains
source :: LuaForce: The force to be destroyed
destination :: LuaForce: The force to reassign entities to.
on_gui_checked_state_changed

Called when LuaGuiElement checked state is changed (related to checkboxes and radio buttons)

Contains
element :: LuaGuiElement: The element whose checked state changed
player_index :: uint: The player who did the change.
on_gui_click

Called when LuaGuiElement is clicked.

Contains
element :: LuaGuiElement: The clicked element.
player_index :: uint: The player who did the clicking.
button :: defines.mouse_button_type: The mouse button used if any.
alt :: boolean: If alt was pressed.
control :: boolean: If control was pressed.
shift :: boolean: If shift was pressed.
on_gui_elem_changed

Called when LuaGuiElement element value is changed (related to choose element buttons)

Contains
element :: LuaGuiElement: The element whose selection state changed
player_index :: uint: The player who did the change.
on_gui_selection_state_changed

Called when LuaGuiElement selection state is changed (related to drop-downs)

Contains
element :: LuaGuiElement: The element whose selection state changed
player_index :: uint: The player who did the change.
on_gui_text_changed

Called when LuaGuiElement text is changed by the player

Contains
element :: LuaGuiElement: The edited element.
player_index :: uint: The player who did the edit.
on_marked_for_deconstruction

Called when an entity is marked for deconstruction with the Deconstruction planner or via script.

Contains
entity :: LuaEntity
player_index :: uint (optional)
on_market_item_purchased

Called after a player purchases some offer from a Market entity.

Contains
player_index :: uint: The player who did the purchasing.
market :: LuaEntity: The market entity.
offer_index :: uint: The index of the offer purchased.
count :: uint: The count of offers purchased.
on_picked_up_item

Called when a player picks up an item.

Contains
item_stack :: SimpleItemStack
player_index :: uint
on_player_alt_selected_area

Called after a player alt-selects an area with a selection-tool item.

Contains
player_index :: uint: The player doing the selection.
area :: BoundingBox: The area selected.
item :: string: The item used to select the area.
entities :: array of LuaEntity: The entities selected.
tiles :: array of LuaTile: The tiles selected.
on_player_ammo_inventory_changed

Called after a players ammo inventory changed in some way.

Contains
player_index :: uint
on_player_armor_inventory_changed

Called after a players armor inventory changed in some way.

Contains
player_index :: uint
on_player_built_tile

Called after a player builds tiles.

Contains
player_index :: uint
positions :: array of Position: The tile positions.
on_player_changed_force

Called after a player changes forces.

Contains
player_index :: uint: The player who changed forces.
force :: LuaForce: The old force.
on_player_changed_surface

Called after a player changes surfaces.

Contains
player_index :: uint: The player who changed surfaces.
surface_index :: uint: The surface index the player was on.
Note: In the instance a player is moved off a surface due to it being deleted this is not called.
on_player_crafted_item

Called when the player crafts an item (upon inserting into player's inventory, not clicking the button to craft). As of 0.11.0, is called for each item crafted as well as what was clicked ("iron-axe" triggers both "iron-stick" with a count of 2 and "iron-axe" with a count of 1, assuming no "iron-sticks" are in the player's inventory)

Contains
item_stack :: SimpleItemStack: The crafted item
player_index :: uint: The player who did the crafting
recipe :: LuaRecipe: The recipe that resulted in this item being crafted
on_player_created

Called after the player was created.

Contains
player_index :: uint
on_player_cursor_stack_changed

Called after a players cursorstack changed in some way.

Contains
player_index :: uint
on_player_died

Called after a player dies.

Contains
player_index :: uint
cause :: LuaEntity (optional)
on_player_driving_changed_state

Called when the player's driving state has changed, this means a player has either entered or left a vehicle.

Contains
player_index :: uint
on_player_dropped_item

Called when a player drops an item on the ground.

Contains
player_index :: uint
entity :: LuaEntity: The item-on-ground entity.
on_player_gun_inventory_changed

Called after a players gun inventory changed in some way.

Contains
player_index :: uint
on_player_joined_game

Called after a player joins the game.

Contains
player_index :: uint
on_player_left_game

Called after a player leaves the game.

Contains
player_index :: uint
on_player_main_inventory_changed

Called after a players main inventory changed in some way.

Contains
player_index :: uint
on_player_mined_entity

Called after the results of an entity being mined are collected just before the entity is destroyed. After this event any items in the buffer will be transferred into the player as if they came from mining the entity.

Contains
player_index :: uint: The index of the player doing the mining.
entity :: LuaEntity: The entity that has been mined.
buffer :: LuaInventory: The temporary inventory that holds the result of mining the entity.
Note: The buffer inventory is special in that it's only valid during this event and has a dynamic size expanding as more items are transferred into it.
on_player_mined_item

Called when the player mines something.

Contains
item_stack :: SimpleItemStack: The item given to the player
player_index :: uint
on_player_mined_tile

Called after a player mines tiles.

Contains
player_index :: uint
positions :: array of Position: The tile positions.
on_player_placed_equipment

Called after the player puts equipment in an equipment grid

Contains
player_index :: uint
equipment :: LuaEquipment: The equipment put in the equipment grid.
grid :: LuaEquipmentGrid: The equiment grid the equipment was put in.
on_player_quickbar_inventory_changed

Called after a players quickbar inventory changed in some way.

Contains
player_index :: uint
on_player_removed_equipment

Called after the player removes equipment from an equipment grid

Contains
player_index :: uint
grid :: LuaEquipmentGrid: The equipment grid removed from.
equipment :: string: The equipment removed.
count :: uint: The count of equipment removed.
on_player_respawned

Called after a player respawns.

Contains
player_index :: uint
player_port :: LuaEntity (optional): The player port used to respawn if one was used.
on_player_rotated_entity

Called when the player rotates an entity. This event is only fired when the entity actually changes its orientation -- pressing the rotate key on an entity that can't be rotated won't fire this event.

Contains
entity :: LuaEntity: The rotated entity.
player_index :: uint
on_player_selected_area

Called after a player selects an area with a selection-tool item.

Contains
player_index :: uint: The player doing the selection.
area :: BoundingBox: The area selected.
item :: string: The item used to select the area.
entities :: array of LuaEntity: The entities selected.
tiles :: array of LuaTile: The tiles selected.
on_player_tool_inventory_changed

Called after a players tool inventory changed in some way.

Contains
player_index :: uint
on_pre_entity_settings_pasted

Called before entity copy-paste is done.

Contains
player_index :: uint
source :: LuaEntity: The source entity settings will be copied from.
destination :: LuaEntity: The destination entity settings will be copied to.
on_pre_player_died

Called before a players dies.

Contains
player_index :: uint
cause :: LuaEntity (optional)
on_pre_surface_deleted

Called just before a surface is deleted.

Contains
surface_index :: uint
on_preplayer_mined_item

Called when the player finishes mining an entity, before the entity is removed from map.

Contains
entity :: LuaEntity: The entity being mined
player_index :: uint
on_put_item

Called when players uses item to build something. Called before on_built_entity.

Contains
position :: Position: Where the item was placed.
player_index :: uint: The player who did the placing.
on_research_finished

Called when a research finishes.

Contains
research :: LuaTechnology: The researched technology
by_script :: boolean: If the technology was researched by script.
on_research_started

Called when a technology research starts.

Contains
research :: LuaTechnology: The technology being researched
on_resource_depleted

Called when a resource entity reaches 0 or its minimum yield for infinite resources.

Contains
entity :: LuaEntity
on_robot_built_entity

Called when a construction robot builds an entity.

Contains
robot :: LuaEntity: The robot that did the building.
created_entity :: LuaEntity: The entity built.
item :: string (optional)
tags :: dictionary stringAny (optional)
on_robot_built_tile

Called after a robot builds tiles.

Contains
robot :: LuaEntity: The robot.
positions :: array of Position: The tile positions.
item :: string (optional)
tags :: dictionary stringAny (optional)
on_robot_mined

Called when a robot mines an entity.

Contains
robot :: LuaEntity: The robot that did the mining.
item_stack :: SimpleItemStack: The entity the robot just picked up.
on_robot_mined_entity

Called after the results of an entity being mined are collected just before the entity is destroyed. After this event any items in the buffer will be transferred into the robot as if they came from mining the entity.

Contains
robot :: LuaEntity: The robot doing the mining.
entity :: LuaEntity: The entity that has been mined.
buffer :: LuaInventory: The temporary inventory that holds the result of mining the entity.
Note: The buffer inventory is special in that it's only valid during this event and has a dynamic size expanding as more items are transferred into it.
on_robot_mined_tile

Called after a robot mines tiles.

Contains
robot :: LuaEntity: The robot.
positions :: array of Position: The tile positions.
on_robot_pre_mined

Called before a robot mines an entity.

Contains
robot :: LuaEntity: The robot that's about to do the mining.
entity :: LuaEntity: The entity which is about to be mined.
on_rocket_launched

Called when the rocket is launched.

Contains
rocket :: LuaEntity
rocket_silo :: LuaEntity (optional)
on_runtime_mod_setting_changed

Called when a runtime mod setting is changed by a player.

Contains
player_index :: uint: The player who changed the setting
setting :: string: The setting name that changed
on_sector_scanned

Called when the radar finishes scanning a sector.

Contains
radar :: LuaEntity: The radar that did the scanning.
chunk_position :: Position: The chunk scanned.
on_selected_entity_changed

Called after the selected entity changes for a given player.

Contains
player_index :: uint: The player whose selected entity changed.
last_entity :: LuaEntity (optional): The last selected entity if it still exists and there was one.
on_surface_created

Called when a surface is created.

Contains
surface_index :: uint
Note: This is not called when the default surface is created as it will always exist.
on_surface_deleted

Called after a surface is deleted.

Contains
surface_index :: uint
on_train_changed_state

Called when a train changes state (started to stopped and vice versa)

Contains
train :: LuaTrain
on_train_created

Called when a new train is created either through disconnecting/connecting an existing one or building a new one.

Contains
train :: LuaTrain
old_train_id_1 :: uint (optional): The first old train id when splitting/merging trains.
old_train_id_2 :: uint (optional): The second old train id when splitting/merging trains.
on_trigger_created_entity

Called when an entity with a trigger prototype (such as capsules) create an entity AND that trigger prototype defined trigger_created_entity="true".

Contains
entity :: LuaEntity