typed-factorio
Version:
Featureful typescript definitions for the Factorio modding api.
921 lines (916 loc) • 1.4 MB
TypeScript
// This is an auto-generated file. Do not edit directly!
/** @noSelfInFile */
import type { EntityType, EquipmentType, ItemType, PrototypeMap } from "factorio:prototype"
import type { ActiveMods, CustomInputName } from "factorio:common"
import type { SettingsPrototypeMap } from "factorio:settings"
/**
* @noResolution
*/
declare module "factorio:runtime" {
/**
* Collection of settings for overriding default ai behavior.
* @see {@link https://lua-api.factorio.com/1.1.110/classes/LuaAISettings.html Online documentation}
* @noSelf
*/
export interface LuaAISettings {
/**
* All methods and properties that this object supports.
* @see {@link https://lua-api.factorio.com/1.1.110/classes/LuaAISettings.html#LuaAISettings.help Online documentation}
*/
help(): string
/**
* If enabled, units that repeatedly fail to succeed at commands will be destroyed.
* @see {@link https://lua-api.factorio.com/1.1.110/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/1.1.110/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/1.1.110/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/1.1.110/classes/LuaAISettings.html#LuaAISettings.path_resolution_modifier Online documentation}
*/
path_resolution_modifier: int8
/**
* 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/1.1.110/classes/LuaAccumulatorControlBehavior.html Online documentation}
* @noSelf
*/
export interface LuaAccumulatorControlBehavior extends LuaControlBehavior {
/**
* All methods and properties that this object supports.
* @see {@link https://lua-api.factorio.com/1.1.110/classes/LuaAccumulatorControlBehavior.html#LuaAccumulatorControlBehavior.help Online documentation}
*/
help(): string
output_signal: SignalID
/**
* 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/1.1.110/classes/LuaAchievementPrototype.html Online documentation}
* @noSelf
*/
export interface LuaAchievementPrototype {
/**
* All methods and properties that this object supports.
* @see {@link https://lua-api.factorio.com/1.1.110/classes/LuaAchievementPrototype.html#LuaAchievementPrototype.help Online documentation}
*/
help(): string
/**
* Name of this prototype.
* @see {@link https://lua-api.factorio.com/1.1.110/classes/LuaAchievementPrototype.html#LuaAchievementPrototype.name Online documentation}
*/
readonly name: string
/**
* The string used to alphabetically sort these prototypes. It is a simple string that has no additional semantic meaning.
* @see {@link https://lua-api.factorio.com/1.1.110/classes/LuaAchievementPrototype.html#LuaAchievementPrototype.order Online documentation}
*/
readonly order: string
readonly localised_name: LocalisedString
readonly localised_description: LocalisedString
readonly allowed_without_fight: boolean
readonly hidden: 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: "LuaAchievementPrototype"
}
/**
* Prototype of a ammo category.
* @see {@link https://lua-api.factorio.com/1.1.110/classes/LuaAmmoCategoryPrototype.html Online documentation}
* @noSelf
*/
export interface LuaAmmoCategoryPrototype {
/**
* All methods and properties that this object supports.
* @see {@link https://lua-api.factorio.com/1.1.110/classes/LuaAmmoCategoryPrototype.html#LuaAmmoCategoryPrototype.help Online documentation}
*/
help(): string
/**
* Name of this prototype.
* @see {@link https://lua-api.factorio.com/1.1.110/classes/LuaAmmoCategoryPrototype.html#LuaAmmoCategoryPrototype.name Online documentation}
*/
readonly name: string
/**
* The string used to alphabetically sort these prototypes. It is a simple string that has no additional semantic meaning.
* @see {@link https://lua-api.factorio.com/1.1.110/classes/LuaAmmoCategoryPrototype.html#LuaAmmoCategoryPrototype.order Online documentation}
*/
readonly order: string
readonly localised_name: LocalisedString
readonly localised_description: LocalisedString
readonly bonus_gui_order: 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: "LuaAmmoCategoryPrototype"
}
/**
* Control behavior for arithmetic combinators.
* @see {@link https://lua-api.factorio.com/1.1.110/classes/LuaArithmeticCombinatorControlBehavior.html Online documentation}
* @noSelf
*/
export interface LuaArithmeticCombinatorControlBehavior extends LuaCombinatorControlBehavior {
/**
* All methods and properties that this object supports.
* @see {@link https://lua-api.factorio.com/1.1.110/classes/LuaArithmeticCombinatorControlBehavior.html#LuaArithmeticCombinatorControlBehavior.help Online documentation}
*/
help(): string
/**
* This arithmetic combinator's parameters.
*
* Writing `nil` clears the combinator's parameters.
* @see {@link https://lua-api.factorio.com/1.1.110/classes/LuaArithmeticCombinatorControlBehavior.html#LuaArithmeticCombinatorControlBehavior.parameters Online documentation}
*/
parameters: ArithmeticCombinatorParameters | 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"
}
/**
* Prototype of an autoplace control.
* @see {@link https://lua-api.factorio.com/1.1.110/classes/LuaAutoplaceControlPrototype.html Online documentation}
* @noSelf
*/
export interface LuaAutoplaceControlPrototype {
/**
* All methods and properties that this object supports.
* @see {@link https://lua-api.factorio.com/1.1.110/classes/LuaAutoplaceControlPrototype.html#LuaAutoplaceControlPrototype.help Online documentation}
*/
help(): string
/**
* Name of this prototype.
* @see {@link https://lua-api.factorio.com/1.1.110/classes/LuaAutoplaceControlPrototype.html#LuaAutoplaceControlPrototype.name Online documentation}
*/
readonly name: string
/**
* The string used to alphabetically sort these prototypes. It is a simple string that has no additional semantic meaning.
* @see {@link https://lua-api.factorio.com/1.1.110/classes/LuaAutoplaceControlPrototype.html#LuaAutoplaceControlPrototype.order Online documentation}
*/
readonly order: string
readonly localised_name: LocalisedString
readonly localised_description: LocalisedString
readonly richness: boolean
readonly can_be_disabled: boolean
readonly control_order: string
/**
* Category name of this prototype.
* @see {@link https://lua-api.factorio.com/1.1.110/classes/LuaAutoplaceControlPrototype.html#LuaAutoplaceControlPrototype.category Online documentation}
*/
readonly category: 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: "LuaAutoplaceControlPrototype"
}
/**
* Entry point for registering event handlers. It is accessible through the global object named `script`.
* @see {@link https://lua-api.factorio.com/1.1.110/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/1.1.110/global.html global} 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/1.1.110/data-lifecycle.html Data Lifecycle} page.
* @param handler The handler for this event. Passing `nil` will unregister it.
* @example
* -- Initialize a `players` table in `global` for later use
* script.on_init(function()
* global.players = {}
* end)
* @see {@link https://lua-api.factorio.com/1.1.110/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/1.1.110/global.html global} 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/1.1.110/global.html global} 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/1.1.110/migrations.html migrations} should be used instead.
*
* For more context, refer to the {@linkplain https://lua-api.factorio.com/1.1.110/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/1.1.110/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/1.1.110/global.html global} table or to the game state through {@link LuaGameScript}.
*
* For more context, refer to the {@linkplain https://lua-api.factorio.com/1.1.110/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/1.1.110/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/1.1.110/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 | E[], f: ((data: E["_eventData"]) => void) | nil): void
on_event(event: CustomInputName, f: ((data: CustomInputEvent) => 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/1.1.110/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 entity so that after it's destroyed, {@link OnEntityDestroyedEvent on_entity_destroyed} is called.
*
* Once an entity 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 entity, all mods listening to {@link OnEntityDestroyedEvent on_entity_destroyed} will receive the event when it is destroyed. Registering the same entity multiple times will still only fire the destruction event once, and will return the same registration number.
*
* Depending on when a given entity is destroyed, {@link OnEntityDestroyedEvent on_entity_destroyed} will either be fired at the end of the current tick or at the end of the next tick.
* @param entity The entity to register.
* @returns The registration number. It is used to identify the entity in the {@link OnEntityDestroyedEvent on_entity_destroyed} event.
* @see {@link https://lua-api.factorio.com/1.1.110/classes/LuaBootstrap.html#LuaBootstrap.register_on_entity_destroyed Online documentation}
*/
register_on_entity_destroyed(entity: LuaEntity): RegistrationNumber
/**
* 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/1.1.110/global.html global}.
*
* ```
* 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/1.1.110/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.
* @see {@link https://lua-api.factorio.com/1.1.110/classes/LuaBootstrap.html#LuaBootstrap.generate_event_name Online documentation}
*/
generate_event_name<T extends table>(): CustomEventId<T>
/**
* 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/1.1.110/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): (data: CustomInputEvent) => void | nil
/**
* Gets the mod event order as a string.
* @see {@link https://lua-api.factorio.com/1.1.110/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/1.1.110/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/1.1.110/classes/LuaBootstrap.html#LuaBootstrap.get_event_filter Online documentation}
*/
get_event_filter<E extends EventId<any, table>>(event: E): E["_filter"][] | nil
/**
* Gets the prototype history for the given type and name.
* @see {@link https://lua-api.factorio.com/1.1.110/classes/LuaBootstrap.html#LuaBootstrap.get_prototype_history Online documentation}
*/
get_prototype_history(type: keyof PrototypeMap, name: string): PrototypeHistory
/**
* 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/1.1.110/classes/LuaBootstrap.html#LuaBootstrap.raise_event > Events that can be raised manually:}
* @param event ID 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/1.1.110/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/1.1.110/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/1.1.110/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: LuaRecipe
}): void
/**
* ## Raised events
* - {@link OnPlayerFastTransferredEvent on_player_fast_transferred} _instantly_ Raised with the provided arguments.
* @see {@link https://lua-api.factorio.com/1.1.110/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/1.1.110/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/1.1.110/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/1.1.110/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/1.1.110/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/1.1.110/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/1.1.110/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/1.1.110/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
/**
* All methods and properties that this object supports.
* @see {@link https://lua-api.factorio.com/1.1.110/classes/LuaBootstrap.html#LuaBootstrap.help Online documentation}
*/
help(): string
/**
* The name of the mod from the environment this is used in.
* @see {@link https://lua-api.factorio.com/1.1.110/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/1.1.110/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/1.1.110/classes/LuaBootstrap.html#LuaBootstrap.active_mods Online documentation}
*/
readonly active_mods: ActiveMods
/**
* 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/1.1.110/classes/LuaBurner.html Online documentation}
* @noSelf
*/
export interface LuaBurner {
/**
* All methods and properties that this object supports.
* @see {@link https://lua-api.factorio.com/1.1.110/classes/LuaBurner.html#LuaBurner.help Online documentation}
*/
help(): string
/**
* The owner of this burner energy source
* @see {@link https://lua-api.factorio.com/1.1.110/classes/LuaBurner.html#LuaBurner.owner Online documentation}
*/
readonly owner: LuaEntity | LuaEquipment
/**
* The fuel inventory.
* @see {@link https://lua-api.factorio.com/1.1.110/classes/LuaBurner.html#LuaBurner.inventory Online documentation}
*/
readonly inventory: LuaInventory
/**
* The burnt result inventory.
* @see {@link https://lua-api.factorio.com/1.1.110/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/1.1.110/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/1.1.110/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/1.1.110/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/1.1.110/classes/LuaBurner.html#LuaBurner.currently_burning Online documentation}
*/
currently_burning?: LuaItemPrototype
/**
* The fuel categories this burner uses.
*
* The value in the dictionary is meaningless and exists just to allow for easy lookup.
* @see {@link https://lua-api.factorio.com/1.1.110/classes/LuaBurner.html#LuaBurner.fuel_categories Online documentation}
*/
readonly fuel_categories: Record<string, true>
/**
* 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: "LuaBurner"
}
/**
* Prototype of a burner energy source.
* @see {@link https://lua-api.factorio.com/1.1.110/classes/LuaBurnerPrototype.html Online documentation}
* @noSelf
*/
export interface LuaBurnerPrototype {
/**
* All methods and properties that this object supports.
* @see {@link https://lua-api.factorio.com/1.1.110/classes/LuaBurnerPrototype.html#LuaBurnerPrototype.help Online documentation}
*/
help(): string
/**
* The emissions of this energy source in `pollution/Joule`. Multiplying it by energy consumption in `Watt` gives `pollution/second`.
* @see {@link https://lua-api.factorio.com/1.1.110/classes/LuaBurnerPrototype.html#LuaBurnerPrototype.emissions Online documentation}
*/
readonly emissions: double
readonly render_no_network_icon: boolean
readonly render_no_power_icon: boolean
readonly effectivity: double
readonly fuel_inventory_size: uint
readonly burnt_inventory_size: uint
/**
* The smoke sources for this burner prototype.
* @see {@link https://lua-api.factorio.com/1.1.110/classes/LuaBurnerPrototype.html#LuaBurnerPrototype.smoke Online documentation}
*/
readonly smoke?: SmokeSource[]
/**
* The light flicker definition for this burner prototype.
* @see {@link https://lua-api.factorio.com/1.1.110/classes/LuaBurnerPrototype.html#LuaBurnerPrototype.light_flicker Online documentation}
*/
readonly light_flicker?: {
readonly minimum_intensity: float
readonly maximum_intensity: float
readonly derivation_change_frequency: float
readonly derivation_change_deviation: float
readonly border_fix_speed: float
readonly minimum_light_size: float
readonly light_intensity_to_size_coefficient: float
readonly color: Color
}
/**
* The value in the dictionary is meaningless and exists just to allow for easy lookup.
* @see {@link https://lua-api.factorio.com/1.1.110/classes/LuaBurnerPrototype.html#LuaBurnerPrototype.fuel_categories Online documentation}
*/
readonly fuel_categories: Record<string, true>
/**
* 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: "LuaBurnerPrototype"
}
/**
* A chunk iterator can be used for iterating chunks coordinates of a surface.
*
* The returned type is a {@link ChunkPositionAndArea} containing the chunk coordinates and its area.
* @example
* for chunk in some_surface.get_chunks() do
* game.player.print("x: " .. chunk.x .. ", y: " .. chunk.y)
* game.player.print("area: " .. serpent.line(chunk.area))
* end
* @see {@link https://lua-api.factorio.com/1.1.110/classes/LuaChunkIterator.html Online documentation}
* @noSelf
*/
export interface LuaChunkIterator extends LuaIterable<ChunkPositionAndArea> {
/**
* All methods and properties that this object supports.
* @see {@link https://lua-api.factorio.com/1.1.110/classes/LuaChunkIterator.html#LuaChunkIterator.help Online documentation}
*/
help(): string
/**
* Gets the next chunk position if the iterator is not yet done and increments the iterator.
* @see {@link https://lua-api.factorio.com/1.1.110/classes/LuaChunkIterator.html#LuaChunkIterator.call_operator Online documentation}
*/
(): ChunkPositionAndArea | 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: "LuaChunkIterator"
}
/**
* A circuit network associated with a given entity, connector, and wire type.
* @see {@link https://lua-api.factorio.com/1.1.110/classes/LuaCircuitNetwork.html Online documentation}
* @noSelf
*/
export interface LuaCircuitNetwork {
/**
* @param signal The signal to read.
* @returns The current value of the signal.
* @see {@link https://lua-api.factorio.com/1.1.110/classes/LuaCircuitNetwork.html#LuaCircuitNetwork.get_signal Online documentation}
*/
get_signal(signal: SignalID): int
/**
* All methods and properties that this object supports.
* @see {@link https://lua-api.factorio.com/1.1.110/classes/LuaCircuitNetwork.html#LuaCircuitNetwork.help Online documentation}
*/
help(): string
/**
* The entity this circuit network reference is associated with.
* @see {@link https://lua-api.factorio.com/1.1.110/classes/LuaCircuitNetwork.html#LuaCircuitNetwork.entity Online documentation}
*/
readonly entity: LuaEntity
/**
* The wire type this network is associated with.
* @see {@link https://lua-api.factorio.com/1.1.110/classes/LuaCircuitNetwork.html#LuaCircuitNetwork.wire_type Online documentation}
*/
readonly wire_type: defines.wire_type
/**
* The circuit connector ID on the associated entity this network was gotten from.
* @see {@link https://lua-api.factorio.com/1.1.110/classes/LuaCircuitNetwork.html#LuaCircuitNetwork.circuit_connector_id Online documentation}
*/
readonly circuit_connector_id: defines.circuit_connector_id
/**
* The circuit network signals last tick. `nil` if there were no signals last tick.
* @see {@link https://lua-api.factorio.com/1.1.110/classes/LuaCircuitNetwork.html#LuaCircuitNetwork.signals Online documentation}
*/
readonly signals?: Signal[]
/**
* The circuit networks ID.
* @see {@link https://lua-api.factorio.com/1.1.110/classes/LuaCircuitNetwork.html#LuaCircuitNetwork.network_id Online documentation}
*/
readonly network_id: uint
/**
* The number of circuits connected to this network.
* @see {@link https://lua-api.factorio.com/1.1.110/classes/LuaCircuitNetwork.html#LuaCircuitNetwork.connected_circuit_count Online documentation}
*/
readonly connected_circuit_count: 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: "LuaCircuitNetwork"
}
/**
* @see {@link https://lua-api.factorio.com/1.1.110/classes/LuaCombinatorControlBehavior.html Online documentation}
* @noSelf
*/
export interface LuaCombinatorControlBehavior extends LuaControlBehavior {
/**
* Gets the value of a specific signal sent by this combinator behavior last tick or `nil` if the signal didn't exist.
* @param signal The signal to get
* @see {@link https://lua-api.factorio.com/1.1.110/classes/LuaCombinatorControlBehavior.html#LuaCombinatorControlBehavior.get_signal_last_tick Online documentation}
*/
get_signal_last_tick(signal: SignalID): int | nil
/**
* The circuit network signals sent by this combinator last tick.
* @see {@link https://lua-api.factorio.com/1.1.110/classes/LuaCombinatorControlBehavior.html#LuaCombinatorControlBehavior.signals_last_tick Online documentation}
*/
readonly signals_last_tick: Signal[]
}
/**
* Allows for the registration of custom console commands through the global object named `commands`. Similarly to {@link LuaBootstrap#on_event event subscriptions}, these don't persist through a save-and-load cycle.
* @see {@link https://lua-api.factorio.com/1.1.110/classes/LuaCommandProcessor.html Online documentation}
* @noSelf
*/
export interface LuaCommandProcessor {
/**
* Add a custom console command.
*
* Trying to add a command with the `name` of a game command or the name of a custom command that is already in use will result in an error.
*
* This example command will register a custom event called `print_tick` that prints the current tick to either the player issuing the command or to everyone on the server, depending on the command parameter:
*
* ```
* commands.add_command("print_tick", nil, function(command)
* if command.player_index ~= nil and command.parameter == "me" then
* game.get_player(command.player_index).print(command.tick)
* else
* game.print(command.tick)
* end
* end)
* ```
*
* This shows the usage of the table that gets passed to any function handling a custom command. This specific example makes use of the `tick` and the optional `player_index` and `parameter` fields. The user is supposed to either call it without any parameter (`"/print_tick"`) or with the `"me"` parameter (`"/print_tick me"`).
* @param name The desired name of the command (case sensitive).
* @param help The localised help message. It will be shown to players using the `/help` command.
* @param _function The function that will be called when this command is invoked.
* @see {@link https://lua-api.factorio.com/1.1.110/classes/LuaCommandProcessor.html#LuaCommandProcessor.add_command Online documentation}
*/
add_command(name: string, help: LocalisedString, _function: (arg1: CustomCommandData) => void): void
/**
* Remove a custom console command.
* @param name The name of the command to remove (case sensitive).
* @returns Whether the command was successfully removed. Returns `false` if the command didn't exist.
* @see {@link https://lua-api.factorio.com/1.1.110/classes/LuaCommandProcessor.html#LuaCommandProcessor.remove_command Online documentation}
*/
remove_command(name: string): boolean
/**
* All methods and properties that this object supports.
* @see {@link https://lua-api.factorio.com/1.1.110/classes/LuaCommandProcessor.html#LuaCommandProcessor.help Online documentation}
*/
help(): string
/**
* Lists the custom commands registered by scripts through `LuaCommandProcessor`.
* @see {@link https://lua-api.factorio.com/1.1.110/classes/LuaCommandProcessor.html#LuaCommandProcessor.commands Online documentation}
*/
readonly commands: Record<string, LocalisedString>
/**
* Lists the built-in commands of the core game. The {@linkplain https://wiki.factorio.com/Console wiki} has an overview of these.
* @see {@link https://lua-api.factorio.com/1.1.110/classes/LuaCommandProcessor.html#LuaCommandProcessor.game_commands Online documentation}
*/
readonly game_commands: Record<string, LocalisedString>
/**
* 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: "LuaCommandProcessor"
}
/**
* Control behavior for constant combinators.
* @see {@link https://lua-api.factorio.com/1.1.110/classes/LuaConstantCombinatorControlBehavior.html Online documentation}
* @noSelf
*/
export interface LuaConstantCombinatorControlBehavior extends LuaControlBehavior {
/**
* Sets the signal at the given index.
* @param signal Passing `nil` clears the signal.
* @see {@link https://lua-api.factorio.com/1.1.110/classes/LuaConstantCombinatorControlBehavior.html#LuaConstantCombinatorControlBehavior.set_signal Online documentation}
*/
set_signal(index: uint, signal?: Signal): void
/**
* Gets the signal at the given index. Returned {@link Signal} will not contain signal if none is set for the index.
* @see {@link https://lua-api.factorio.com/1.1.110/classes/LuaConstantCombinatorControlBehavior.html#LuaConstantCombinatorControlBehavior.get_signal Online documentation}
*/
get_signal(index: uint): Signal
/**
* All methods and properties that this object supports.
* @see {@link https://lua-api.factorio.com/1.1.110/classes/LuaConstantCombinatorControlBehavior.html#LuaConstantCombinatorControlBehavior.help Online documentation}
*/
help(): string
/**
* This constant combinator's parameters. `nil` if the {@link LuaEntityPrototype#item_slot_count item_slot_count} of the combinator's prot