UNPKG

typed-factorio

Version:

Featureful typescript definitions for the Factorio modding api.

874 lines (870 loc) 1.54 MB
// This is an auto-generated file. Do not edit directly! /** @noSelfInFile */ import type { EntityType, EquipmentType, ItemType, PrototypeType } from "factorio:prototype" import type { ActiveMods, CustomInputName } from "factorio:common" /** * @noResolution */ declare module "factorio:runtime" { /** * Collection of settings for overriding default ai behavior. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaAISettings.html Online documentation} */ export interface LuaAISettings { /** * If enabled, units that repeatedly fail to succeed at commands will be destroyed. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaAISettings.html#LuaAISettings.allow_destroy_when_commands_fail Online documentation} */ allow_destroy_when_commands_fail: boolean /** * If enabled, units that have nothing else to do will attempt to return to a spawner. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaAISettings.html#LuaAISettings.allow_try_return_to_spawner Online documentation} */ allow_try_return_to_spawner: boolean /** * If enabled, units will try to separate themselves from nearby friendly units. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaAISettings.html#LuaAISettings.do_separation Online documentation} */ do_separation: boolean /** * Defines how coarse the pathfinder's grid is, where smaller values mean a coarser grid. Defaults to `0`, which equals a resolution of `1x1` tiles, centered on tile centers. Values range from `-8` to `8` inclusive, where each integer increment doubles/halves the resolution. So, a resolution of `-8` equals a grid of `256x256` tiles, and a resolution of `8` equals `1/256` of a tile. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaAISettings.html#LuaAISettings.path_resolution_modifier Online documentation} */ path_resolution_modifier: int8 /** * The number of "slots" that the unit takes up in a unit group. Must be greater than 0. * * If this value is changed after the unit has been added to a group, the exact behavior is undefined. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaAISettings.html#LuaAISettings.size_in_group Online documentation} */ size_in_group: float /** * If enabled, the unit will join attack groups. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaAISettings.html#LuaAISettings.join_attacks Online documentation} */ join_attacks: boolean /** * Is this object valid? This Lua object holds a reference to an object within the game engine. It is possible that the game-engine object is removed whilst a mod still holds the corresponding Lua object. If that happens, the object becomes invalid, i.e. this attribute will be `false`. Mods are advised to check for object validity if any change to the game state might have occurred between the creation of the Lua object and its access. */ readonly valid: boolean /** * The class name of this object. Available even when `valid` is false. For LuaStruct objects it may also be suffixed with a dotted path to a member of the struct. */ readonly object_name: "LuaAISettings" } /** * Control behavior for accumulators. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaAccumulatorControlBehavior.html Online documentation} */ export interface LuaAccumulatorControlBehavior extends LuaControlBehavior { /** * `true` if this accumulator sends its charge percent to circuit network. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaAccumulatorControlBehavior.html#LuaAccumulatorControlBehavior.read_charge Online documentation} */ read_charge: boolean get output_signal(): SignalID | nil set output_signal(value: SignalIDWrite | nil) /** * Is this object valid? This Lua object holds a reference to an object within the game engine. It is possible that the game-engine object is removed whilst a mod still holds the corresponding Lua object. If that happens, the object becomes invalid, i.e. this attribute will be `false`. Mods are advised to check for object validity if any change to the game state might have occurred between the creation of the Lua object and its access. */ readonly valid: boolean /** * The class name of this object. Available even when `valid` is false. For LuaStruct objects it may also be suffixed with a dotted path to a member of the struct. */ readonly object_name: "LuaAccumulatorControlBehavior" } /** * Prototype of a achievement. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaAchievementPrototype.html Online documentation} */ export interface LuaAchievementPrototype extends LuaPrototypeBase { readonly allowed_without_fight: boolean readonly objective_condition?: string readonly amount?: uint readonly limited_to_one_game?: boolean readonly within?: uint readonly to_build?: LuaEntityPrototype readonly surface?: string readonly count?: uint readonly more_than_manually?: boolean readonly dont_build?: LuaEntityPrototype[] readonly excluded?: LuaEntityPrototype[] readonly included?: LuaEntityPrototype[] readonly dont_research?: LuaItemPrototype[] readonly research_with?: LuaItemPrototype[] readonly last_hour_only?: boolean readonly minimum_energy_produced?: double readonly armor?: LuaItemPrototype readonly alternative_armor?: LuaItemPrototype readonly limit_quality?: LuaQualityPrototype readonly damage_type?: LuaDamagePrototype readonly damage_dealer?: LuaEntityPrototype[] readonly to_kill?: LuaEntityPrototype[] readonly personally?: boolean readonly in_vehicle?: boolean readonly type_to_kill?: string readonly not_to_kill?: LuaEntityPrototype readonly type_not_to_kill?: string readonly module?: string[] readonly limit_equip_quality?: LuaQualityPrototype readonly minimum_damage?: float readonly should_survive?: boolean readonly type_of_dealer?: string readonly item_product?: LuaItemPrototype readonly quality?: LuaQualityPrototype readonly fluid_product?: LuaFluidPrototype readonly technology?: LuaTechnologyPrototype readonly research_all?: boolean readonly science_pack?: LuaItemPrototype readonly ammo_type?: LuaItemPrototype readonly minimum_distance?: double readonly to_use?: LuaItemPrototype /** * Is this object valid? This Lua object holds a reference to an object within the game engine. It is possible that the game-engine object is removed whilst a mod still holds the corresponding Lua object. If that happens, the object becomes invalid, i.e. this attribute will be `false`. Mods are advised to check for object validity if any change to the game state might have occurred between the creation of the Lua object and its access. */ readonly valid: boolean /** * The class name of this object. Available even when `valid` is false. For LuaStruct objects it may also be suffixed with a dotted path to a member of the struct. */ readonly object_name: "LuaAchievementPrototype" } /** * Prototype of an Active Trigger. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaActiveTriggerPrototype.html Online documentation} */ export interface LuaActiveTriggerPrototype extends LuaPrototypeBase { /** * The max number of jumps per trigger. default = 5. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaActiveTriggerPrototype.html#LuaActiveTriggerPrototype.max_jumps Online documentation} */ readonly max_jumps: uint /** * The max length of jumps. default = 5. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaActiveTriggerPrototype.html#LuaActiveTriggerPrototype.max_range_per_jump Online documentation} */ readonly max_range_per_jump: double /** * The max distance jumps are allowed to travel away from the original target. default = infinity. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaActiveTriggerPrototype.html#LuaActiveTriggerPrototype.max_range Online documentation} */ readonly max_range: double /** * The tick delay between each jump. 0 = all jumps instantaneous. default = 0. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaActiveTriggerPrototype.html#LuaActiveTriggerPrototype.jump_delay_ticks Online documentation} */ readonly jump_delay_ticks: uint /** * The chance that a new fork will spawn after each jump [0,1]. default = 0. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaActiveTriggerPrototype.html#LuaActiveTriggerPrototype.fork_chance Online documentation} */ readonly fork_chance: double /** * The maximum number of forks that can spawn from a single jump. default = 1. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaActiveTriggerPrototype.html#LuaActiveTriggerPrototype.max_forks_per_jump Online documentation} */ readonly max_forks_per_jump: uint /** * maximum number of forks allowed to spawn for the entire chain. default = infinity. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaActiveTriggerPrototype.html#LuaActiveTriggerPrototype.max_forks Online documentation} */ readonly max_forks: uint /** * Is this object valid? This Lua object holds a reference to an object within the game engine. It is possible that the game-engine object is removed whilst a mod still holds the corresponding Lua object. If that happens, the object becomes invalid, i.e. this attribute will be `false`. Mods are advised to check for object validity if any change to the game state might have occurred between the creation of the Lua object and its access. */ readonly valid: boolean /** * The class name of this object. Available even when `valid` is false. For LuaStruct objects it may also be suffixed with a dotted path to a member of the struct. */ readonly object_name: "LuaActiveTriggerPrototype" } /** * Control behavior for agricultural tower * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaAgriculturalTowerControlBehavior.html Online documentation} */ export interface LuaAgriculturalTowerControlBehavior extends LuaGenericOnOffControlBehavior { /** * `true` if the agricultural tower reads seeds and harvested plants. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaAgriculturalTowerControlBehavior.html#LuaAgriculturalTowerControlBehavior.read_contents Online documentation} */ read_contents: boolean /** * Is this object valid? This Lua object holds a reference to an object within the game engine. It is possible that the game-engine object is removed whilst a mod still holds the corresponding Lua object. If that happens, the object becomes invalid, i.e. this attribute will be `false`. Mods are advised to check for object validity if any change to the game state might have occurred between the creation of the Lua object and its access. */ readonly valid: boolean /** * The class name of this object. Available even when `valid` is false. For LuaStruct objects it may also be suffixed with a dotted path to a member of the struct. */ readonly object_name: "LuaAgriculturalTowerControlBehavior" } /** * Airborne pollutant prototype. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaAirbornePollutantPrototype.html Online documentation} */ export interface LuaAirbornePollutantPrototype extends LuaPrototypeBase { readonly chart_color: Color readonly affects_evolution: boolean readonly damages_trees: boolean readonly localised_name_with_amount_key: string /** * Is this object valid? This Lua object holds a reference to an object within the game engine. It is possible that the game-engine object is removed whilst a mod still holds the corresponding Lua object. If that happens, the object becomes invalid, i.e. this attribute will be `false`. Mods are advised to check for object validity if any change to the game state might have occurred between the creation of the Lua object and its access. */ readonly valid: boolean /** * The class name of this object. Available even when `valid` is false. For LuaStruct objects it may also be suffixed with a dotted path to a member of the struct. */ readonly object_name: "LuaAirbornePollutantPrototype" } /** * Prototype of a ammo category. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaAmmoCategoryPrototype.html Online documentation} */ export interface LuaAmmoCategoryPrototype extends LuaPrototypeBase { readonly bonus_gui_order: string /** * An alternative prototype that will be used to display info about this prototype in Factoriopedia. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaAmmoCategoryPrototype.html#LuaAmmoCategoryPrototype.factoriopedia_alternative Online documentation} */ readonly factoriopedia_alternative?: LuaAmmoCategoryPrototype /** * Is this object valid? This Lua object holds a reference to an object within the game engine. It is possible that the game-engine object is removed whilst a mod still holds the corresponding Lua object. If that happens, the object becomes invalid, i.e. this attribute will be `false`. Mods are advised to check for object validity if any change to the game state might have occurred between the creation of the Lua object and its access. */ readonly valid: boolean /** * The class name of this object. Available even when `valid` is false. For LuaStruct objects it may also be suffixed with a dotted path to a member of the struct. */ readonly object_name: "LuaAmmoCategoryPrototype" } /** * Control behavior for arithmetic combinators. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaArithmeticCombinatorControlBehavior.html Online documentation} */ export interface LuaArithmeticCombinatorControlBehavior extends LuaCombinatorControlBehavior { /** * This arithmetic combinator's parameters. Writing `nil` clears the combinator's parameters. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaArithmeticCombinatorControlBehavior.html#LuaArithmeticCombinatorControlBehavior.parameters Online documentation} */ get parameters(): ArithmeticCombinatorParameters | nil set parameters(value: ArithmeticCombinatorParametersWrite | nil) /** * Is this object valid? This Lua object holds a reference to an object within the game engine. It is possible that the game-engine object is removed whilst a mod still holds the corresponding Lua object. If that happens, the object becomes invalid, i.e. this attribute will be `false`. Mods are advised to check for object validity if any change to the game state might have occurred between the creation of the Lua object and its access. */ readonly valid: boolean /** * The class name of this object. Available even when `valid` is false. For LuaStruct objects it may also be suffixed with a dotted path to a member of the struct. */ readonly object_name: "LuaArithmeticCombinatorControlBehavior" } /** * Control behavior for artillery turrets. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaArtilleryTurretControlBehavior.html Online documentation} */ export interface LuaArtilleryTurretControlBehavior extends LuaGenericOnOffControlBehavior { /** * `true` if the turret will send the ammunition or fluid it contains to the circuit network. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaArtilleryTurretControlBehavior.html#LuaArtilleryTurretControlBehavior.read_ammo Online documentation} */ read_ammo: boolean /** * Is this object valid? This Lua object holds a reference to an object within the game engine. It is possible that the game-engine object is removed whilst a mod still holds the corresponding Lua object. If that happens, the object becomes invalid, i.e. this attribute will be `false`. Mods are advised to check for object validity if any change to the game state might have occurred between the creation of the Lua object and its access. */ readonly valid: boolean /** * The class name of this object. Available even when `valid` is false. For LuaStruct objects it may also be suffixed with a dotted path to a member of the struct. */ readonly object_name: "LuaArtilleryTurretControlBehavior" } /** * Control behavior for assembling machines. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaAssemblingMachineControlBehavior.html Online documentation} */ export interface LuaAssemblingMachineControlBehavior extends LuaGenericOnOffControlBehavior { /** * `true` if the assembling machine sets its recipe from the circuit network. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaAssemblingMachineControlBehavior.html#LuaAssemblingMachineControlBehavior.circuit_set_recipe Online documentation} */ circuit_set_recipe: boolean /** * `true` if the assembling machine reads its ingredients contents, product contents, materials in crafting and trash inventories. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaAssemblingMachineControlBehavior.html#LuaAssemblingMachineControlBehavior.circuit_read_contents Online documentation} */ circuit_read_contents: boolean /** * `true` if the read contents should include items in crafting. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaAssemblingMachineControlBehavior.html#LuaAssemblingMachineControlBehavior.include_in_crafting Online documentation} */ include_in_crafting: boolean /** * `true` if the read contents should include fuel (content of energy source) * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaAssemblingMachineControlBehavior.html#LuaAssemblingMachineControlBehavior.include_fuel Online documentation} */ include_fuel: boolean /** * `true` if the assembling machine outputs ingredients of current recipe as a signals to circuit network. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaAssemblingMachineControlBehavior.html#LuaAssemblingMachineControlBehavior.circuit_read_ingredients Online documentation} */ circuit_read_ingredients: boolean /** * `true` if the the assembling machine sends a signal when the recipe finishes. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaAssemblingMachineControlBehavior.html#LuaAssemblingMachineControlBehavior.circuit_read_recipe_finished Online documentation} */ circuit_read_recipe_finished: boolean /** * The signal sent when the assembling machine finishes a recipe. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaAssemblingMachineControlBehavior.html#LuaAssemblingMachineControlBehavior.circuit_recipe_finished_signal Online documentation} */ get circuit_recipe_finished_signal(): SignalID | nil set circuit_recipe_finished_signal(value: SignalIDWrite | nil) /** * `true` if the the assembling machine sends a signal when it is working. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaAssemblingMachineControlBehavior.html#LuaAssemblingMachineControlBehavior.circuit_read_working Online documentation} */ circuit_read_working: boolean /** * The signal sent when the assembling machine is working. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaAssemblingMachineControlBehavior.html#LuaAssemblingMachineControlBehavior.circuit_working_signal Online documentation} */ get circuit_working_signal(): SignalID | nil set circuit_working_signal(value: SignalIDWrite | nil) /** * Is this object valid? This Lua object holds a reference to an object within the game engine. It is possible that the game-engine object is removed whilst a mod still holds the corresponding Lua object. If that happens, the object becomes invalid, i.e. this attribute will be `false`. Mods are advised to check for object validity if any change to the game state might have occurred between the creation of the Lua object and its access. */ readonly valid: boolean /** * The class name of this object. Available even when `valid` is false. For LuaStruct objects it may also be suffixed with a dotted path to a member of the struct. */ readonly object_name: "LuaAssemblingMachineControlBehavior" } /** * Prototype of an asteroid chunk. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaAsteroidChunkPrototype.html Online documentation} */ export interface LuaAsteroidChunkPrototype extends LuaPrototypeBase { readonly mineable_properties: MineableProperties readonly hide_from_signal_gui: boolean readonly item_signal_alias?: LuaItemPrototype /** * An alternative prototype that will be used to display info about this prototype in Factoriopedia. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaAsteroidChunkPrototype.html#LuaAsteroidChunkPrototype.factoriopedia_alternative Online documentation} */ readonly factoriopedia_alternative?: LuaAsteroidChunkPrototype /** * Is this object valid? This Lua object holds a reference to an object within the game engine. It is possible that the game-engine object is removed whilst a mod still holds the corresponding Lua object. If that happens, the object becomes invalid, i.e. this attribute will be `false`. Mods are advised to check for object validity if any change to the game state might have occurred between the creation of the Lua object and its access. */ readonly valid: boolean /** * The class name of this object. Available even when `valid` is false. For LuaStruct objects it may also be suffixed with a dotted path to a member of the struct. */ readonly object_name: "LuaAsteroidChunkPrototype" } /** * Control behavior for asteroid collectors. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaAsteroidCollectorControlBehavior.html Online documentation} */ export interface LuaAsteroidCollectorControlBehavior extends LuaGenericOnOffControlBehavior { /** * `true` if this asteroid collector has filters set from circuit network * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaAsteroidCollectorControlBehavior.html#LuaAsteroidCollectorControlBehavior.set_filter Online documentation} */ set_filter: boolean /** * `true` if this asteroid collector reads its content and sends it to a circuit network * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaAsteroidCollectorControlBehavior.html#LuaAsteroidCollectorControlBehavior.read_content Online documentation} */ read_content: boolean /** * `true` if read contents should include content of hands (items that were captured but are not yet in the asteroid collector's main inventory). * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaAsteroidCollectorControlBehavior.html#LuaAsteroidCollectorControlBehavior.include_hands Online documentation} */ include_hands: boolean /** * Is this object valid? This Lua object holds a reference to an object within the game engine. It is possible that the game-engine object is removed whilst a mod still holds the corresponding Lua object. If that happens, the object becomes invalid, i.e. this attribute will be `false`. Mods are advised to check for object validity if any change to the game state might have occurred between the creation of the Lua object and its access. */ readonly valid: boolean /** * The class name of this object. Available even when `valid` is false. For LuaStruct objects it may also be suffixed with a dotted path to a member of the struct. */ readonly object_name: "LuaAsteroidCollectorControlBehavior" } /** * Prototype of an autoplace control. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaAutoplaceControlPrototype.html Online documentation} */ export interface LuaAutoplaceControlPrototype extends LuaPrototypeBase { readonly richness: boolean readonly can_be_disabled: boolean /** * Category name of this prototype. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaAutoplaceControlPrototype.html#LuaAutoplaceControlPrototype.category Online documentation} */ readonly category: "resource" | "terrain" | "cliff" | "enemy" /** * Is this object valid? This Lua object holds a reference to an object within the game engine. It is possible that the game-engine object is removed whilst a mod still holds the corresponding Lua object. If that happens, the object becomes invalid, i.e. this attribute will be `false`. Mods are advised to check for object validity if any change to the game state might have occurred between the creation of the Lua object and its access. */ readonly valid: boolean /** * The class name of this object. Available even when `valid` is false. For LuaStruct objects it may also be suffixed with a dotted path to a member of the struct. */ readonly object_name: "LuaAutoplaceControlPrototype" } /** * Entry point for registering event handlers. It is accessible through the global object named `script`. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaBootstrap.html Online documentation} * @noSelf */ export interface LuaBootstrap { /** * Register a function to be run on mod initialization. * * This is only called when a new save game is created or when a save file is loaded that previously didn't contain the mod. During it, the mod gets the chance to set up initial values that it will use for its lifetime. It has full access to {@link LuaGameScript} and the {@linkplain https://lua-api.factorio.com/2.0.47/auxiliary/storage.html storage} table and can change anything about them that it deems appropriate. No other events will be raised for the mod until it has finished this step. * * For more context, refer to the {@linkplain https://lua-api.factorio.com/2.0.47/auxiliary/data-lifecycle.html Data Lifecycle} page. * @param handler The handler for this event. Passing `nil` will unregister it. * @example * -- Initialize a `players` table in `storage` for later use * script.on_init(function() * storage.players = {} * end) * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaBootstrap.html#LuaBootstrap.on_init Online documentation} */ on_init(handler: (() => void) | nil): void /** * Register a function to be run on save load. This is only called for mods that have been part of the save previously, or for players connecting to a running multiplayer session. * * It gives the mod the opportunity to rectify potential differences in local state introduced by the save/load cycle. Doing anything other than the following three will lead to desyncs, breaking multiplayer and replay functionality. Access to {@link LuaGameScript} is not available. The {@linkplain https://lua-api.factorio.com/2.0.47/auxiliary/storage.html storage} table can be accessed and is safe to read from, but not write to, as doing so will lead to an error. * * The only legitimate uses of this event are these: * * - Re-setup {@linkplain https://www.lua.org/pil/13.html metatables} as they are not persisted through the save/load cycle. * * - Re-setup conditional event handlers, meaning subscribing to an event only when some condition is met to save processing time. * * - Create local references to data stored in the {@linkplain https://lua-api.factorio.com/2.0.47/auxiliary/storage.html storage} table. * * For all other purposes, {@link LuaBootstrap#on_init LuaBootstrap::on_init}, {@link LuaBootstrap#on_configuration_changed LuaBootstrap::on_configuration_changed} or {@linkplain https://lua-api.factorio.com/2.0.47/auxiliary/migrations.html migrations} should be used instead. * * For more context, refer to the {@linkplain https://lua-api.factorio.com/2.0.47/auxiliary/data-lifecycle.html Data Lifecycle} page. * @param handler The handler for this event. Passing `nil` will unregister it. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaBootstrap.html#LuaBootstrap.on_load Online documentation} */ on_load(handler: (() => void) | nil): void /** * Register a function to be run when mod configuration changes. * * This is called when the game version or any mod version changed, when any mod was added or removed, when a startup setting has changed, when any prototypes have been added or removed, or when a migration was applied. It allows the mod to make any changes it deems appropriate to both the data structures in its {@linkplain https://lua-api.factorio.com/2.0.47/auxiliary/storage.html storage} table or to the game state through {@link LuaGameScript}. * * For more context, refer to the {@linkplain https://lua-api.factorio.com/2.0.47/auxiliary/data-lifecycle.html Data Lifecycle} page. * @param handler The handler for this event. Passing `nil` will unregister it. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaBootstrap.html#LuaBootstrap.on_configuration_changed Online documentation} */ on_configuration_changed(handler: ((arg1: ConfigurationChangedData) => void) | nil): void /** * Register a handler to run on the specified event(s). Each mod can only register once for every event, as any additional registration will overwrite the previous one. This holds true even if different filters are used for subsequent registrations. * @param event The event(s) or custom-input to invoke the handler on. * @param handler The handler for this event. Passing `nil` will unregister it. * @param filters The filters for this event. Can only be used when registering for individual events. * @example * -- Register for the on_tick event to print the current tick to console each tick * script.on_event(defines.events.on_tick, * function(event) game.print(event.tick) end) * @example * -- Register for the on_built_entity event, limiting it to only be received when a `"fast-inserter"` is built * script.on_event(defines.events.on_built_entity, * function(event) game.print("Gotta go fast!") end, * {{filter = "name", name = "fast-inserter"}}) * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaBootstrap.html#LuaBootstrap.on_event Online documentation} */ on_event<E extends EventId<any, table>>( event: E, handler: ((data: E["_eventData"]) => void) | nil, filters?: E["_filter"][], ): void on_event<E extends EventId<any>>(event: E | readonly E[], f: ((data: E["_eventData"]) => void) | nil): void on_event(event: CustomInputName | LuaCustomInputPrototype, f: ((data: CustomInputEvent) => void) | nil): void on_event<E extends LuaEventType>(event: E, f: ((data: EventTypeOf<E>) => void) | nil): void /** * Register a handler to run every nth-tick(s). When the game is on tick 0 it will trigger all registered handlers. * @param tick The nth-tick(s) to invoke the handler on. Passing `nil` as the only parameter will unregister all nth-tick handlers. * @param handler The handler to run. Passing `nil` will unregister it for the provided nth-tick(s). * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaBootstrap.html#LuaBootstrap.on_nth_tick Online documentation} */ on_nth_tick(tick: uint | readonly uint[] | nil, handler: ((arg1: NthTickEventData) => void) | nil): void /** * Registers an object so that after it's destroyed, {@link OnObjectDestroyedEvent on_object_destroyed} is called. * * Once an object is registered, it stays registered until it is actually destroyed, even through save/load cycles. The registration is global across all mods, meaning once one mod registers an object, all mods listening to {@link OnObjectDestroyedEvent on_object_destroyed} will receive the event when it is destroyed. Registering the same object multiple times will still only fire the destruction event once, and will return the same registration number. * * Depending on when a given object is destroyed, {@link OnObjectDestroyedEvent on_object_destroyed} will either be fired at the end of the current tick or at the end of the next tick. * @param object The object to register. * @returns The registration number. It is used to identify the object in the {@link OnObjectDestroyedEvent on_object_destroyed} event. * @returns The {@link RegistrationTarget useful identifier} of the object if it has one. This identifier is specific to the object type, for example for trains it is the value {@link LuaTrain#id LuaTrain::id}. * @returns Type of the target object. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaBootstrap.html#LuaBootstrap.register_on_object_destroyed Online documentation} */ register_on_object_destroyed(object: RegistrationTarget): LuaMultiReturn<[uint64, uint64, defines.target_type]> /** * Register a metatable to have linkage recorded and restored when saving/loading. * * The metatable itself will not be saved. Instead, only the linkage to a registered metatable is saved, and the metatable registered under that name will be used when loading the table. * * `register_metatable()` can not be used in the console, in event listeners or during a `remote.call()`. * * The metatable first needs to be defined in the mod's root scope, then registered using this method. From then on, it will be properly restored for tables in {@linkplain https://lua-api.factorio.com/2.0.47/auxiliary/storage.html storage}. * * ``` * local metatable = * { * __index = function(key) * return "no value for key " .. key * end * } * script.register_metatable("my_metatable", metatable) * ``` * * This previously defined `metatable` can then be set on any table as usual: * * ``` * local table = {key="value"} * setmetatable(table, metatable) * ``` * @param name The name of this metatable. Names must be unique per mod. * @param metatable The metatable to register. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaBootstrap.html#LuaBootstrap.register_metatable Online documentation} */ register_metatable(name: string, metatable: table): void /** * Generate a new, unique event ID that can be used to raise custom events with {@link LuaBootstrap#raise_event LuaBootstrap::raise_event}. * @returns The newly generated event ID. This will be a new value that does not correspond to any named entry in defines.events. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaBootstrap.html#LuaBootstrap.generate_event_name Online documentation} */ generate_event_name<T extends table>(): CustomEventId<T> /** * Converts LuaEventType into related value of defines.events. Value will be provided also if event was not given a constant inside of defines.events. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaBootstrap.html#LuaBootstrap.get_event_id Online documentation} */ get_event_id<E extends EventId<any, any>>(event: E): E get_event_id<E extends LuaEventType>(event: E): EventId<EventTypeOf<E>> /** * Find the event handler for an event. * @param event The event identifier to get a handler for. * @returns Reference to the function currently registered as the handler, if it was found. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaBootstrap.html#LuaBootstrap.get_event_handler Online documentation} */ get_event_handler<E extends EventId<any>>(event: E): (data: E["_eventData"]) => void | nil get_event_handler(event: CustomInputName | LuaCustomInputPrototype): (data: CustomInputEvent) => void | nil get_event_handler<E extends LuaEventType>(event: E): (data: EventTypeOf<E>) => void | nil /** * Gets the mod event order as a string. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaBootstrap.html#LuaBootstrap.get_event_order Online documentation} */ get_event_order(): string /** * Sets the filters for the given event. The filters are only retained when set after the actual event registration, because registering for an event with different or no filters will overwrite previously set ones. * * Limit the {@link OnMarkedForDeconstructionEvent on_marked_for_deconstruction} event to only be received when a non-ghost entity is marked for deconstruction. * * ``` * script.set_event_filter(defines.events.on_marked_for_deconstruction, {{filter = "ghost", invert = true}}) * ``` * * Limit the {@link OnBuiltEntityEvent on_built_entity} event to only be received when either a `unit` or a `unit-spawner` is built. * * ``` * script.set_event_filter(defines.events.on_built_entity, {{filter = "type", type = "unit"}, {filter = "type", type = "unit-spawner"}}) * ``` * * Limit the {@link OnEntityDamagedEvent on_entity_damaged} event to only be received when a `rail` is damaged by an `acid` attack. * * ``` * script.set_event_filter(defines.events.on_entity_damaged, {{filter = "rail"}, {filter = "damage-type", type = "acid", mode = "and"}}) * ``` * @param event ID of the event to filter. * @param filters The filters or `nil` to clear them. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaBootstrap.html#LuaBootstrap.set_event_filter Online documentation} */ set_event_filter<E extends EventId<any, table>>(event: E, filters: E["_filter"][] | nil): void /** * Gets the filters for the given event. * @param event ID of the event to get. * @returns The filters or `nil` if none are defined. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaBootstrap.html#LuaBootstrap.get_event_filter Online documentation} */ get_event_filter<E extends EventId<any, table>>(event: E): E["_filter"][] | nil /** * Raise an event. Only events generated with {@link LuaBootstrap#generate_event_name LuaBootstrap::generate_event_name} and the following can be raised: * * {@link https://lua-api.factorio.com/2.0.47/classes/LuaBootstrap.html#LuaBootstrap.raise_event > Events that can be raised manually:} * @param event ID or name of the event to raise. * @param data Table with extra data that will be passed to the event handler. Any invalid LuaObjects will silently stop the event from being raised. * @example * -- Raise the on_console_chat event with the desired message 'from' the first player * local data = {player_index = 1, message = "Hello friends!"} * script.raise_event(defines.events.on_console_chat, data) * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaBootstrap.html#LuaBootstrap.raise_event Online documentation} */ raise_event<E extends RaiseableEvents | CustomEventId<any>>( event: E, data: Omit<E["_eventData"], keyof EventData>, ): void /** * ## Raised events * - {@link OnConsoleChatEvent on_console_chat} _instantly_ Raised with the provided arguments. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaBootstrap.html#LuaBootstrap.raise_console_chat Online documentation} */ raise_console_chat(params: { /** * The player doing the chatting. */ readonly player_index: PlayerIndex /** * The chat message to send. */ readonly message: string }): void /** * ## Raised events * - {@link OnPlayerCraftedItemEvent on_player_crafted_item} _instantly_ Raised with the provided arguments. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaBootstrap.html#LuaBootstrap.raise_player_crafted_item Online documentation} */ raise_player_crafted_item(params: { /** * The item that has been crafted. */ readonly item_stack: LuaItemStack /** * The player doing the crafting. */ readonly player_index: PlayerIndex /** * The recipe used to craft this item. */ readonly recipe: RecipeID }): void /** * ## Raised events * - {@link OnPlayerFastTransferredEvent on_player_fast_transferred} _instantly_ Raised with the provided arguments. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaBootstrap.html#LuaBootstrap.raise_player_fast_transferred Online documentation} */ raise_player_fast_transferred(params: { /** * The player transferred from or to. */ readonly player_index: PlayerIndex /** * The entity transferred from or to. */ readonly entity: LuaEntity /** * Whether the transfer was from player to entity. If `false`, the transfer was from entity to player. */ readonly from_player: boolean /** * Whether the transfer was a split action (half stack). */ readonly is_split: boolean }): void /** * ## Raised events * - {@link OnBiterBaseBuiltEvent on_biter_base_built} _instantly_ Raised with the provided arguments. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaBootstrap.html#LuaBootstrap.raise_biter_base_built Online documentation} */ raise_biter_base_built(params: { /** * The entity that was built. */ readonly entity: LuaEntity }): void /** * ## Raised events * - {@link OnMarketItemPurchasedEvent on_market_item_purchased} _instantly_ Raised with the provided arguments. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaBootstrap.html#LuaBootstrap.raise_market_item_purchased Online documentation} */ raise_market_item_purchased(params: { /** * 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 }): void /** * ## Raised events * - {@link ScriptRaisedBuiltEvent script_raised_built} _instantly_ Raised with the provided arguments. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaBootstrap.html#LuaBootstrap.raise_script_built Online documentation} */ raise_script_built(params: { /** * The entity that has been built. */ readonly entity: LuaEntity }): void /** * ## Raised events * - {@link ScriptRaisedDestroyEvent script_raised_destroy} _instantly_ Raised with the provided arguments. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaBootstrap.html#LuaBootstrap.raise_script_destroy Online documentation} */ raise_script_destroy(params: { /** * The entity that was destroyed. */ readonly entity: LuaEntity }): void /** * ## Raised events * - {@link ScriptRaisedReviveEvent script_raised_revive} _instantly_ Raised with the provided arguments. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaBootstrap.html#LuaBootstrap.raise_script_revive Online documentation} */ raise_script_revive(params: { /** * The entity that was revived. */ readonly entity: LuaEntity /** * The tags associated with this entity, if any. */ readonly tags?: Tags }): void /** * ## Raised events * - {@link ScriptRaisedTeleportedEvent script_raised_teleported} _instantly_ Raised with the provided arguments. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaBootstrap.html#LuaBootstrap.raise_script_teleported Online documentation} */ raise_script_teleported(params: { /** * The entity that was teleported. */ readonly entity: LuaEntity /** * The entity's surface before the teleportation. */ readonly old_surface_index: uint8 /** * The entity's position before the teleportation. */ readonly old_position: MapPosition | MapPositionArray }): void /** * ## Raised events * - {@link ScriptRaisedSetTilesEvent script_raised_set_tiles} _instantly_ Raised with the provided arguments. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaBootstrap.html#LuaBootstrap.raise_script_set_tiles Online documentation} */ raise_script_set_tiles(params: { /** * The surface whose tiles have been changed. */ readonly surface_index: SurfaceIndex /** * The tiles that have been changed. */ readonly tiles: readonly TileWrite[] }): void /** * The name of the mod from the environment this is used in. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaBootstrap.html#LuaBootstrap.mod_name Online documentation} */ readonly mod_name: string /** * Information about the currently running scenario/campaign/tutorial. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaBootstrap.html#LuaBootstrap.level Online documentation} */ readonly level: { /** * Is this level a simulation? (The main menu and 'Tips and tricks' use simulations) */ readonly is_simulation?: boolean /** * Is this level a tutorial? */ readonly is_tutorial?: boolean /** * The campaign name if any. */ readonly campaign_name?: string /** * The level name. */ readonly level_name: string /** * The mod name if any. */ readonly mod_name?: string } /** * A dictionary listing the names of all currently active mods and mapping them to their version. * @example * -- This will print the names and versions of all active mods to the console. * for name, version in pairs(script.active_mods) do * game.print(name .. " version " .. version) * end * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaBootstrap.html#LuaBootstrap.active_mods Online documentation} */ readonly active_mods: ActiveMods /** * A dictionary of feature flags mapping to whether they are enabled. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaBootstrap.html#LuaBootstrap.feature_flags Online documentation} */ readonly feature_flags: { readonly quality: boolean readonly rail_bridges: boolean readonly space_travel: boolean readonly spoiling: boolean readonly freezing: boolean readonly segmented_units: boolean readonly expansion_shaders: boolean } /** * The class name of this object. Available even when `valid` is false. For LuaStruct objects it may also be suffixed with a dotted path to a member of the struct. */ readonly object_name: "LuaBootstrap" } /** * A reference to the burner energy source owned by a specific {@link LuaEntity} or {@link LuaEquipment}. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaBurner.html Online documentation} */ export interface LuaBurner { /** * The owner of this burner energy source * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaBurner.html#LuaBurner.owner Online documentation} */ readonly owner: LuaEntity | LuaEquipment /** * The fuel inventory. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaBurner.html#LuaBurner.inventory Online documentation} */ readonly inventory: LuaInventory /** * The burnt result inventory. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaBurner.html#LuaBurner.burnt_result_inventory Online documentation} */ readonly burnt_result_inventory: LuaInventory /** * The current heat (energy) stored in this burner. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaBurner.html#LuaBurner.heat Online documentation} */ heat: double /** * The maximum heat (maximum energy) that this burner can store. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaBurner.html#LuaBurner.heat_capacity Online documentation} */ readonly heat_capacity: double /** * The amount of energy left in the currently-burning fuel item. * * Writing to this will silently do nothing if there's no {@link LuaBurner#currently_burning LuaBurner::currently_burning} set. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaBurner.html#LuaBurner.remaining_burning_fuel Online documentation} */ remaining_burning_fuel: double /** * The currently burning item. Writing `nil` will void the currently burning item without producing a {@link LuaBurner#burnt_result LuaBurner::burnt_result}. * * Writing to this automatically handles correcting {@link LuaBurner#remaining_burning_fuel LuaBurner::remaining_burning_fuel}. * @see {@link https://lua-api.factorio.com/2.0.47/classes/LuaBurner.html#LuaBurner.currently_burning Online docum