typed-factorio
Version:
Featureful typescript definitions for the Factorio modding api.
1,635 lines (1,633 loc) • 147 kB
TypeScript
// This is an auto-generated file. Do not edit directly!
/** @noSelfInFile */
/**
* @noResolution
*/
declare module "factorio:runtime" {
/**
* Called when a {@link import("factorio:prototype").CustomInputPrototype CustomInputPrototype} is activated.
* @example
* -- This will be raised when a custom input with the name "my-potato-control" and action "lua" is pressed
* script.on_event("my-potato-control", function(event)
* game.print("Keyboard shortcut pressed on tick: " ..tostring(event.tick))
* end)
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#CustomInputEvent Online documentation}
*/
interface CustomInputEvent extends EventData {
/**
* The player that activated the custom input.
*/
readonly player_index: PlayerIndex
/**
* The prototype name of the custom input that was activated.
*/
readonly input_name: string
/**
* The mouse cursor position when the custom input was activated.
*/
readonly cursor_position: MapPosition
/**
* Cursor direction.
*/
readonly cursor_direction?: defines.direction
/**
* The mouse cursor display location when the custom input was activated.
*/
readonly cursor_display_location: GuiLocation
/**
* Information about the prototype that is selected when the custom input is used. Needs to be enabled on the custom input's prototype. `nil` if none is selected.
*/
readonly selected_prototype?: SelectedPrototypeData
/**
* Identifier of the event
*/
readonly name: defines.events
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called when an achievement is gained.
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_achievement_gained Online documentation}
*/
interface OnAchievementGainedEvent extends EventData {
/**
* The player who gained the achievement.
*/
readonly player_index: PlayerIndex
readonly achievement: LuaAchievementPrototype
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_achievement_gained
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called when a unit/group completes a command.
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_ai_command_completed Online documentation}
*/
interface OnAiCommandCompletedEvent extends EventData {
/**
* unit_number/group_number of the unit/group which just completed a command.
*/
readonly unit_number: UnitNumber
readonly result: defines.behavior_result
/**
* Was this command generated by a distraction.
*/
readonly was_distracted: boolean
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_ai_command_completed
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called when an area of the map is cloned.
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_area_cloned Online documentation}
*/
interface OnAreaClonedEvent extends EventData {
readonly source_surface: LuaSurface
readonly source_area: BoundingBox
readonly destination_surface: LuaSurface
readonly destination_area: BoundingBox
readonly destination_force?: LuaForce
readonly clone_tiles: boolean
readonly clone_entities: boolean
readonly clone_decoratives: boolean
readonly clear_destination_entities: boolean
readonly clear_destination_decoratives: boolean
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_area_cloned
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called when a biter migration builds a base.
*
* This will be called multiple times for each migration, once for every biter that is sacrificed to build part of the new base.
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_biter_base_built Online documentation}
*/
interface OnBiterBaseBuiltEvent extends EventData {
/**
* The entity that was built.
*/
readonly entity: LuaEntity
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_biter_base_built
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called when a set of positions on the map is cloned.
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_brush_cloned Online documentation}
*/
interface OnBrushClonedEvent extends EventData {
readonly source_offset: TilePosition
readonly destination_offset: TilePosition
readonly source_surface: LuaSurface
readonly source_positions: TilePosition[]
readonly destination_surface: LuaSurface
readonly destination_force?: LuaForce
readonly clone_tiles: boolean
readonly clone_entities: boolean
readonly clone_decoratives: boolean
readonly clear_destination_entities: boolean
readonly clear_destination_decoratives: boolean
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_brush_cloned
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called when a {@link defines.command.build_base} command reaches its destination, and before building starts.
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_build_base_arrived Online documentation}
*/
interface OnBuildBaseArrivedEvent extends EventData {
/**
* The unit the command was assigned to.
*/
readonly unit?: LuaEntity
/**
* The unit group the command was assigned to.
*/
readonly group?: LuaCommandable
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_build_base_arrived
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called when player builds something.
*
* Event filter: [LuaPlayerBuiltEntityEventFilter](LuaPlayerBuiltEntityEventFilter]
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_built_entity Online documentation}
*/
interface OnBuiltEntityEvent extends EventData {
readonly entity: LuaEntity
readonly player_index: PlayerIndex
readonly consumed_items: LuaInventory
/**
* The tags associated with this entity if any.
*/
readonly tags?: Tags
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_built_entity
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called when the deconstruction of an entity is canceled.
*
* Event filter: [LuaEntityDeconstructionCancelledEventFilter](LuaEntityDeconstructionCancelledEventFilter]
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_cancelled_deconstruction Online documentation}
*/
interface OnCancelledDeconstructionEvent extends EventData {
readonly entity: LuaEntity
readonly player_index?: PlayerIndex
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_cancelled_deconstruction
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called when the upgrade of an entity is canceled.
*
* Event filter: [LuaUpgradeCancelledEventFilter](LuaUpgradeCancelledEventFilter]
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_cancelled_upgrade Online documentation}
*/
interface OnCancelledUpgradeEvent extends EventData {
readonly entity: LuaEntity
readonly player_index?: PlayerIndex
readonly target: LuaEntityPrototype
readonly quality: LuaQualityPrototype
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_cancelled_upgrade
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called after a cargo pod has delivered its cargo.
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_cargo_pod_delivered_cargo Online documentation}
*/
interface OnCargoPodDeliveredCargoEvent extends EventData {
readonly cargo_pod: LuaEntity
/**
* The spawned container if any. Created when destination type is {@link defines.cargo_destination.surface surface}.
*/
readonly spawned_container?: LuaEntity
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_cargo_pod_delivered_cargo
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called when a cargo pod departs a surface.
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_cargo_pod_finished_ascending Online documentation}
*/
interface OnCargoPodFinishedAscendingEvent extends EventData {
readonly cargo_pod: LuaEntity
/**
* True for pods spawned on a rocket. This event triggers for platform and modded pods as well, but only when true will the pod count towards rocket launch statistics and trigger 'rocket-launched' achievement with objective_condition.
*/
readonly launched_by_rocket: boolean
/**
* The player that is riding the cargo pod, if any.
*/
readonly player_index?: PlayerIndex
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_cargo_pod_finished_ascending
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called when a cargo pods lands on a surface, either at a station or on the ground.
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_cargo_pod_finished_descending Online documentation}
*/
interface OnCargoPodFinishedDescendingEvent extends EventData {
readonly cargo_pod: LuaEntity
/**
* True for pods spawned on a rocket.
*/
readonly launched_by_rocket: boolean
/**
* The player that is riding the cargo pod, if any.
*/
readonly player_index?: PlayerIndex
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_cargo_pod_finished_descending
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called when a character corpse expires due to timeout or all of the items being removed from it.
*
* this is not called if the corpse is mined. See {@link defines.events.on_pre_player_mined_item} to detect that.
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_character_corpse_expired Online documentation}
*/
interface OnCharacterCorpseExpiredEvent extends EventData {
/**
* The corpse.
*/
readonly corpse: LuaEntity
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_character_corpse_expired
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called when a chart tag is created.
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_chart_tag_added Online documentation}
*/
interface OnChartTagAddedEvent extends EventData {
readonly tag: LuaCustomChartTag
readonly force: LuaForce
readonly player_index?: PlayerIndex
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_chart_tag_added
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called when a chart tag is modified by a player.
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_chart_tag_modified Online documentation}
*/
interface OnChartTagModifiedEvent extends EventData {
readonly tag: LuaCustomChartTag
readonly player_index?: PlayerIndex
readonly force: LuaForce
readonly old_text: string
readonly old_icon: SignalID
readonly old_position: MapPosition
readonly old_surface: LuaSurface
readonly old_player_index?: uint
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_chart_tag_modified
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called just before a chart tag is deleted.
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_chart_tag_removed Online documentation}
*/
interface OnChartTagRemovedEvent extends EventData {
readonly tag: LuaCustomChartTag
readonly force: LuaForce
readonly player_index?: PlayerIndex
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_chart_tag_removed
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called when a chunk is charted or re-charted.
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_chunk_charted Online documentation}
*/
interface OnChunkChartedEvent extends EventData {
readonly surface_index: SurfaceIndex
readonly position: ChunkPosition
/**
* Area of the chunk.
*/
readonly area: BoundingBox
readonly force: LuaForce
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_chunk_charted
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called when one or more chunks are deleted using {@link LuaSurface#delete_chunk LuaSurface::delete_chunk}.
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_chunk_deleted Online documentation}
*/
interface OnChunkDeletedEvent extends EventData {
readonly surface_index: SurfaceIndex
/**
* The chunks deleted.
*/
readonly positions: ChunkPosition[]
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_chunk_deleted
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called when a chunk is generated.
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_chunk_generated Online documentation}
*/
interface OnChunkGeneratedEvent extends EventData {
/**
* Area of the chunk.
*/
readonly area: BoundingBox
/**
* Position of the chunk.
*/
readonly position: ChunkPosition
/**
* The surface the chunk is on.
*/
readonly surface: LuaSurface
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_chunk_generated
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called when a combat robot expires through a lack of energy, or timeout.
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_combat_robot_expired Online documentation}
*/
interface OnCombatRobotExpiredEvent extends EventData {
readonly robot: LuaEntity
/**
* The entity that owns the robot if any.
*/
readonly owner?: LuaEntity
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_combat_robot_expired
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called when a message is sent to the in-game console, either by a player or through the server interface.
*
* This event only fires for plain messages, not for any commands (including `/shout` or `/whisper`).
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_console_chat Online documentation}
*/
interface OnConsoleChatEvent extends EventData {
/**
* The player doing the chatting, if any.
*/
readonly player_index?: PlayerIndex
/**
* The chat message that was sent.
*/
readonly message: string
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_console_chat
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called when someone enters a command-like message regardless of it being a valid command.
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_console_command Online documentation}
*/
interface OnConsoleCommandEvent extends EventData {
/**
* The player if any.
*/
readonly player_index?: PlayerIndex
/**
* The command as typed without the preceding forward slash ('/').
*/
readonly command: string
/**
* The parameters provided if any.
*/
readonly parameters: string
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_console_command
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called when a cutscene is cancelled by the player or by script.
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_cutscene_cancelled Online documentation}
*/
interface OnCutsceneCancelledEvent extends EventData {
/**
* The player the cutscene was shown to.
*/
readonly player_index: PlayerIndex
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_cutscene_cancelled
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called when a cutscene finishes naturally (was not cancelled).
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_cutscene_finished Online documentation}
*/
interface OnCutsceneFinishedEvent extends EventData {
/**
* The player the cutscene was shown to.
*/
readonly player_index: PlayerIndex
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_cutscene_finished
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called when a cutscene starts.
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_cutscene_started Online documentation}
*/
interface OnCutsceneStartedEvent extends EventData {
/**
* The player the cutscene is being shown to.
*/
readonly player_index: PlayerIndex
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_cutscene_started
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called when a cutscene is playing, each time it reaches a waypoint in that cutscene.
*
* This refers to an index in the table previously passed to set_controller which started the cutscene.
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_cutscene_waypoint_reached Online documentation}
*/
interface OnCutsceneWaypointReachedEvent extends EventData {
/**
* The player index of the player viewing the cutscene.
*/
readonly player_index: PlayerIndex
/**
* The index of the waypoint we just completed.
*/
readonly waypoint_index: uint
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_cutscene_waypoint_reached
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called when an entity is cloned. The filter applies to the source entity.
*
* Event filter: [LuaEntityClonedEventFilter](LuaEntityClonedEventFilter]
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_entity_cloned Online documentation}
*/
interface OnEntityClonedEvent extends EventData {
readonly source: LuaEntity
readonly destination: LuaEntity
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_entity_cloned
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called after an entity has been recolored either by the player or through script.
*
* Automatic recoloring due to {@link LuaPlayer#color LuaPlayer::color} will not raise events, as that is a separate mechanism.
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_entity_color_changed Online documentation}
*/
interface OnEntityColorChangedEvent extends EventData {
/**
* The entity that was recolored.
*/
readonly entity: LuaEntity
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_entity_color_changed
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called when an entity is damaged. This is not called when an entities health is set directly by another mod.
*
* Event filter: [LuaEntityDamagedEventFilter](LuaEntityDamagedEventFilter]
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_entity_damaged Online documentation}
*/
interface OnEntityDamagedEvent extends EventData {
readonly entity: LuaEntity
readonly damage_type: LuaDamagePrototype
/**
* The damage amount before resistances.
*/
readonly original_damage_amount: float
/**
* The damage amount after resistances.
*/
readonly final_damage_amount: float
/**
* The health of the entity after the damage was applied.
*/
readonly final_health: float
/**
* The entity that originally triggered the events that led to this damage, if available (e.g. the character, turret, etc. that pulled the trigger).
*/
readonly cause?: LuaEntity
/**
* The entity that is directly dealing the damage, if available (e.g. the projectile, flame, sticker, grenade, laser beam, etc.).
*/
readonly source?: LuaEntity
/**
* The force that did the attacking if any.
*/
readonly force?: LuaForce
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_entity_damaged
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called when an entity dies.
*
* Event filter: [LuaEntityDiedEventFilter](LuaEntityDiedEventFilter]
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_entity_died Online documentation}
*/
interface OnEntityDiedEvent extends EventData {
/**
* The entity that died.
*/
readonly entity: LuaEntity
/**
* The entity that did the killing if available.
*/
readonly cause?: LuaEntity
/**
* The loot generated by this entity if any.
*/
readonly loot: LuaInventory
/**
* The force that did the killing if any.
*/
readonly force?: LuaForce
/**
* The damage type if any.
*/
readonly damage_type?: LuaDamagePrototype
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_entity_died
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called when one of an entity's logistic slots changes.
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_entity_logistic_slot_changed Online documentation}
*/
interface OnEntityLogisticSlotChangedEvent extends EventData {
/**
* The player who changed the slot, or `nil` if changed by script.
*/
readonly player_index?: PlayerIndex
/**
* The entity for whom a logistic slot was changed.
*/
readonly entity: LuaEntity
/**
* The section changed.
*/
readonly section: LuaLogisticSection
/**
* The slot index that was changed.
*/
readonly slot_index: uint
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_entity_logistic_slot_changed
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called after an entity has been renamed either by the player or through script.
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_entity_renamed Online documentation}
*/
interface OnEntityRenamedEvent extends EventData {
/**
* If by_script is true this will not be included.
*/
readonly player_index?: PlayerIndex
readonly by_script: boolean
readonly entity: LuaEntity
readonly old_name: string
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_entity_renamed
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called after entity copy-paste is done.
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_entity_settings_pasted Online documentation}
*/
interface OnEntitySettingsPastedEvent extends EventData {
readonly player_index: PlayerIndex
/**
* The source entity settings were copied from.
*/
readonly source: LuaEntity
/**
* The destination entity settings were copied to.
*/
readonly destination: LuaEntity
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_entity_settings_pasted
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called when an entity is spawned by a EnemySpawner
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_entity_spawned Online documentation}
*/
interface OnEntitySpawnedEvent extends EventData {
readonly spawner: LuaEntity
readonly entity: LuaEntity
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_entity_spawned
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called after equipment is inserted into an equipment grid.
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_equipment_inserted Online documentation}
*/
interface OnEquipmentInsertedEvent extends EventData {
/**
* The equipment grid inserted into.
*/
readonly grid: LuaEquipmentGrid
/**
* The equipment inserted.
*/
readonly equipment: LuaEquipment
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_equipment_inserted
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called after equipment is removed from an equipment grid.
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_equipment_removed Online documentation}
*/
interface OnEquipmentRemovedEvent extends EventData {
/**
* The equipment grid removed from.
*/
readonly grid: LuaEquipmentGrid
/**
* The equipment removed.
*/
readonly equipment: string
/**
* The equipment quality.
*/
readonly quality: string
/**
* The count of equipment removed.
*/
readonly count: uint
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_equipment_removed
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called when the a forces cease fire values change.
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_force_cease_fire_changed Online documentation}
*/
interface OnForceCeaseFireChangedEvent extends EventData {
/**
* The force who's cease fire changed.
*/
readonly force: LuaForce
/**
* Which force was added or removed.
*/
readonly other_force: LuaForce
/**
* If the other force was added or removed.
*/
readonly added: boolean
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_force_cease_fire_changed
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called when a new force is created using `game.create_force()`
*
* This is not called when the default forces (`'player'`, `'enemy'`, `'neutral'`) are created as they will always exist.
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_force_created Online documentation}
*/
interface OnForceCreatedEvent extends EventData {
/**
* The newly created force.
*/
readonly force: LuaForce
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_force_created
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called when the a forces friends change.
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_force_friends_changed Online documentation}
*/
interface OnForceFriendsChangedEvent extends EventData {
/**
* The force who's friends changed.
*/
readonly force: LuaForce
/**
* Which force was added or removed.
*/
readonly other_force: LuaForce
/**
* If the other force was added or removed.
*/
readonly added: boolean
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_force_friends_changed
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called when {@link LuaForce#reset LuaForce::reset} is finished.
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_force_reset Online documentation}
*/
interface OnForceResetEvent extends EventData {
readonly force: LuaForce
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_force_reset
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called after two forces have been merged using `game.merge_forces()`.
*
* The source force is invalidated before this event is called and the name can be re-used in this event if desired.
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_forces_merged Online documentation}
*/
interface OnForcesMergedEvent extends EventData {
/**
* The force destroyed.
*/
readonly source_name: string
/**
* The index of the destroyed force.
*/
readonly source_index: uint
/**
* The force entities where reassigned to.
*/
readonly destination: LuaForce
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_forces_merged
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called when two forces are about to be merged using `game.merge_forces()`.
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_forces_merging Online documentation}
*/
interface OnForcesMergingEvent extends EventData {
/**
* The force to be destroyed
*/
readonly source: LuaForce
/**
* The force to reassign entities to.
*/
readonly destination: LuaForce
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_forces_merging
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called when a game is created from a scenario. This is fired for every mod, even when the scenario's save data already includes it. In those cases however, {@link LuaBootstrap#on_init LuaBootstrap::on_init} is not fired.
*
* This event is not fired when the scenario is loaded via the map editor.
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_game_created_from_scenario Online documentation}
*/
interface OnGameCreatedFromScenarioEvent extends EventData {
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_game_created_from_scenario
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called when {@link LuaGuiElement} checked state is changed (related to checkboxes and radio buttons).
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_gui_checked_state_changed Online documentation}
*/
interface OnGuiCheckedStateChangedEvent extends EventData {
/**
* The element whose checked state changed.
*/
readonly element: LuaGuiElement
/**
* The player who did the change.
*/
readonly player_index: PlayerIndex
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_gui_checked_state_changed
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called when {@link LuaGuiElement} is clicked.
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_gui_click Online documentation}
*/
interface OnGuiClickEvent extends EventData {
/**
* The clicked element.
*/
readonly element: LuaGuiElement
/**
* The player who did the clicking.
*/
readonly player_index: PlayerIndex
/**
* The mouse button used if any.
*/
readonly button: defines.mouse_button_type
/**
* The display location of the player's cursor.
*/
readonly cursor_display_location: GuiLocation
/**
* If alt was pressed.
*/
readonly alt: boolean
/**
* If control was pressed.
*/
readonly control: boolean
/**
* If shift was pressed.
*/
readonly shift: boolean
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_gui_click
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called when the player closes the GUI they have open.
*
* This can only be raised when the GUI's player controller is still valid. If a GUI is thus closed due to the player disconnecting, dying, or becoming a spectator in other ways, it won't cause this event to be raised.
*
* It's not advised to open any other GUI during this event because if this is run as a request to open a different GUI the game will force close the new opened GUI without notice to ensure the original requested GUI is opened.
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_gui_closed Online documentation}
*/
interface OnGuiClosedEvent extends EventData {
/**
* The player.
*/
readonly player_index: PlayerIndex
/**
* The GUI type that was open.
*/
readonly gui_type: defines.gui_type
/**
* The entity that was open
*/
readonly entity?: LuaEntity
/**
* The item that was open
*/
readonly item?: LuaItemStack
/**
* The equipment that was open
*/
readonly equipment?: LuaEquipment
/**
* The other player that was open
*/
readonly other_player?: LuaPlayer
/**
* The custom GUI element that was open
*/
readonly element?: LuaGuiElement
/**
* The technology that was automatically selected when opening the research GUI
*/
readonly technology?: LuaTechnology
/**
* The tile position that was open
*/
readonly tile_position?: TilePosition
/**
* The script inventory that was open
*/
readonly inventory?: LuaInventory
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_gui_closed
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called when a {@link LuaGuiElement} is confirmed, for example by pressing Enter in a textfield.
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_gui_confirmed Online documentation}
*/
interface OnGuiConfirmedEvent extends EventData {
/**
* The confirmed element.
*/
readonly element: LuaGuiElement
/**
* The player who did the confirming.
*/
readonly player_index: PlayerIndex
/**
* If alt was pressed.
*/
readonly alt: boolean
/**
* If control was pressed.
*/
readonly control: boolean
/**
* If shift was pressed.
*/
readonly shift: boolean
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_gui_confirmed
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called when {@link LuaGuiElement} element value is changed (related to choose element buttons).
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_gui_elem_changed Online documentation}
*/
interface OnGuiElemChangedEvent extends EventData {
/**
* The element whose element value changed.
*/
readonly element: LuaGuiElement
/**
* The player who did the change.
*/
readonly player_index: PlayerIndex
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_gui_elem_changed
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called when {@link LuaGuiElement} is hovered by the mouse.
*
* Only fired for events whose {@link LuaGuiElement#raise_hover_events LuaGuiElement::raise_hover_events} is `true`.
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_gui_hover Online documentation}
*/
interface OnGuiHoverEvent extends EventData {
/**
* The element that is being hovered over.
*/
readonly element: LuaGuiElement
/**
* The player whose cursor is hovering.
*/
readonly player_index: PlayerIndex
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_gui_hover
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called when the player's cursor leaves a {@link LuaGuiElement} that was previously hovered.
*
* Only fired for events whose {@link LuaGuiElement#raise_hover_events LuaGuiElement::raise_hover_events} is `true`.
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_gui_leave Online documentation}
*/
interface OnGuiLeaveEvent extends EventData {
/**
* The element that was being hovered.
*/
readonly element: LuaGuiElement
/**
* The player whose cursor was hovering.
*/
readonly player_index: PlayerIndex
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_gui_leave
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called when {@link LuaGuiElement} element location is changed (related to frames in `player.gui.screen`).
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_gui_location_changed Online documentation}
*/
interface OnGuiLocationChangedEvent extends EventData {
/**
* The element whose location changed.
*/
readonly element: LuaGuiElement
/**
* The player who did the change.
*/
readonly player_index: PlayerIndex
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_gui_location_changed
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called when the player opens a GUI.
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_gui_opened Online documentation}
*/
interface OnGuiOpenedEvent extends EventData {
/**
* The player.
*/
readonly player_index: PlayerIndex
/**
* The GUI type that was opened.
*/
readonly gui_type: defines.gui_type
/**
* The entity that was opened
*/
readonly entity?: LuaEntity
/**
* The item that was opened
*/
readonly item?: LuaItemStack
/**
* The equipment that was opened
*/
readonly equipment?: LuaEquipment
/**
* The other player that was opened
*/
readonly other_player?: LuaPlayer
/**
* The custom GUI element that was opened
*/
readonly element?: LuaGuiElement
/**
* The script inventory that was opened
*/
readonly inventory?: LuaInventory
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_gui_opened
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called when {@link LuaGuiElement} selected tab is changed (related to tabbed-panes).
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_gui_selected_tab_changed Online documentation}
*/
interface OnGuiSelectedTabChangedEvent extends EventData {
/**
* The tabbed pane whose selected tab changed.
*/
readonly element: LuaGuiElement
/**
* The player who did the change.
*/
readonly player_index: PlayerIndex
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_gui_selected_tab_changed
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called when {@link LuaGuiElement} selection state is changed (related to drop-downs and listboxes).
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_gui_selection_state_changed Online documentation}
*/
interface OnGuiSelectionStateChangedEvent extends EventData {
/**
* The element whose selection state changed.
*/
readonly element: LuaGuiElement
/**
* The player who did the change.
*/
readonly player_index: PlayerIndex
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_gui_selection_state_changed
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called when {@link LuaGuiElement} switch state is changed (related to switches).
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_gui_switch_state_changed Online documentation}
*/
interface OnGuiSwitchStateChangedEvent extends EventData {
/**
* The switch whose switch state changed.
*/
readonly element: LuaGuiElement
/**
* The player who did the change.
*/
readonly player_index: PlayerIndex
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_gui_switch_state_changed
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called when {@link LuaGuiElement} text is changed by the player.
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_gui_text_changed Online documentation}
*/
interface OnGuiTextChangedEvent extends EventData {
/**
* The edited element.
*/
readonly element: LuaGuiElement
/**
* The player who did the edit.
*/
readonly player_index: PlayerIndex
/**
* The new text in the element.
*/
readonly text: string
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_gui_text_changed
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called when {@link LuaGuiElement} slider value is changed (related to the slider element).
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_gui_value_changed Online documentation}
*/
interface OnGuiValueChangedEvent extends EventData {
/**
* The element whose value changed.
*/
readonly element: LuaGuiElement
/**
* The player who did the change.
*/
readonly player_index: PlayerIndex
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_gui_value_changed
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called when a land mine is armed.
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_land_mine_armed Online documentation}
*/
interface OnLandMineArmedEvent extends EventData {
readonly mine: LuaEntity
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_land_mine_armed
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called when a custom {@link import("factorio:prototype").ShortcutPrototype Lua shortcut} is pressed.
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_lua_shortcut Online documentation}
*/
interface OnLuaShortcutEvent extends EventData {
readonly player_index: PlayerIndex
/**
* Shortcut prototype name of the shortcut that was clicked.
*/
readonly prototype_name: string
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_lua_shortcut
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called when an entity is marked for deconstruction with the Deconstruction planner or via script.
*
* Event filter: [LuaEntityMarkedForDeconstructionEventFilter](LuaEntityMarkedForDeconstructionEventFilter]
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_marked_for_deconstruction Online documentation}
*/
interface OnMarkedForDeconstructionEvent extends EventData {
readonly entity: LuaEntity
readonly player_index?: PlayerIndex
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_marked_for_deconstruction
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called when an entity is marked for upgrade with the Upgrade planner or via script.
*
* Event filter: [LuaEntityMarkedForUpgradeEventFilter](LuaEntityMarkedForUpgradeEventFilter]
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_marked_for_upgrade Online documentation}
*/
interface OnMarkedForUpgradeEvent extends EventData {
readonly player_index?: PlayerIndex
readonly entity: LuaEntity
readonly target: LuaEntityPrototype
readonly quality: LuaQualityPrototype
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_marked_for_upgrade
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called after a player purchases some offer from a `market` entity.
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_market_item_purchased Online documentation}
*/
interface OnMarketItemPurchasedEvent extends EventData {
/**
* The player who did the purchasing.
*/
readonly player_index: PlayerIndex
/**
* The market entity.
*/
readonly market: LuaEntity
/**
* The index of the offer purchased.
*/
readonly offer_index: uint
/**
* The amount of offers purchased.
*/
readonly count: uint
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_market_item_purchased
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called when the player uses the 'Open item GUI' control on an item defined with the 'mod-openable' flag
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_mod_item_opened Online documentation}
*/
interface OnModItemOpenedEvent extends EventData {
/**
* The player.
*/
readonly player_index: PlayerIndex
/**
* The item clicked on.
*/
readonly item: LuaItemPrototype
/**
* The item quality clicked on.
*/
readonly quality: LuaQualityPrototype
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_mod_item_opened
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called when {@link LuaGameScript#is_multiplayer LuaGameScript::is_multiplayer} changes to true. May also be raised when it was already true but a game was loaded from a save file and with hosting.
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_multiplayer_init Online documentation}
*/
interface OnMultiplayerInitEvent extends EventData {
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_multiplayer_init
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called after an object is destroyed which was registered with {@link LuaBootstrap#register_on_object_destroyed LuaBootstrap::register_on_object_destroyed} previously.
*
* Depending on when a given object is destroyed, this event will be fired at the end of the current tick or at the end of the next tick. The event's timing is independent of the in-world object being destroyed.
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_object_destroyed Online documentation}
*/
interface OnObjectDestroyedEvent extends EventData {
/**
* The number returned by {@link LuaBootstrap#register_on_object_destroyed register_on_object_destroyed} to uniquely identify this object during this event.
*/
readonly registration_number: RegistrationNumber
/**
* The {@link RegistrationTarget useful identifier} of the object. Same as second value returned by {@link LuaBootstrap#register_on_object_destroyed LuaBootstrap::register_on_object_destroyed}
*/
readonly useful_id: uint64
/**
* Type of the object that was destroyed. Same as third value returned by {@link LuaBootstrap#register_on_object_destroyed LuaBootstrap::register_on_object_destroyed}
*/
readonly type: defines.target_type
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_object_destroyed
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called directly after a permission group is added.
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_permission_group_added Online documentation}
*/
interface OnPermissionGroupAddedEvent extends EventData {
/**
* The player that added the group or `nil` if by a mod.
*/
readonly player_index?: PlayerIndex
/**
* The group added.
*/
readonly group: LuaPermissionGroup
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_permission_group_added
/**
* Tick the event was generated.
*/
readonly tick: uint
}
/**
* Called directly after a permission group is deleted.
* @see {@link https://lua-api.factorio.com/2.0.47/events.html#on_permission_group_deleted Online documentation}
*/
interface OnPermissionGroupDeletedEvent extends EventData {
/**
* The player doing the deletion or `nil` if by a mod.
*/
readonly player_index?: PlayerIndex
/**
* The group that was deleted.
*/
readonly group_name: string
/**
* The group id that was deleted.
*/
readonly id: uint
/**
* Identifier of the event
*/
readonly name: typeof defines.events.on_permission_group_deleted
/**
* Tick the event was generated.
*/
readonly tic