typed-factorio
Version:
Featureful typescript definitions for the Factorio modding api.
1,272 lines (1,268 loc) • 328 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" {
/**
* @see AutoplaceSettingsWrite
* @see {@link https://lua-api.factorio.com/1.1.110/concepts.html#AutoplaceSettings Online documentation}
*/
export interface AutoplaceSettings {
/**
* Whether missing autoplace names for this type should be default enabled. Always defined when reading autoplace settings.
*/
readonly treat_missing_as_default?: boolean
/**
* Always defined when reading autoplace settings.
*/
readonly settings?: Record<string, AutoplaceControl>
}
/**
* Write form of {@link AutoplaceSettings}, where table-or-array concepts are allowed to take an array form.
* @see {@link https://lua-api.factorio.com/1.1.110/concepts.html#AutoplaceSettings Online documentation}
*/
export interface AutoplaceSettingsWrite {
/**
* Whether missing autoplace names for this type should be default enabled. Always defined when reading autoplace settings.
*/
readonly treat_missing_as_default?: boolean
/**
* Always defined when reading autoplace settings.
*/
readonly settings?: Record<string, AutoplaceControlWrite>
}
/**
* The text is aligned so that the target position is at the given side of the text.
*
* For example, `"right"` aligned text means the right side of the text is at the target position. Or in other words, the target is on the right of the text.
*
* ## Union members
* - `"left"`
* - `"right"`
* - `"center"`
* @see {@link https://lua-api.factorio.com/1.1.110/concepts.html#TextAlign Online documentation}
*/
export type TextAlign = "left" | "right" | "center"
/**
* The text is aligned so that the target position is at the given side of the text.
*
* For example, `"top"` aligned text means the top of the text is at the target position. Or in other words, the target is at the top of the text.
*
* ## Union members
* - `"top"`
* - `"middle"`
* - `"baseline"`
* - `"bottom"`
* @see {@link https://lua-api.factorio.com/1.1.110/concepts.html#VerticalTextAlign Online documentation}
*/
export type VerticalTextAlign = "top" | "middle" | "baseline" | "bottom"
/**
* Common attributes to all variants of {@link GuiArrowSpecification}.
*/
export interface BaseGuiArrowSpecification {
readonly margin: uint
/**
* 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: uint
}
/**
* `"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: uint
readonly source: "player" | "target" | "player-quickbar" | "player-equipment-bar"
}
/**
* 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/1.1.110/concepts.html#GuiArrowSpecification Online documentation}
*/
export type GuiArrowSpecification =
| EntityGuiArrowSpecification
| PositionGuiArrowSpecification
| CraftingQueueGuiArrowSpecification
| ItemStackGuiArrowSpecification
| OtherGuiArrowSpecification
export interface PrintSettings {
/**
* Color of the message to print. Defaults to white.
*/
readonly color?: Color | ColorArray
/**
* If a sound should be emitted for this message. Defaults to `defines.print_sound.use_player_settings`.
*/
readonly sound?: defines.print_sound
/**
* Condition when to skip adding message. Defaults to `defines.print_skip.if_redundant`.
*/
readonly skip?: defines.print_skip
/**
* The sound to play. If not given, {@link import("factorio:prototype").UtilitySounds#console_message UtilitySounds::console_message} will be used instead.
*/
readonly sound_path?: SoundPath
/**
* The volume of the sound to play. Must be between 0 and 1 inclusive. Defaults to 1.
*/
readonly volume_modifier?: double
/**
* If set to false, message will not be part of game state and will disappear from output console after save-load. Defaults to `true`.
*/
readonly game_state?: boolean
}
/**
* 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/1.1.110/concepts.html#MapViewSettings 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-non-standard-map-info"?: boolean
}
/**
* One of the following values:
*
* ## Union members
* - `"entity"`: The normal entity selection box. Yellow 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.
* @see {@link https://lua-api.factorio.com/1.1.110/concepts.html#CursorBoxRenderType Online documentation}
*/
export type CursorBoxRenderType =
| "entity"
| "electricity"
| "copy"
| "not-allowed"
| "pair"
| "logistics"
| "train-visualization"
| "blueprint-snap-rectangle"
/**
* Types `"signal"` and `"item-group"` do not support filters.
*
* Filters are always used as an array of filters of a specific type. Every filter can only be used with its corresponding event, and different types of event filters can not be mixed.
*
* ## Union members
* - {@link ModSettingPrototypeFilter}
* - {@link DecorativePrototypeFilter}
* - EntityPrototypeFilter
* - TechnologyPrototypeFilter
* - RecipePrototypeFilter
* - {@link EquipmentPrototypeFilter}
* - {@link AchievementPrototypeFilter}
* - FluidPrototypeFilter
* - ItemPrototypeFilter
* - TilePrototypeFilter
* @see PrototypeFilterWrite
* @see {@link https://lua-api.factorio.com/1.1.110/concepts.html#PrototypeFilter Online documentation}
*/
export type PrototypeFilter =
| ModSettingPrototypeFilter[]
| DecorativePrototypeFilter[]
| EntityPrototypeFilter[]
| TechnologyPrototypeFilter[]
| RecipePrototypeFilter[]
| EquipmentPrototypeFilter[]
| AchievementPrototypeFilter[]
| FluidPrototypeFilter[]
| ItemPrototypeFilter[]
| TilePrototypeFilter[]
/**
* Write form of {@link PrototypeFilter}, where table-or-array concepts are allowed to take an array form.
* @see {@link https://lua-api.factorio.com/1.1.110/concepts.html#PrototypeFilter Online documentation}
*/
export type PrototypeFilterWrite =
| readonly ModSettingPrototypeFilter[]
| readonly DecorativePrototypeFilter[]
| readonly EntityPrototypeFilterWrite[]
| readonly TechnologyPrototypeFilterWrite[]
| readonly RecipePrototypeFilterWrite[]
| readonly EquipmentPrototypeFilter[]
| readonly AchievementPrototypeFilter[]
| readonly FluidPrototypeFilterWrite[]
| readonly ItemPrototypeFilterWrite[]
| readonly TilePrototypeFilterWrite[]
/**
* A set of trigger target masks.
* @see {@link https://lua-api.factorio.com/1.1.110/concepts.html#TriggerTargetMask Online documentation}
*/
export type TriggerTargetMask = Record<string, true>
export interface DamageTypeFilters {
/**
* Whether this is a whitelist or a blacklist of damage types. `true` means whitelist.
*/
readonly whitelist: boolean
/**
* The damage types to filter for. The value in the dictionary is meaningless and exists just to allow for easy lookup.
*/
readonly types: Record<string, true>
}
export interface TriggerDelivery {
readonly type: "instant" | "projectile" | "flame-thrower" | "beam" | "stream" | "artillery"
readonly source_effects: TriggerEffectItem[]
readonly target_effects: TriggerEffectItem[]
}
/**
* Used by {@link TriggerEffectItem}.
*
* ## Union members
* - `"damage"`
* - `"create-entity"`
* - `"create-explosion"`
* - `"create-fire"`
* - `"create-smoke"`
* - `"create-trivial-smoke"`
* - `"create-particle"`
* - `"create-sticker"`
* - `"create-decorative"`
* - `"nested-result"`
* - `"play-sound"`
* - `"push-back"`
* - `"destroy-cliffs"`
* - `"show-explosion-on-chart"`
* - `"insert-item"`
* - `"script"`
* - `"set-tile"`
* - `"invoke-tile-trigger"`
* - `"destroy-decoratives"`
* - `"camera-effect"`
* @see {@link https://lua-api.factorio.com/1.1.110/concepts.html#TriggerEffectItemType Online documentation}
*/
export type TriggerEffectItemType =
| "damage"
| "create-entity"
| "create-explosion"
| "create-fire"
| "create-smoke"
| "create-trivial-smoke"
| "create-particle"
| "create-sticker"
| "create-decorative"
| "nested-result"
| "play-sound"
| "push-back"
| "destroy-cliffs"
| "show-explosion-on-chart"
| "insert-item"
| "script"
| "set-tile"
| "invoke-tile-trigger"
| "destroy-decoratives"
| "camera-effect"
export interface TriggerEffectItem {
readonly type: TriggerEffectItemType
readonly repeat_count: uint16
readonly repeat_count_deviation: uint16
readonly probability: float
readonly affects_target: boolean
readonly show_in_tooltip: boolean
readonly damage_type_filters?: DamageTypeFilters
}
export interface TriggerItem {
readonly type: "direct" | "area" | "line" | "cluster"
readonly action_delivery?: TriggerDelivery[]
/**
* The trigger will only affect entities that contain any of these flags.
*/
readonly entity_flags?: EntityPrototypeFlags
readonly ignore_collision_condition: boolean
/**
* The trigger will only affect entities that would collide with given collision mask.
*/
readonly collision_mask: CollisionMask
readonly trigger_target_mask: TriggerTargetMask
/**
* If `"enemy"`, the trigger will only affect entities whose force is different from the attacker's and for which there is no cease-fire set. `"ally"` is the opposite of `"enemy"`.
*/
readonly force: ForceCondition
readonly repeat_count: uint
readonly probability: float
}
export interface RailEnd {
readonly rail: LuaEntity
readonly direction: defines.rail_direction
}
export interface TrainStopGoal {
/**
* Train stop target. Must be connected to rail ({@link LuaEntity#connected_rail LuaEntity::connected_rail} returns valid LuaEntity).
*/
readonly train_stop: LuaEntity
}
/**
* A `string` specifying the type of request for {@link LuaGameScript#request_train_path LuaGameScript::request_train_path}.
*
* ## Union members
* - `"path"`: The method will return {@link TrainPathFinderPathResult}.
* - `"any-goal-accessible"`: The method will return {@link TrainPathAnyGoalResult}.
* - `"all-goals-accessible"`: The method will return {@link TrainPathAllGoalsResult}.
* - `"all-goals-penalties"`: The method will return {@link TrainPathAllGoalsResult} with `penalties`.
* @see {@link https://lua-api.factorio.com/1.1.110/concepts.html#TrainPathRequestType Online documentation}
*/
export type TrainPathRequestType = "path" | "any-goal-accessible" | "all-goals-accessible" | "all-goals-penalties"
export interface TrainPathFinderPathResult {
/**
* True if found path.
*/
readonly found_path: boolean
/**
* Only returned if `return_path` was set to true and path was found. Contains all rails in order that are part of the found path.
*/
readonly path?: LuaEntity[]
/**
* If path was found, provides index of the specific goal to which the path goes to.
*/
readonly goal_index?: uint
/**
* Penalty of the path to goal if path was found.
*/
readonly penalty?: double
/**
* If path was found, provides total length of all rails of the path.
*/
readonly total_length?: double
/**
* If path was found, tells if the path was reached from the `from_front` or train's front end.
*/
readonly is_front?: boolean
/**
* Amount of steps pathfinder performed. This is a measure of how expensive this search was.
*/
readonly steps_count: uint
}
export interface TrainPathAnyGoalResult {
/**
* True if any goal was accessible.
*/
readonly found_path: boolean
/**
* If any goal was accessible, this gives index of the particular goal that was found.
*/
readonly goal_index?: uint
/**
* Penalty of the path to goal if a goal was accessible.
*/
readonly penalty?: double
/**
* Amount of steps pathfinder performed. This is a measure of how expensive this search was.
*/
readonly steps_count: uint
}
export interface TrainPathAllGoalsResult {
/**
* Amount of goals that are accessible.
*/
readonly amount_accessible: uint
/**
* Array of the same length as requested goals: each field will tell if related goal is accessible for the train.
*/
readonly accessible: boolean[]
/**
* Array of the same length as requested goals. Only present if request type was `"all-goals-penalties"`.
*/
readonly penalties?: double[]
/**
* Amount of steps pathfinder performed. This is a measure of how expensive this search was.
*/
readonly steps_count: uint
}
/**
* Used to filter out irrelevant event callbacks in a performant way.
*
* Filters are always used as an array of filters of a specific type. Every filter can only be used with its corresponding event, and different types of event filters can not be mixed.
*
* ## Union members
* - {@link LuaScriptRaisedDestroyEventFilter}
* - {@link LuaScriptRaisedReviveEventFilter}
* - {@link LuaScriptRaisedBuiltEventFilter}
* - {@link LuaPostEntityDiedEventFilter}
* - {@link LuaEntityDiedEventFilter}
* - {@link LuaPlayerBuiltEntityEventFilter}
* - {@link LuaEntityMarkedForDeconstructionEventFilter}
* - {@link LuaRobotMinedEntityEventFilter}
* - {@link LuaPreGhostDeconstructedEventFilter}
* - {@link LuaEntityMarkedForUpgradeEventFilter}
* - {@link LuaUpgradeCancelledEventFilter}
* - {@link LuaSectorScannedEventFilter}
* - {@link LuaPreGhostUpgradedEventFilter}
* - {@link LuaPreRobotMinedEntityEventFilter}
* - {@link LuaEntityDeconstructionCancelledEventFilter}
* - LuaEntityDamagedEventFilter
* - {@link LuaScriptRaisedTeleportedEventFilter}
* - {@link LuaEntityClonedEventFilter}
* - {@link LuaPlayerRepairedEntityEventFilter}
* - {@link LuaRobotBuiltEntityEventFilter}
* - {@link LuaPlayerMinedEntityEventFilter}
* - {@link LuaPrePlayerMinedEntityEventFilter}
* @see EventFilterWrite
* @see {@link https://lua-api.factorio.com/1.1.110/concepts.html#EventFilter Online documentation}
*/
export type EventFilter =
| LuaScriptRaisedDestroyEventFilter[]
| LuaScriptRaisedReviveEventFilter[]
| LuaScriptRaisedBuiltEventFilter[]
| LuaPostEntityDiedEventFilter[]
| LuaEntityDiedEventFilter[]
| LuaPlayerBuiltEntityEventFilter[]
| LuaEntityMarkedForDeconstructionEventFilter[]
| LuaRobotMinedEntityEventFilter[]
| LuaPreGhostDeconstructedEventFilter[]
| LuaEntityMarkedForUpgradeEventFilter[]
| LuaUpgradeCancelledEventFilter[]
| LuaSectorScannedEventFilter[]
| LuaPreGhostUpgradedEventFilter[]
| LuaPreRobotMinedEntityEventFilter[]
| LuaEntityDeconstructionCancelledEventFilter[]
| LuaEntityDamagedEventFilter[]
| LuaScriptRaisedTeleportedEventFilter[]
| LuaEntityClonedEventFilter[]
| LuaPlayerRepairedEntityEventFilter[]
| LuaRobotBuiltEntityEventFilter[]
| LuaPlayerMinedEntityEventFilter[]
| LuaPrePlayerMinedEntityEventFilter[]
/**
* Write form of {@link EventFilter}, where table-or-array concepts are allowed to take an array form.
* @see {@link https://lua-api.factorio.com/1.1.110/concepts.html#EventFilter Online documentation}
*/
export type EventFilterWrite =
| readonly LuaScriptRaisedDestroyEventFilter[]
| readonly LuaScriptRaisedReviveEventFilter[]
| readonly LuaScriptRaisedBuiltEventFilter[]
| readonly LuaPostEntityDiedEventFilter[]
| readonly LuaEntityDiedEventFilter[]
| readonly LuaPlayerBuiltEntityEventFilter[]
| readonly LuaEntityMarkedForDeconstructionEventFilter[]
| readonly LuaRobotMinedEntityEventFilter[]
| readonly LuaPreGhostDeconstructedEventFilter[]
| readonly LuaEntityMarkedForUpgradeEventFilter[]
| readonly LuaUpgradeCancelledEventFilter[]
| readonly LuaSectorScannedEventFilter[]
| readonly LuaPreGhostUpgradedEventFilter[]
| readonly LuaPreRobotMinedEntityEventFilter[]
| readonly LuaEntityDeconstructionCancelledEventFilter[]
| readonly LuaEntityDamagedEventFilterWrite[]
| readonly LuaScriptRaisedTeleportedEventFilter[]
| readonly LuaEntityClonedEventFilter[]
| readonly LuaPlayerRepairedEntityEventFilter[]
| readonly LuaRobotBuiltEntityEventFilter[]
| readonly LuaPlayerMinedEntityEventFilter[]
| readonly LuaPrePlayerMinedEntityEventFilter[]
/**
* Used by {@link TechnologyModifier}.
*
* ## Union members
* - `"inserter-stack-size-bonus"`
* - `"stack-inserter-capacity-bonus"`
* - `"laboratory-speed"`
* - `"character-logistic-trash-slots"`
* - `"maximum-following-robots-count"`
* - `"worker-robot-speed"`
* - `"worker-robot-storage"`
* - `"ghost-time-to-live"`
* - `"turret-attack"`
* - `"ammo-damage"`
* - `"give-item"`
* - `"gun-speed"`
* - `"unlock-recipe"`
* - `"character-crafting-speed"`
* - `"character-mining-speed"`
* - `"character-running-speed"`
* - `"character-build-distance"`
* - `"character-item-drop-distance"`
* - `"character-reach-distance"`
* - `"character-resource-reach-distance"`
* - `"character-item-pickup-distance"`
* - `"character-loot-pickup-distance"`
* - `"character-inventory-slots-bonus"`
* - `"deconstruction-time-to-live"`
* - `"max-failed-attempts-per-tick-per-construction-queue"`
* - `"max-successful-attempts-per-tick-per-construction-queue"`
* - `"character-health-bonus"`
* - `"mining-drill-productivity-bonus"`
* - `"train-braking-force-bonus"`
* - `"zoom-to-world-enabled"`
* - `"zoom-to-world-ghost-building-enabled"`
* - `"zoom-to-world-blueprint-enabled"`
* - `"zoom-to-world-deconstruction-planner-enabled"`
* - `"zoom-to-world-upgrade-planner-enabled"`
* - `"zoom-to-world-selection-tool-enabled"`
* - `"worker-robot-battery"`
* - `"laboratory-productivity"`
* - `"follower-robot-lifetime"`
* - `"artillery-range"`
* - `"nothing"`
* - `"character-logistic-requests"`
* @see {@link https://lua-api.factorio.com/1.1.110/concepts.html#ModifierType Online documentation}
*/
export type ModifierType =
| "inserter-stack-size-bonus"
| "stack-inserter-capacity-bonus"
| "laboratory-speed"
| "character-logistic-trash-slots"
| "maximum-following-robots-count"
| "worker-robot-speed"
| "worker-robot-storage"
| "ghost-time-to-live"
| "turret-attack"
| "ammo-damage"
| "give-item"
| "gun-speed"
| "unlock-recipe"
| "character-crafting-speed"
| "character-mining-speed"
| "character-running-speed"
| "character-build-distance"
| "character-item-drop-distance"
| "character-reach-distance"
| "character-resource-reach-distance"
| "character-item-pickup-distance"
| "character-loot-pickup-distance"
| "character-inventory-slots-bonus"
| "deconstruction-time-to-live"
| "max-failed-attempts-per-tick-per-construction-queue"
| "max-successful-attempts-per-tick-per-construction-queue"
| "character-health-bonus"
| "mining-drill-productivity-bonus"
| "train-braking-force-bonus"
| "zoom-to-world-enabled"
| "zoom-to-world-ghost-building-enabled"
| "zoom-to-world-blueprint-enabled"
| "zoom-to-world-deconstruction-planner-enabled"
| "zoom-to-world-upgrade-planner-enabled"
| "zoom-to-world-selection-tool-enabled"
| "worker-robot-battery"
| "laboratory-productivity"
| "follower-robot-lifetime"
| "artillery-range"
| "nothing"
| "character-logistic-requests"
/**
* One of the following values:
*
* ## Union members
* - `"none"`
* - `"whitelist"`
* - `"blacklist"`
* @see {@link https://lua-api.factorio.com/1.1.110/concepts.html#PrototypeFilterMode Online documentation}
*/
export type PrototypeFilterMode = "none" | "whitelist" | "blacklist"
export interface RadiusVisualisationSpecification {
readonly distance: double
readonly offset: Vector
readonly draw_in_cursor: boolean
readonly draw_on_selection: boolean
}
/**
* ## Union members
* - `"west-to-east"`
* - `"north-to-south"`
* - `"east-to-west"`
* - `"south-to-north"`
* - `"west-to-north"`
* - `"north-to-east"`
* - `"east-to-south"`
* - `"south-to-west"`
* - `"west-to-south"`
* - `"north-to-west"`
* - `"east-to-north"`
* - `"south-to-east"`
* - `"west-to-none"`
* - `"none-to-east"`
* - `"east-to-none"`
* - `"none-to-west"`
* - `"north-to-none"`
* - `"none-to-south"`
* - `"south-to-none"`
* - `"none-to-north"`
* @see {@link https://lua-api.factorio.com/1.1.110/concepts.html#CliffOrientation Online documentation}
*/
export type CliffOrientation =
| "west-to-east"
| "north-to-south"
| "east-to-west"
| "south-to-north"
| "west-to-north"
| "north-to-east"
| "east-to-south"
| "south-to-west"
| "west-to-south"
| "north-to-west"
| "east-to-north"
| "south-to-east"
| "west-to-none"
| "none-to-east"
| "east-to-none"
| "none-to-west"
| "north-to-none"
| "none-to-south"
| "south-to-none"
| "none-to-north"
export interface ElemID {
readonly type: ElemType
/**
* Name of a prototype as defined by `type`.
*/
readonly name: string
}
/**
* State of a GUI {@link LuaGuiElement#switch_state switch}.
*
* ## Union members
* - `"left"`
* - `"right"`
* - `"none"`
* @see {@link https://lua-api.factorio.com/1.1.110/concepts.html#SwitchState Online documentation}
*/
export type SwitchState = "left" | "right" | "none"
/**
* 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"`
* @see {@link https://lua-api.factorio.com/1.1.110/concepts.html#ElemType Online documentation}
*/
export type ElemType =
| "achievement"
| "decorative"
| "entity"
| "equipment"
| "fluid"
| "item"
| "item-group"
| "recipe"
| "signal"
| "technology"
| "tile"
/**
* Localised strings are a way to support translation of in-game text. 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/1.1.110/concepts.html#LocalisedString Online documentation}
*/
export type LocalisedString = string | number | boolean | LuaObject | nil | [string, ...LocalisedString[]]
export interface DisplayResolution {
readonly width: uint
readonly height: uint
}
export interface LogisticParameters {
/**
* The item. `nil` clears the filter.
*/
readonly name?: string
/**
* Defaults to `0`.
*/
readonly min?: uint
/**
* Defaults to max uint.
*/
readonly max?: uint
}
/**
* The smooth orientation. It is a {@link float} in the range `[0, 1)` that covers a full circle, starting at the top and going clockwise. This means a value of `0` indicates "north", a value of `0.5` indicates "south".
*
* For example then, a value of `0.625` would indicate "south-west", and a value of `0.875` would indicate "north-west".
* @see {@link https://lua-api.factorio.com/1.1.110/concepts.html#RealOrientation Online documentation}
*/
export type RealOrientation = float
/**
* Coordinates on a surface, for example of an entity. MapPositions may be specified either as a dictionary with `x`, `y` as keys, or simply as an array with two elements.
*
* The coordinates are saved as a fixed-size 32 bit integer, with 8 bits reserved for decimal precision, meaning the smallest value step is `1/2^8 = 0.00390625` tiles.
* @see MapPositionArray
* @example
* -- Explicit definition
* {x = 5.5, y = 2}
* {y = 2.25, x = 5.125}
* @example
* -- Shorthand
* {1.625, 2.375}
* @see {@link https://lua-api.factorio.com/1.1.110/concepts.html#MapPosition Online documentation}
*/
export interface MapPosition {
readonly x: double
readonly y: double
}
/**
* Array form of {@link MapPosition}.
* @see MapPosition
* @see {@link https://lua-api.factorio.com/1.1.110/concepts.html#MapPosition Online documentation}
*/
export type MapPositionArray = readonly [double, double]
/**
* 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/1.1.110/concepts.html#ChunkPosition Online documentation}
*/
export interface ChunkPosition {
readonly x: int
readonly y: int
}
/**
* Array form of {@link ChunkPosition}.
* @see ChunkPosition
* @see {@link https://lua-api.factorio.com/1.1.110/concepts.html#ChunkPosition Online documentation}
*/
export type ChunkPositionArray = readonly [int, int]
/**
* Coordinates of a tile on a {@link LuaSurface} where each integer `x`/`y` represents a different tile. This uses the same format as {@link MapPosition}, except it rounds any non-integer `x`/`y` down to whole numbers. It can be specified either with or without explicit keys.
* @see TilePositionArray
* @see {@link https://lua-api.factorio.com/1.1.110/concepts.html#TilePosition Online documentation}
*/
export interface TilePosition {
readonly x: int
readonly y: int
}
/**
* Array form of {@link TilePosition}.
* @see TilePosition
* @see {@link https://lua-api.factorio.com/1.1.110/concepts.html#TilePosition Online documentation}
*/
export type TilePositionArray = readonly [int, int]
/**
* Position inside an equipment grid. This uses the same format as {@link MapPosition}, meaning it can be specified either with or without explicit keys.
* @see EquipmentPositionArray
* @example
* -- Explicit definition
* {x = 5, y = 2}
* {y = 2, x = 5}
* @example
* -- Shorthand
* {1, 2}
* @see {@link https://lua-api.factorio.com/1.1.110/concepts.html#EquipmentPosition Online documentation}
*/
export interface EquipmentPosition {
readonly x: int
readonly y: int
}
/**
* Array form of {@link EquipmentPosition}.
* @see EquipmentPosition
* @see {@link https://lua-api.factorio.com/1.1.110/concepts.html#EquipmentPosition Online documentation}
*/
export type EquipmentPositionArray = readonly [int, int]
/**
* Screen coordinates of a GUI element in a {@link LuaGui}. This uses the same format as {@link TilePosition}, meaning it can be specified either with or without explicit keys.
* @see GuiLocationArray
* @see {@link https://lua-api.factorio.com/1.1.110/concepts.html#GuiLocation Online documentation}
*/
export interface GuiLocation {
readonly x: int
readonly y: int
}
/**
* Array form of {@link GuiLocation}.
* @see GuiLocation
* @see {@link https://lua-api.factorio.com/1.1.110/concepts.html#GuiLocation Online documentation}
*/
export type GuiLocationArray = readonly [int, int]
/**
* A {@link ChunkPosition} with an added bounding box for the area of the chunk.
* @see {@link https://lua-api.factorio.com/1.1.110/concepts.html#ChunkPositionAndArea Online documentation}
*/
export interface ChunkPositionAndArea {
readonly x: int
readonly y: int
readonly area: BoundingBox
}
/**
* A table used to define a manual shape for a piece of equipment.
* @see {@link https://lua-api.factorio.com/1.1.110/concepts.html#EquipmentPoint Online documentation}
*/
export interface EquipmentPoint {
readonly x: uint
readonly y: uint
}
export interface GuiAnchor {
readonly gui: defines.relative_gui_type
readonly position: defines.relative_gui_position
/**
* If provided, only anchors the GUI element when the opened things type matches the type.
*/
readonly type?: string
/**
* If provided, only anchors the GUI element when the opened thing matches the name. `name` takes precedence over `names`.
*/
readonly name?: string
/**
* If provided, only anchors the GUI element when the opened thing matches one of the names. When reading an anchor, `names` is always populated.
*/
readonly names?: string[]
}
export interface TabAndContent {
readonly tab: LuaGuiElement
readonly content: LuaGuiElement
}
export interface OldTileAndPosition {
readonly old_tile: LuaTilePrototype
readonly position: TilePosition
}
/**
* A dictionary of string to the four basic Lua types: `string`, `boolean`, `number`, `table`.
*
* Note that the API returns tags as a simple table, meaning any modifications to it will not propagate back to the game. Thus, to modify a set of tags, the whole table needs to be written back to the respective property.
* @example
* {a = 1, b = true, c = "three", d = {e = "f"}}
* @see {@link https://lua-api.factorio.com/1.1.110/concepts.html#Tags Online documentation}
*/
export type Tags = Record<string, AnyBasic>
/**
* The vectors for all 5 position attributes are a table with `x` and `y` keys instead of an array.
* @see {@link https://lua-api.factorio.com/1.1.110/concepts.html#SmokeSource Online documentation}
*/
export interface SmokeSource {
readonly name: string
readonly frequency: double
readonly offset: double
readonly position?: MapPosition
readonly north_position?: MapPosition
readonly east_position?: MapPosition
readonly south_position?: MapPosition
readonly west_position?: MapPosition
readonly deviation?: MapPosition
readonly starting_frame_speed: uint16
readonly starting_frame_speed_deviation: double
readonly starting_frame: uint16
readonly starting_frame_deviation: double
readonly slow_down_factor: uint8
readonly height: float
readonly height_deviation: float
readonly starting_vertical_speed: float
readonly starting_vertical_speed_deviation: float
readonly vertical_speed_slowdown: float
}
/**
* A vector is a two-element array containing the `x` and `y` components. In some specific cases, the vector is a table with `x` and `y` keys instead, which the documentation will point out.
* @example
* right = {1.0, 0.0}
* @see {@link https://lua-api.factorio.com/1.1.110/concepts.html#Vector Online documentation}
*/
export type Vector = MapPositionArray
/**
* Two positions, specifying the top-left and bottom-right corner of the box respectively. Like with {@link MapPosition}, the names of the members may be omitted. When read from the game, the third member `orientation` is present if it is non-zero.
* @see BoundingBoxArray
* @example
* -- Explicit definition
* {left_top = {x = -2, y = -3}, right_bottom = {x = 5, y = 8}}
* @example
* -- Shorthand
* {{-2, -3}, {5, 8}}
* @see {@link https://lua-api.factorio.com/1.1.110/concepts.html#BoundingBox Online documentation}
*/
export interface BoundingBox {
readonly left_top: MapPosition
readonly right_bottom: MapPosition
readonly orientation?: RealOrientation
}
/**
* Write form of {@link BoundingBox}, as a table, where positions are allowed to take an array form.
*/
export interface BoundingBoxWrite {
readonly left_top: MapPosition | MapPositionArray
readonly right_bottom: MapPosition | MapPositionArray
readonly orientation?: RealOrientation
}
/**
* Array form of {@link BoundingBox}.
* @see BoundingBox
* @see {@link https://lua-api.factorio.com/1.1.110/concepts.html#BoundingBox Online documentation}
*/
export type BoundingBoxArray = readonly [MapPosition | MapPositionArray, MapPosition | MapPositionArray]
/**
* An area defined using the map editor.
* @see ScriptAreaWrite
* @see {@link https://lua-api.factorio.com/1.1.110/concepts.html#ScriptArea Online documentation}
*/
export interface ScriptArea {
readonly area: BoundingBox
readonly name: string
readonly color: Color
readonly id: uint
}
/**
* Write form of {@link ScriptArea}, where table-or-array concepts are allowed to take an array form.
* @see {@link https://lua-api.factorio.com/1.1.110/concepts.html#ScriptArea Online documentation}
*/
export interface ScriptAreaWrite {
readonly area: BoundingBoxWrite | BoundingBoxArray
readonly name: string
readonly color: Color | ColorArray
readonly id: uint
}
/**
* A position defined using the map editor.
* @see ScriptPositionWrite
* @see {@link https://lua-api.factorio.com/1.1.110/concepts.html#ScriptPosition Online documentation}
*/
export interface ScriptPosition {
readonly position: MapPosition
readonly name: string
readonly color: Color
readonly id: uint
}
/**
* Write form of {@link ScriptPosition}, where table-or-array concepts are allowed to take an array form.
* @see {@link https://lua-api.factorio.com/1.1.110/concepts.html#ScriptPosition Online documentation}
*/
export interface ScriptPositionWrite {
readonly position: MapPosition | MapPositionArray
readonly name: string
readonly color: Color | ColorArray
readonly id: uint
}
/**
* Red, green, blue and alpha values, all in range [0, 1] or all in range [0, 255] if any value is > 1. All values here are optional. Color channels default to `0`, the alpha channel defaults to `1`.
*
* Similar to {@link MapPosition}, Color allows the short-hand notation of passing an array of exactly 3 or 4 numbers. The game usually expects colors to be in pre-multiplied form (color channels are pre-multiplied by alpha).
* @see ColorArray
* @example
* red1 = {r = 0.5, g = 0, b = 0, a = 0.5} -- Half-opacity red
* red2 = {r = 0.5, a = 0.5} -- Same color as red1
* black = {} -- All channels omitted: black
* red1_short = {0.5, 0, 0, 0.5} -- Same color as red1 in short-hand notation
* @see {@link https://lua-api.factorio.com/1.1.110/concepts.html#Color Online documentation}
*/
export interface Color {
readonly r?: float
readonly g?: float
readonly b?: float
readonly a?: float
}
/**
* Array form of {@link Color}.
* @see Color
* @see {@link https://lua-api.factorio.com/1.1.110/concepts.html#Color Online documentation}
*/
export type ColorArray = readonly [r: double, g: double, b: double, a?: double]
/**
* Same as {@link Color}, but red, green, blue and alpha values can be any floating point number, without any special handling of the range [1, 255].
* @see ColorModifierArray
* @see {@link https://lua-api.factorio.com/1.1.110/concepts.html#ColorModifier Online documentation}
*/
export interface ColorModifier {
readonly r?: float
readonly g?: float
readonly b?: float
readonly a?: float
}
/**
* Array form of {@link ColorModifier}.
* @see ColorModifier
* @see {@link https://lua-api.factorio.com/1.1.110/concepts.html#ColorModifier Online documentation}
*/
export type ColorModifierArray = readonly [r: double, g: double, b: double, a?: double]
export interface CraftingQueueItem {
/**
* The index of the item in the crafting queue.
*/
readonly index: uint
/**
* The recipe being crafted.
*/
readonly recipe: string
/**
* The amount of items being crafted.
*/
readonly count: uint
/**
* The item is a prerequisite for another item in the queue.
*/
readonly prerequisite: boolean
}
export interface Alert {
/**
* The tick this alert was created.
*/
readonly tick: uint
readonly target?: LuaEntity
readonly prototype?: LuaEntityPrototype
readonly position?: MapPosition
/**
* The SignalID used for a custom alert. Only present for custom alerts.
*/
readonly icon?: SignalID
/**
* The message for a custom alert. Only present for custom alerts.
*/
readonly message?: LocalisedString
}
/**
* One vertex of a ScriptRenderPolygon.
* @see {@link https://lua-api.factorio.com/1.1.110/concepts.html#ScriptRenderVertexTarget Online documentation}
*/
export interface ScriptRenderVertexTarget {
readonly target: (MapPosition | MapPositionArray) | LuaEntity
/**
* Only used if `target` is a LuaEntity.
*/
readonly target_offset?: Vector
}
export interface PathfinderWaypoint {
/**
* The position of the waypoint on its surface.
*/
readonly position: MapPosition
/**
* `true` if the path from the previous waypoint to this one goes through an entity that must be destroyed.
*/
readonly needs_destroy_to_reach: boolean
}
export interface CutsceneWaypoint {
/**
* Position to pan the camera to.
*/
readonly position?: MapPosition | MapPositionArray
/**
* Entity or unit group to pan the camera to.
*/
readonly target?: LuaEntity | LuaUnitGroup
/**
* How many ticks it will take to reach this waypoint from the previous one.
*/
readonly transition_time: uint
/**
* Time in ticks to wait before moving to the next waypoint.
*/
readonly time_to_wait: uint
/**
* Zoom level to be set when the waypoint is reached. When not specified, the previous waypoint's zoom is used.
*/
readonly zoom?: double
}
export interface Decorative {
/**
* The name of the decorative prototype.
*/
readonly name: string
readonly position: TilePosition | TilePositionArray
readonly amount: uint8
}
export interface DecorativeResult {
readonly position: TilePosition
readonly decorative: LuaDecorativePrototype
readonly amount: uint
}
export interface PrototypeHistory {
/**
* The mod that created this prototype.
*/
readonly created: string
/**
* The mods that changed this prototype in the order they changed it.
*/
readonly changed: string[]
}
/**
* Either `icon`, `text`, or both must be provided.
* @see {@link https://lua-api.factorio.com/1.1.110/concepts.html#ChartTagSpec Online documentation}
*/
export interface ChartTagSpec {
readonly position: MapPosition | MapPositionArray
readonly icon?: SignalID
readonly text?: string
readonly last_user?: PlayerIdentification
}
/**
* 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/1.1.110/concepts.html#GameViewSettings 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/1.1.110/concepts.html#GameViewSettings.show_controller_gui 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/1.1.110/concepts.html#GameViewSettings.show_minimap 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/1.1.110/concepts.html#GameViewSettings.show_research_info Online documentation}
*/
show_research_info: boolean
/**
* Show overlay icons on entities. Also known as "alt-mode".
* @see {@link https://lua-api.factorio.com/1.1.110/concepts.html#GameViewSettings.show_entity_info Online documentation}
*/
show_entity_info: boolean
/**
* Show the flashing alert icons next to the player's toolbar.
* @see {@link https://lua-api.factorio.com/1.1.110/concepts.html#GameViewSettings.show_alert_gui 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/1.1.110/concepts.html#GameViewSettings.update_entity_selection 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/1.1.110/concepts.html#GameViewSettings.show_rail_block_visualisation Online documentation}
*/
show_rail_block_visualisation: boolean
/**
* Shows or hides the buttons row.
* @see {@link https://lua-api.factorio.com/1.1.110/concepts.html#GameViewSettings.show_side_menu Online documentation}
*/
show_side_menu: boolean
/**
* Shows or hides the view options when map is opened.
* @see {@link https://lua-api.factorio.com/1.1.110/concepts.html#GameViewSettings.show_map_view_options 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/1.1.110/concepts.html#GameViewSettings.show_entity_tooltip Online documentation}
*/
show_entity_tooltip: boolean
/**
* Shows or hides quickbar of shortcuts.
* @see {@link https://lua-api.factorio.com/1.1.110/concepts.html#GameViewSettings.show_quickbar Online documentation}
*/
show_quickbar: boolean
/**
* Shows or hides the shortcut bar.
* @see {@link https://lua-api.factorio.com/1.1.110/concepts.html#GameViewSettings.show_shortcut_bar Online documentation}
*/
show_shortcut_bar: boolean
/**
* Shows or hides the crafting queue.
* @see {@link https://lua-api.factorio.com/1.1.110/concepts.html#GameViewSettings.show_crafting_queue Online documentation}
*/
show_crafting_queue: boolean
/**
* Shows or hides the tool window with the weapons and armor.
* @see {@link https://lua-api.factorio.com/1.1.110/concepts.html#GameViewSettings.show_tool_bar 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/1.1.110/concepts.html#GameViewSettings.show_hotkey_suggestions Online documentation}
*/
show_hotkey_suggestions: boolean
}
/**
* These values are for the time frame of one second (60 ticks).
* @see {@link https://lua-api.factorio.com/1.1.110/concepts.html#PollutionMapSettings Online documentation}
*/
export interface PollutionMapSettings {
/**
* Whether pollution is enabled at all.
*/
readonly enabled: boolean
/**
* The amount that is diffused to a neighboring chunk (possibly repeated for other directions as well). Defaults to `0.02`.
*/
readonly diffusion_ratio: double
/**
* The amount of PUs that need to be in a chunk for it to start diffusing. Defaults to `15`.
*/
readonly min_to_diffuse: double
/**
* The amount of pollution eaten by a chunk's tiles as a percentage of 1. Also known as absorption modifier. Defaults to `1`.
*/
readonly ageing: double
/**
* Any amount of pollution larger than this value is visualized as this value instead. Defaults to `150`.
*/
readonly expected_max_per_chunk: double
/**
* Any amount of pollution smaller than this value (but bigger than zero