typed-factorio
Version:
Featureful typescript definitions for the Factorio modding api.
1,296 lines (1,292 loc) • 580 kB
TypeScript
// This is an auto-generated file. Do not edit directly!
/** @noSelfInFile */
import type { EntityType } from "factorio:prototype"
import type { VersionString } from "factorio:common"
/**
* @noResolution
*/
declare module "factorio:runtime" {
/**
* Weight of an object. The weight is stored as a fixed-size 64 bit integer, with 16 bits reserved for decimal precision, meaning the smallest value step is `1/2^16`.
* @see {@link https://lua-api.factorio.com/2.0.75/concepts/Weight.html Online documentation}
*/
export type Weight = double
export interface CircularParticleCreationSpecification {
/**
* Name of the {@link LuaEntityPrototype}.
*/
readonly name: string
readonly direction: float
readonly direction_deviation: float
readonly speed: float
readonly speed_deviation: float
readonly starting_frame_speed: float
readonly starting_frame_speed_deviation: float
readonly height: float
readonly height_deviation: float
readonly vertical_speed: float
readonly vertical_speed_deviation: float
readonly center: Vector
readonly creation_distance: double
readonly creation_distance_orientation: double
readonly use_source_position: boolean
}
/**
* ## Union members
* - `"input"`
* - `"output"`
* @see {@link https://lua-api.factorio.com/2.0.75/concepts/BeltConnectionType.html Online documentation}
*/
export type BeltConnectionType = "input" | "output"
/**
* Identifies a statistics prototype, depending on the statistics type.
*
* ## Union members
* - {@link ItemWithQualityID}: Used with item production statistics.
* - {@link FluidID}: Used with fluid production statistics.
* - {@link EntityWithQualityID}: Used with electric network, entity build count, and kill count statistics.
* - {@link EntityID}: Used with pollution statistics.
* @see {@link https://lua-api.factorio.com/2.0.75/concepts/FlowStatisticsID.html Online documentation}
*/
export type FlowStatisticsID = ItemWithQualityID | FluidID | EntityWithQualityID | EntityID
export type ItemStackIndex = uint16
export type LogisticFilterIndex = uint16
export type ItemCountType = uint32
export type InventoryIndex = uint8
/**
* A string that specifies how the inputs should be compared.
*
* While the API accepts both versions for `"less/greater than or equal to"` and `"not equal"`, it'll always return `"≥"`, `"≤"` or `"≠"` respectively when reading them back.
*
* ## Union members
* - `"="`: "equal to"
* - `">"`: "greater than"
* - `"<"`: "lesser than"
* - `"≥"`: "greater than or equal to"
* - `">="`: "greater than or equal to"
* - `"≤"`: "lesser than or equal to"
* - `"<="`: "lesser than or equal to"
* - `"≠"`: "not equal to"
* - `"!="`: "not equal to"
* @see {@link https://lua-api.factorio.com/2.0.75/concepts/ComparatorString.html Online documentation}
*/
export type ComparatorString = "=" | ">" | "<" | "≥" | ">=" | "≤" | "<=" | "≠" | "!="
export type ComparatorStringRead = "=" | ">" | "<" | "≥" | "≤" | "≠"
export type SpriteType =
| "item"
| "entity"
| "technology"
| "recipe"
| "fluid"
| "tile"
| "item-group"
| "virtual-signal"
| "shortcut"
| "achievement"
| "equipment"
| "ammo-category"
| "decorative"
| "space-connection"
| "space-location"
| "surface"
| "airborne-pollutant"
| "asteroid-chunk"
| "quality"
| "file"
| "utility"
/**
* It can be either the name of a {@link import("factorio:prototype").SpritePrototype SpritePrototype} defined in the data stage, or a path in form "type/name" or "type.name".
*
* The validity of a SpritePath can be verified at runtime using {@link LuaHelpers#is_valid_sprite_path LuaHelpers::is_valid_sprite_path}.
*
* {@link https://lua-api.factorio.com/2.0.75/concepts/SpritePath.html > The supported types are:}
* @see {@link https://lua-api.factorio.com/2.0.75/concepts/SpritePath.html Online documentation}
*/
export type SpritePath = (string & { _?: never }) | `${SpriteType}${"/" | "."}${string}`
/**
* Parameters that affect the look and control of the game. Updating any of the member attributes here will immediately take effect in the game engine.
* @see {@link https://lua-api.factorio.com/2.0.75/concepts/GameViewSettings.html Online documentation}
*/
export interface GameViewSettings {
/**
* Show the controller GUI elements. This includes the toolbar, the selected tool slot, the armour slot, and the gun and ammunition slots.
* @see {@link https://lua-api.factorio.com/2.0.75/concepts/GameViewSettings.show_controller_gui.html Online documentation}
*/
show_controller_gui: boolean
/**
* Show the chart in the upper right-hand corner of the screen.
* @see {@link https://lua-api.factorio.com/2.0.75/concepts/GameViewSettings.show_minimap.html Online documentation}
*/
show_minimap: boolean
/**
* Show research progress and name in the upper right-hand corner of the screen.
* @see {@link https://lua-api.factorio.com/2.0.75/concepts/GameViewSettings.show_research_info.html Online documentation}
*/
show_research_info: boolean
/**
* Show overlay icons on entities. Also known as "alt-mode".
* @see {@link https://lua-api.factorio.com/2.0.75/concepts/GameViewSettings.show_entity_info.html Online documentation}
*/
show_entity_info: boolean
/**
* Show the flashing alert icons next to the player's toolbar.
* @see {@link https://lua-api.factorio.com/2.0.75/concepts/GameViewSettings.show_alert_gui.html Online documentation}
*/
show_alert_gui: boolean
/**
* When `true` (the default), mousing over an entity will select it. Otherwise, moving the mouse won't update entity selection.
* @see {@link https://lua-api.factorio.com/2.0.75/concepts/GameViewSettings.update_entity_selection.html Online documentation}
*/
update_entity_selection: boolean
/**
* When `true` (`false` is default), the rails will always show the rail block visualisation.
* @see {@link https://lua-api.factorio.com/2.0.75/concepts/GameViewSettings.show_rail_block_visualisation.html Online documentation}
*/
show_rail_block_visualisation: boolean
/**
* Shows or hides the buttons row.
* @see {@link https://lua-api.factorio.com/2.0.75/concepts/GameViewSettings.show_side_menu.html Online documentation}
*/
show_side_menu: boolean
/**
* Shows or hides the view options when map is opened.
* @see {@link https://lua-api.factorio.com/2.0.75/concepts/GameViewSettings.show_map_view_options.html Online documentation}
*/
show_map_view_options: boolean
/**
* Shows or hides the tooltip that is displayed when selecting an entity.
* @see {@link https://lua-api.factorio.com/2.0.75/concepts/GameViewSettings.show_entity_tooltip.html Online documentation}
*/
show_entity_tooltip: boolean
/**
* Shows or hides quickbar of shortcuts.
* @see {@link https://lua-api.factorio.com/2.0.75/concepts/GameViewSettings.show_quickbar.html Online documentation}
*/
show_quickbar: boolean
/**
* Shows or hides the shortcut bar.
* @see {@link https://lua-api.factorio.com/2.0.75/concepts/GameViewSettings.show_shortcut_bar.html Online documentation}
*/
show_shortcut_bar: boolean
/**
* Shows or hides the crafting queue.
* @see {@link https://lua-api.factorio.com/2.0.75/concepts/GameViewSettings.show_crafting_queue.html Online documentation}
*/
show_crafting_queue: boolean
/**
* Shows or hides the tool window with the weapons and armor.
* @see {@link https://lua-api.factorio.com/2.0.75/concepts/GameViewSettings.show_tool_bar.html Online documentation}
*/
show_tool_bar: boolean
/**
* Shows or hides the mouse and keyboard/controller button hints in the bottom left corner if they are enabled in the interface settings.
* @see {@link https://lua-api.factorio.com/2.0.75/concepts/GameViewSettings.show_hotkey_suggestions.html Online documentation}
*/
show_hotkey_suggestions: boolean
/**
* Shows or hides the surface list while in Remote View.
* @see {@link https://lua-api.factorio.com/2.0.75/concepts/GameViewSettings.show_surface_list.html Online documentation}
*/
show_surface_list: boolean
}
export interface HeatConnection {
readonly position: Vector
readonly direction: defines.direction
}
/**
* @example
* -- Most common collision mask of buildings:
* collision_mask = {layers = {item = true, meltable = true, object = true, player = true, water_tile = true, is_object = true, is_lower_object = true}}
* @see {@link https://lua-api.factorio.com/2.0.75/concepts/CollisionMask.html Online documentation}
*/
export interface CollisionMask {
/**
* Every key in the dictionary is the name of one {@link LuaCollisionLayerPrototype layer} the object collides with. The value is meaningless and always `true`. An empty table means that no layers are set.
*/
readonly layers: Record<string, true>
/**
* Any two entities that both have this option enabled on their prototype and have an identical collision mask layers list will not collide. Other collision mask options are not included in the identical layer list check. This does mean that two different prototypes with the same collision mask layers and this option enabled will not collide. Defaults to `false`.
*/
readonly not_colliding_with_itself?: boolean
/**
* Uses the prototypes position rather than its collision box when doing collision checks with tile prototypes. Allows the prototype to overlap colliding tiles up until its center point. This is only respected for character movement and cars driven by players. Defaults to `false`.
*/
readonly consider_tile_transitions?: boolean
/**
* Any prototype with this collision option will only be checked for collision with other prototype's collision masks if they are a tile. Defaults to `false`.
*/
readonly colliding_with_tiles_only?: boolean
}
export interface Loot {
/**
* Item prototype name of the result.
*/
readonly item: string
/**
* Probability that any loot at all will drop, as a number in range [0, 1].
*/
readonly probability: double
/**
* Minimum amount of loot to drop.
*/
readonly count_min: double
/**
* Maximum amount of loot to drop.
*/
readonly count_max: double
}
/**
* The percentual increase of the attribute. A value of `0.6` means a 60% increase.
*
* Quality values are multiplied by {@link LuaQualityPrototype#next_probability LuaQualityPrototype::next_probability}. For example, if a module's quality effect is 0.2 and the current quality's next_probability is 0.1, then the chance to get the next quality item is 2%.
* @see {@link https://lua-api.factorio.com/2.0.75/concepts/ModuleEffectValue.html Online documentation}
*/
export type ModuleEffectValue = float
/**
* @example
* -- These are the effects of the vanilla Speed Module 3
* {speed = 0.5, consumption = 0.7, quality = -0.25}
* @see {@link https://lua-api.factorio.com/2.0.75/concepts/ModuleEffects.html Online documentation}
*/
export interface ModuleEffects {
readonly consumption?: ModuleEffectValue
readonly speed?: ModuleEffectValue
readonly productivity?: ModuleEffectValue
readonly pollution?: ModuleEffectValue
readonly quality?: ModuleEffectValue
}
/**
* `math.huge` represents the maximum possible tick.
* @see {@link https://lua-api.factorio.com/2.0.75/concepts/MapTick.html Online documentation}
*/
export type MapTick = uint64
/**
* @see BlueprintSignalIconWrite
* @see {@link https://lua-api.factorio.com/2.0.75/concepts/BlueprintSignalIcon.html Online documentation}
*/
export interface BlueprintSignalIcon {
/**
* The icon to use.
*/
readonly signal: SignalID
/**
* Index of the icon in the blueprint icons slots. An integer in the range [1, 4].
*/
readonly index: uint32
}
/**
* Write form of {@link BlueprintSignalIcon}, where some properties allow additional values as input compared to the read form.
* @see {@link https://lua-api.factorio.com/2.0.75/concepts/BlueprintSignalIcon.html Online documentation}
*/
export interface BlueprintSignalIconWrite {
/**
* The icon to use.
*/
readonly signal: SignalIDWrite
/**
* Index of the icon in the blueprint icons slots. An integer in the range [1, 4].
*/
readonly index: uint32
}
/**
* A number between 0 and 255 inclusive, represented by one of the following named strings or the string version of the number. For example `"10"` and `"decals"` are both valid. Higher values are rendered above lower values.
*
* ## Union members
* - `string`: A string of a number
* - `"zero"`: 0
* - `"background-transitions"`: 1
* - `"under-tiles"`: 2
* - `"decals"`: 10
* - `"above-tiles"`: 11
* - `"ground-layer-1"`: 12
* - `"ground-layer-2"`: 13
* - `"ground-layer-3"`: 14
* - `"ground-layer-4"`: 15
* - `"ground-layer-5"`: 16
* - `"lower-radius-visualization"`: 29
* - `"radius-visualization"`: 30
* - `"transport-belt-integration"`: 65
* - `"resource"`: 66
* - `"building-smoke"`: 67
* - `"rail-stone-path-lower"`: 68
* - `"rail-stone-path"`: 76
* - `"rail-tie"`: 84
* - `"decorative"`: 92
* - `"ground-patch"`: 93
* - `"ground-patch-higher"`: 94
* - `"ground-patch-higher2"`: 95
* - `"rail-chain-signal-metal"`: 96
* - `"rail-screw"`: 97
* - `"rail-metal"`: 100
* - `"remnants"`: 102
* - `"floor"`: 103
* - `"transport-belt"`: 104
* - `"transport-belt-endings"`: 105
* - `"floor-mechanics-under-corpse"`: 106
* - `"corpse"`: 107
* - `"floor-mechanics"`: 108
* - `"item"`: 109
* - `"transport-belt-reader"`: 117
* - `"lower-object"`: 118
* - `"transport-belt-circuit-connector"`: 120
* - `"lower-object-above-shadow"`: 121
* - `"lower-object-overlay"`: 122
* - `"object-under"`: 123
* - `"object"`: 124
* - `"cargo-hatch"`: 125
* - `"higher-object-under"`: 126
* - `"higher-object-above"`: 127
* - `"train-stop-top"`: 128
* - `"item-in-inserter-hand"`: 129
* - `"above-inserters"`: 130
* - `"wires"`: 131
* - `"under-elevated"`: 132
* - `"elevated-rail-stone-path-lower"`: 133
* - `"elevated-rail-stone-path"`: 134
* - `"elevated-rail-tie"`: 135
* - `"elevated-rail-screw"`: 136
* - `"elevated-rail-metal"`: 137
* - `"elevated-lower-object"`: 141
* - `"elevated-object"`: 142
* - `"elevated-higher-object"`: 143
* - `"fluid-visualization"`: 149
* - `"wires-above"`: 150
* - `"entity-info-icon"`: 153
* - `"entity-info-icon-above"`: 154
* - `"explosion"`: 157
* - `"projectile"`: 158
* - `"smoke"`: 159
* - `"air-object"`: 160
* - `"air-entity-info-icon"`: 161
* - `"light-effect"`: 162
* - `"selection-box"`: 187
* - `"higher-selection-box"`: 188
* - `"collision-selection-box"`: 189
* - `"arrow"`: 190
* - `"cursor"`: 226
* @see {@link https://lua-api.factorio.com/2.0.75/concepts/RenderLayer.html Online documentation}
*/
export type RenderLayer =
| `${bigint}`
| "zero"
| "background-transitions"
| "under-tiles"
| "decals"
| "above-tiles"
| "ground-layer-1"
| "ground-layer-2"
| "ground-layer-3"
| "ground-layer-4"
| "ground-layer-5"
| "lower-radius-visualization"
| "radius-visualization"
| "transport-belt-integration"
| "resource"
| "building-smoke"
| "rail-stone-path-lower"
| "rail-stone-path"
| "rail-tie"
| "decorative"
| "ground-patch"
| "ground-patch-higher"
| "ground-patch-higher2"
| "rail-chain-signal-metal"
| "rail-screw"
| "rail-metal"
| "remnants"
| "floor"
| "transport-belt"
| "transport-belt-endings"
| "floor-mechanics-under-corpse"
| "corpse"
| "floor-mechanics"
| "item"
| "transport-belt-reader"
| "lower-object"
| "transport-belt-circuit-connector"
| "lower-object-above-shadow"
| "lower-object-overlay"
| "object-under"
| "object"
| "cargo-hatch"
| "higher-object-under"
| "higher-object-above"
| "train-stop-top"
| "item-in-inserter-hand"
| "above-inserters"
| "wires"
| "under-elevated"
| "elevated-rail-stone-path-lower"
| "elevated-rail-stone-path"
| "elevated-rail-tie"
| "elevated-rail-screw"
| "elevated-rail-metal"
| "elevated-lower-object"
| "elevated-object"
| "elevated-higher-object"
| "fluid-visualization"
| "wires-above"
| "entity-info-icon"
| "entity-info-icon-above"
| "explosion"
| "projectile"
| "smoke"
| "air-object"
| "air-entity-info-icon"
| "light-effect"
| "selection-box"
| "higher-selection-box"
| "collision-selection-box"
| "arrow"
| "cursor"
export interface IconDrawSpecification {
readonly shift: Vector
readonly scale: float
readonly scale_for_many: float
readonly render_layer: "entity-info-icon" | "entity-info-icon-above" | "air-entity-info-icon"
}
/**
* What is shown in the map view. If a field is not given, that setting will not be changed.
* @see {@link https://lua-api.factorio.com/2.0.75/concepts/MapViewSettings.html Online documentation}
*/
export interface MapViewSettings {
readonly "show-logistic-network"?: boolean
readonly "show-electric-network"?: boolean
readonly "show-turret-range"?: boolean
readonly "show-pollution"?: boolean
readonly "show-networkless-logistic-members"?: boolean
readonly "show-train-station-names"?: boolean
readonly "show-player-names"?: boolean
readonly "show-tags"?: boolean
readonly "show-worker-robots"?: boolean
readonly "show-rail-signal-states"?: boolean
readonly "show-recipe-icons"?: boolean
readonly "show-pipelines"?: boolean
readonly "show-non-standard-map-info"?: boolean
}
/**
* ## Union members
* - `"entity"`: The normal entity selection box. Yellow by default.
* - `"multiplayer-entity"`: The multiplayer entity selection box which gets tinted using {@link LuaPlayer#chat_color LuaPlayer::chat_color}. White by default.
* - `"electricity"`: The selection box used to specify electric poles an entity is connected to. Light blue by default.
* - `"copy"`: The selection box used when doing entity copy-paste. Green by default.
* - `"not-allowed"`: The selection box used when specifying colliding entities. Red by default.
* - `"pair"`: Light blue by default.
* - `"logistics"`: Light blue by default.
* - `"train-visualization"`: White by default.
* - `"blueprint-snap-rectangle"`: Green by default.
* - `"spidertron-remote-selected"`
* - `"spidertron-remote-to-be-selected"`
* @see {@link https://lua-api.factorio.com/2.0.75/concepts/CursorBoxRenderType.html Online documentation}
*/
export type CursorBoxRenderType =
| "entity"
| "multiplayer-entity"
| "electricity"
| "copy"
| "not-allowed"
| "pair"
| "logistics"
| "train-visualization"
| "blueprint-snap-rectangle"
| "spidertron-remote-selected"
| "spidertron-remote-to-be-selected"
export interface IconSequencePositioning {
readonly inventory_index: defines.inventory
readonly max_icons_per_row: uint8
readonly max_icon_rows: uint8
readonly shift: Vector
readonly scale: float
readonly separation_multiplier: float
readonly multi_row_initial_height_modifier: float
}
/**
* The name of a {@link LuaCollisionLayerPrototype}.
* @example
* "is_lower_object"
* @see {@link https://lua-api.factorio.com/2.0.75/concepts/CollisionLayerID.html Online documentation}
*/
export type CollisionLayerID = string
/**
* Scroll policy of a {@link LuaGuiElement scroll pane}.
*
* ## Union members
* - `"never"`
* - `"dont-show-but-allow-scrolling"`
* - `"always"`
* - `"auto"`
* - `"auto-and-reserve-space"`
* @see {@link https://lua-api.factorio.com/2.0.75/concepts/ScrollPolicy.html Online documentation}
*/
export type ScrollPolicy = "never" | "dont-show-but-allow-scrolling" | "always" | "auto" | "auto-and-reserve-space"
/**
* A set of flags. Active flags are in the dictionary as `true`, while inactive flags aren't present at all.
*
* To write to this, use an array[`string`] of the mouse buttons that should be possible to use with on button. The flag `"left-and-right"` can also be set, which will set `"left"` and `"right"` to `true`.
*
* ## Union members
* - `"left"`
* - `"right"`
* - `"middle"`
* - `"button-4"`
* - `"button-5"`
* - `"button-6"`
* - `"button-7"`
* - `"button-8"`
* - `"button-9"`
* @see {@link https://lua-api.factorio.com/2.0.75/concepts/MouseButtonFlags.html Online documentation}
*/
export interface MouseButtonFlags {
readonly left?: true
readonly right?: true
readonly middle?: true
readonly "button-4"?: true
readonly "button-5"?: true
readonly "button-6"?: true
readonly "button-7"?: true
readonly "button-8"?: true
readonly "button-9"?: true
}
export type MouseButtonFlagsWrite = MouseButtonFlags | ReadonlyArray<keyof MouseButtonFlags | "left-and-right">
/**
* State of a GUI {@link LuaGuiElement#switch_state switch}.
*
* ## Union members
* - `"left"`
* - `"right"`
* - `"none"`
* @see {@link https://lua-api.factorio.com/2.0.75/concepts/SwitchState.html Online documentation}
*/
export type SwitchState = "left" | "right" | "none"
/**
* ## Union members
* - `"button"`: A clickable element. Relevant event: {@link OnGuiClickEvent on_gui_click}
* - `"sprite-button"`: A `button` that displays a sprite rather than text. Relevant event: {@link OnGuiClickEvent on_gui_click}
* - `"checkbox"`: A clickable element with a check mark that can be turned off or on. Relevant event: {@link OnGuiCheckedStateChangedEvent on_gui_checked_state_changed}
* - `"flow"`: An invisible container that lays out its children either horizontally or vertically.
* - `"frame"`: A non-transparent box that contains other elements. It can have a title (set via the `caption` attribute). Just like a `flow`, it lays out its children either horizontally or vertically. Relevant event: {@link OnGuiLocationChangedEvent on_gui_location_changed}
* - `"label"`: A piece of text.
* - `"line"`: A horizontal or vertical separation line.
* - `"progressbar"`: A partially filled bar that can be used to indicate progress.
* - `"table"`: An invisible container that lays out its children in a specific number of columns. The width of each column is determined by the widest element it contains.
* - `"textfield"`: A single-line box the user can type into. Relevant events: {@link OnGuiTextChangedEvent on_gui_text_changed}, {@link OnGuiConfirmedEvent on_gui_confirmed}
* - `"radiobutton"`: An element that is similar to a `checkbox`, but with a circular appearance. Clicking a selected radio button will not unselect it. Radio buttons are not linked to each other in any way. Relevant event: {@link OnGuiCheckedStateChangedEvent on_gui_checked_state_changed}
* - `"sprite"`: An element that shows an image.
* - `"scroll-pane"`: An invisible element that is similar to a `flow`, but has the ability to show and use scroll bars.
* - `"drop-down"`: A drop-down containing strings of text. Relevant event: {@link OnGuiSelectionStateChangedEvent on_gui_selection_state_changed}
* - `"list-box"`: A list of strings, only one of which can be selected at a time. Shows a scroll bar if necessary. Relevant event: {@link OnGuiSelectionStateChangedEvent on_gui_selection_state_changed}
* - `"camera"`: A camera that shows the game at the given position on the given surface. It can visually track an {@link LuaGuiElement#entity entity} that is set after the element has been created.
* - `"choose-elem-button"`: A button that lets the player pick from a certain kind of prototype, with optional filtering. Relevant event: {@link OnGuiElemChangedEvent on_gui_elem_changed}
* - `"text-box"`: A multi-line `textfield`. Relevant event: {@link OnGuiTextChangedEvent on_gui_text_changed}
* - `"slider"`: A horizontal number line which can be used to choose a number. Relevant event: {@link OnGuiValueChangedEvent on_gui_value_changed}
* - `"minimap"`: A minimap preview, similar to the normal player minimap. It can visually track an {@link LuaGuiElement#entity entity} that is set after the element has been created.
* - `"entity-preview"`: A preview of an entity. The {@link LuaGuiElement#entity entity} has to be set after the element has been created.
* - `"empty-widget"`: An empty element that just exists. The root GUI elements `screen` and `relative` are `empty-widget`s.
* - `"tabbed-pane"`: A collection of `tab`s and their contents. Relevant event: {@link OnGuiSelectedTabChangedEvent on_gui_selected_tab_changed}
* - `"tab"`: A tab for use in a `tabbed-pane`.
* - `"switch"`: A switch with three possible states. Can have labels attached to either side. Relevant event: {@link OnGuiSwitchStateChangedEvent on_gui_switch_state_changed}
* @see {@link https://lua-api.factorio.com/2.0.75/concepts/GuiElementType.html Online documentation}
*/
export type GuiElementType =
| "button"
| "sprite-button"
| "checkbox"
| "flow"
| "frame"
| "label"
| "line"
| "progressbar"
| "table"
| "textfield"
| "radiobutton"
| "sprite"
| "scroll-pane"
| "drop-down"
| "list-box"
| "camera"
| "choose-elem-button"
| "text-box"
| "slider"
| "minimap"
| "entity-preview"
| "empty-widget"
| "tabbed-pane"
| "tab"
| "switch"
export interface PrototypeWithQuality {
/**
* Name of a prototype.
*/
readonly name: string
/**
* Name of a quality prototype. Always defined when reading, defaults to "normal" when writing.
*/
readonly quality?: string
}
export interface PrototypeWithQualityRead {
readonly name: string
readonly quality: string
}
/**
* A `string` specifying a type for {@link LuaGuiElement#elem_type choose elem buttons}. It's also used by {@link ElemID} for {@link LuaGuiElement#elem_tooltip LuaGuiElement::elem_tooltip}.
*
* ## Union members
* - `"achievement"`
* - `"decorative"`
* - `"entity"`
* - `"equipment"`
* - `"fluid"`
* - `"item"`
* - `"item-group"`
* - `"recipe"`
* - `"signal"`
* - `"technology"`
* - `"tile"`
* - `"asteroid-chunk"`
* - `"space-location"`
* - `"item-with-quality"`
* - `"entity-with-quality"`
* - `"recipe-with-quality"`
* - `"equipment-with-quality"`
* @see {@link https://lua-api.factorio.com/2.0.75/concepts/ElemType.html Online documentation}
*/
export type ElemType =
| "achievement"
| "decorative"
| "entity"
| "equipment"
| "fluid"
| "item"
| "item-group"
| "recipe"
| "signal"
| "technology"
| "tile"
| "asteroid-chunk"
| "space-location"
| "item-with-quality"
| "entity-with-quality"
| "recipe-with-quality"
| "equipment-with-quality"
export interface ElemID {
readonly type: ElemType
/**
* Name of a prototype as defined by `type`.
*/
readonly name: string
/**
* Name of a quality prototype if `type` uses quality.
*/
readonly quality?: string
/**
* Only loaded, and mandatory if `type` is `"signal"`.
*/
readonly signal_type?: SignalIDType
}
/**
* A vector is a two-element array or dictionary containing the `x` and `y` components. The game will always provide the array format. Positive x goes east, positive y goes south.
* @see VectorTable
* @example
* right = {1.0, 0.0}
* @see {@link https://lua-api.factorio.com/2.0.75/concepts/Vector.html Online documentation}
*/
export type Vector = readonly [float, float]
/**
* Table form of {@link Vector}.
* @see Vector
* @see {@link https://lua-api.factorio.com/2.0.75/concepts/Vector.html Online documentation}
*/
export interface VectorTable {
readonly x: float
readonly y: float
}
/**
* Coordinates of a chunk in a {@link LuaSurface} where each integer `x`/`y` represents a different chunk. This uses the same format as {@link MapPosition}, meaning it can be specified either with or without explicit keys. A {@link MapPosition} can be translated to a ChunkPosition by dividing the `x`/`y` values by 32.
* @see ChunkPositionArray
* @see {@link https://lua-api.factorio.com/2.0.75/concepts/ChunkPosition.html Online documentation}
*/
export interface ChunkPosition {
readonly x: int32
readonly y: int32
}
/**
* Array form of {@link ChunkPosition}.
* @see ChunkPosition
* @see {@link https://lua-api.factorio.com/2.0.75/concepts/ChunkPosition.html Online documentation}
*/
export type ChunkPositionArray = readonly [int32, int32]
export interface ItemStackLocation {
readonly inventory: defines.inventory
readonly slot: uint32
}
export interface ItemWithQualityCount {
/**
* Name of the item prototype.
*/
readonly name: string
/**
* Quality of the item prototype.
*/
readonly quality: string
/**
* The number of items.
*/
readonly count: ItemCountType
}
/**
* An item filter may be specified in two ways, either as a string which is an item prototype name or as a table.
* @see ItemFilterWrite
* @see {@link https://lua-api.factorio.com/2.0.75/concepts/ItemFilter.html Online documentation}
*/
export type ItemFilter =
| {
/**
* The item.
*/
readonly name?: LuaItemPrototype
/**
* The quality.
*/
readonly quality?: LuaQualityPrototype
/**
* The quality comparison type.
*/
readonly comparator?: ComparatorStringRead
}
| string
/**
* Write form of {@link ItemFilter}, where some properties allow additional values as input compared to the read form.
* @see {@link https://lua-api.factorio.com/2.0.75/concepts/ItemFilter.html Online documentation}
*/
export type ItemFilterWrite =
| {
/**
* The item.
*/
readonly name?: ItemID
/**
* The quality.
*/
readonly quality?: QualityID
/**
* The quality comparison type.
*/
readonly comparator?: ComparatorString
}
| string
/**
* Localised strings are a way to support translation of in-game text. They offer a language-independent code representation of the text that should be shown to players.
*
* It is an array where the first element is the key and the remaining elements are parameters that will be substituted for placeholders in the template designated by the key.
*
* The key identifies the string template. For example, `"gui-alert-tooltip.attack"` (for the template `"__1__ objects are being damaged"`; see the file `data/core/locale/en.cfg`).
*
* The template can contain placeholders such as `__1__` or `__2__`. These will be replaced by the respective parameter in the LocalisedString. The parameters themselves can be other localised strings, which will be processed recursively in the same fashion. Localised strings can not be recursed deeper than 20 levels and can not have more than 20 parameters.
*
* There are two special flags for the localised string, indicated by the key being a particular string. First, if the key is the empty string (`""`), then all parameters will be concatenated (after processing, if any are localised strings themselves). Second, if the key is a question mark (`"?"`), then the first valid parameter will be used. A parameter can be invalid if its name doesn't match any string template. If no parameters are valid, the last one is returned. This is useful to implement a fallback for missing locale templates.
*
* Furthermore, when an API function expects a localised string, it will also accept a regular string (i.e. not a table) which will not be translated, as well as a number, boolean or `nil`, which will be converted to their textual representation.
* @example
* -- In the English translation, this will print "No ammo"; in the Czech translation, it will print "Bez munice":
* game.player.print({"description.no-ammo"})
* -- The 'description.no-ammo' template contains no placeholders, so no further parameters are necessary.
* @example
* -- In the English translation, this will print "Durability: 5/9"; in the Japanese one, it will print "耐久度: 5/9":
* game.player.print({"description.durability", 5, 9})
* @example
* -- This will print "hello" in all translations:
* game.player.print({"", "hello"})
* @example
* -- This will print "Iron plate: 60" in the English translation and "Eisenplatte: 60" in the German translation.
* game.print({"", {"item-name.iron-plate"}, ": ", 60})
* @example
* -- As an example of a localised string with fallback, consider this:
* {"?", {"", {"entity-description.furnace"}, "\n"}, {"item-description.furnace"}, "optional fallback"}
* -- If 'entity-description.furnace' exists, it is concatenated with "\n" and returned. Otherwise, if 'item-description.furnace'
* -- exists, it is returned as-is. Otherwise, "optional fallback" is returned. If this value wasn't specified, the
* -- translation result would be "Unknown key: 'item-description.furnace'".
* @see {@link https://lua-api.factorio.com/2.0.75/concepts/LocalisedString.html Online documentation}
*/
export type LocalisedString = string | number | boolean | LuaObject | nil | [string, ...LocalisedString[]]
export interface BaseCommand {
/**
* Type of command. The remaining fields depend on the value of this field.
*/
readonly type: defines.command
}
/**
* {@link defines.command.attack} variant of {@link Command}.
*/
export interface AttackCommand extends BaseCommand {
readonly type: defines.command.attack
readonly target: LuaEntity
/**
* Defaults to `defines.distraction.by_enemy`.
*/
readonly distraction?: defines.distraction
}
/**
* {@link defines.command.go_to_location} variant of {@link Command}.
*/
export interface GoToLocationCommand extends BaseCommand {
readonly type: defines.command.go_to_location
/**
* The position to path to. Either this or `destination_entity` need to be specified. If both are, `destination_entity` is used.
*/
readonly destination?: MapPosition
/**
* The entity to path to. Either this or `destination` need to be specified. If both are, `destination_entity` is used.
*/
readonly destination_entity?: LuaEntity
/**
* Defaults to `defines.distraction.by_enemy`.
*/
readonly distraction?: defines.distraction
/**
* Flags that affect pathfinder behavior.
*/
readonly pathfind_flags?: PathfinderFlags
/**
* How close the pathfinder needs to get to its destination (in tiles). Defaults to `3`.
*/
readonly radius?: double
}
export interface GoToLocationCommandWrite extends BaseCommand {
readonly type: defines.command.go_to_location
/**
* The position to path to. Either this or `destination_entity` need to be specified. If both are, `destination_entity` is used.
*/
readonly destination?: MapPosition | MapPositionArray
/**
* The entity to path to. Either this or `destination` need to be specified. If both are, `destination_entity` is used.
*/
readonly destination_entity?: LuaEntity
/**
* Defaults to `defines.distraction.by_enemy`.
*/
readonly distraction?: defines.distraction
/**
* Flags that affect pathfinder behavior.
*/
readonly pathfind_flags?: PathfinderFlags
/**
* How close the pathfinder needs to get to its destination (in tiles). Defaults to `3`.
*/
readonly radius?: double
}
/**
* {@link defines.command.compound} variant of {@link Command}.
*/
export interface CompoundCommand extends BaseCommand {
readonly type: defines.command.compound
/**
* How the commands should be chained together.
*/
readonly structure_type: defines.compound_command
/**
* The sub-commands.
*/
readonly commands: Command[]
}
export interface CompoundCommandWrite extends BaseCommand {
readonly type: defines.command.compound
/**
* How the commands should be chained together.
*/
readonly structure_type: defines.compound_command
/**
* The sub-commands.
*/
readonly commands: readonly CommandWrite[]
}
/**
* {@link defines.command.group} variant of {@link Command}.
*/
export interface GroupCommand extends BaseCommand {
readonly type: defines.command.group
/**
* The group whose command to follow.
*/
readonly group: LuaCommandable
/**
* Defaults to `defines.distraction.by_enemy`.
*/
readonly distraction?: defines.distraction
/**
* Whether the unit will use the group distraction or the commands distraction. Defaults to true.
*/
readonly use_group_distraction?: boolean
}
/**
* {@link defines.command.attack_area} variant of {@link Command}.
*/
export interface AttackAreaCommand extends BaseCommand {
readonly type: defines.command.attack_area
/**
* Center of the attack area.
*/
readonly destination: MapPosition
/**
* Radius of the attack area.
*/
readonly radius: double
/**
* Defaults to `defines.distraction.by_enemy`.
*/
readonly distraction?: defines.distraction
}
export interface AttackAreaCommandWrite extends BaseCommand {
readonly type: defines.command.attack_area
/**
* Center of the attack area.
*/
readonly destination: MapPosition | MapPositionArray
/**
* Radius of the attack area.
*/
readonly radius: double
/**
* Defaults to `defines.distraction.by_enemy`.
*/
readonly distraction?: defines.distraction
}
/**
* {@link defines.command.wander} variant of {@link Command}.
*/
export interface WanderCommand extends BaseCommand {
readonly type: defines.command.wander
/**
* Defaults to `defines.distraction.by_enemy`.
*/
readonly distraction?: defines.distraction
/**
* Defaults to 10. Does not apply when `wander_in_group` is `true`.
*/
readonly radius?: double
/**
* When commanding a group, defines how the group will wander. When `true`, the units in the group will wander around inside the group's radius, just like gathering biters. When `false`, the units will wander as a group, ie they will all walk together in the same random direction. Default is true for groups. Passing true for a single unit is an error.
*/
readonly wander_in_group?: boolean
/**
* Ticks to wander before successfully completing the command. Default is max uint32, which means wander forever.
*/
readonly ticks_to_wait?: uint32
}
/**
* {@link defines.command.stop} variant of {@link Command}.
*/
export interface StopCommand extends BaseCommand {
readonly type: defines.command.stop
/**
* Defaults to `defines.distraction.by_enemy`.
*/
readonly distraction?: defines.distraction
/**
* Ticks to wander before successfully completing the command. Default is max uint32, which means stop forever.
*/
readonly ticks_to_wait?: uint32
}
/**
* {@link defines.command.flee} variant of {@link Command}.
*/
export interface FleeCommand extends BaseCommand {
readonly type: defines.command.flee
/**
* The entity to flee from
*/
readonly from: LuaEntity
/**
* Defaults to `defines.distraction.by_enemy`.
*/
readonly distraction?: defines.distraction
}
/**
* {@link defines.command.build_base} variant of {@link Command}.
*/
export interface BuildBaseCommand extends BaseCommand {
readonly type: defines.command.build_base
/**
* Where to build the base.
*/
readonly destination: MapPosition
/**
* Defaults to `defines.distraction.by_enemy`.
*/
readonly distraction?: defines.distraction
/**
* Whether the units should ignore expansion candidate chunks. When `false`, they will obey and not build a base in a non-candidate chunk. Defaults to `false`.
*/
readonly ignore_planner?: boolean
}
export interface BuildBaseCommandWrite extends BaseCommand {
readonly type: defines.command.build_base
/**
* Where to build the base.
*/
readonly destination: MapPosition | MapPositionArray
/**
* Defaults to `defines.distraction.by_enemy`.
*/
readonly distraction?: defines.distraction
/**
* Whether the units should ignore expansion candidate chunks. When `false`, they will obey and not build a base in a non-candidate chunk. Defaults to `false`.
*/
readonly ignore_planner?: boolean
}
/**
* Commands can be given to enemies and unit groups.
*
* Other attributes may be specified depending on `type`:
* - {@link defines.command.attack}: {@link AttackCommand}
* - {@link defines.command.go_to_location}: {@link GoToLocationCommand}
* - {@link defines.command.compound}: {@link CompoundCommand}
* - {@link defines.command.group}: {@link GroupCommand}
* - {@link defines.command.attack_area}: {@link AttackAreaCommand}
* - {@link defines.command.wander}: {@link WanderCommand}
* - {@link defines.command.stop}: {@link StopCommand}
* - {@link defines.command.flee}: {@link FleeCommand}
* - {@link defines.command.build_base}: {@link BuildBaseCommand}
* @see {@link https://lua-api.factorio.com/2.0.75/concepts/Command.html Online documentation}
*/
export type Command =
| AttackCommand
| GoToLocationCommand
| CompoundCommand
| GroupCommand
| AttackAreaCommand
| WanderCommand
| StopCommand
| FleeCommand
| BuildBaseCommand
/**
* Write form of {@link Command}, where some properties allow additional values as input compared to the read form.
* @see {@link https://lua-api.factorio.com/2.0.75/concepts/Command.html Online documentation}
*/
export type CommandWrite =
| AttackCommand
| GoToLocationCommandWrite
| CompoundCommandWrite
| GroupCommand
| AttackAreaCommandWrite
| WanderCommand
| StopCommand
| FleeCommand
| BuildBaseCommandWrite
/**
* Common attributes to all variants of {@link GuiArrowSpecification}.
*/
export interface BaseGuiArrowSpecification {
readonly margin: uint32
/**
* This determines which of the following fields will be required.
*/
readonly type: GuiArrowType
}
/**
* `"entity"` variant of {@link GuiArrowSpecification}.
*/
export interface EntityGuiArrowSpecification extends BaseGuiArrowSpecification {
readonly type: "entity"
readonly entity: LuaEntity
}
/**
* `"position"` variant of {@link GuiArrowSpecification}.
*/
export interface PositionGuiArrowSpecification extends BaseGuiArrowSpecification {
readonly type: "position"
readonly position: MapPosition | MapPositionArray
}
/**
* `"crafting_queue"` variant of {@link GuiArrowSpecification}.
*/
export interface CraftingQueueGuiArrowSpecification extends BaseGuiArrowSpecification {
readonly type: "crafting_queue"
/**
* Index in the crafting queue to point to.
*/
readonly crafting_queueindex: uint32
}
/**
* `"item_stack"` variant of {@link GuiArrowSpecification}.
*/
export interface ItemStackGuiArrowSpecification extends BaseGuiArrowSpecification {
readonly type: "item_stack"
/**
* Which inventory the stack is in.
*/
readonly inventory_index: defines.inventory
/**
* Which stack to point to.
*/
readonly item_stack_index: uint32
readonly source: "player" | "target" | "player-quickbar"
}
/**
* Variants of {@link GuiArrowSpecification} with no additional attributes.
*/
export interface OtherGuiArrowSpecification extends BaseGuiArrowSpecification {
readonly type: "nowhere" | "goal" | "entity_info" | "active_window"
}
/**
* Used for specifying where a GUI arrow should point to.
*
* Base attributes: {@link BaseGuiArrowSpecification}
*
* Other attributes may be specified depending on `type`:
* - `"entity"`: {@link EntityGuiArrowSpecification}
* - `"position"`: {@link PositionGuiArrowSpecification}
* - `"crafting_queue"`: {@link CraftingQueueGuiArrowSpecification}
* - `"item_stack"`: {@link ItemStackGuiArrowSpecification}
* @see {@link https://lua-api.factorio.com/2.0.75/concepts/GuiArrowSpecification.html Online documentation}
*/
export type GuiArrowSpecification =
| EntityGuiArrowSpecification
| PositionGuiArrowSpecification
| CraftingQueueGuiArrowSpecification
| ItemStackGuiArrowSpecification
| OtherGuiArrowSpecification
/**
* Used by {@link GuiArrowSpecification}.
*
* ## Union members
* - `"nowhere"`: Will remove the arrow entirely.
* - `"goal"`: Will point to the current goal.
* - `"entity_info"`
* - `"active_window"`
* - `"entity"`
* - `"position"`
* - `"crafting_queue"`
* - `"item_stack"`: Will point to a given item stack in an inventory.
* @see {@link https://lua-api.factorio.com/2.0.75/concepts/GuiArrowType.html Online documentation}
*/
export type GuiArrowType =
| "nowhere"
| "goal"
| "entity_info"
| "active_window"
| "entity"
| "position"
| "crafting_queue"
| "item_stack"
/**
* Reading this always returns the table with the named keys.
*
* If this is specified as a three-element array then the array items are x, y and z, in that order.
* @see Vector3DArray
* @see {@link https://lua-api.factorio.com/2.0.75/concepts/Vector3D.html Online documentation}
*/
export interface Vector3D {
readonly x: float
readonly y: float
readonly z: float
}
/**
* Array form of {@link Vector3D}.
* @see Vector3D
* @see {@link https://lua-api.factorio.com/2.0.75/concepts/Vector3D.html Online documentation}
*/
export type Vector3DArray = readonly [float, float, float]
export interface RidingState {
readonly acceleration: defines.riding.acceleration
readonly direction: defines.riding.direction
}
export type ItemWithQualityCounts = ItemWithQualityCount[]
export interface EquipmentWithQualityCounts {
/**
* Name of the equipment prototype.
*/
readonly name: string
/**
* The number of equipment items.
*/
readonly count: uint32
/**
* Name of the equipment's quality prototype.
*/
readonly quality: string
}
export interface ItemToPlace {
/**
* Name of the item prototype.
*/
readonly name: string
/**
* The number of items.
*/
readonly count: ItemCountType
}
/**
* @see TrainScheduleWrite
* @see {@link https://lua-api.factorio.com/2.0.75/concepts/TrainSchedule.html Online documentation}
*/
export interface TrainSchedule {
/**
* Index of the currently active record
*/
readonly current: uint32
readonly records: ScheduleRecord[]
}
/**
* Write form of {@link TrainSchedule}, where some properties allow additional values as input compared to the read form.
* @see {@link https://lua-api.factorio.com/2.0.75/concepts/TrainSchedule.html Online documentation}
*/
export interface TrainScheduleWrite {
/**
* Index of the currently active record
*/
readonly current: uint32
readonly records: readonly ScheduleRecordWrite[]
}
/**
* @see PlatformScheduleWrite
* @see {@link https://lua-api.factorio.com/2.0.75/concepts/PlatformSchedule.html Online documentation}
*/
export interface PlatformSchedule {
/**
* Index of the currently active record
*/
readonly current: uint32
readonly records: ScheduleRecord[]
}
/**
* Write form of {@link PlatformSchedule}, where some properties allow additional values as input compared to the read form.
* @see {@link https://lua-api.factorio.com/2.0.75/concepts/PlatformSchedule.html Online documentation}
*/
export interface PlatformScheduleWrite {
/**
* Index of the currently active record
*/
readonly current: uint32
readonly records: readonly ScheduleRecordWrite[]
}
export interface RailLocation {
readonly position: MapPosition
readonly direction: defines.direction
readonly rail_layer: defines.rail_layer
}
export interface EffectReceiver {
readonly base_effect: ModuleEffects
readonly uses_module_effects: boolean
readonly uses_beacon_effects: boolean
/**
* Controls whether {@link LuaSurface#global_effect LuaSurface::global_effect} affects this receiver.
*/
readonly uses_surface_effects: boolean
}
/**
* A recipe prototype with optional quality specification.
* @see {@link https://lua-api.factorio.com/2.0.75/concepts/RecipeIDAndQualityIDPair.html Online documentation}
*/
export interface RecipeIDAndQualityIDPair {
/**
* Recipe prototype.
*/
readonly name: LuaRecipePrototype
/**
* Quality prototype.
*/
readonly quality: LuaQualityPrototype
}
export interface WorkerRobotOrder {
/**
*