From 17b4fc3b9a5089f5d729a77baecb11c5488066a4 Mon Sep 17 00:00:00 2001 From: Adam <897017+asemy@users.noreply.github.com> Date: Wed, 13 Oct 2021 21:29:21 +0200 Subject: [PATCH] set up tstl factorio mod, and auto deploy stuff. A bit of mucking around with kotlin/js & dukat but it didn't go anywhere. Add a license. --- LICENSE | 24 + .../factoriowebmap/archetype/base.gradle.kts | 6 +- .../archetype/kotlin-js.gradle.kts | 13 +- .../factoriowebmap/archetype/node.gradle.kts | 23 + modules/mod/build.gradle.kts | 104 +- modules/mod/src/events.ts | 19 - .../resources/mod-data}/changelog.txt | 0 .../{ => main/resources/mod-data}/info.json | 2 +- .../resources/mod-data}/thumbnail.png | Bin .../mod/src/{ => main/typescript}/control.ts | 0 modules/mod/src/main/typescript/events.ts | 30 + .../{ => main/typescript}/package-lock.json | 19 - .../src/{ => main/typescript}/package.json | 0 .../src/{ => main/typescript}/tsconfig.json | 0 .../test/resources/server}/docker-compose.yml | 2 +- .../test/data/config/map-gen-settings.json | 78 + .../mod/test/data/config/map-settings.json | 120 + modules/mod/test/data/config/rconpw | 1 + .../mod/test/data/config/server-settings.json | 69 + modules/mod/test/data/mods/mod-list.json | 11 + modules/mod/test/data/player-data.json | 532 + modules/mod2/build.gradle.kts | 6 + .../builtin-types.module_typed-factorio.kt | 12 - .../classes.module_typed-factorio.kt | 6 +- ...es.defines.events.module_typed-factorio.kt | 4 +- modules/mod2/dukat-custom/eventId.kt | 11 + .../dukat-custom/global.module_lua-types.kt | 42 +- modules/mod2/dukat-custom/tsstdlib/lib.es5.kt | 4 +- modules/mod2/src/main/kotlin/events.kt | 11 + modules/mod2/typed-factorio/README.md | 113 + modules/mod2/typed-factorio/data/types.d.ts | 13 + .../generated/builtin-types.d.ts | 66 + .../typed-factorio/generated/classes.d.ts | 20023 ++++++++++++++++ .../typed-factorio/generated/concepts.d.ts | 5635 +++++ .../typed-factorio/generated/defines.d.ts | 1642 ++ .../mod2/typed-factorio/generated/events.d.ts | 2976 +++ .../generated/global-objects.d.ts | 51 + .../mod2/typed-factorio/generated/index.d.ts | 7 + modules/mod2/typed-factorio/package.json | 39 + .../mod2/typed-factorio/runtime/index.d.ts | 10 + .../runtime/librariesAndFunctions.d.ts | 123 + .../mod2/typed-factorio/runtime/mod-gui.d.ts | 11 + .../mod2/typed-factorio/runtime/pairs.d.ts | 13 + modules/mod2/typed-factorio/runtime/util.d.ts | 120 + .../mod2/typed-factorio/settings/types.d.ts | 120 + settings.gradle.kts | 4 +- src/jsMain/kotlin/factorio.kt | 3 - 47 files changed, 32006 insertions(+), 112 deletions(-) create mode 100644 LICENSE create mode 100644 buildSrc/src/main/kotlin/dev/adamko/factoriowebmap/archetype/node.gradle.kts delete mode 100644 modules/mod/src/events.ts rename modules/mod/src/{ => main/resources/mod-data}/changelog.txt (100%) rename modules/mod/src/{ => main/resources/mod-data}/info.json (86%) rename modules/mod/src/{ => main/resources/mod-data}/thumbnail.png (100%) rename modules/mod/src/{ => main/typescript}/control.ts (100%) create mode 100644 modules/mod/src/main/typescript/events.ts rename modules/mod/src/{ => main/typescript}/package-lock.json (98%) rename modules/mod/src/{ => main/typescript}/package.json (100%) rename modules/mod/src/{ => main/typescript}/tsconfig.json (100%) rename modules/mod/{test => src/test/resources/server}/docker-compose.yml (90%) create mode 100644 modules/mod/test/data/config/map-gen-settings.json create mode 100644 modules/mod/test/data/config/map-settings.json create mode 100644 modules/mod/test/data/config/rconpw create mode 100644 modules/mod/test/data/config/server-settings.json create mode 100644 modules/mod/test/data/mods/mod-list.json create mode 100644 modules/mod/test/data/player-data.json create mode 100644 modules/mod2/dukat-custom/eventId.kt create mode 100644 modules/mod2/src/main/kotlin/events.kt create mode 100644 modules/mod2/typed-factorio/README.md create mode 100644 modules/mod2/typed-factorio/data/types.d.ts create mode 100644 modules/mod2/typed-factorio/generated/builtin-types.d.ts create mode 100644 modules/mod2/typed-factorio/generated/classes.d.ts create mode 100644 modules/mod2/typed-factorio/generated/concepts.d.ts create mode 100644 modules/mod2/typed-factorio/generated/defines.d.ts create mode 100644 modules/mod2/typed-factorio/generated/events.d.ts create mode 100644 modules/mod2/typed-factorio/generated/global-objects.d.ts create mode 100644 modules/mod2/typed-factorio/generated/index.d.ts create mode 100644 modules/mod2/typed-factorio/package.json create mode 100644 modules/mod2/typed-factorio/runtime/index.d.ts create mode 100644 modules/mod2/typed-factorio/runtime/librariesAndFunctions.d.ts create mode 100644 modules/mod2/typed-factorio/runtime/mod-gui.d.ts create mode 100644 modules/mod2/typed-factorio/runtime/pairs.d.ts create mode 100644 modules/mod2/typed-factorio/runtime/util.d.ts create mode 100644 modules/mod2/typed-factorio/settings/types.d.ts delete mode 100644 src/jsMain/kotlin/factorio.kt diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..0804e5f --- /dev/null +++ b/LICENSE @@ -0,0 +1,24 @@ +COPYRIGHT (C) LIMITED USE SOFTWARE LICENSE AGREEMENT + +All rights are reserved by the copyright holder. + +Permission is granted to use this software as a Factorio mod. + +Permission is granted distribute this software under the +condition that the distribution is publicly accessible, +and no payment or registration is required. Additionally, +all distributions must include the full source code of the +software, without restrictions or limitations. + +Permission is granted to make modifications to this software +under the condition that any claim of ownership is +relinquished, and any modification becomes the property of +the original copyright holder of this software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT +NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +For more information contact fredthedeadhead@gmail.com diff --git a/buildSrc/src/main/kotlin/dev/adamko/factoriowebmap/archetype/base.gradle.kts b/buildSrc/src/main/kotlin/dev/adamko/factoriowebmap/archetype/base.gradle.kts index 02ed00f..555967c 100644 --- a/buildSrc/src/main/kotlin/dev/adamko/factoriowebmap/archetype/base.gradle.kts +++ b/buildSrc/src/main/kotlin/dev/adamko/factoriowebmap/archetype/base.gradle.kts @@ -4,11 +4,11 @@ plugins { base } -group = rootProject.group.toString() + "." + project.name +group = "${rootProject.group}.${project.name}" version = rootProject.version -val projectId by extra(rootProject.name + "-" + project.name) -val modBuildDir by extra(layout.buildDirectory.dir(projectId).get()) +val projectId by extra("${rootProject.name}-${project.name}") +//val modBuildDir by extra(layout.buildDirectory.dir(projectId).get()) //group = "dev.adamko.factoriowebmap" //version = "0.0.1" diff --git a/buildSrc/src/main/kotlin/dev/adamko/factoriowebmap/archetype/kotlin-js.gradle.kts b/buildSrc/src/main/kotlin/dev/adamko/factoriowebmap/archetype/kotlin-js.gradle.kts index 176bf65..2dcac1b 100644 --- a/buildSrc/src/main/kotlin/dev/adamko/factoriowebmap/archetype/kotlin-js.gradle.kts +++ b/buildSrc/src/main/kotlin/dev/adamko/factoriowebmap/archetype/kotlin-js.gradle.kts @@ -12,10 +12,11 @@ import org.jetbrains.kotlin.gradle.targets.js.npm.NpmProject plugins { kotlin("js") - id("com.github.node-gradle.node") - id("dev.adamko.factoriowebmap.archetype.base") + id("dev.adamko.factoriowebmap.archetype.node") } + + kotlin { js(IR) { @@ -47,16 +48,18 @@ val rootPackageJson by rootProject.tasks.getting(RootPackageJsonTask::class) //fun NpmTask.setNodeModulesPath(folder: File): Unit = // setNodeModulesPath(folder.normalize().absolutePath) +// https://github.com/node-gradle/gradle-node-plugin/issues/150 +// https://github.com/lamba92/kotlingram/blob/master/examples/js-bot/build.gradle.kts val nodePath: Directory by extra { val file = rootPackageJson.rootPackageJson.parentFile.normalize() - logger.lifecycle("Found root NODE_PATH: $file") + logger.lifecycle("Kotlin/JS NODE_PATH: $file") project.layout.dir(provider { file }).get() } val nodeModulesDir: Directory by extra { val file = nodePath.dir(NpmProject.NODE_MODULES) - logger.lifecycle("Found root NODE_MODULES: $file") + logger.lifecycle("Kotlin/JS NODE_MODULES: $file") file } @@ -66,7 +69,7 @@ node { distBaseUrl.set(null as String?) // set by dependencyResolutionManagement - nodeProjectDir.set(nodePath) +// nodeProjectDir.set(nodePath) // nodeProjectDir.set(packageJson.packageJson.parentFile.normalize()) } diff --git a/buildSrc/src/main/kotlin/dev/adamko/factoriowebmap/archetype/node.gradle.kts b/buildSrc/src/main/kotlin/dev/adamko/factoriowebmap/archetype/node.gradle.kts new file mode 100644 index 0000000..cb83376 --- /dev/null +++ b/buildSrc/src/main/kotlin/dev/adamko/factoriowebmap/archetype/node.gradle.kts @@ -0,0 +1,23 @@ +package dev.adamko.factoriowebmap.archetype + +import org.gradle.kotlin.dsl.kotlin +import com.github.gradle.node.npm.task.NpmTask +import com.github.gradle.node.task.NodeTask +import org.jetbrains.kotlin.gradle.targets.js.dukat.DtsResolver +import org.jetbrains.kotlin.gradle.targets.js.npm.tasks.RootPackageJsonTask +import org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinPackageJsonTask +import org.jetbrains.kotlin.util.parseSpaceSeparatedArgs +import org.jetbrains.kotlin.gradle.targets.js.npm.NpmProject + +plugins { + id("com.github.node-gradle.node") + id("dev.adamko.factoriowebmap.archetype.base") +} + +node { + download.set(true) + version.set("14.18.0") + + distBaseUrl.set(null as String?) // set by dependencyResolutionManagement +} + diff --git a/modules/mod/build.gradle.kts b/modules/mod/build.gradle.kts index 742c8f3..5124676 100644 --- a/modules/mod/build.gradle.kts +++ b/modules/mod/build.gradle.kts @@ -1,28 +1,22 @@ import com.github.gradle.node.npm.task.NpmTask +import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension import org.jetbrains.kotlin.util.parseSpaceSeparatedArgs plugins { - base - id("com.github.node-gradle.node") + id("dev.adamko.factoriowebmap.archetype.node") } -group = "${rootProject.group}.mod" -version = rootProject.version +val projectId: String by project.extra + + +val tsSrcDir = layout.projectDirectory.dir("src/main/typescript") +val modBuildDir = layout.buildDirectory.dir(projectId).get() node { - download.set(true) - version.set("14.18.0") - - nodeProjectDir.set(layout.projectDirectory.dir("src")) - - distBaseUrl.set(null as String?) // set root dependencyResolutionManagement + nodeProjectDir.set(tsSrcDir) } -val projectId = rootProject.name + "-" + project.name -val modBuildDir = layout.buildDirectory.dir(projectId).get() -//val tsSrcDir = layout.projectDirectory.dir("src") - -val tstlTask = tasks.register("tstl") { +val tstlTask = tasks.register("typescriptToLua") { description = "Typescript To Lua" group = projectId @@ -30,15 +24,25 @@ val tstlTask = tasks.register("tstl") { execOverrides { standardOutput = System.out } - npmCommand.set(listOf("run", "build")) + npmCommand.set(listOf( + "run", + "build", +// "--workspace=factorio-web-map-mod", + )) - val outputDir = modBuildDir.dir("tstl") - args.set(parseSpaceSeparatedArgs("-- --outDir $outputDir")) + inputs.dir(node.nodeProjectDir) + + val outputDir = modBuildDir.dir("typescriptToLua") outputs.dir(outputDir) + args.set(parseSpaceSeparatedArgs("-- --outDir $outputDir")) +// args.set(listOf( +// "--", +// "--outDir $outputDir", +// "--workspace=factorio-web-map-mod", +// )) ignoreExitValue.set(false) // workingDir.set(tsSrcDir.asFile) - inputs.dir(node.nodeProjectDir) // inputs.dir("node_modules") // inputs.dir(fileTree("src")) // inputs.files( @@ -56,18 +60,62 @@ val modPackageTask = tasks.register("package") { dependsOn(tstlTask) - from(layout.projectDirectory.dir("src")) { - exclude("*.ts") - into(rootProject.name) - } - from(tstlTask) { - into(rootProject.name) - } + from( + layout.projectDirectory.dir("src/main/resources/mod-data"), + rootProject.layout.projectDirectory.file("LICENSE"), + tstlTask, + ) + into(rootProject.name) + + // Factorio required format is: + // - filename: `mod-name_version.zip` + // - zip contains dir `mod-name` archiveFileName.set("${rootProject.name}_${rootProject.version}.zip") destinationDirectory.set(modBuildDir.dir("dist")) - } -tasks.build { dependsOn(tstlTask, modPackageTask) } +//tasks.build { dependsOn(tstlTask, modPackageTask) } +val copyModToServerTask = tasks.register("copyModToServer") { + description = "Copy the mod to the Factorio Docker server" + group = projectId + + dependsOn(modPackageTask) + + from(modPackageTask) + into(layout.projectDirectory.dir("src/test/resources/server/data/mods").asFile) +} + +val copyModToClientTask = tasks.register("copyModToClient") { + description = "Copy the mod to the Factorio client" + group = projectId + + dependsOn(modPackageTask) + + from(modPackageTask) + into("""D:\Users\Adam\AppData\Roaming\Factorio\mods""") +} + +val serverRestartTask = tasks.register("serverRestart") { + group = projectId + + workingDir = layout.projectDirectory.dir("src/test/resources/server/").asFile + commandLine = parseSpaceSeparatedArgs("docker-compose restart") +} + +tasks.register("serverStop") { + group = projectId + + workingDir = layout.projectDirectory.dir("src/test/resources/server/").asFile + commandLine = parseSpaceSeparatedArgs("docker-compose stop") +} + +val launch = tasks.register("modLauncher") { + group = projectId + dependsOn( + copyModToServerTask, + copyModToClientTask, + serverRestartTask, + ) +} diff --git a/modules/mod/src/events.ts b/modules/mod/src/events.ts deleted file mode 100644 index dc2b9b5..0000000 --- a/modules/mod/src/events.ts +++ /dev/null @@ -1,19 +0,0 @@ -script.on_event( - [defines.events.on_pre_build, defines.events.on_player_dropped_item], - (e: OnPreBuildEvent | OnPlayerDroppedItemEvent) => { - game.print("player " + e.player_index + " dropped item, tick:" + e.tick) - } -); - -script.on_event( - defines.events.on_tick, - (e: OnTickEvent) => { - if (e.tick % 60 == 0) { - game.print("test mod tick: " + e.tick) - } - } -); - -script.on_load(() => { - game.print("loaded Factorio Web Map!") -}); diff --git a/modules/mod/src/changelog.txt b/modules/mod/src/main/resources/mod-data/changelog.txt similarity index 100% rename from modules/mod/src/changelog.txt rename to modules/mod/src/main/resources/mod-data/changelog.txt diff --git a/modules/mod/src/info.json b/modules/mod/src/main/resources/mod-data/info.json similarity index 86% rename from modules/mod/src/info.json rename to modules/mod/src/main/resources/mod-data/info.json index f24f7d0..edb1777 100644 --- a/modules/mod/src/info.json +++ b/modules/mod/src/main/resources/mod-data/info.json @@ -1,6 +1,6 @@ { "name": "factorio-web-map", - "version": "0.0.1", + "version": "0.0.2", "title": "Factorio Web Map", "author": "fredthedeadhead", "factorio_version": "1.1", diff --git a/modules/mod/src/thumbnail.png b/modules/mod/src/main/resources/mod-data/thumbnail.png similarity index 100% rename from modules/mod/src/thumbnail.png rename to modules/mod/src/main/resources/mod-data/thumbnail.png diff --git a/modules/mod/src/control.ts b/modules/mod/src/main/typescript/control.ts similarity index 100% rename from modules/mod/src/control.ts rename to modules/mod/src/main/typescript/control.ts diff --git a/modules/mod/src/main/typescript/events.ts b/modules/mod/src/main/typescript/events.ts new file mode 100644 index 0000000..946f1b9 --- /dev/null +++ b/modules/mod/src/main/typescript/events.ts @@ -0,0 +1,30 @@ +script.on_event( + [defines.events.on_pre_build, defines.events.on_player_dropped_item], + (e: OnPreBuildEvent | OnPlayerDroppedItemEvent) => { + game.print("player " + e.player_index + " dropped item, tick:" + e.tick) + } +); + +script.on_event( + defines.events.on_tick, + (e: OnTickEvent) => { + if (e.tick % 60 == 0) { + let msg = "test mod tick: " + e.tick + "\n" + // game.print(msg) + game.write_file("tick.log", msg, true) + + + let groups = game.permissions.groups.map(val => { + return val.name + "\n" + serpent.block(val) + }).join("\n") + + game.write_file("permissions.json", groups, false) + // game.write_file("permissions-groups.json", serpent.block(game.permissions.groups), false) + } + } +); + + +// script.on_load(() => { +// game.print("loaded Factorio Web Map!") +// }); diff --git a/modules/mod/src/package-lock.json b/modules/mod/src/main/typescript/package-lock.json similarity index 98% rename from modules/mod/src/package-lock.json rename to modules/mod/src/main/typescript/package-lock.json index 403b9ef..d5b6264 100644 --- a/modules/mod/src/package-lock.json +++ b/modules/mod/src/main/typescript/package-lock.json @@ -907,16 +907,6 @@ "object-assign": "^4.1.1" } }, - "react-dom": { - "version": "17.0.2", - "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-17.0.2.tgz", - "integrity": "sha512-s4h96KtLDUQlsENhMn1ar8t2bEa+q/YAtj8pPPdIjPDGBDIVNsrD9aXNWqspUe6AzKCIG0C1HZZLqLV7qpOBGA==", - "requires": { - "loose-envify": "^1.1.0", - "object-assign": "^4.1.1", - "scheduler": "^0.20.2" - } - }, "rechoir": { "version": "0.7.1", "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.7.1.tgz", @@ -962,15 +952,6 @@ "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", "dev": true }, - "scheduler": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.20.2.tgz", - "integrity": "sha512-2eWfGgAqqWFGqtdMmcL5zCMK1U8KlXv8SQFGglL3CEtd0aDVDWgeF/YoCmvln55m5zSk3J/20hTaSBeSObsQDQ==", - "requires": { - "loose-envify": "^1.1.0", - "object-assign": "^4.1.1" - } - }, "schema-utils": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-3.1.1.tgz", diff --git a/modules/mod/src/package.json b/modules/mod/src/main/typescript/package.json similarity index 100% rename from modules/mod/src/package.json rename to modules/mod/src/main/typescript/package.json diff --git a/modules/mod/src/tsconfig.json b/modules/mod/src/main/typescript/tsconfig.json similarity index 100% rename from modules/mod/src/tsconfig.json rename to modules/mod/src/main/typescript/tsconfig.json diff --git a/modules/mod/test/docker-compose.yml b/modules/mod/src/test/resources/server/docker-compose.yml similarity index 90% rename from modules/mod/test/docker-compose.yml rename to modules/mod/src/test/resources/server/docker-compose.yml index 5359a78..78bc9a8 100644 --- a/modules/mod/test/docker-compose.yml +++ b/modules/mod/src/test/resources/server/docker-compose.yml @@ -1,7 +1,7 @@ version: "3.9" services: factorio: - image: factoriotools/factorio:1.1.41 + image: factoriotools/factorio:1.1.42 # logging: # driver: "json-file" container_name: "factorio" diff --git a/modules/mod/test/data/config/map-gen-settings.json b/modules/mod/test/data/config/map-gen-settings.json new file mode 100644 index 0000000..7a2b412 --- /dev/null +++ b/modules/mod/test/data/config/map-gen-settings.json @@ -0,0 +1,78 @@ +{ + "_terrain_segmentation_comment": "The inverse of 'water scale' in the map generator GUI.", + "terrain_segmentation": 1, + + "_water_comment": + [ + "The equivalent to 'water coverage' in the map generator GUI. Higher coverage means more water in larger oceans.", + "Water level = 10 * log2(this value)" + ], + "water": 1, + + "_comment_width+height": "Width and height of map, in tiles; 0 means infinite", + "width": 0, + "height": 0, + + "_starting_area_comment": "Multiplier for 'biter free zone radius'", + "starting_area": 1, + + "peaceful_mode": false, + "autoplace_controls": + { + "coal": {"frequency": 1, "size": 1, "richness": 1}, + "stone": {"frequency": 1, "size": 1, "richness": 1}, + "copper-ore": {"frequency": 1, "size": 1,"richness": 1}, + "iron-ore": {"frequency": 1, "size": 1, "richness": 1}, + "uranium-ore": {"frequency": 1, "size": 1, "richness": 1}, + "crude-oil": {"frequency": 1, "size": 1, "richness": 1}, + "trees": {"frequency": 1, "size": 1, "richness": 1}, + "enemy-base": {"frequency": 1, "size": 1, "richness": 1} + }, + + "cliff_settings": + { + "_name_comment": "Name of the cliff prototype", + "name": "cliff", + + "_cliff_elevation_0_comment": "Elevation of first row of cliffs", + "cliff_elevation_0": 10, + + "_cliff_elevation_interval_comment": + [ + "Elevation difference between successive rows of cliffs.", + "This is inversely proportional to 'frequency' in the map generation GUI. Specifically, when set from the GUI the value is 40 / frequency." + ], + "cliff_elevation_interval": 40, + + "_richness_comment": "Called 'cliff continuity' in the map generator GUI. 0 will result in no cliffs, 10 will make all cliff rows completely solid", + "richness": 1 + }, + + "_property_expression_names_comment": + [ + "Overrides for property value generators (map type)", + "Leave 'elevation' blank to get 'normal' terrain.", + "Use 'elevation': '0_16-elevation' to reproduce terrain from 0.16.", + "Use 'elevation': '0_17-island' to get an island.", + "Moisture and terrain type are also controlled via this.", + "'control-setting:moisture:frequency:multiplier' is the inverse of the 'moisture scale' in the map generator GUI.", + "'control-setting:moisture:bias' is the 'moisture bias' in the map generator GUI.", + "'control-setting:aux:frequency:multiplier' is the inverse of the 'terrain type scale' in the map generator GUI.", + "'control-setting:aux:bias' is the 'terrain type bias' in the map generator GUI." + ], + "property_expression_names": + { + "control-setting:moisture:frequency:multiplier": "1", + "control-setting:moisture:bias": "0", + "control-setting:aux:frequency:multiplier": "1", + "control-setting:aux:bias": "0" + }, + + "starting_points": + [ + { "x": 0, "y": 0} + ], + + "_seed_comment": "Use null for a random seed, number for a specific seed.", + "seed": null +} diff --git a/modules/mod/test/data/config/map-settings.json b/modules/mod/test/data/config/map-settings.json new file mode 100644 index 0000000..62798d9 --- /dev/null +++ b/modules/mod/test/data/config/map-settings.json @@ -0,0 +1,120 @@ +{ + "difficulty_settings": + { + "recipe_difficulty": 0, + "technology_difficulty": 0, + "technology_price_multiplier": 1, + "research_queue_setting": "after-victory" + }, + "pollution": + { + "enabled": true, + "_comment_min_to_diffuse_1": "these are values for 60 ticks (1 simulated second)", + "_comment_min_to_diffuse_2": "amount that is diffused to neighboring chunk", + "diffusion_ratio": 0.02, + "min_to_diffuse": 15, + "ageing": 1, + "expected_max_per_chunk": 150, + "min_to_show_per_chunk": 50, + "min_pollution_to_damage_trees": 60, + "pollution_with_max_forest_damage": 150, + "pollution_per_tree_damage": 50, + "pollution_restored_per_tree_damage": 10, + "max_pollution_to_restore_trees": 20, + "enemy_attack_pollution_consumption_modifier": 1 + }, + "enemy_evolution": + { + "enabled": true, + "time_factor": 0.000004, + "destroy_factor": 0.002, + "pollution_factor": 0.0000009 + }, + "enemy_expansion": + { + "enabled": true, + "min_base_spacing": 3, + "max_expansion_distance": 7, + "friendly_base_influence_radius": 2, + "enemy_building_influence_radius": 2, + "building_coefficient": 0.1, + "other_base_coefficient": 2.0, + "neighbouring_chunk_coefficient": 0.5, + "neighbouring_base_chunk_coefficient": 0.4, + "max_colliding_tiles_coefficient": 0.9, + "settler_group_min_size": 5, + "settler_group_max_size": 20, + "min_expansion_cooldown": 14400, + "max_expansion_cooldown": 216000 + }, + "unit_group": + { + "min_group_gathering_time": 3600, + "max_group_gathering_time": 36000, + "max_wait_time_for_late_members": 7200, + "max_group_radius": 30.0, + "min_group_radius": 5.0, + "max_member_speedup_when_behind": 1.4, + "max_member_slowdown_when_ahead": 0.6, + "max_group_slowdown_factor": 0.3, + "max_group_member_fallback_factor": 3, + "member_disown_distance": 10, + "tick_tolerance_when_member_arrives": 60, + "max_gathering_unit_groups": 30, + "max_unit_group_size": 200 + }, + "steering": + { + "default": + { + "radius": 1.2, + "separation_force": 0.005, + "separation_factor": 1.2, + "force_unit_fuzzy_goto_behavior": false + }, + "moving": + { + "radius": 3, + "separation_force": 0.01, + "separation_factor": 3, + "force_unit_fuzzy_goto_behavior": false + } + }, + "path_finder": + { + "fwd2bwd_ratio": 5, + "goal_pressure_ratio": 2, + "max_steps_worked_per_tick": 100, + "max_work_done_per_tick": 8000, + "use_path_cache": true, + "short_cache_size": 5, + "long_cache_size": 25, + "short_cache_min_cacheable_distance": 10, + "short_cache_min_algo_steps_to_cache": 50, + "long_cache_min_cacheable_distance": 30, + "cache_max_connect_to_cache_steps_multiplier": 100, + "cache_accept_path_start_distance_ratio": 0.2, + "cache_accept_path_end_distance_ratio": 0.15, + "negative_cache_accept_path_start_distance_ratio": 0.3, + "negative_cache_accept_path_end_distance_ratio": 0.3, + "cache_path_start_distance_rating_multiplier": 10, + "cache_path_end_distance_rating_multiplier": 20, + "stale_enemy_with_same_destination_collision_penalty": 30, + "ignore_moving_enemy_collision_distance": 5, + "enemy_with_different_destination_collision_penalty": 30, + "general_entity_collision_penalty": 10, + "general_entity_subsequent_collision_penalty": 3, + "extended_collision_penalty": 3, + "max_clients_to_accept_any_new_request": 10, + "max_clients_to_accept_short_new_request": 100, + "direct_distance_to_consider_short_request": 100, + "short_request_max_steps": 1000, + "short_request_ratio": 0.5, + "min_steps_to_check_path_find_termination": 2000, + "start_to_goal_cost_multiplier_to_terminate_path_find": 500.0, + "overload_levels": [0, 100, 500], + "overload_multipliers": [2, 3, 4], + "negative_path_cache_delay_interval": 20 + }, + "max_failed_behavior_count": 3 +} diff --git a/modules/mod/test/data/config/rconpw b/modules/mod/test/data/config/rconpw new file mode 100644 index 0000000..581e57b --- /dev/null +++ b/modules/mod/test/data/config/rconpw @@ -0,0 +1 @@ +we3Sai7phaeFohc diff --git a/modules/mod/test/data/config/server-settings.json b/modules/mod/test/data/config/server-settings.json new file mode 100644 index 0000000..0bb77f5 --- /dev/null +++ b/modules/mod/test/data/config/server-settings.json @@ -0,0 +1,69 @@ +{ + "name": "Name of the game as it will appear in the game listing", + "description": "Description of the game that will appear in the listing", + "tags": ["game", "tags"], + + "_comment_max_players": "Maximum number of players allowed, admins can join even a full server. 0 means unlimited.", + "max_players": 0, + + "_comment_visibility": ["public: Game will be published on the official Factorio matching server", + "lan: Game will be broadcast on LAN"], + "visibility": + { + "public": true, + "lan": true + }, + + "_comment_credentials": "Your factorio.com login credentials. Required for games with visibility public", + "username": "", + "password": "", + + "_comment_token": "Authentication token. May be used instead of 'password' above.", + "token": "", + + "game_password": "", + + "_comment_require_user_verification": "When set to true, the server will only allow clients that have a valid Factorio.com account", + "require_user_verification": true, + + "_comment_max_upload_in_kilobytes_per_second" : "optional, default value is 0. 0 means unlimited.", + "max_upload_in_kilobytes_per_second": 0, + + "_comment_max_upload_slots" : "optional, default value is 5. 0 means unlimited.", + "max_upload_slots": 5, + + "_comment_minimum_latency_in_ticks": "optional one tick is 16ms in default speed, default value is 0. 0 means no minimum.", + "minimum_latency_in_ticks": 0, + + "_comment_ignore_player_limit_for_returning_players": "Players that played on this map already can join even when the max player limit was reached.", + "ignore_player_limit_for_returning_players": false, + + "_comment_allow_commands": "possible values are, true, false and admins-only", + "allow_commands": "admins-only", + + "_comment_autosave_interval": "Autosave interval in minutes", + "autosave_interval": 10, + + "_comment_autosave_slots": "server autosave slots, it is cycled through when the server autosaves.", + "autosave_slots": 5, + + "_comment_afk_autokick_interval": "How many minutes until someone is kicked when doing nothing, 0 for never.", + "afk_autokick_interval": 0, + + "_comment_auto_pause": "Whether should the server be paused when no players are present.", + "auto_pause": true, + + "only_admins_can_pause_the_game": true, + + "_comment_autosave_only_on_server": "Whether autosaves should be saved only on server or also on all connected clients. Default is true.", + "autosave_only_on_server": true, + + "_comment_non_blocking_saving": "Highly experimental feature, enable only at your own risk of losing your saves. On UNIX systems, server will fork itself to create an autosave. Autosaving on connected Windows clients will be disabled regardless of autosave_only_on_server option.", + "non_blocking_saving": false, + + "_comment_segment_sizes": "Long network messages are split into segments that are sent over multiple ticks. Their size depends on the number of peers currently connected. Increasing the segment size will increase upload bandwidth requirement for the server and download bandwidth requirement for clients. This setting only affects server outbound messages. Changing these settings can have a negative impact on connection stability for some clients.", + "minimum_segment_size": 25, + "minimum_segment_size_peer_count": 20, + "maximum_segment_size": 100, + "maximum_segment_size_peer_count": 10 +} diff --git a/modules/mod/test/data/mods/mod-list.json b/modules/mod/test/data/mods/mod-list.json new file mode 100644 index 0000000..95a6869 --- /dev/null +++ b/modules/mod/test/data/mods/mod-list.json @@ -0,0 +1,11 @@ + +{ + "mods": + [ + + { + "name": "base", + "enabled": true + } + ] +} diff --git a/modules/mod/test/data/player-data.json b/modules/mod/test/data/player-data.json new file mode 100644 index 0000000..c59d595 --- /dev/null +++ b/modules/mod/test/data/player-data.json @@ -0,0 +1,532 @@ + +{ + "available-campaign-levels": + { + "tight-spot": + { + "level-01": "hard" + }, + "transport-belt-madness": + { + "level-01": "hard" + }, + "tutorial": + { + "level-01": "hard" + } + }, + "tips": + { + "introduction": + { + "status": "unlocked", + "elapsed": 0 + }, + "show-info": + { + "status": "dependencies-not-met" + }, + "e-confirm": + { + "status": "locked" + }, + "clear-cursor": + { + "status": "dependencies-not-met" + }, + "pipette": + { + "status": "locked" + }, + "stack-transfers": + { + "status": "locked", + "skip_status": + { + "conditions": + [ + + {}, + + {}, + + {} + ] + } + }, + "entity-transfers": + { + "status": "locked", + "conditions": + [ + + {}, + + { + "elapsed": 0 + } + ], + "skip_status": + { + "conditions": + [ + + {}, + + {} + ] + } + }, + "z-dropping": + { + "status": "locked", + "conditions": + [ + + {}, + + { + "elapsed": 0 + } + ] + }, + "shoot-targeting": + { + "status": "locked", + "conditions": + [ + + {}, + + { + "elapsed": 0 + } + ] + }, + "bulk-crafting": + { + "status": "locked", + "conditions": + [ + + {}, + + {} + ] + }, + "inserters": + { + "status": "locked" + }, + "burner-inserter-refueling": + { + "status": "locked" + }, + "long-handed-inserters": + { + "status": "locked" + }, + "move-between-labs": + { + "status": "locked" + }, + "insertion-limits": + { + "status": "locked" + }, + "limit-chests": + { + "status": "locked", + "conditions": + [ + + {}, + + {} + ] + }, + "transport-belts": + { + "status": "locked" + }, + "belt-lanes": + { + "status": "locked" + }, + "splitters": + { + "status": "locked" + }, + "splitter-filters": + { + "status": "locked" + }, + "underground-belts": + { + "status": "locked" + }, + "electric-network": + { + "status": "locked", + "conditions": + [ + + { + "conditions": + [ + + { + "conditions": + [ + + {}, + + {} + ] + }, + + { + "elapsed": 0 + } + ] + }, + + {}, + + {}, + + {} + ] + }, + "steam-power": + { + "status": "dependencies-not-met" + }, + "electric-pole-connections": + { + "status": "locked", + "conditions": + [ + + { + "elapsed": 0 + }, + + {} + ] + }, + "low-power": + { + "status": "locked" + }, + "connect-switch": + { + "status": "locked" + }, + "copy-entity-settings": + { + "status": "locked" + }, + "copy-paste-trains": + { + "status": "locked" + }, + "copy-paste-filters": + { + "status": "locked", + "conditions": + [ + + {}, + + {} + ] + }, + "copy-paste-requester-chest": + { + "status": "locked", + "conditions": + [ + + {}, + + {} + ] + }, + "copy-paste-spidertron": + { + "status": "locked" + }, + "drag-building": + { + "status": "locked" + }, + "drag-building-poles": + { + "status": "locked" + }, + "drag-building-underground-belts": + { + "status": "locked" + }, + "fast-belt-bending": + { + "status": "locked" + }, + "fast-obstacle-traversing": + { + "status": "locked", + "conditions": + [ + + {}, + + {} + ] + }, + "trains": + { + "status": "locked" + }, + "rail-building": + { + "status": "locked" + }, + "train-stops": + { + "status": "locked", + "conditions": + [ + + {}, + + { + "conditions": + [ + + {}, + + {} + ] + } + ] + }, + "rail-signals-basic": + { + "status": "locked", + "conditions": + [ + + {}, + + { + "conditions": + [ + + {}, + + {} + ] + } + ] + }, + "rail-signals-advanced": + { + "status": "locked", + "conditions": + [ + + {}, + + {} + ] + }, + "gate-over-rail": + { + "status": "locked", + "conditions": + [ + + {}, + + {}, + + {} + ] + }, + "pump-connection": + { + "status": "locked" + }, + "train-stop-same-name": + { + "status": "locked" + }, + "logistic-network": + { + "status": "locked", + "conditions": + [ + + {}, + + {} + ] + }, + "personal-logistics": + { + "status": "locked" + }, + "construction-robots": + { + "status": "locked" + }, + "passive-provider-chest": + { + "status": "dependencies-not-met" + }, + "storage-chest": + { + "status": "dependencies-not-met" + }, + "requester-chest": + { + "status": "locked" + }, + "active-provider-chest": + { + "status": "locked" + }, + "buffer-chest": + { + "status": "locked" + }, + "ghost-building": + { + "status": "locked" + }, + "ghost-rail-planner": + { + "status": "locked", + "conditions": + [ + + { + "conditions": + [ + + {}, + + {} + ] + }, + + {} + ] + }, + "copy-paste": + { + "status": "locked", + "conditions": + [ + + {}, + + { + "elapsed": 0 + } + ] + }, + "fast-replace": + { + "status": "locked", + "conditions": + [ + + {}, + + {}, + + {} + ] + }, + "fast-replace-direction": + { + "status": "locked" + }, + "fast-replace-belt-splitter": + { + "status": "locked", + "skip_status": + { + "conditions": + [ + + {}, + + {} + ] + } + }, + "fast-replace-belt-underground": + { + "status": "locked" + }, + "rotating-assemblers": + { + "status": "locked", + "conditions": + [ + + {}, + + {} + ] + }, + "circuit-network": + { + "status": "locked", + "conditions": + [ + + {}, + + { + "elapsed": 0 + } + ] + } + }, + "service-username": "", + "service-token": "", + "last-used-filters": + { + "players": "any", + "password": "any", + "mods": "any", + "friends": "any" + }, + "column-ordering": + { + "public-index": "name", + "public-ascending": true, + "lan-index": "name", + "lan-ascending": true + }, + "editor-lua-snippets": + [ + + { + "name": "Example (Turn trees into biters)", + "code": "local surface = game.player.surface\nlocal entities = surface.find_entities_filtered{area = area, type = 'tree'}\nfor k, tree in pairs(entities) do\n local position = tree.position\n tree.destroy()\n surface.create_entity{name = 'small-biter', position = position}\nend" + } + ], + "last-played-version": + { + "game_version": "1.1.41", + "build_version": 58972, + "build_mode": "headless", + "platform": "linux64" + }, + "blueprint-view": "grid" +} diff --git a/modules/mod2/build.gradle.kts b/modules/mod2/build.gradle.kts index c981bd1..60d7616 100644 --- a/modules/mod2/build.gradle.kts +++ b/modules/mod2/build.gradle.kts @@ -157,3 +157,9 @@ tasks { } } } + + +configure { + versions.dukat.version = "0.5.8-rc.4-dev.20211001" +// versions.dukat.version = "0.5.8-rc.4" +} diff --git a/modules/mod2/dukat-custom/builtin-types.module_typed-factorio.kt b/modules/mod2/dukat-custom/builtin-types.module_typed-factorio.kt index ecd4eab..28b7280 100644 --- a/modules/mod2/dukat-custom/builtin-types.module_typed-factorio.kt +++ b/modules/mod2/dukat-custom/builtin-types.module_typed-factorio.kt @@ -2,18 +2,6 @@ import kotlin.js.* import kotlinext.js.PropertyDescriptor -import org.khronos.webgl.* -import org.w3c.dom.* -import org.w3c.dom.events.* -import org.w3c.dom.parsing.* -import org.w3c.dom.svg.* -import org.w3c.dom.url.* -import org.w3c.fetch.* -import org.w3c.files.* -import org.w3c.notifications.* -import org.w3c.performance.* -import org.w3c.workers.* -import org.w3c.xhr.* typealias float = Number diff --git a/modules/mod2/dukat-custom/classes.module_typed-factorio.kt b/modules/mod2/dukat-custom/classes.module_typed-factorio.kt index 7b92c6a..6522dd4 100644 --- a/modules/mod2/dukat-custom/classes.module_typed-factorio.kt +++ b/modules/mod2/dukat-custom/classes.module_typed-factorio.kt @@ -183,9 +183,9 @@ external interface LuaBootstrap { fun on_init(f: (() -> Unit)?) fun on_load(f: (() -> Unit)?) fun on_configuration_changed(f: ((param1: ConfigurationChangedData) -> Unit)?) - fun on_event(event: E, f: ((data: Any) -> Unit)?, filters: Array = definedExternally) - fun on_event(event: E, f: ((data: Any) -> Unit)?) - fun on_event(event: Array, f: ((data: Any) -> Unit)?) + fun on_event(event: E, f: ((data: E) -> Unit)?, filters: Array = definedExternally) + fun on_event(event: E, f: ((data: E) -> Unit)?) + fun on_event(event: Array, f: ((data: Any) -> Unit)?) fun on_event(event: String, f: ((data: CustomInputEvent) -> Unit)?) fun on_nth_tick(tick: uint?, f: ((param1: NthTickEventData) -> Unit)?) fun on_nth_tick(tick: Array?, f: ((param1: NthTickEventData) -> Unit)?) diff --git a/modules/mod2/dukat-custom/defines/events/defines.defines.events.module_typed-factorio.kt b/modules/mod2/dukat-custom/defines/events/defines.defines.events.module_typed-factorio.kt index 948e6bc..cccc0aa 100644 --- a/modules/mod2/dukat-custom/defines/events/defines.defines.events.module_typed-factorio.kt +++ b/modules/mod2/dukat-custom/defines/events/defines.defines.events.module_typed-factorio.kt @@ -2,6 +2,8 @@ @file:Suppress("INTERFACE_WITH_SUPERCLASS", "OVERRIDING_FINAL_MEMBER", "RETURN_TYPE_MISMATCH_ON_OVERRIDE", "CONFLICTING_OVERLOADS") package defines.events +import EventId +import OnTickEvent import kotlin.js.* import org.khronos.webgl.* import org.w3c.dom.* @@ -17,7 +19,7 @@ import org.w3c.workers.* import org.w3c.xhr.* import uint -external var on_tick: uint /* uint & `T$93` */ +external var on_tick: EventId /* uint & `T$93` */ external var on_gui_click: uint /* uint & `T$93` */ diff --git a/modules/mod2/dukat-custom/eventId.kt b/modules/mod2/dukat-custom/eventId.kt new file mode 100644 index 0000000..b4cd976 --- /dev/null +++ b/modules/mod2/dukat-custom/eventId.kt @@ -0,0 +1,11 @@ + +external class TsUInt : tsstdlib.Number + +external class EventId { + @JsName("_eventData") + val eventData: DataT + + @JsName("_filter") + val filter: FilterT + +} \ No newline at end of file diff --git a/modules/mod2/dukat-custom/global.module_lua-types.kt b/modules/mod2/dukat-custom/global.module_lua-types.kt index 1a0a17e..470dcc5 100644 --- a/modules/mod2/dukat-custom/global.module_lua-types.kt +++ b/modules/mod2/dukat-custom/global.module_lua-types.kt @@ -1,4 +1,5 @@ -@file:Suppress("INTERFACE_WITH_SUPERCLASS", "OVERRIDING_FINAL_MEMBER", "RETURN_TYPE_MISMATCH_ON_OVERRIDE", "CONFLICTING_OVERLOADS") +@file:Suppress("INTERFACE_WITH_SUPERCLASS", "OVERRIDING_FINAL_MEMBER", + "RETURN_TYPE_MISMATCH_ON_OVERRIDE", "CONFLICTING_OVERLOADS") import kotlin.js.* import org.khronos.webgl.* @@ -17,11 +18,11 @@ import tsstdlib.Record import tsstdlib.Iterable external interface LuaThread { - var __internal__: Any + var __internal__: Any } external interface LuaUserdata { - var __internal__: Any + var __internal__: Any } external var _VERSION: String /* "Lua 5.1" | "Lua 5.2" | "Lua 5.3" | "Lua 5.4" */ @@ -30,13 +31,15 @@ external var _G: Any external fun assert(v: V): Any -external fun > assert(v: V, vararg args: A): dynamic /* JsTuple, Any> */ +external fun > assert(v: V, + vararg args: A): dynamic /* JsTuple, Any> */ external fun collectgarbage(opt: String /* "collect" | "stop" | "restart" */ = definedExternally) external fun collectgarbage() -external fun collectgarbage(opt: String /* "setpause" | "setstepmul" | "step" */, arg: Number): dynamic /* Number | Boolean */ +external fun collectgarbage(opt: String /* "setpause" | "setstepmul" | "step" */, + arg: Number): dynamic /* Number | Boolean */ external fun dofile(filename: String = definedExternally): Any @@ -44,17 +47,25 @@ external fun error(message: String, level: Number = definedExternally): Any external fun getmetatable(obj: T): LuaMetatable__1? -external fun ipairs(t: Record): Iterable> */> /* Iterable> */> & LuaIterator> */, undefined> & LuaExtension */ +external fun ipairs( + t: kotlinext.js.Record): + Iterable> */> +/* Iterable> */> & LuaIterator> */, undefined> & LuaExtension */ -external fun next(table: Any?, index: Any = definedExternally): dynamic /* JsTuple | JsTuple<> */ +external fun next(table: Any?, + index: Any = definedExternally): dynamic /* JsTuple | JsTuple<> */ -external fun pairs(t: LuaTable): Iterable> */> /* Iterable> */> & LuaIterator> */, undefined> & LuaExtension */ +external fun pairs( + t: LuaTable): Iterable> */> /* Iterable> */> & LuaIterator> */, undefined> & LuaExtension */ -external fun pairs(t: T): Iterable> */> /* Iterable> */> & LuaIterator> */, undefined> & LuaExtension */ +external fun pairs( + t: T): Iterable> */> /* Iterable> */> & LuaIterator> */, undefined> & LuaExtension */ -external fun , R> pcall(f: (self: This, args: Args) -> R, context: This, vararg args: Args): dynamic /* JsTuple | JsTuple */ +external fun , R> pcall(f: (self: This, args: Args) -> R, context: This, + vararg args: Args): dynamic /* JsTuple | JsTuple */ -external fun , R> pcall(f: (self: Unit, args: A) -> R, vararg args: A): dynamic /* JsTuple | JsTuple */ +external fun , R> pcall(f: (self: Unit, args: A) -> R, + vararg args: A): dynamic /* JsTuple | JsTuple */ external fun print(vararg args: Any) @@ -68,14 +79,17 @@ external fun rawlen(v: String?): Number external fun rawset(table: T, index: K, value: Any): T -external fun select(index: Number, vararg args: T): Array /* Array & LuaExtension */ +external fun select(index: Number, + vararg args: T): Array /* Array & LuaExtension */ external fun select(index: String /* "#" */, vararg args: T): Number -external fun setmetatable(table: T, metatable: LuaMetatable? = definedExternally): Any +external fun setmetatable(table: T, + metatable: LuaMetatable? = definedExternally): Any external fun tonumber(e: Any, base: Number = definedExternally): Number? external fun tostring(v: Any): String -external fun type(v: Any): String /* "nil" | "number" | "string" | "boolean" | "table" | "function" | "thread" | "userdata" */ \ No newline at end of file +external fun type( + v: Any): String /* "nil" | "number" | "string" | "boolean" | "table" | "function" | "thread" | "userdata" */ \ No newline at end of file diff --git a/modules/mod2/dukat-custom/tsstdlib/lib.es5.kt b/modules/mod2/dukat-custom/tsstdlib/lib.es5.kt index 8235e3b..a96c4b5 100644 --- a/modules/mod2/dukat-custom/tsstdlib/lib.es5.kt +++ b/modules/mod2/dukat-custom/tsstdlib/lib.es5.kt @@ -63,7 +63,9 @@ typealias Partial = Any typealias Pick = Any -typealias Record = Any +@Deprecated("use Kotlin Wrapper", ReplaceWith("kotlinext.js.Record")) +typealias Record = kotlinext.js.Record + typealias Exclude = Any diff --git a/modules/mod2/src/main/kotlin/events.kt b/modules/mod2/src/main/kotlin/events.kt new file mode 100644 index 0000000..5684b55 --- /dev/null +++ b/modules/mod2/src/main/kotlin/events.kt @@ -0,0 +1,11 @@ +fun main() { + + +script.on_event( + defines.events.on_tick +) { event -> + +} + + +} diff --git a/modules/mod2/typed-factorio/README.md b/modules/mod2/typed-factorio/README.md new file mode 100644 index 0000000..08ae6dc --- /dev/null +++ b/modules/mod2/typed-factorio/README.md @@ -0,0 +1,113 @@ +# Typed Factorio + +Complete and featureful typescript definitions for the Factorio modding lua api. This is intended to be used with [TypescriptToLua](https://typescripttolua.github.io/). + +This project aims to provide type definitions for the Factorio API that are as complete as possible. This means minimal `any`s and `unknown`s, correct nullability, and smart types where possible. The generator integrates both the Factorio JSON api docs and manually defined additions and overrides. + +## Installation + +To use in your TypescriptToLua project: + +1. Install this package + +``` +npm install typed-factorio + +or + +yarn add typed-factorio +``` + +2. Add to your `tsconfig.json`: + +```diff +{ + "compilerOptions": { ++ "types": [ "typed-factorio/runtime" ] + } +} +``` + +This will add the types for the runtime stage to your entire project. + +Note: When types are updated, or released for a new factorio version, you will need update your package version to get the types. + +### Settings and data stage + +There are also definitions for the settings/data stage. + +To avoid type conflicts, the global tables for the settings/data stages have to be declared manually where you need them. These types can be imported from `typed-factorio/data/types` or `typed-factorio/settings/types`. + +Example: + +```ts +import { Data, Mods } from "typed-factorio/data/types" +// or +import { Data, Mods } from "typed-factorio/settings/types" + +declare const data: Data +declare const mods: Mods + +data.extend([{ ... }]) +``` + +There are currently full types for settings stage, but only basic types for the data stage. + +### Factorio lualib modules + +Currently, there are types for the following modules: + +- `util` +- `mod-gui` + +If you have a need for types to more lualib modules, feel free to open an issue or pull request on GitHub. + +## Type features + +Typed-factorio has 100% complete types for the runtime stage. Description-only concepts and some not documented types are filled in manually. + +### Lua features + +The types include [TypescriptToLua language extensions](https://typescripttolua.github.io/docs/advanced/language-extensions/) +and [lua-types](https://github.com/TypeScriptToLua/lua-types) (for v5.2) as dependencies. + +This is to use tstl features such as `LuaLengthMethod` and `LuaMultiReturn`. + +### `nil` + +The types consistently use `undefined` to represent `nil`. +`null` is not used, because `undefined` in typescript is much more similar to `nil` in lua, and optional parameters/properties already use `undefined`. + +A class attribute is marked as possibly undefined only if the _read_ type is possibly `nil`. For properties where `nil` is not possible on _read_, but is possible on _write_, you can write `nil` by using `undefined!` or `myNullableValue!`, e.g. `controlBehavior.parameters = undefined!`. + +### Variant parameter types + +Variant parameter types (types with "additional fields can be specified depending on ...") are handled as discriminated unions. This gives proper type checking for individual variants. + +The type for a specific variant is prefixed with the either variant name or "Other" for variants without additional fields, e.g. `AmmoDamageTechnologyModifier`, `OtherTechnologyModifier` + +### Events + +`script.on_event()`, `script.get/set_filters()`, and `script.raise_event()` all have type checking on the event data/filter type, inferred from what is passed as the event name/id. + +You can pass a type parameter to `script.generate_event_name()`, and it will return an `EventId` that holds type info of the event data. Event functions on `script` can then use the type data when the `EventId` is passed. + +### Array-like types + +Classes that have an index operator, a length operator, and have an array-like structure, inherit from `(Readonly)Array`. These are `LuaInventory`, `LuaFluidBox`, `LuaTransportLine`. This allows you to use these classes like arrays, meaning having array methods, and `.length` translating to the lua length operator. However, this also means, like typescript arrays, they are **0-indexed, not 1-indexed**. + +### Table or array types + +For table or array types (e.g. Position), there also are types such as `PositionTable` and `PositionArray` that refer to the table or array form specifically. + +### LuaGuiElement + +`LuaGuiElement` is broken up into a discriminated union for each gui element type (See [here](https://basarat.gitbook.io/typescript/type-system/discriminated-unions) for information on discriminated unions). The type for a specific GuiElement type is `GuiElement`, e.g. `ButtonGuiElement`. + +Similarly, the table passed to `LuaGuiElement.add`, referred to as `GuiSpec`, is also broken up into a discriminated union for each gui element type. The type for a specific GuiSpec type is `GuiSpec`, e.g. `ListBoxGuiSpec`. + +This is done both to provide more accurate types, and for possible integration with [JSX](https://typescripttolua.github.io/docs/jsx/). + +### Examples + +Check out the `test` directory on GitHub for more examples on particular type features. diff --git a/modules/mod2/typed-factorio/data/types.d.ts b/modules/mod2/typed-factorio/data/types.d.ts new file mode 100644 index 0000000..408f32a --- /dev/null +++ b/modules/mod2/typed-factorio/data/types.d.ts @@ -0,0 +1,13 @@ +export interface Data { + readonly raw: Record> + + /** + * The `data` table expects a specific format for each item in the table. Missing properties will either fall back to + * default values or give an error indicating what's missing. Extra properties that the game isn't looking for are + * simply ignored. + */ + extend(prototypes: Record[]): void +} + +/** A mapping of mod names to mod version for all enabled mods. */ +export type Mods = Record diff --git a/modules/mod2/typed-factorio/generated/builtin-types.d.ts b/modules/mod2/typed-factorio/generated/builtin-types.d.ts new file mode 100644 index 0000000..bcd4172 --- /dev/null +++ b/modules/mod2/typed-factorio/generated/builtin-types.d.ts @@ -0,0 +1,66 @@ +/** @noSelfInFile */ + +/** + * A floating-point number. This is a single-precision floating point number. Whilst Lua only uses double-precision + * numbers, when a function takes a float, the game engine will immediately convert the double-precision number to + * single-precision. + * + * {@link https://lua-api.factorio.com/next/Builtin-Types.html#float View documentation} + */ +type float = number + +/** + * A double-precision floating-point number. This is the same data type as all Lua numbers use. + * + * {@link https://lua-api.factorio.com/next/Builtin-Types.html#double View documentation} + */ +type double = number + +/** + * 32-bit signed integer. Possible values are -2,147,483,648 to 2,147,483,647. + * + * {@link https://lua-api.factorio.com/next/Builtin-Types.html#int View documentation} + */ +type int = number + +/** + * 8-bit signed integer. Possible values are -128 to 127. + * + * {@link https://lua-api.factorio.com/next/Builtin-Types.html#int8 View documentation} + */ +type int8 = number + +/** + * 32-bit unsigned integer. Possible values are 0 to 4,294,967,295. + * + * {@link https://lua-api.factorio.com/next/Builtin-Types.html#uint View documentation} + */ +type uint = number + +/** + * 8-bit unsigned integer. Possible values are 0 to 255. + * + * {@link https://lua-api.factorio.com/next/Builtin-Types.html#uint8 View documentation} + */ +type uint8 = number + +/** + * 16-bit unsigned integer. Possible values are 0 to 65535. + * + * {@link https://lua-api.factorio.com/next/Builtin-Types.html#uint16 View documentation} + */ +type uint16 = number + +/** + * 64-bit unsigned integer. Possible values are 0 to 18,446,744,073,709,551,615. + * + * {@link https://lua-api.factorio.com/next/Builtin-Types.html#uint64 View documentation} + */ +type uint64 = number + +/** + * Tables are enclosed in curly brackets, like this `{}` + * + * {@link https://lua-api.factorio.com/next/Builtin-Types.html#table View documentation} + */ +type table = object diff --git a/modules/mod2/typed-factorio/generated/classes.d.ts b/modules/mod2/typed-factorio/generated/classes.d.ts new file mode 100644 index 0000000..65469c5 --- /dev/null +++ b/modules/mod2/typed-factorio/generated/classes.d.ts @@ -0,0 +1,20023 @@ +/** @noSelfInFile */ + +/** + * Collection of settings for overriding default ai behavior. + * + * {@link https://lua-api.factorio.com/next/LuaAISettings.html View documentation} + * + * @noSelf + */ +interface LuaAISettings { + /** + * If enabled, units that repeatedly fail to succeed at commands will be destroyed. + * + * {@link https://lua-api.factorio.com/next/LuaAISettings.html#LuaAISettings.allow_destroy_when_commands_fail View documentation} + */ + allow_destroy_when_commands_fail: boolean + /** + * If enabled, units that have nothing else to do will attempt to return to a spawner. + * + * {@link https://lua-api.factorio.com/next/LuaAISettings.html#LuaAISettings.allow_try_return_to_spawner View documentation} + */ + allow_try_return_to_spawner: boolean + /** + * If enabled, units will try to separate themselves from nearby friendly units. + * + * {@link https://lua-api.factorio.com/next/LuaAISettings.html#LuaAISettings.do_separation View documentation} + */ + do_separation: boolean + /** + * The pathing resolution modifier, must be between -8 and 8. + * + * {@link https://lua-api.factorio.com/next/LuaAISettings.html#LuaAISettings.path_resolution_modifier View 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" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * Control behavior for accumulators. + * + * {@link https://lua-api.factorio.com/next/LuaAccumulatorControlBehavior.html View documentation} + * + * @noSelf + */ +interface LuaAccumulatorControlBehavior extends LuaControlBehavior { + 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" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * Prototype of a achievement. + * + * {@link https://lua-api.factorio.com/next/LuaAchievementPrototype.html View documentation} + * + * @noSelf + */ +interface LuaAchievementPrototype { + /** + * Name of this prototype. + * + * {@link https://lua-api.factorio.com/next/LuaAchievementPrototype.html#LuaAchievementPrototype.name View documentation} + */ + readonly name: string + /** + * Order string of this prototype. + * + * {@link https://lua-api.factorio.com/next/LuaAchievementPrototype.html#LuaAchievementPrototype.order View 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" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * Prototype of a ammo category. + * + * {@link https://lua-api.factorio.com/next/LuaAmmoCategoryPrototype.html View documentation} + * + * @noSelf + */ +interface LuaAmmoCategoryPrototype { + /** + * Name of this prototype. + * + * {@link https://lua-api.factorio.com/next/LuaAmmoCategoryPrototype.html#LuaAmmoCategoryPrototype.name View documentation} + */ + readonly name: string + /** + * Order string of this prototype. + * + * {@link https://lua-api.factorio.com/next/LuaAmmoCategoryPrototype.html#LuaAmmoCategoryPrototype.order View 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" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * Control behavior for arithmetic combinators. + * + * {@link https://lua-api.factorio.com/next/LuaArithmeticCombinatorControlBehavior.html View documentation} + * + * @noSelf + */ +interface LuaArithmeticCombinatorControlBehavior extends LuaCombinatorControlBehavior { + /** + * The arithmetic combinator parameters. + * + * **Note**: `parameters` may be `nil` in order to clear the parameters. + * + * {@link https://lua-api.factorio.com/next/LuaArithmeticCombinatorControlBehavior.html#LuaArithmeticCombinatorControlBehavior.parameters View documentation} + */ + parameters: ArithmeticCombinatorParameters + /** + * 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" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * Prototype of an autoplace control. + * + * {@link https://lua-api.factorio.com/next/LuaAutoplaceControlPrototype.html View documentation} + * + * @noSelf + */ +interface LuaAutoplaceControlPrototype { + /** + * Name of this prototype. + * + * {@link https://lua-api.factorio.com/next/LuaAutoplaceControlPrototype.html#LuaAutoplaceControlPrototype.name View documentation} + */ + readonly name: string + /** + * Order string of this prototype. + * + * {@link https://lua-api.factorio.com/next/LuaAutoplaceControlPrototype.html#LuaAutoplaceControlPrototype.order View documentation} + */ + readonly order: string + readonly localised_name: LocalisedString + readonly localised_description: LocalisedString + readonly richness: boolean + readonly control_order: string + /** + * Category name of this prototype. + * + * {@link https://lua-api.factorio.com/next/LuaAutoplaceControlPrototype.html#LuaAutoplaceControlPrototype.category View 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" + /** All methods and properties that this object supports. */ + help(): string +} + +type RaiseableEvents = + | typeof defines.events.on_console_chat + | typeof defines.events.on_player_crafted_item + | typeof defines.events.on_player_fast_transferred + | typeof defines.events.on_biter_base_built + | typeof defines.events.on_market_item_purchased + | typeof defines.events.script_raised_built + | typeof defines.events.script_raised_destroy + | typeof defines.events.script_raised_revive + | typeof defines.events.script_raised_set_tiles + +/** + * Entry point for registering event handlers. It is accessible through the global object named `script`. + * + * {@link https://lua-api.factorio.com/next/LuaBootstrap.html View documentation} + * + * @noSelf + */ +interface LuaBootstrap { + /** + * Register a callback 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 `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. + * + * {@link https://lua-api.factorio.com/next/LuaBootstrap.html#LuaBootstrap.on_init View documentation} + * + * @example + * Initialize a `players` table in `global` for later use. + * + * ```lua + * script.on_init(function() + * global.players = {} + * end) + * ``` + * + * @param f - The handler for this event. Passing `nil` will unregister it. + */ + on_init(f: (() => void) | undefined): 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 do + * some very specific actions, should it need to. Doing anything other than these three will lead to desyncs, which + * breaks multiplayer and replay functionality. Access to {@link LuaGameScript} and {@link LuaRendering} is not + * available. The `global` table can be accessed and is safe to read from, but not write to. + * + * The only legitimate uses of this event are these three: + * + * - Re-setup {@link https://www.lua.org/pil/13.html metatables} as they are not persisted through save-load. + * - Re-setup conditional event handlers. + * - Create local references to data stored in the {@link https://lua-api.factorio.com/next/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 migration scripts should + * be used instead. + * + * {@link https://lua-api.factorio.com/next/LuaBootstrap.html#LuaBootstrap.on_load View documentation} + * + * @param f - The handler for this event. Passing `nil` will unregister it. + */ + on_load(f: (() => void) | undefined): void + /** + * Register a function to be run when mod configuration changes. This is called when the game version or any mod + * version changes; when any mod is added or removed; or when prototypes or startup mod settings have changed. It + * allows the mod to make any changes it deems appropriate to both the data structures in its `global` table or to + * the game state through {@link LuaGameScript}. + * + * {@link https://lua-api.factorio.com/next/LuaBootstrap.html#LuaBootstrap.on_configuration_changed View documentation} + * + * @param f - The handler for this event. Passing `nil` will unregister it. + */ + on_configuration_changed(f: ((param1: ConfigurationChangedData) => void) | undefined): 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. + * + * {@link https://lua-api.factorio.com/next/LuaBootstrap.html#LuaBootstrap.on_event View documentation} + * + * @example + * Register for the {@link OnTickEvent on_tick} event to print the current tick to console each tick. + * + * ```lua + * script.on_event(defines.events.on_tick, + * function(event) game.print(event.tick) end) + * ``` + * + * @example + * Register for the {@link OnBuiltEntityEvent on_built_entity} event, limiting it to only be received when a `"fast-inserter"` is built. + * + * ```lua + * script.on_event(defines.events.on_built_entity, + * function(event) game.print("Gotta go fast!") end, + * {{filter = "name", name = "fast-inserter"}}) + * ``` + * + * @param event - The event(s) or custom-input to invoke the handler on. + * @param f - 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. + */ + on_event>( + event: E, + f: ((data: E["_eventData"]) => void) | undefined, + filters?: E["_filter"][] + ): void + on_event>(event: E | E[], f: ((data: E["_eventData"]) => void) | undefined): void + on_event(event: string, f: ((data: CustomInputEvent) => void) | undefined): void + /** + * Register a handler to run every nth-tick(s). When the game is on tick 0 it will trigger all registered handlers. + * + * {@link https://lua-api.factorio.com/next/LuaBootstrap.html#LuaBootstrap.on_nth_tick View documentation} + * + * @param tick - The nth-tick(s) to invoke the handler on. Passing `nil` as the only parameter will unregister all + * nth-tick handlers. + * @param f - The handler to run. Passing `nil` will unregister it for the provided nth-tick(s). + */ + on_nth_tick(tick: uint | uint[] | undefined, f: ((param1: NthTickEventData) => void) | undefined): 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. + * + * **Note**: 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. + * + * {@link https://lua-api.factorio.com/next/LuaBootstrap.html#LuaBootstrap.register_on_entity_destroyed View documentation} + * + * @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. + */ + register_on_entity_destroyed(entity: LuaEntity): uint64 + /** + * Generate a new, unique event ID that can be used to raise custom events with + * {@link LuaBootstrap.raise_event LuaBootstrap::raise_event}. + * + * {@link https://lua-api.factorio.com/next/LuaBootstrap.html#LuaBootstrap.generate_event_name View documentation} + * + * @returns The newly generated event ID. + */ + generate_event_name(): CustomEventId + /** + * Find the event handler for an event. + * + * {@link https://lua-api.factorio.com/next/LuaBootstrap.html#LuaBootstrap.get_event_handler View documentation} + * + * @param event - The event identifier to get a handler for. + * @returns Reference to the function currently registered as the handler. + */ + get_event_handler>(event: E): (data: E["_eventData"]) => void + get_event_handler(event: string): (data: CustomInputEvent) => void + /** + * Gets the mod event order as a string. + * + * {@link https://lua-api.factorio.com/next/LuaBootstrap.html#LuaBootstrap.get_event_order View 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. + * + * {@link https://lua-api.factorio.com/next/LuaBootstrap.html#LuaBootstrap.set_event_filter View documentation} + * + * @example + * Limit the {@link OnMarkedForDeconstructionEvent on_marked_for_deconstruction} event to only be received when a non-ghost entity is marked for deconstruction. + * + * ```lua + * script.set_event_filter(defines.events.on_marked_for_deconstruction, {{filter = "ghost", invert = true}}) + * ``` + * + * @example + * Limit the {@link OnBuiltEntityEvent on_built_entity} event to only be received when either a `unit` or a `unit-spawner` is built. + * + * ```lua + * script.set_event_filter(defines.events.on_built_entity, {{filter = "type", type = "unit"}, {filter = "type", type = "unit-spawner"}}) + * ``` + * + * @example + * Limit the {@link OnEntityDamagedEvent on_entity_damaged} event to only be received when a `rail` is damaged by an `acid` attack. + * + * ```lua + * 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. + */ + set_event_filter>(event: E, filters: E["_filter"][] | undefined): void + /** + * Gets the filters for the given event. + * + * {@link https://lua-api.factorio.com/next/LuaBootstrap.html#LuaBootstrap.get_event_filter View documentation} + * + * @param event - ID of the event to get. + * @returns The filters or `nil` if none are defined. + */ + get_event_filter>(event: E): E["_filter"][] | undefined + /** + * Raise an event. Only events generated with + * {@link LuaBootstrap.generate_event_name LuaBootstrap::generate_event_name} and the following can be raised: + * + * - {@link OnConsoleChatEvent on_console_chat} + * - {@link OnPlayerCraftedItemEvent on_player_crafted_item} + * - {@link OnPlayerFastTransferredEvent on_player_fast_transferred} + * - {@link OnBiterBaseBuiltEvent on_biter_base_built} + * - {@link OnMarketItemPurchasedEvent on_market_item_purchased} + * - {@link ScriptRaisedBuiltEvent script_raised_built} + * - {@link ScriptRaisedDestroyEvent script_raised_destroy} + * - {@link ScriptRaisedReviveEvent script_raised_revive} + * - {@link ScriptRaisedSetTilesEvent script_raised_set_tiles} + * + * {@link https://lua-api.factorio.com/next/LuaBootstrap.html#LuaBootstrap.raise_event View documentation} + * + * @example + * Raise the {@link OnConsoleChatEvent on_console_chat} event with the desired message 'from' the first player. + * + * ```lua + * local data = {player_index = 1, message = "Hello friends!"} + * script.raise_event(defines.events.on_console_chat, data) + * ``` + * + * @param event - ID of the event to raise. + * @param data - Table with extra data that will be passed to the event handler. + */ + raise_event>( + event: E, + data: Omit + ): void + /** + * Raises {@link OnConsoleChatEvent on_console_chat} with the given parameters. + * + * {@link https://lua-api.factorio.com/next/LuaBootstrap.html#LuaBootstrap.raise_console_chat View documentation} + */ + raise_console_chat(params: { + /** The player doing the chatting. */ + readonly player_index: uint + /** The chat message to send. */ + readonly message: string + }): void + /** + * Raises {@link OnPlayerCraftedItemEvent on_player_crafted_item} with the given parameters. + * + * {@link https://lua-api.factorio.com/next/LuaBootstrap.html#LuaBootstrap.raise_player_crafted_item View documentation} + */ + raise_player_crafted_item(params: { + /** The item that has been crafted. */ + readonly item_stack: LuaItemStack + /** The player doing the crafting. */ + readonly player_index: uint + /** The recipe used to craft this item. */ + readonly recipe: LuaRecipe + }): void + /** + * Raises {@link OnPlayerFastTransferredEvent on_player_fast_transferred} with the given parameters. + * + * {@link https://lua-api.factorio.com/next/LuaBootstrap.html#LuaBootstrap.raise_player_fast_transferred View documentation} + */ + raise_player_fast_transferred(params: { + /** The player transferred from or to. */ + readonly player_index: uint + /** 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 + }): void + /** + * Raises {@link OnBiterBaseBuiltEvent on_biter_base_built} with the given parameters. + * + * {@link https://lua-api.factorio.com/next/LuaBootstrap.html#LuaBootstrap.raise_biter_base_built View documentation} + */ + raise_biter_base_built(params: { + /** The entity that was built. */ + readonly entity: LuaEntity + }): void + /** + * Raises {@link OnMarketItemPurchasedEvent on_market_item_purchased} with the given parameters. + * + * {@link https://lua-api.factorio.com/next/LuaBootstrap.html#LuaBootstrap.raise_market_item_purchased View documentation} + */ + raise_market_item_purchased(params: { + /** The player who did the purchasing. */ + readonly player_index: uint + /** 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 + /** + * Raises {@link ScriptRaisedBuiltEvent script_raised_built} with the given parameters. + * + * {@link https://lua-api.factorio.com/next/LuaBootstrap.html#LuaBootstrap.raise_script_built View documentation} + */ + raise_script_built(params: { + /** The entity that has been built. */ + readonly entity: LuaEntity + }): void + /** + * Raises {@link ScriptRaisedDestroyEvent script_raised_destroy} with the given parameters. + * + * {@link https://lua-api.factorio.com/next/LuaBootstrap.html#LuaBootstrap.raise_script_destroy View documentation} + */ + raise_script_destroy(params: { + /** The entity that was destroyed. */ + readonly entity: LuaEntity + }): void + /** + * Raises {@link ScriptRaisedReviveEvent script_raised_revive} with the given parameters. + * + * {@link https://lua-api.factorio.com/next/LuaBootstrap.html#LuaBootstrap.raise_script_revive View 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 + /** + * Raises {@link ScriptRaisedSetTilesEvent script_raised_set_tiles} with the given parameters. + * + * {@link https://lua-api.factorio.com/next/LuaBootstrap.html#LuaBootstrap.raise_script_set_tiles View documentation} + */ + raise_script_set_tiles(params: { + /** The surface whose tiles have been changed. */ + readonly surface_index: uint + /** The tiles that have been changed. */ + readonly tiles: Tile[] + }): void + /** + * The name of the mod from the environment this is used in. + * + * {@link https://lua-api.factorio.com/next/LuaBootstrap.html#LuaBootstrap.mod_name View documentation} + */ + readonly mod_name: string + /** + * Information about the currently running scenario/campaign/tutorial. + * + * {@link https://lua-api.factorio.com/next/LuaBootstrap.html#LuaBootstrap.level View 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. + * + * {@link https://lua-api.factorio.com/next/LuaBootstrap.html#LuaBootstrap.active_mods View documentation} + * + * @example + * This will print the names and versions of all active mods to the console. + * + * ```lua + * for name, version in pairs(script.active_mods) do + * game.print(name .. " version " .. version) + * end + * ``` + */ + readonly active_mods: Record + /** This object's name. */ + readonly object_name: "LuaBootstrap" +} + +/** + * A reference to the burner energy source owned by a specific {@link LuaEntity} or {@link LuaEquipment}. + * + * {@link https://lua-api.factorio.com/next/LuaBurner.html View documentation} + * + * @noSelf + */ +interface LuaBurner { + /** + * The owner of this burner energy source + * + * {@link https://lua-api.factorio.com/next/LuaBurner.html#LuaBurner.owner View documentation} + */ + readonly owner: LuaEntity | LuaEquipment + /** + * The fuel inventory. + * + * {@link https://lua-api.factorio.com/next/LuaBurner.html#LuaBurner.inventory View documentation} + */ + readonly inventory: LuaInventory + /** + * The burnt result inventory. + * + * {@link https://lua-api.factorio.com/next/LuaBurner.html#LuaBurner.burnt_result_inventory View documentation} + */ + readonly burnt_result_inventory: LuaInventory + heat: double + readonly heat_capacity: double + /** + * **Note**: Writing will silently do nothing if there's no + * {@link LuaBurner.currently_burning LuaBurner::currently_burning} set. + * + * {@link https://lua-api.factorio.com/next/LuaBurner.html#LuaBurner.remaining_burning_fuel View documentation} + */ + remaining_burning_fuel: double + /** + * **Note**: Writing automatically handles correcting + * {@link LuaBurner.remaining_burning_fuel LuaBurner::remaining_burning_fuel}. + * + * {@link https://lua-api.factorio.com/next/LuaBurner.html#LuaBurner.currently_burning View documentation} + */ + currently_burning: LuaItemPrototype + /** + * The fuel categories this burner uses. + * + * **Note**: The value in the dictionary is meaningless and exists just to allow the dictionary type for easy lookup. + * + * {@link https://lua-api.factorio.com/next/LuaBurner.html#LuaBurner.fuel_categories View documentation} + */ + readonly fuel_categories: Record + /** + * 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" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * Prototype of a burner energy source. + * + * {@link https://lua-api.factorio.com/next/LuaBurnerPrototype.html View documentation} + * + * @noSelf + */ +interface LuaBurnerPrototype { + 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 if any. + * + * {@link https://lua-api.factorio.com/next/LuaBurnerPrototype.html#LuaBurnerPrototype.smoke View documentation} + */ + readonly smoke: SmokeSource[] + /** + * The light flicker definition for this burner prototype if any. + * + * {@link https://lua-api.factorio.com/next/LuaBurnerPrototype.html#LuaBurnerPrototype.light_flicker View 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 + } + /** + * **Note**: The value in the dictionary is meaningless and exists just to allow the dictionary type for easy lookup. + * + * {@link https://lua-api.factorio.com/next/LuaBurnerPrototype.html#LuaBurnerPrototype.fuel_categories View documentation} + */ + readonly fuel_categories: Record + /** + * 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" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * 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. + * + * {@link https://lua-api.factorio.com/next/LuaChunkIterator.html View documentation} + * + * @example + * ```lua + * 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 + * ``` + * + * @noSelf + */ +interface LuaChunkIterator extends LuaIterable { + /** + * Get the next chunk position or `nil`, and increments the iterator. + * + * {@link https://lua-api.factorio.com/next/LuaChunkIterator.html#LuaChunkIterator.operator%20() View documentation} + */ + (): ChunkPositionAndArea | undefined + /** + * 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" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * A circuit network associated with a given entity, connector, and wire type. + * + * {@link https://lua-api.factorio.com/next/LuaCircuitNetwork.html View documentation} + * + * @noSelf + */ +interface LuaCircuitNetwork { + /** + * {@link https://lua-api.factorio.com/next/LuaCircuitNetwork.html#LuaCircuitNetwork.get_signal View documentation} + * + * @param signal - The signal to read. + * @returns The current value of the signal. + */ + get_signal(signal: SignalID): int + /** + * The entity this circuit network reference is associated with + * + * {@link https://lua-api.factorio.com/next/LuaCircuitNetwork.html#LuaCircuitNetwork.entity View documentation} + */ + readonly entity: LuaEntity + /** + * The wire type this network is associated with. + * + * {@link https://lua-api.factorio.com/next/LuaCircuitNetwork.html#LuaCircuitNetwork.wire_type View documentation} + */ + readonly wire_type: defines.wire_type + /** + * The circuit connector ID on the associated entity this network was gotten from. + * + * {@link https://lua-api.factorio.com/next/LuaCircuitNetwork.html#LuaCircuitNetwork.circuit_connector_id View documentation} + */ + readonly circuit_connector_id: defines.circuit_connector_id + /** + * The circuit network signals last tick. `nil` if there are no signals. + * + * {@link https://lua-api.factorio.com/next/LuaCircuitNetwork.html#LuaCircuitNetwork.signals View documentation} + */ + readonly signals: Signal[] | undefined + /** + * The circuit networks ID. + * + * {@link https://lua-api.factorio.com/next/LuaCircuitNetwork.html#LuaCircuitNetwork.network_id View documentation} + */ + readonly network_id: uint + /** + * The number of circuits connected to this network. + * + * {@link https://lua-api.factorio.com/next/LuaCircuitNetwork.html#LuaCircuitNetwork.connected_circuit_count View 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" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * {@link https://lua-api.factorio.com/next/LuaCombinatorControlBehavior.html View documentation} + * + * @noSelf + */ +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. + * + * {@link https://lua-api.factorio.com/next/LuaCombinatorControlBehavior.html#LuaCombinatorControlBehavior.get_signal_last_tick View documentation} + * + * @param signal - The signal to get + * @returns The value or `nil` if none. + */ + get_signal_last_tick(signal: SignalID): int | undefined + /** + * The circuit network signals sent by this combinator last tick. + * + * {@link https://lua-api.factorio.com/next/LuaCombinatorControlBehavior.html#LuaCombinatorControlBehavior.signals_last_tick View documentation} + */ + readonly signals_last_tick: Signal[] +} + +/** + * Allows for the registration of custom console commands. Similarly to + * {@link LuaBootstrap.on_event event subscriptions}, these don't persist through a save-and-load cycle. + * + * {@link https://lua-api.factorio.com/next/LuaCommandProcessor.html View documentation} + * + * @noSelf + */ +interface LuaCommandProcessor { + /** + * Add a custom console command. + * + * **Note**: 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. + * + * {@link https://lua-api.factorio.com/next/LuaCommandProcessor.html#LuaCommandProcessor.add_command View documentation} + * + * @example + * This 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. It 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"`). + * + * ```lua + * 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) + * ``` + * + * @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. + */ + add_command(name: string, help: LocalisedString, _function: (param1: CustomCommandData) => void): void + /** + * Remove a custom console command. + * + * {@link https://lua-api.factorio.com/next/LuaCommandProcessor.html#LuaCommandProcessor.remove_command View documentation} + * + * @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. + */ + remove_command(name: string): boolean + /** + * Lists the custom commands registered by scripts through `LuaCommandProcessor`. + * + * {@link https://lua-api.factorio.com/next/LuaCommandProcessor.html#LuaCommandProcessor.commands View documentation} + */ + readonly commands: Record + /** + * Lists the built-in commands of the core game. The {@link https://wiki.factorio.com/Console wiki} has an overview of these. + * + * {@link https://lua-api.factorio.com/next/LuaCommandProcessor.html#LuaCommandProcessor.game_commands View documentation} + */ + readonly game_commands: Record + /** This object's name. */ + readonly object_name: "LuaCommandProcessor" +} + +/** + * Control behavior for constant combinators. + * + * {@link https://lua-api.factorio.com/next/LuaConstantCombinatorControlBehavior.html View documentation} + * + * @noSelf + */ +interface LuaConstantCombinatorControlBehavior extends LuaControlBehavior { + /** + * Sets the signal at the given index + * + * {@link https://lua-api.factorio.com/next/LuaConstantCombinatorControlBehavior.html#LuaConstantCombinatorControlBehavior.set_signal View documentation} + * + * @param index + * @param signal + */ + 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. + * + * {@link https://lua-api.factorio.com/next/LuaConstantCombinatorControlBehavior.html#LuaConstantCombinatorControlBehavior.get_signal View documentation} + * + * @param index + */ + get_signal(index: uint): Signal + /** + * The constant combinator parameters + * + * **Note**: Setting to `nil` clears the parameters. + * + * {@link https://lua-api.factorio.com/next/LuaConstantCombinatorControlBehavior.html#LuaConstantCombinatorControlBehavior.parameters View documentation} + */ + parameters: ConstantCombinatorParameters[] + /** + * Turns this constant combinator on and off. + * + * {@link https://lua-api.factorio.com/next/LuaConstantCombinatorControlBehavior.html#LuaConstantCombinatorControlBehavior.enabled View documentation} + */ + enabled: boolean + /** + * The number of signals this constant combinator supports + * + * {@link https://lua-api.factorio.com/next/LuaConstantCombinatorControlBehavior.html#LuaConstantCombinatorControlBehavior.signals_count View documentation} + */ + readonly signals_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: "LuaConstantCombinatorControlBehavior" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * Control behavior for container entities. + * + * {@link https://lua-api.factorio.com/next/LuaContainerControlBehavior.html View documentation} + * + * @noSelf + */ +interface LuaContainerControlBehavior extends LuaControlBehavior { + /** + * 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: "LuaContainerControlBehavior" + /** All methods and properties that this object supports. */ + help(): string +} + +interface BaseControlSetGuiArrow { + /** + * Where to point to. This field determines what other fields are mandatory. May be `"nowhere"`, `"goal"`, + * `"entity_info"`, `"active_window"`, `"entity"`, `"position"`, `"crafting_queue"`, or `"item_stack"`. + */ + readonly type: + | "nowhere" + | "goal" + | "entity_info" + | "active_window" + | "entity" + | "position" + | "crafting_queue" + | "item_stack" +} + +interface EntityControlSetGuiArrow extends BaseControlSetGuiArrow { + readonly type: "entity" + readonly entity: LuaEntity +} + +interface PositionControlSetGuiArrow extends BaseControlSetGuiArrow { + readonly type: "position" + readonly position: Position +} + +interface CraftingQueueControlSetGuiArrow extends BaseControlSetGuiArrow { + readonly type: "crafting_queue" + readonly crafting_queueindex: uint +} + +interface ItemStackControlSetGuiArrow extends BaseControlSetGuiArrow { + readonly type: "item_stack" + readonly inventory_index: defines.inventory + readonly item_stack_index: uint + /** May be either `"player"` or `"target"`. */ + readonly source: "player" | "target" +} + +interface OtherControlSetGuiArrow extends BaseControlSetGuiArrow { + readonly type: "nowhere" | "goal" | "entity_info" | "active_window" +} + +type ControlSetGuiArrow = + | EntityControlSetGuiArrow + | PositionControlSetGuiArrow + | CraftingQueueControlSetGuiArrow + | ItemStackControlSetGuiArrow + | OtherControlSetGuiArrow + +/** + * This is an abstract base class containing the common functionality between {@link LuaPlayer} and entities (see + * {@link LuaEntity}). When accessing player-related functions through a {@link LuaEntity}, it must refer to a character entity. + * + * {@link https://lua-api.factorio.com/next/LuaControl.html View documentation} + * + * @noSelf + */ +interface LuaControl { + /** + * Get an inventory belonging to this entity. This can be either the "main" inventory or some auxiliary one, like + * the module slots or logistic trash slots. + * + * **Note**: A given {@link defines.inventory} is only meaningful for the corresponding LuaObject type. EG: + * get_inventory(defines.inventory.character_main) is only meaningful if 'this' is a player character. You may get a + * value back but if the type of 'this' isn't the type referred to by the {@link defines.inventory} it's almost + * guaranteed to not be the inventory asked for. + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.get_inventory View documentation} + * + * @param inventory + * @returns Or `nil` if this entity doesn't have an inventory with the given index. + */ + get_inventory(inventory: defines.inventory): LuaInventory | undefined + /** + * Gets the main inventory for this character or player if this is a character or player. + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.get_main_inventory View documentation} + * + * @returns Or `nil` if this entity is not a character or player. + */ + get_main_inventory(): LuaInventory | undefined + /** + * Can at least some items be inserted? + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.can_insert View documentation} + * + * @param items - Items that would be inserted. + * @returns `true` if at least a part of the given items could be inserted into this inventory. + */ + can_insert(items: ItemStackIdentification): boolean + /** + * Insert items into this entity. This works the same way as inserters or shift-clicking: the "best" inventory is + * chosen automatically. + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.insert View documentation} + * + * @param items - Items to insert. + * @returns Number of items actually inserted. + */ + insert(items: ItemStackIdentification): uint + /** + * Create an arrow which points at this entity. This is used in the tutorial. For examples, see `control.lua` in the + * campaign missions. + * + * Other attributes may be specified depending on `type`: + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.set_gui_arrow View documentation} + */ + set_gui_arrow(params: ControlSetGuiArrow): void + /** + * Removes the arrow created by `set_gui_arrow`. + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.clear_gui_arrow View documentation} + */ + clear_gui_arrow(): void + /** + * Get the number of all or some items in this entity. + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.get_item_count View documentation} + * + * @param item - Prototype name of the item to count. If not specified, count all items. + */ + get_item_count(item?: string): uint + /** + * Does this entity have any item inside it? + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.has_items_inside View documentation} + */ + has_items_inside(): boolean + /** + * Can a given entity be opened or accessed? + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.can_reach_entity View documentation} + * + * @param entity + */ + can_reach_entity(entity: LuaEntity): boolean + /** + * Remove all items from this entity. + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.clear_items_inside View documentation} + */ + clear_items_inside(): void + /** + * Remove items from this entity. + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.remove_item View documentation} + * + * @param items - Items to remove. + * @returns Number of items actually removed. + */ + remove_item(items: ItemStackIdentification): uint + /** + * Teleport the entity to a given position, possibly on another surface. + * + * **Note**: Some entities may not be teleported. For instance, transport belts won't allow teleportation and this + * method will always return `false` when used on any such entity. + * + * **Note**: You can also pass 1 or 2 numbers as the parameters and they will be used as relative teleport + * coordinates `'teleport(0, 1)'` to move the entity 1 tile positive y. `'teleport(4)'` to move the entity 4 tiles + * to the positive x. + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.teleport View documentation} + * + * @param position - Where to teleport to. + * @param surface - Surface to teleport to. If not given, will teleport to the entity's current surface. Only + * players, cars, and spidertrons can be teleported cross-surface. + * @returns `true` when the entity was successfully teleported. + */ + teleport(position: Position, surface?: SurfaceIdentification): boolean + /** + * Select an entity, as if by hovering the mouse above it. + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.update_selected_entity View documentation} + * + * @param position - Position of the entity to select + */ + update_selected_entity(position: Position): void + /** + * Unselect any selected entity. + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.clear_selected_entity View documentation} + */ + clear_selected_entity(): void + /** + * Disable the flashlight. + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.disable_flashlight View documentation} + */ + disable_flashlight(): void + /** + * Enable the flashlight. + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.enable_flashlight View documentation} + */ + enable_flashlight(): void + /** + * Is the flashlight enabled. + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.is_flashlight_enabled View documentation} + */ + is_flashlight_enabled(): void + /** + * Gets the count of the given recipe that can be crafted. + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.get_craftable_count View documentation} + * + * @param recipe - The recipe. + * @returns The count that can be crafted. + */ + get_craftable_count(recipe: string | LuaRecipe): uint + /** + * Begins crafting the given count of the given recipe. + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.begin_crafting View documentation} + * + * @returns The count that was actually started crafting. + */ + begin_crafting(params: { + /** The count to craft. */ + readonly count: uint + /** The recipe to craft. */ + readonly recipe: string | LuaRecipe + /** If false and the recipe can't be crafted the requested number of times printing the failure is skipped. */ + readonly silent?: boolean + }): uint + /** + * Cancels crafting the given count of the given crafting queue index. + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.cancel_crafting View documentation} + */ + cancel_crafting(params: { + /** The crafting queue index. */ + readonly index: uint + /** The count to cancel crafting. */ + readonly count: uint + }): void + /** + * Mines the given entity as if this player (or character) mined it. + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.mine_entity View documentation} + * + * @param entity - The entity to mine + * @param force - Forces mining the entity even if the items can't fit in the player. + * @returns If the mining succeeded. + */ + mine_entity(entity: LuaEntity, force?: boolean): boolean + /** + * Mines the given tile as if this player (or character) mined it. + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.mine_tile View documentation} + * + * @param tile - The tile to mine. + * @returns If the mining succeeded. + */ + mine_tile(tile: LuaTile): boolean + /** + * When `true` control adapter is a LuaPlayer object, `false` for entities including characters with players + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.is_player View documentation} + */ + is_player(): boolean + /** + * Open the technology GUI and select a given technology. + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.open_technology_gui View documentation} + * + * @param technology - The technology to select after opening the GUI. + */ + open_technology_gui(technology?: TechnologyIdentification): void + /** + * Sets a personal logistic request and auto-trash slot to the given value. + * + * **Note**: This will silently fail if personal logistics are not researched yet. + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.set_personal_logistic_slot View documentation} + * + * @param slot_index - The slot to set. + * @param value - The logistic request parameters. + * @returns Whether the slot was set successfully. + */ + set_personal_logistic_slot(slot_index: uint, value: PersonalLogisticParameters): boolean + /** + * Sets a vehicle logistic request and auto-trash slot to the given value. + * + * **Note**: This will silently fail if the vehicle does not use logistics. + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.set_vehicle_logistic_slot View documentation} + * + * @param slot_index - The slot to set. + * @param value - The logistic request parameters. + * @returns Whether the slot was set successfully. + */ + set_vehicle_logistic_slot(slot_index: uint, value: PersonalLogisticParameters): boolean + /** + * Gets the parameters of a personal logistic request and auto-trash slot. + * + * **Note**: This will silently return an empty value (`name` will be `nil`) if personal logistics are not researched yet. + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.get_personal_logistic_slot View documentation} + * + * @param slot_index - The slot to get. + */ + get_personal_logistic_slot(slot_index: uint): PersonalLogisticParameters + /** + * Gets the parameters of a vehicle logistic request and auto-trash slot. + * + * **Note**: This will silently return an empty value (`name` will be `nil`) if the vehicle does not use logistics. + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.get_vehicle_logistic_slot View documentation} + * + * @param slot_index - The slot to get. + */ + get_vehicle_logistic_slot(slot_index: uint): PersonalLogisticParameters + /** + * **Note**: This will silently fail if personal logistics are not researched yet. + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.clear_personal_logistic_slot View documentation} + * + * @param slot_index - The slot to clear. + */ + clear_personal_logistic_slot(slot_index: uint): void + /** + * **Note**: This will silently fail if the vehicle does not use logistics. + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.clear_vehicle_logistic_slot View documentation} + * + * @param slot_index - The slot to clear. + */ + clear_vehicle_logistic_slot(slot_index: uint): void + /** + * Returns whether the player is holding a blueprint, it takes into account a blueprint as an item as well as + * blueprint from the blueprint record from the blueprint library. Note that the is_cursor_blueprint and + * get_cursor_blueprint_entities refer to the currently selected blueprint, so it returns blueprint related + * information also when holding a blueprint book with a blueprint being selected in it. + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.is_cursor_blueprint View documentation} + */ + is_cursor_blueprint(): boolean + /** + * Gets the entities that are part of the currently selected blueprint, regardless of it being in a blueprint book + * or picked from the blueprint library. Returns `nil` if there is no currently selected blueprint. + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.get_blueprint_entities View documentation} + */ + get_blueprint_entities(): BlueprintEntity[] | undefined + /** + * Returns whether the player is holding something in the cursor. It takes into account items from the blueprint + * library, as well as items and ghost cursor. + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.is_cursor_empty View documentation} + */ + is_cursor_empty(): boolean + /** + * The surface this entity is currently on. + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.surface View documentation} + */ + readonly surface: LuaSurface + /** + * Current position of the entity. + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.position View documentation} + */ + readonly position: PositionTable + /** + * The vehicle the player is currently sitting in; `nil` if none. + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.vehicle View documentation} + */ + readonly vehicle: LuaEntity | undefined + /** + * The force of this entity. Reading will always give a {@link LuaForce}, but it is possible to assign either + * {@link string} or {@link LuaForce} to this attribute to change the force. + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.force View documentation} + */ + force: ForceIdentification + /** + * The currently selected entity; `nil` if none. Assigning an entity will select it if selectable otherwise clears selection. + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.selected View documentation} + */ + selected: LuaEntity | undefined + /** + * The GUI target the player currently has open; `nil` if none. + * + * **Note**: Write supports any of the types. Read will return the entity, equipment, equipment-grid, player, element or nil. + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.opened View documentation} + */ + opened: + | LuaEntity + | LuaItemStack + | LuaEquipment + | LuaEquipmentGrid + | LuaPlayer + | LuaGuiElement + | defines.gui_type + | undefined + /** + * Size of the crafting queue. + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.crafting_queue_size View documentation} + */ + readonly crafting_queue_size: uint + /** + * The crafting queue progress [0-1] 0 when no recipe is being crafted. + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.crafting_queue_progress View documentation} + */ + readonly crafting_queue_progress: double + /** + * Current walking state. + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.walking_state View documentation} + * + * @example + * Make the player go north. Note that a one-shot action like this will only make the player walk for one tick. + * + * ```lua + * game.player.walking_state = {walking = true, direction = defines.direction.north} + * ``` + */ + walking_state: { + /** If `false`, the player is currently not walking; otherwise it's going somewhere */ + readonly walking: boolean + /** Direction where the player is walking */ + readonly direction: defines.direction + } + /** + * Current riding state of this car or the vehicle this player is riding in. + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.riding_state View documentation} + */ + riding_state: RidingState + /** + * Current mining state. + * + * **Note**: When the player isn't mining tiles the player will mine what ever entity is currently selected. See + * {@link LuaControl.selected LuaControl::selected} and + * {@link LuaControl.update_selected_entity LuaControl::update_selected_entity}. + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.mining_state View documentation} + */ + mining_state: { + /** Whether the player is mining at all */ + readonly mining: boolean + /** What tiles the player is mining; only used when the player is mining tiles (holding a tile in the cursor). */ + readonly position?: Position + } + /** + * Current shooting state. + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.shooting_state View documentation} + */ + shooting_state: { + /** The current state */ + readonly state: defines.shooting + /** The position being shot at */ + readonly position: Position + } + /** + * Current item-picking state. + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.picking_state View documentation} + */ + picking_state: boolean + /** + * Current repair state. + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.repair_state View documentation} + */ + repair_state: { + /** The current state */ + readonly repairing: boolean + /** The position being repaired */ + readonly position: Position + } + /** + * The player's cursor stack, or `nil` if the player controller is a spectator. Even though this property is marked + * as read-only, it returns a {@link LuaItemStack}, meaning it can be manipulated like so: + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.cursor_stack View documentation} + * + * @example + * ```lua + * player.cursor_stack.clear() + * ``` + */ + readonly cursor_stack: LuaItemStack | undefined + /** + * The ghost prototype in the player's cursor. + * + * **Note**: When read, it will be a {@link LuaItemPrototype}. + * + * **Note**: Items in the cursor stack will take priority over the cursor ghost. + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.cursor_ghost View documentation} + */ + cursor_ghost: ItemPrototypeIdentification + /** + * `true` if the player is in a vehicle. Writing to this attribute puts the player in or out of a vehicle. + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.driving View documentation} + */ + driving: boolean + /** + * Gets the current crafting queue items. + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.crafting_queue View documentation} + */ + readonly crafting_queue: CraftingQueueItem[] + /** + * The current combat robots following the character + * + * **Note**: When called on a {@link LuaPlayer}, it must be associated with a character(see + * {@link LuaPlayer.character LuaPlayer::character}). + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.following_robots View documentation} + */ + readonly following_robots: LuaEntity[] + /** + * When `true` hand crafting is free and instant + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.cheat_mode View documentation} + */ + cheat_mode: boolean + /** + * **Note**: When called on a {@link LuaPlayer}, it must be associated with a character (see + * {@link LuaPlayer.character LuaPlayer::character}). + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.character_crafting_speed_modifier View documentation} + */ + character_crafting_speed_modifier: double + /** + * **Note**: When called on a {@link LuaPlayer}, it must be associated with a character (see + * {@link LuaPlayer.character LuaPlayer::character}). + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.character_mining_speed_modifier View documentation} + */ + character_mining_speed_modifier: double + /** + * **Note**: When called on a {@link LuaPlayer}, it must be associated with a character (see + * {@link LuaPlayer.character LuaPlayer::character}). + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.character_additional_mining_categories View documentation} + */ + character_additional_mining_categories: string[] + /** + * Modifies the running speed of this character by the given value as a percentage. Setting the running modifier to + * `0.5` makes the character run 50% faster. The minimum value of `-1` reduces the movement speed by 100%, resulting + * in a speed of `0`. + * + * **Note**: When called on a {@link LuaPlayer}, it must be associated with a character (see + * {@link LuaPlayer.character LuaPlayer::character}). + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.character_running_speed_modifier View documentation} + */ + character_running_speed_modifier: double + /** + * **Note**: When called on a {@link LuaPlayer}, it must be associated with a character (see + * {@link LuaPlayer.character LuaPlayer::character}). + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.character_build_distance_bonus View documentation} + */ + character_build_distance_bonus: uint + /** + * **Note**: When called on a {@link LuaPlayer}, it must be associated with a character (see + * {@link LuaPlayer.character LuaPlayer::character}). + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.character_item_drop_distance_bonus View documentation} + */ + character_item_drop_distance_bonus: uint + /** + * **Note**: When called on a {@link LuaPlayer}, it must be associated with a character (see + * {@link LuaPlayer.character LuaPlayer::character}). + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.character_reach_distance_bonus View documentation} + */ + character_reach_distance_bonus: uint + /** + * **Note**: When called on a {@link LuaPlayer}, it must be associated with a character (see + * {@link LuaPlayer.character LuaPlayer::character}). + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.character_resource_reach_distance_bonus View documentation} + */ + character_resource_reach_distance_bonus: uint + /** + * **Note**: When called on a {@link LuaPlayer}, it must be associated with a character (see + * {@link LuaPlayer.character LuaPlayer::character}). + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.character_item_pickup_distance_bonus View documentation} + */ + character_item_pickup_distance_bonus: uint + /** + * **Note**: When called on a {@link LuaPlayer}, it must be associated with a character (see + * {@link LuaPlayer.character LuaPlayer::character}). + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.character_loot_pickup_distance_bonus View documentation} + */ + character_loot_pickup_distance_bonus: uint + /** + * **Note**: When called on a {@link LuaPlayer}, it must be associated with a character (see + * {@link LuaPlayer.character LuaPlayer::character}). + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.character_inventory_slots_bonus View documentation} + */ + character_inventory_slots_bonus: uint + /** + * **Note**: When called on a {@link LuaPlayer}, it must be associated with a character (see + * {@link LuaPlayer.character LuaPlayer::character}). + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.character_trash_slot_count_bonus View documentation} + */ + character_trash_slot_count_bonus: uint + /** + * **Note**: When called on a {@link LuaPlayer}, it must be associated with a character (see + * {@link LuaPlayer.character LuaPlayer::character}). + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.character_maximum_following_robot_count_bonus View documentation} + */ + character_maximum_following_robot_count_bonus: uint + /** + * **Note**: When called on a {@link LuaPlayer}, it must be associated with a character (see + * {@link LuaPlayer.character LuaPlayer::character}). + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.character_health_bonus View documentation} + */ + character_health_bonus: float + /** + * If personal logistic requests are enabled for this character or players character. + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.character_personal_logistic_requests_enabled View documentation} + */ + character_personal_logistic_requests_enabled: boolean + /** + * If personal logistic requests are enabled for this vehicle (spidertron). + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.vehicle_logistic_requests_enabled View documentation} + */ + vehicle_logistic_requests_enabled: boolean + /** + * Returns the {@link defines.gui_type} or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.opened_gui_type View documentation} + */ + readonly opened_gui_type: defines.gui_type | undefined + /** + * The build distance of this character or max uint when not a character or player connected to a character. + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.build_distance View documentation} + */ + readonly build_distance: uint + /** + * The item drop distance of this character or max uint when not a character or player connected to a character. + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.drop_item_distance View documentation} + */ + readonly drop_item_distance: uint + /** + * The reach distance of this character or max uint when not a character or player connected to a character. + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.reach_distance View documentation} + */ + readonly reach_distance: uint + /** + * The item pickup distance of this character or max double when not a character or player connected to a character. + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.item_pickup_distance View documentation} + */ + readonly item_pickup_distance: double + /** + * The loot pickup distance of this character or max double when not a character or player connected to a character. + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.loot_pickup_distance View documentation} + */ + readonly loot_pickup_distance: double + /** + * The resource reach distance of this character or max double when not a character or player connected to a character. + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.resource_reach_distance View documentation} + */ + readonly resource_reach_distance: double + /** + * If this character entity is in combat. + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.in_combat View documentation} + */ + readonly in_combat: boolean + /** + * Gets the current movement speed of this character, including effects from exoskeletons, tiles, stickers and shooting. + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.character_running_speed View documentation} + */ + readonly character_running_speed: double + /** + * Gets the current mining progress between 0 and 1 of this character, or 0 if they aren't mining. + * + * {@link https://lua-api.factorio.com/next/LuaControl.html#LuaControl.character_mining_progress View documentation} + */ + readonly character_mining_progress: double +} + +/** + * The control behavior for an entity. Inserters have logistic network and circuit network behavior logic, lamps have + * circuit logic and so on. This is an abstract base class that concrete control behaviors inherit. + * + * **Note**: An control reference becomes invalid once the control behavior is removed or the entity (see + * {@link LuaEntity}) it resides in is destroyed. + * + * {@link https://lua-api.factorio.com/next/LuaControlBehavior.html View documentation} + * + * @noSelf + */ +interface LuaControlBehavior { + /** + * {@link https://lua-api.factorio.com/next/LuaControlBehavior.html#LuaControlBehavior.get_circuit_network View documentation} + * + * @param wire - Wire color of the network connected to this entity. + * @param circuit_connector - The connector to get circuit network for. Must be specified for entities with more + * than one circuit network connector. + * @returns The circuit network or nil. + */ + get_circuit_network( + wire: defines.wire_type, + circuit_connector?: defines.circuit_connector_id + ): LuaCircuitNetwork | undefined + /** + * The concrete type of this control behavior. + * + * {@link https://lua-api.factorio.com/next/LuaControlBehavior.html#LuaControlBehavior.type View documentation} + */ + readonly type: defines.control_behavior.type + /** + * The entity this control behavior belongs to. + * + * {@link https://lua-api.factorio.com/next/LuaControlBehavior.html#LuaControlBehavior.entity View documentation} + */ + readonly entity: LuaEntity +} + +/** + * A custom tag that shows on the map view. + * + * {@link https://lua-api.factorio.com/next/LuaCustomChartTag.html View documentation} + * + * @noSelf + */ +interface LuaCustomChartTag { + /** + * Destroys this tag. + * + * {@link https://lua-api.factorio.com/next/LuaCustomChartTag.html#LuaCustomChartTag.destroy View documentation} + */ + destroy(): void + /** + * This tag's icon, if it has one. Writing `nil` removes it. + * + * {@link https://lua-api.factorio.com/next/LuaCustomChartTag.html#LuaCustomChartTag.icon View documentation} + */ + icon: SignalID | undefined + /** + * The player who last edited this tag. + * + * {@link https://lua-api.factorio.com/next/LuaCustomChartTag.html#LuaCustomChartTag.last_user View documentation} + */ + last_user: LuaPlayer + /** + * The position of this tag. + * + * {@link https://lua-api.factorio.com/next/LuaCustomChartTag.html#LuaCustomChartTag.position View documentation} + */ + readonly position: PositionTable + text: string + /** + * The unique ID for this tag on this force. + * + * {@link https://lua-api.factorio.com/next/LuaCustomChartTag.html#LuaCustomChartTag.tag_number View documentation} + */ + readonly tag_number: uint + /** + * The force this tag belongs to. + * + * {@link https://lua-api.factorio.com/next/LuaCustomChartTag.html#LuaCustomChartTag.force View documentation} + */ + readonly force: LuaForce + /** + * The surface this tag belongs to. + * + * {@link https://lua-api.factorio.com/next/LuaCustomChartTag.html#LuaCustomChartTag.surface View documentation} + */ + readonly surface: LuaSurface + /** + * 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: "LuaCustomChartTag" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * Prototype of a custom input. + * + * {@link https://lua-api.factorio.com/next/LuaCustomInputPrototype.html View documentation} + * + * @noSelf + */ +interface LuaCustomInputPrototype { + /** + * Name of this prototype. + * + * {@link https://lua-api.factorio.com/next/LuaCustomInputPrototype.html#LuaCustomInputPrototype.name View documentation} + */ + readonly name: string + /** + * Order string of this prototype. + * + * {@link https://lua-api.factorio.com/next/LuaCustomInputPrototype.html#LuaCustomInputPrototype.order View documentation} + */ + readonly order: string + readonly localised_name: LocalisedString + readonly localised_description: LocalisedString + /** + * The default key sequence for this custom input. + * + * {@link https://lua-api.factorio.com/next/LuaCustomInputPrototype.html#LuaCustomInputPrototype.key_sequence View documentation} + */ + readonly key_sequence: string + /** + * The default alternative key sequence for this custom input. `nil` when not defined. + * + * {@link https://lua-api.factorio.com/next/LuaCustomInputPrototype.html#LuaCustomInputPrototype.alternative_key_sequence View documentation} + */ + readonly alternative_key_sequence: string | undefined + /** + * The linked game control name or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaCustomInputPrototype.html#LuaCustomInputPrototype.linked_game_control View documentation} + */ + readonly linked_game_control: string | undefined + /** + * The consuming type: `"none"` or `"game-only"`. + * + * {@link https://lua-api.factorio.com/next/LuaCustomInputPrototype.html#LuaCustomInputPrototype.consuming View documentation} + */ + readonly consuming: "none" | "game-only" + /** + * The action that happens when this custom input is triggered. + * + * {@link https://lua-api.factorio.com/next/LuaCustomInputPrototype.html#LuaCustomInputPrototype.action View documentation} + */ + readonly action: string + /** + * If this custom input is enabled. Disabled custom inputs exist but are not used by the game. + * + * {@link https://lua-api.factorio.com/next/LuaCustomInputPrototype.html#LuaCustomInputPrototype.enabled View documentation} + */ + readonly enabled: boolean + /** + * If this custom input is enabled while using the spectator controller. + * + * {@link https://lua-api.factorio.com/next/LuaCustomInputPrototype.html#LuaCustomInputPrototype.enabled_while_spectating View documentation} + */ + readonly enabled_while_spectating: boolean + /** + * If this custom input is enabled while using the cutscene controller. + * + * {@link https://lua-api.factorio.com/next/LuaCustomInputPrototype.html#LuaCustomInputPrototype.enabled_while_in_cutscene View documentation} + */ + readonly enabled_while_in_cutscene: boolean + /** + * If this custom input will include the selected prototype (if any) when triggered. + * + * {@link https://lua-api.factorio.com/next/LuaCustomInputPrototype.html#LuaCustomInputPrototype.include_selected_prototype View documentation} + */ + readonly include_selected_prototype: boolean + /** + * The item that gets spawned when this custom input is fired or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaCustomInputPrototype.html#LuaCustomInputPrototype.item_to_spawn View documentation} + */ + readonly item_to_spawn: LuaItemPrototype | undefined + /** + * 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: "LuaCustomInputPrototype" + /** All methods and properties that this object supports. */ + help(): string +} + +type CustomTableIndex +/** + * Access an element of this custom table. + * + * {@link https://lua-api.factorio.com/next/LuaCustomTable.html#LuaCustomTable.operator%20[] View documentation} + */ = { + [P in K]: V +} + +/** @noSelf */ +interface LuaCustomTableMembers { + /** + * Number of elements in this table. + * + * {@link https://lua-api.factorio.com/next/LuaCustomTable.html#LuaCustomTable.operator%20# View documentation} + */ + readonly length: LuaLengthMethod + /** + * 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: "LuaCustomTable" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * Lazily evaluated table. For performance reasons, we sometimes return a custom table-like type instead of a native Lua + * table. This custom type lazily constructs the necessary Lua wrappers of the corresponding C++ objects, therefore + * preventing their unnecessary construction in some cases. + * + * There are some notable consequences to the usage of a custom table type rather than the native Lua table type: + * Iterating a custom table is only possible using the `pairs` Lua function; `ipairs` won't work. Another key difference + * is that custom tables cannot be serialised into a game save file -- if saving the game would require serialisation of + * a custom table, an error will be displayed and the game will not be saved. + * + * {@link https://lua-api.factorio.com/next/LuaCustomTable.html View documentation} + * + * @example + * In previous versions of Factorio, this would create a {@link LuaPlayer} instance for every player in the game, even though only one such wrapper is needed. In the current version, accessing {@link LuaGameScript.players game.players} by itself does not create any {@link LuaPlayer} instances; they are created lazily when accessed. Therefore, this example only constructs one {@link LuaPlayer} instance, no matter how many elements there are in `game.players`. + * + * ```lua + * game.players["Oxyd"].character.die() + * ``` + * + * @example + * Custom tables may be iterated using `pairs`. + * + * ```lua + * for _, p in pairs(game.players) do game.player.print(p.name); end + * ``` + * + * @example + * The following will produce no output because `ipairs` is not supported with custom tables. + * + * ```lua + * for _, p in ipairs(game.players) do game.player.print(p.name); end -- incorrect; use pairs instead + * ``` + * + * @example + * This statement will execute successfully and `global.p` will be useable as one might expect. However, as soon as the user tries to save the game, a "LuaCustomTable cannot be serialized" error will be shown. The game will remain unsaveable so long as `global.p` refers to an instance of a custom table. + * + * ```lua + * global.p = game.players -- This has high potential to make the game unsaveable + * ``` + */ +type LuaCustomTable = LuaCustomTableMembers & CustomTableIndex + +/** + * Prototype of a damage. + * + * {@link https://lua-api.factorio.com/next/LuaDamagePrototype.html View documentation} + * + * @noSelf + */ +interface LuaDamagePrototype { + /** + * Name of this prototype. + * + * {@link https://lua-api.factorio.com/next/LuaDamagePrototype.html#LuaDamagePrototype.name View documentation} + */ + readonly name: string + /** + * Order string of this prototype. + * + * {@link https://lua-api.factorio.com/next/LuaDamagePrototype.html#LuaDamagePrototype.order View documentation} + */ + readonly order: string + readonly localised_name: LocalisedString + readonly localised_description: LocalisedString + /** + * Whether this damage type is hidden from entity tooltips. + * + * {@link https://lua-api.factorio.com/next/LuaDamagePrototype.html#LuaDamagePrototype.hidden View documentation} + */ + 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: "LuaDamagePrototype" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * Control behavior for decider combinators. + * + * {@link https://lua-api.factorio.com/next/LuaDeciderCombinatorControlBehavior.html View documentation} + * + * @noSelf + */ +interface LuaDeciderCombinatorControlBehavior extends LuaCombinatorControlBehavior { + /** + * The decider combinator parameters + * + * **Note**: Setting to `nil` clears the parameters. + * + * {@link https://lua-api.factorio.com/next/LuaDeciderCombinatorControlBehavior.html#LuaDeciderCombinatorControlBehavior.parameters View documentation} + */ + parameters: DeciderCombinatorParameters + /** + * 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: "LuaDeciderCombinatorControlBehavior" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * Prototype of an optimized decorative. + * + * {@link https://lua-api.factorio.com/next/LuaDecorativePrototype.html View documentation} + * + * @noSelf + */ +interface LuaDecorativePrototype { + /** + * Name of this prototype. + * + * {@link https://lua-api.factorio.com/next/LuaDecorativePrototype.html#LuaDecorativePrototype.name View documentation} + */ + readonly name: string + /** + * Order string of this prototype. + * + * {@link https://lua-api.factorio.com/next/LuaDecorativePrototype.html#LuaDecorativePrototype.order View documentation} + */ + readonly order: string + readonly localised_name: LocalisedString + readonly localised_description: LocalisedString + /** + * The bounding box used for collision checking. + * + * {@link https://lua-api.factorio.com/next/LuaDecorativePrototype.html#LuaDecorativePrototype.collision_box View documentation} + */ + readonly collision_box: BoundingBoxTable + /** + * The collision masks this decorative uses + * + * {@link https://lua-api.factorio.com/next/LuaDecorativePrototype.html#LuaDecorativePrototype.collision_mask View documentation} + */ + readonly collision_mask: CollisionMask + readonly collision_mask_with_flags: CollisionMaskWithFlags + /** + * Autoplace specification for this decorative prototype. `nil` if none. + * + * {@link https://lua-api.factorio.com/next/LuaDecorativePrototype.html#LuaDecorativePrototype.autoplace_specification View documentation} + */ + readonly autoplace_specification: AutoplaceSpecification | undefined + /** + * 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: "LuaDecorativePrototype" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * Prototype of an electric energy source. + * + * {@link https://lua-api.factorio.com/next/LuaElectricEnergySourcePrototype.html View documentation} + * + * @noSelf + */ +interface LuaElectricEnergySourcePrototype { + readonly buffer_capacity: double + readonly usage_priority: string + readonly input_flow_limit: double + readonly output_flow_limit: double + readonly drain: double + readonly emissions: double + readonly render_no_network_icon: boolean + readonly render_no_power_icon: 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: "LuaElectricEnergySourcePrototype" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * The primary interface for interacting with entities through the Lua API. Entities are everything that exists on the + * map except for tiles (see {@link LuaTile}). + * + * Most functions on LuaEntity also work when the entity is contained in a ghost. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html View documentation} + * + * @noSelf + */ +interface LuaEntity extends LuaControl { + /** + * Gets the entities output inventory if it has one. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.get_output_inventory View documentation} + * + * @returns A reference to the entities output inventory. + */ + get_output_inventory(): LuaInventory + /** + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.get_module_inventory View documentation} + * + * @returns Inventory for storing modules of this entity; `nil` if this entity has no module inventory. + */ + get_module_inventory(): LuaInventory | undefined + /** + * The fuel inventory for this entity or `nil` if this entity doesn't have a fuel inventory. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.get_fuel_inventory View documentation} + */ + get_fuel_inventory(): LuaInventory | undefined + /** + * The burnt result inventory for this entity or `nil` if this entity doesn't have a burnt result inventory. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.get_burnt_result_inventory View documentation} + */ + get_burnt_result_inventory(): LuaInventory | undefined + /** + * Damages the entity. + * + * *Can only be used if this is EntityWithHealth* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.damage View documentation} + * + * @param damage - The amount of damage to be done + * @param force - The force that will be doing the damage. + * @param type - The type of damage to be done, defaults to "impact". + * @param dealer - The entity to consider as the damage dealer. + * @returns The total damage actually applied after resistances. + */ + damage(damage: float, force: ForceIdentification, type?: string, dealer?: LuaEntity): float + /** + * Checks if the entity can be destroyed + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.can_be_destroyed View documentation} + * + * @returns If the entity can be destroyed. + */ + can_be_destroyed(): boolean + /** + * Destroys the entity. + * + * **Note**: Not all entities can be destroyed - things such as rails under trains cannot be destroyed until the + * train is moved or destroyed. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.destroy View documentation} + * + * @returns Returns `false` if the entity was valid and destruction failed, `true` in all other cases. + */ + destroy(params?: { + /** Whether neighbouring cliffs should be corrected. Defaults to `false`. */ + readonly do_cliff_correction?: boolean + /** If `true`, {@link ScriptRaisedDestroyEvent script_raised_destroy} will be called. Defaults to `false`. */ + readonly raise_destroy?: boolean + }): boolean + /** + * Give the entity a command. + * + * *Can only be used if this is Unit* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.set_command View documentation} + * + * @param command + */ + set_command(command: Command): void + /** + * Give the entity a distraction command. + * + * *Can only be used if this is Unit* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.set_distraction_command View documentation} + * + * @param command + */ + set_distraction_command(command: Command): void + /** + * Has this unit been assigned a command? + * + * *Can only be used if this is Unit* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.has_command View documentation} + */ + has_command(): boolean + /** + * Immediately kills the entity. Does nothing if the entity doesn't have health. + * + * Unlike {@link LuaEntity.destroy LuaEntity::destroy}, `die` will trigger the + * {@link OnEntityDiedEvent on_entity_died} event and the entity will produce a corpse and drop loot if it has any. + * + * **Note**: If `force` is not specified, `on_entity_died` will blame the `"neutral"` force. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.die View documentation} + * + * @example + * This function can be called with only the `cause` argument and no `force`: + * + * ```lua + * entity.die(nil, killer_entity) + * ``` + * + * @param force - The force to attribute the kill to. + * @param cause - The cause to attribute the kill to. + * @returns Whether the entity was successfully killed. + */ + die(force?: ForceIdentification, cause?: LuaEntity): boolean + /** + * Test whether this entity's prototype has a flag set. + * + * **Note**: `entity.has_flag(f)` is a shortcut for `entity.prototype.has_flag(f)`. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.has_flag View documentation} + * + * @param flag - The flag to test + * @returns `true` if the entity has the given flag set. + */ + has_flag(flag: string): boolean + /** + * Same as {@link LuaEntity.has_flag LuaEntity::has_flag} but targets the inner entity on a entity ghost. + * + * *Can only be used if this is EntityGhost* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.ghost_has_flag View documentation} + * + * @param flag - The flag to test + * @returns `true` if the entity has the given flag set. + */ + ghost_has_flag(flag: string): boolean + /** + * Offer a thing on the market. + * + * *Can only be used if this is Market* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.add_market_item View documentation} + * + * @example + * Adds market offer, 1 copper ore for 10 iron ore. + * + * ```lua + * market.add_market_item{price={{"iron-ore", 10}}, offer={type="give-item", item="copper-ore"}} + * ``` + * + * @example + * Adds market offer, 1 copper ore for 5 iron ore and 5 stone ore. + * + * ```lua + * market.add_market_item{price={{"iron-ore", 5}, {"stone", 5}}, offer={type="give-item", item="copper-ore"}} + * ``` + * + * @param offer + */ + add_market_item(offer: Offer): void + /** + * Remove an offer from a market. + * + * **Note**: The other offers are moved down to fill the gap created by removing the offer, which decrements the + * overall size of the offer array. + * + * *Can only be used if this is Market* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.remove_market_item View documentation} + * + * @param offer - Index of offer to remove. + * @returns `true` if the offer was successfully removed; `false` when the given index was not valid. + */ + remove_market_item(offer: uint): boolean + /** + * Get all offers in a market as an array. + * + * *Can only be used if this is Market* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.get_market_items View documentation} + */ + get_market_items(): Offer[] + /** + * Removes all offers from a market. + * + * *Can only be used if this is Market* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.clear_market_items View documentation} + */ + clear_market_items(): void + /** + * Connect two devices with a circuit wire or copper cable. Depending on which type of connection should be made, + * there are different procedures: + * + * - To connect two electric poles, `target` must be a {@link LuaEntity} that specifies another electric pole. This + * will connect them with copper cable. + * - To connect two devices with circuit wire, `target` must be a table of type {@link WireConnectionDefinition}. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.connect_neighbour View documentation} + * + * @param target - The target with which to establish a connection. + * @returns Whether the connection was successfully formed. + */ + connect_neighbour(target: LuaEntity | WireConnectionDefinition): boolean + /** + * Disconnect circuit wires or copper cables between devices. Depending on which type of connection should be cut, + * there are different procedures: + * + * - To remove all copper cables, leave the `target` parameter blank: `pole.disconnect_neighbour()`. + * - To remove all wires of a specific color, set `target` to {@link defines.wire_type.red} or {@link defines.wire_type.green}. + * - To remove a specific copper cable between two electric poles, `target` must be a {@link LuaEntity} that specifies + * the other pole: `pole1.disconnect_neighbour(pole2)`. + * - To remove a specific circuit wire, `target` must be a table of type {@link WireConnectionDefinition}. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.disconnect_neighbour View documentation} + * + * @param target - The target with which to cut a connection. + */ + disconnect_neighbour(target?: defines.wire_type | LuaEntity | WireConnectionDefinition): void + /** + * Sets the entity to be deconstructed by construction robots. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.order_deconstruction View documentation} + * + * @param force - The force whose robots are supposed to do the deconstruction. + * @param player - The player to set the last_user to if any. + * @returns If the entity was marked for deconstruction. + */ + order_deconstruction(force: ForceIdentification, player?: PlayerIdentification): boolean + /** + * Cancels deconstruction if it is scheduled, does nothing otherwise. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.cancel_deconstruction View documentation} + * + * @param force - The force who did the deconstruction order. + * @param player - The player to set the last_user to if any. + */ + cancel_deconstruction(force: ForceIdentification, player?: PlayerIdentification): void + /** + * Is this entity marked for deconstruction? + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.to_be_deconstructed View documentation} + */ + to_be_deconstructed(): boolean + /** + * Sets the entity to be upgraded by construction robots. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.order_upgrade View documentation} + * + * @returns If the entity was marked for upgrade. + */ + order_upgrade(params: { + /** The force whose robots are supposed to do the upgrade. */ + readonly force: ForceIdentification + /** The prototype of the entity to upgrade to. */ + readonly target: EntityPrototypeIdentification + readonly player?: PlayerIdentification + /** The new direction if any. */ + readonly direction?: defines.direction + }): boolean + /** + * Cancels upgrade if it is scheduled, does nothing otherwise. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.cancel_upgrade View documentation} + * + * @param force - The force who did the upgrade order. + * @param player - The player to set the last_user to if any. + * @returns If the cancel was successful. + */ + cancel_upgrade(force: ForceIdentification, player?: PlayerIdentification): boolean + /** + * Is this entity marked for upgrade? + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.to_be_upgraded View documentation} + */ + to_be_upgraded(): boolean + /** + * Get a logistic requester slot. + * + * **Note**: Useable only on entities that have requester slots. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.get_request_slot View documentation} + * + * @param slot - The slot index. + * @returns Contents of the specified slot; `nil` if the given slot contains no request. + */ + get_request_slot(slot: uint): SimpleItemStack | undefined + /** + * Set a logistic requester slot. + * + * **Note**: Useable only on entities that have requester slots. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.set_request_slot View documentation} + * + * @param request - What to request. + * @param slot - The slot index. + * @returns If the slot was set. + */ + set_request_slot(request: ItemStackIdentification, slot: uint): boolean + /** + * Clear a logistic requester slot. + * + * **Note**: Useable only on entities that have requester slots. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.clear_request_slot View documentation} + * + * @param slot - The slot index. + */ + clear_request_slot(slot: uint): void + /** + * Returns whether a craft is currently in process. It does not indicate whether progress is currently being made, + * but whether any crafting action has made progress in this machine. + * + * *Can only be used if this is CraftingMachine* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.is_crafting View documentation} + */ + is_crafting(): void + /** + * *Can only be used if this is Gate* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.is_opened View documentation} + * + * @returns `true` if this gate is currently opened. + */ + is_opened(): boolean + /** + * *Can only be used if this is Gate* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.is_opening View documentation} + * + * @returns `true` if this gate is currently opening. + */ + is_opening(): boolean + /** + * *Can only be used if this is Gate* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.is_closed View documentation} + * + * @returns `true` if this gate is currently closed. + */ + is_closed(): boolean + /** + * *Can only be used if this is Gate* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.is_closing View documentation} + * + * @returns `true` if this gate is currently closing + */ + is_closing(): boolean + /** + * *Can only be used if this is Gate* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.request_to_open View documentation} + * + * @param force - The force that requests the gate to be open. + * @param extra_time - Extra ticks to stay open. + */ + request_to_open(force: ForceIdentification, extra_time?: uint): void + /** + * *Can only be used if this is Gate* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.request_to_close View documentation} + * + * @param force - The force that requests the gate to be closed. + */ + request_to_close(force: ForceIdentification): void + /** + * Get a transport line of a belt or belt connectable entity. + * + * *Can only be used if this is TransportBeltConnectable* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.get_transport_line View documentation} + * + * @param index - Index of the requested transport line. + */ + get_transport_line(index: uint): LuaTransportLine + /** + * Get the maximum transport line index of a belt or belt connectable entity. + * + * *Can only be used if this is TransportBeltConnectable* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.get_max_transport_line_index View documentation} + */ + get_max_transport_line_index(): uint + /** + * *Can only be used if this is RocketSilo* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.launch_rocket View documentation} + * + * @returns `true` if the rocket was successfully launched. Return value of `false` means the silo is not ready for launch. + */ + launch_rocket(): boolean + /** + * Revive a ghost. I.e. turn it from a ghost to a real entity or tile. + * + * **Note**: If this is an entity ghost and it is successfully revived this will also return the revived entity or + * `nil` as a second return value and possibly item request proxy as the third parameter depending on value of + * return_item_request_proxy. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.revive View documentation} + * + * @returns Any items the new real entity collided with or `nil` if the ghost could not be revived. + */ + revive(params?: { + /** If `true` the function will return item request proxy as the third parameter. */ + readonly return_item_request_proxy?: boolean + /** + * If true, and an entity ghost; {@link ScriptRaisedReviveEvent script_raised_revive} will be called. Else if + * true, and a tile ghost; {@link ScriptRaisedSetTilesEvent script_raised_set_tiles} will be called. + */ + readonly raise_revive?: boolean + }): LuaMultiReturn<[undefined] | [Record, LuaEntity, LuaEntity | undefined]> + /** + * Revives a ghost silently. + * + * **Note**: If this is an entity ghost and it is successfully revived this will also return the revived entity or + * `nil` as a second return value and possibly item request proxy as the third parameter depending on value of + * return_item_request_proxy. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.silent_revive View documentation} + * + * @returns Any items the new real entity collided with or `nil` if the ghost could not be revived. + */ + silent_revive(params?: { + /** If `true` the function will return item request proxy as the third parameter. */ + readonly return_item_request_proxy?: boolean + /** + * If true, and an entity ghost; {@link ScriptRaisedReviveEvent script_raised_revive} will be called. Else if + * true, and a tile ghost; {@link ScriptRaisedSetTilesEvent script_raised_set_tiles} will be called. + */ + readonly raise_revive?: boolean + }): LuaMultiReturn<[undefined] | [Record, LuaEntity, LuaEntity | undefined]> + /** + * *Can only be used if this is Rail* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.get_connected_rail View documentation} + * + * @returns Rail connected in the specified manner to this one. + */ + get_connected_rail(params: { + readonly rail_direction: defines.rail_direction + readonly rail_connection_direction: defines.rail_connection_direction + }): LuaEntity + /** + * Get the rails that this signal is connected to. + * + * *Can only be used if this is RailSignal* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.get_connected_rails View documentation} + */ + get_connected_rails(): LuaEntity[] + /** + * Get the rail signal or train stop at the start/end of the rail segment this rail is in, or `nil` if the rail + * segment doesn't start/end with a signal nor a train stop. + * + * **Note**: A rail segment is a continuous section of rail with no branches, signals, nor train stops. + * + * *Can only be used if this is Rail* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.get_rail_segment_entity View documentation} + * + * @param direction - The direction of travel relative to this rail. + * @param in_else_out - If true, gets the entity at the entrance of the rail segment, otherwise gets the entity at + * the exit of the rail segment. + */ + get_rail_segment_entity(direction: defines.rail_direction, in_else_out: boolean): LuaEntity | undefined + /** + * Get the rail at the end of the rail segment this rail is in. + * + * **Note**: A rail segment is a continuous section of rail with no branches, signals, nor train stops. + * + * **Note**: This function has a second return value. A {@link defines.rail_direction} that points out of the rail + * segment from the end rail. + * + * *Can only be used if this is Rail* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.get_rail_segment_end View documentation} + * + * @param direction + */ + get_rail_segment_end(direction: defines.rail_direction): LuaMultiReturn<[LuaEntity, defines.rail_direction]> + /** + * Get the length of the rail segment this rail is in. + * + * **Note**: A rail segment is a continuous section of rail with no branches, signals, nor train stops. + * + * *Can only be used if this is Rail* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.get_rail_segment_length View documentation} + */ + get_rail_segment_length(): double + /** + * Get a rail from each rail segment that overlaps with this rail's rail segment. + * + * **Note**: A rail segment is a continuous section of rail with no branches, signals, nor train stops. + * + * *Can only be used if this is Rail* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.get_rail_segment_overlaps View documentation} + */ + get_rail_segment_overlaps(): LuaEntity[] + /** + * Get the filter for a slot in an inserter, loader, or logistic storage container. + * + * **Note**: The entity must allow filters. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.get_filter View documentation} + * + * @param slot_index - Index of the slot to get the filter for. + * @returns Prototype name of the item being filtered. `nil` if the given slot has no filter. + */ + get_filter(slot_index: uint): string | undefined + /** + * Set the filter for a slot in an inserter, loader, or logistic storage container. + * + * **Note**: The entity must allow filters. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.set_filter View documentation} + * + * @param slot_index - Index of the slot to set the filter for. + * @param item - Prototype name of the item to filter. + */ + set_filter(slot_index: uint, item: string): void + /** + * Gets the filter for this infinity container at the given index or `nil` if the filter index doesn't exist or is empty. + * + * *Can only be used if this is InfinityContainer* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.get_infinity_container_filter View documentation} + * + * @param index - The index to get. + */ + get_infinity_container_filter(index: uint): InfinityInventoryFilter | undefined + /** + * Sets the filter for this infinity container at the given index. + * + * *Can only be used if this is InfinityContainer* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.set_infinity_container_filter View documentation} + * + * @param index - The index to set. + * @param filter - The new filter or `nil` to clear the filter. + */ + set_infinity_container_filter(index: uint, filter: InfinityInventoryFilter | undefined): void + /** + * Gets the filter for this infinity pipe or `nil` if the filter is empty. + * + * *Can only be used if this is InfinityPipe* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.get_infinity_pipe_filter View documentation} + */ + get_infinity_pipe_filter(): InfinityPipeFilter | undefined + /** + * Sets the filter for this infinity pipe. + * + * *Can only be used if this is InfinityPipe* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.set_infinity_pipe_filter View documentation} + * + * @param filter - The new filter or `nil` to clear the filter. + */ + set_infinity_pipe_filter(filter: InfinityPipeFilter | undefined): void + /** + * Gets the heat setting for this heat interface. + * + * *Can only be used if this is HeatInterface* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.get_heat_setting View documentation} + */ + get_heat_setting(): HeatSetting + /** + * Sets the heat setting for this heat interface. + * + * *Can only be used if this is HeatInterface* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.set_heat_setting View documentation} + * + * @param filter - The new setting. + */ + set_heat_setting(filter: HeatSetting): void + /** + * Gets the control behavior of the entity (if any). + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.get_control_behavior View documentation} + * + * @returns The control behavior or nil. + */ + get_control_behavior(): LuaControlBehavior | undefined + /** + * Gets (and or creates if needed) the control behavior of the entity. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.get_or_create_control_behavior View documentation} + * + * @returns The control behavior or nil. + */ + get_or_create_control_behavior(): LuaControlBehavior | undefined + /** + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.get_circuit_network View documentation} + * + * @param wire - Wire color of the network connected to this entity. + * @param circuit_connector - The connector to get circuit network for. Must be specified for entities with more + * than one circuit network connector. + * @returns The circuit network or nil. + */ + get_circuit_network( + wire: defines.wire_type, + circuit_connector?: defines.circuit_connector_id + ): LuaCircuitNetwork | undefined + /** + * Read a single signal from the combined circuit networks. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.get_merged_signal View documentation} + * + * @param signal - The signal to read. + * @param circuit_connector - The connector to get signals for. Must be specified for entities with more than one + * circuit network connector. + * @returns The current value of the signal. + */ + get_merged_signal(signal: SignalID, circuit_connector?: defines.circuit_connector_id): int + /** + * The merged circuit network signals or `nil` if there are no signals. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.get_merged_signals View documentation} + * + * @param circuit_connector - The connector to get signals for. Must be specified for entities with more than one + * circuit network connector. + * @returns The sum of signals on both the red and green networks, or nil if it doesn't have a circuit connector. + */ + get_merged_signals(circuit_connector?: defines.circuit_connector_id): Signal[] | undefined + /** + * Whether this entity supports a backer name. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.supports_backer_name View documentation} + */ + supports_backer_name(): boolean + /** + * Copies settings from the given entity onto this entity. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.copy_settings View documentation} + * + * @param entity + * @param by_player - If provided, the copying is done 'as' this player and + * {@link OnEntitySettingsPastedEvent on_entity_settings_pasted} is triggered. + * @returns Any items removed from this entity as a result of copying the settings. + */ + copy_settings(entity: LuaEntity, by_player?: PlayerIdentification): Record + /** + * Gets all the `LuaLogisticPoint`s that this entity owns. Optionally returns only the point specified by the index parameter. + * + * **Note**: When `index` is not given, this will be a single `LuaLogisticPoint` for most entities. For some (such + * as the player character), it can be zero or more. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.get_logistic_point View documentation} + * + * @param index - If provided, only returns the `LuaLogisticPoint` specified by this index. + */ + get_logistic_point(index?: defines.logistic_member_index): LuaLogisticPoint | LuaLogisticPoint[] + /** + * Plays a note with the given instrument and note. + * + * *Can only be used if this is ProgrammableSpeaker* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.play_note View documentation} + * + * @param instrument + * @param note + * @returns If the request is valid. The sound may or may not be played depending on polyphony settings. + */ + play_note(instrument: uint, note: uint): boolean + /** + * Connects the rolling stock in the given direction. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.connect_rolling_stock View documentation} + * + * @param direction + * @returns If any connection was made + */ + connect_rolling_stock(direction: defines.rail_direction): boolean + /** + * Tries to disconnect this rolling stock in the given direction. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.disconnect_rolling_stock View documentation} + * + * @param direction + * @returns If anything was disconnected + */ + disconnect_rolling_stock(direction: defines.rail_direction): boolean + /** + * Reconnect loader, beacon, cliff and mining drill connections to entities that might have been teleported out or + * in by the script. The game doesn't do this automatically as we don't want to loose performance by checking this + * in normal games. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.update_connections View documentation} + */ + update_connections(): void + /** + * Current recipe being assembled by this machine or `nil` if no recipe is set. + * + * *Can only be used if this is CraftingMachine* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.get_recipe View documentation} + */ + get_recipe(): LuaRecipe | undefined + /** + * Sets the current recipe in this assembly machine. + * + * *Can only be used if this is CraftingMachine* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.set_recipe View documentation} + * + * @param recipe - The new recipe or `nil` to clear the recipe. + * @returns Any items removed from this entity as a result of setting the recipe. + */ + set_recipe(recipe: string | LuaRecipe | undefined): Record + /** + * Rotates this entity as if the player rotated it. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.rotate View documentation} + * + * @returns Whether the rotation was successful. + */ + rotate(params?: { + /** If `true`, rotate the entity in the counter-clockwise direction. */ + readonly reverse?: boolean + readonly by_player?: PlayerIdentification + /** If the player is not given should extra items be spilled or returned as a second return value from this. */ + readonly spill_items?: boolean + /** When true, each spilled item will be flagged with the {@link LuaEntity.to_be_looted LuaEntity::to_be_looted} flag. */ + readonly enable_looted?: boolean + /** When provided the spilled items will be marked for deconstruction by this force. */ + readonly force?: LuaForce | string + }): boolean + /** + * Gets the driver of this vehicle if any. + * + * **Note**: May be `nil` if the vehicle contains no driver. To check if there's a passenger see + * {@link LuaEntity.get_passenger LuaEntity::get_passenger}. + * + * *Can only be used if this is Vehicle* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.get_driver View documentation} + */ + get_driver(): LuaEntity | LuaPlayer | undefined + /** + * Sets the driver of this vehicle. + * + * **Note**: This differs over {@link LuaEntity.set_passenger LuaEntity::set_passenger} in that the passenger can't + * drive the vehicle. + * + * *Can only be used if this is Vehicle* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.set_driver View documentation} + * + * @param driver - The new driver or `nil` to eject the current driver if any. + */ + set_driver(driver: LuaEntity | PlayerIdentification | undefined): void + /** + * Gets the passenger of this car or spidertron if any. + * + * **Note**: May be `nil` if the vehicle contains no passenger. To check if there's a driver see + * {@link LuaEntity.get_driver LuaEntity::get_driver}. + * + * **Note**: This differs over {@link LuaEntity.get_driver LuaEntity::get_driver} in that the passenger can't drive the car. + * + * *Can only be used if this is Vehicle* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.get_passenger View documentation} + */ + get_passenger(): LuaEntity | LuaPlayer | undefined + /** + * Sets the passenger of this car or spidertron. + * + * **Note**: This differs over {@link LuaEntity.get_driver LuaEntity::get_driver} in that the passenger can't drive the car. + * + * *Can only be used if this is Vehicle* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.set_passenger View documentation} + * + * @param passenger + */ + set_passenger(passenger: LuaEntity | PlayerIdentification): void + /** + * Returns true if this entity is connected to an electric network. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.is_connected_to_electric_network View documentation} + */ + is_connected_to_electric_network(): boolean + /** + * The trains scheduled to stop at this train stop. + * + * *Can only be used if this is TrainStop* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.get_train_stop_trains View documentation} + */ + get_train_stop_trains(): LuaTrain[] + /** + * The train currently stopped at this train stop or `nil` if none. + * + * *Can only be used if this is TrainStop* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.get_stopped_train View documentation} + */ + get_stopped_train(): LuaTrain | undefined + /** + * Clones this entity. + * + * **Note**: {@link defines.events.on_entity_cloned} is raised. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.clone View documentation} + * + * @returns The cloned entity or `nil` if this entity can't be cloned/can't be cloned to the given location. + */ + clone(params: { + /** The destination position */ + readonly position: Position + /** The destination surface */ + readonly surface?: LuaSurface + readonly force?: ForceIdentification + /** If false, the building effect smoke will not be shown around the new entity. */ + readonly create_build_effect_smoke?: boolean + }): LuaEntity | undefined + /** + * Get the amount of all or some fluid in this entity. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.get_fluid_count View documentation} + * + * @param fluid - Prototype name of the fluid to count. If not specified, count all fluids. + */ + get_fluid_count(fluid?: string): double + /** + * Get amounts of all fluids in this entity. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.get_fluid_contents View documentation} + * + * @returns The amounts, indexed by fluid names. + */ + get_fluid_contents(): Record + /** + * Remove fluid from this entity. + * + * **Note**: If temperature is given only fluid matching that exact temperature is removed. If minimum and maximum + * is given fluid within that range is removed. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.remove_fluid View documentation} + * + * @returns Amount of fluid actually removed. + */ + remove_fluid(params: { + /** Fluid prototype name. */ + readonly name: string + /** Amount to remove */ + readonly amount: double + readonly minimum_temperature?: double + readonly maximum_temperature?: double + readonly temperature?: double + }): double + /** + * Insert fluid into this entity. Fluidbox is chosen automatically. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.insert_fluid View documentation} + * + * @param fluid - Fluid to insert. + * @returns Amount of fluid actually inserted. + */ + insert_fluid(fluid: Fluid): double + /** + * Remove all fluids from this entity. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.clear_fluid_inside View documentation} + */ + clear_fluid_inside(): void + /** + * Get the source of this beam. + * + * *Can only be used if this is Beam* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.get_beam_source View documentation} + */ + get_beam_source(): BeamTarget + /** + * Set the source of this beam. + * + * *Can only be used if this is Beam* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.set_beam_source View documentation} + * + * @param source + */ + set_beam_source(source: LuaEntity | Position): void + /** + * Get the target of this beam. + * + * *Can only be used if this is Beam* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.get_beam_target View documentation} + */ + get_beam_target(): BeamTarget + /** + * Set the target of this beam. + * + * *Can only be used if this is Beam* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.set_beam_target View documentation} + * + * @param target + */ + set_beam_target(target: LuaEntity | Position): void + /** + * The radius of this entity. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.get_radius View documentation} + */ + get_radius(): double + /** + * The health ratio of this entity between 1 and 0 (for full health and no health respectively). + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.get_health_ratio View documentation} + */ + get_health_ratio(): float + /** + * Creates the same smoke that is created when you place a building by hand. You can play the building sound to go + * with it by using {@link LuaSurface.play_sound LuaSurface::play_sound}, eg: + * entity.surface.play_sound{path="entity-build/"..entity.prototype.name, position=entity.position} + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.create_build_effect_smoke View documentation} + */ + create_build_effect_smoke(): void + /** + * Release the unit from the spawner which spawned it. This allows the spawner to continue spawning additional units. + * + * *Can only be used if this is Unit* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.release_from_spawner View documentation} + */ + release_from_spawner(): void + /** + * Toggle this entity's equipment movement bonus. Does nothing if the entity does not have an equipment grid. + * + * **Note**: This property can also be read and written on the equipment grid of this entity. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.toggle_equipment_movement_bonus View documentation} + */ + toggle_equipment_movement_bonus(): void + /** + * If this character can shoot the given entity or position. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.can_shoot View documentation} + * + * @param target + * @param position + */ + can_shoot(target: LuaEntity, position: Position): boolean + /** + * Only works if the entity is a speech-bubble, with an "effect" defined in its wrapper_flow_style. Starts animating + * the opacity of the speech bubble towards zero, and destroys the entity when it hits zero. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.start_fading_out View documentation} + */ + start_fading_out(): void + /** + * Returns the new entity prototype. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.get_upgrade_target View documentation} + * + * @returns Nil if this entity is not marked for upgrade. + */ + get_upgrade_target(): LuaEntityPrototype | undefined + /** + * Returns the new entity direction after upgrading. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.get_upgrade_direction View documentation} + * + * @returns Nil if this entity is not marked for upgrade. + */ + get_upgrade_direction(): defines.direction | undefined + /** + * Returns the amount of damage to be taken by this entity. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.get_damage_to_be_taken View documentation} + */ + get_damage_to_be_taken(): float + /** + * Depletes and destroys this resource entity. + * + * *Can only be used if this is ResourceEntity* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.deplete View documentation} + */ + deplete(): void + /** + * Mines this entity. + * + * **Note**: 'standard' operation is to keep calling mine() with an inventory until all items are transferred and + * the items dealt with. + * + * **Note**: The result of mining the entity (the item(s) it produces when mined) will be dropped on the ground if + * they don't fit into the provided inventory. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.mine View documentation} + * + * @returns Whether mining succeeded. + */ + mine(params?: { + /** + * If provided the item(s) will be transferred into this inventory. If provided, this must be an inventory + * created with {@link LuaGameScript.create_inventory LuaGameScript::create_inventory} or be a basic inventory + * owned by some entity. + */ + readonly inventory?: LuaInventory + /** + * If true, when the item(s) don't fit into the given inventory the entity is force mined. If false, the mining + * operation fails when there isn't enough room to transfer all of the items into the inventory. Defaults to + * false. This is ignored and acts as 'true' if no inventory is provided. + */ + readonly force?: boolean + /** If true, {@link ScriptRaisedDestroyEvent script_raised_destroy} will be raised. Defaults to true. */ + readonly raise_destroyed?: boolean + /** + * If true, the minable state of the entity is ignored. Defaults to false. If false, an entity that isn't + * minable (set as not-minable in the prototype or isn't minable for other reasons) will fail to be mined. + */ + readonly ignore_minable?: boolean + }): boolean + /** + * Triggers spawn_decoration actions defined in the entity prototype or does nothing if entity is not "turret" or + * "unit-spawner". + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.spawn_decorations View documentation} + */ + spawn_decorations(): void + /** + * Can wires reach between these entities. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.can_wires_reach View documentation} + * + * @param entity + */ + can_wires_reach(entity: LuaEntity): boolean + /** + * Gets rolling stock connected to the given end of this stock + * + * **Note**: This will also return {@link defines.rail_direction} of other rolling stock that is connected back to + * this rolling stock + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.get_connected_rolling_stock View documentation} + * + * @param direction + * @returns One of connected rolling stocks + */ + get_connected_rolling_stock(direction: defines.rail_direction): LuaEntity + /** + * Is this entity or tile ghost or item request proxy registered for construction? If false, it means a construction + * robot has been dispatched to build the entity, or it is not an entity that can be constructed. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.is_registered_for_construction View documentation} + */ + is_registered_for_construction(): boolean + /** + * Is this entity registered for deconstruction with this force? If false, it means a construction robot has been + * dispatched to deconstruct it, or it is not marked for deconstruction. This is worst-case O(N) complexity where N + * is the current number of things in the deconstruct queue. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.is_registered_for_deconstruction View documentation} + * + * @param force - The force construction manager to check. + */ + is_registered_for_deconstruction(force: ForceIdentification): boolean + /** + * Is this entity registered for upgrade? If false, it means a construction robot has been dispatched to upgrade it, + * or it is not marked for upgrade. This is worst-case O(N) complexity where N is the current number of things in + * the upgrade queue. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.is_registered_for_upgrade View documentation} + */ + is_registered_for_upgrade(): boolean + /** + * Is this entity registered for repair? If false, it means a construction robot has been dispatched to upgrade it, + * or it is not damaged. This is worst-case O(N) complexity where N is the current number of things in the repair queue. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.is_registered_for_repair View documentation} + */ + is_registered_for_repair(): boolean + /** + * Adds the given position to this spidertron's autopilot's queue of destinations. + * + * *Can only be used if this is SpiderVehicle* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.add_autopilot_destination View documentation} + * + * @param position - The position the spidertron should move to. + */ + add_autopilot_destination(position: Position): void + /** + * Connects current linked belt with another one. + * + * Neighbours have to be of different type. If given linked belt is connected to something else it will be + * disconnected first. If provided neighbour is connected to something else it will also be disconnected first. + * Automatically updates neighbour to be connected back to this one. + * + * **Note**: Can also be used on entity ghost if it contains linked-belt + * + * *Can only be used if this is LinkedBelt* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.connect_linked_belts View documentation} + * + * @param neighbour - Another linked belt or entity ghost containing linked belt to connect or nil to disconnect + */ + connect_linked_belts(neighbour: LuaEntity | undefined): void + /** + * Disconnects linked belt from its neighbour. + * + * **Note**: Can also be used on entity ghost if it contains linked-belt + * + * *Can only be used if this is LinkedBelt* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.disconnect_linked_belts View documentation} + */ + disconnect_linked_belts(): void + /** + * Name of the entity prototype. E.g. "inserter" or "filter-inserter". + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.name View documentation} + */ + readonly name: "inserter" | "filter-inserter" + /** + * Name of the entity or tile contained in this ghost + * + * *Can only be used if this is Ghost* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.ghost_name View documentation} + */ + readonly ghost_name: string + /** + * Localised name of the entity. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.localised_name View documentation} + */ + readonly localised_name: LocalisedString + readonly localised_description: LocalisedString + /** + * Localised name of the entity or tile contained in this ghost. + * + * *Can only be used if this is Ghost* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.ghost_localised_name View documentation} + */ + readonly ghost_localised_name: LocalisedString + /** + * *Can only be used if this is Ghost* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.ghost_localised_description View documentation} + */ + readonly ghost_localised_description: LocalisedString + /** + * The entity prototype type of this entity. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.type View documentation} + */ + readonly type: string + /** + * The prototype type of the entity or tile contained in this ghost. + * + * *Can only be used if this is Ghost* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.ghost_type View documentation} + */ + readonly ghost_type: string + /** + * Deactivating an entity will stop all its operations (car will stop moving, inserters will stop working, fish will + * stop moving etc). + * + * **Note**: Entities that are not active naturally can't be set to be active (setting it to be active will do nothing) + * + * **Note**: Ghosts, simple smoke, and corpses can't be modified at this time. + * + * **Note**: It is even possible to set the character to not be active, so he can't move and perform most of the tasks. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.active View documentation} + */ + active: boolean + /** + * When the entity is not destructible it can't be damaged. + * + * **Note**: An indestructible entity can still be mined. + * + * **Note**: Entities that are indestructible naturally (they have no health, like smoke, resource etc) can't be set + * to be destructible. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.destructible View documentation} + */ + destructible: boolean + /** + * **Note**: Not minable entities can still be destroyed. + * + * **Note**: Entities that are not minable naturally (like smoke, character, enemy units etc) can't be set to minable. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.minable View documentation} + */ + minable: boolean + /** + * When entity is not to be rotatable (inserter, transport belt etc), it can't be rotated by player using the R key. + * + * **Note**: Entities that are not rotatable naturally (like chest or furnace) can't be set to be rotatable. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.rotatable View documentation} + */ + rotatable: boolean + /** + * Player can't open gui of this entity and he can't quick insert/input stuff in to the entity when it is not operable. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.operable View documentation} + */ + operable: boolean + /** + * The current health of the entity, or `nil` if it doesn't have health. Health is automatically clamped to be + * between `0` and max health (inclusive). Entities with a health of `0` can not be attacked. + * + * **Note**: To get the maximum possible health of this entity, see + * {@link LuaEntityPrototype.max_health LuaEntityPrototype::max_health} on its prototype. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.health View documentation} + */ + health: float | undefined + /** + * The current direction this entity is facing. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.direction View documentation} + */ + direction: defines.direction + /** + * Whether the entity has direction. When it is false for this entity, it will always return north direction when asked for. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.supports_direction View documentation} + */ + readonly supports_direction: boolean + /** + * The smooth orientation of this entity, if it supports orientation. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.orientation View documentation} + */ + orientation: RealOrientation + /** + * The orientation of this cliff. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.cliff_orientation View documentation} + */ + readonly cliff_orientation: CliffOrientation + /** + * The relative orientation of the vehicle turret, artillery turret, artillery wagon or `nil` if this entity isn't a + * vehicle with a vehicle turret or artillery turret/wagon. + * + * **Note**: Writing does nothing if the vehicle doesn't have a turret. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.relative_turret_orientation View documentation} + */ + relative_turret_orientation: RealOrientation | undefined + /** + * The torso orientation of this spider vehicle. + * + * *Can only be used if this is SpiderVehicle* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.torso_orientation View documentation} + */ + torso_orientation: RealOrientation + /** + * Count of resource units contained. + * + * *Can only be used if this is ResourceEntity* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.amount View documentation} + */ + amount: uint + /** + * Count of initial resource units contained. + * + * **Note**: If this is not an infinite resource reading will give `nil` and writing will give an error. + * + * *Can only be used if this is ResourceEntity* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.initial_amount View documentation} + */ + initial_amount: uint | undefined + /** + * Multiplies the acceleration the vehicle can create for one unit of energy. By default is `1`. + * + * *Can only be used if this is Car* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.effectivity_modifier View documentation} + */ + effectivity_modifier: float + /** + * Multiplies the energy consumption. + * + * *Can only be used if this is Car* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.consumption_modifier View documentation} + */ + consumption_modifier: float + /** + * Multiplies the car friction rate. + * + * *Can only be used if this is Car* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.friction_modifier View documentation} + * + * @example + * This will allow the car to go much faster + * + * ```lua + * game.player.vehicle.friction_modifier = 0.5 + * ``` + */ + friction_modifier: float + /** + * Whether the driver of this car or spidertron is the gunner, if false, the passenger is the gunner. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.driver_is_gunner View documentation} + */ + driver_is_gunner: boolean + /** + * Read when this spidertron auto-targets enemies + * + * *Can only be used if this is SpiderVehicle* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.vehicle_automatic_targeting_parameters View documentation} + */ + vehicle_automatic_targeting_parameters: VehicleAutomaticTargetingParameters + /** + * The current speed of this car in tiles per tick, rolling stock, projectile or spider vehicle, or current max + * speed of the unit. Only the speed of units, cars, and projectiles are writable. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.speed View documentation} + */ + speed: float + /** + * The current speed of this unit in tiles per tick, taking into account any walking speed modifier given by the + * tile the unit is standing on. + * + * *Can only be used if this is Unit* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.effective_speed View documentation} + */ + readonly effective_speed: float + /** + * *Can only be used if this is ItemEntity* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.stack View documentation} + */ + readonly stack: LuaItemStack + /** + * The entity prototype of this entity. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.prototype View documentation} + */ + readonly prototype: LuaEntityPrototype + /** + * The prototype of the entity or tile contained in this ghost. + * + * *Can only be used if this is Ghost* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.ghost_prototype View documentation} + */ + readonly ghost_prototype: LuaEntityPrototype | LuaTilePrototype + /** + * Position where the entity puts its stuff. + * + * **Note**: Meaningful only for entities that put stuff somewhere, such as mining drills or inserters. Mining + * drills can't have their drop position changed; inserters must have `allow_custom_vectors` set to true on their + * prototype to allow changing the drop position. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.drop_position View documentation} + */ + drop_position: Position + /** + * Where the inserter will pick up items from. + * + * **Note**: Inserters must have `allow_custom_vectors` set to true on their prototype to allow changing the pickup position. + * + * *Can only be used if this is Inserter* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.pickup_position View documentation} + */ + pickup_position: Position + /** + * The entity this entity is putting its stuff to or `nil` if there is no such entity. + * + * **Note**: Meaningful only for entities that put stuff somewhere, such as mining drills or inserters. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.drop_target View documentation} + */ + drop_target: LuaEntity | undefined + /** + * The entity the inserter will attempt to pick up from. For example, this can be a transport belt or a storage chest. + * + * *Can only be used if this is Inserter* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.pickup_target View documentation} + */ + pickup_target: LuaEntity + /** + * Index of the currently selected weapon slot of this character, car, or spidertron, or `nil` if the car/spidertron + * doesn't have guns. + * + * *Can only be used if this is Character or Car* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.selected_gun_index View documentation} + */ + selected_gun_index: uint | undefined + /** + * Energy stored in the entity (heat in furnace, energy stored in electrical devices etc.). always 0 for entities + * that don't have the concept of energy stored inside. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.energy View documentation} + * + * @example + * ```lua + * game.player.print("Machine energy: " .. game.player.selected.energy .. "J") + * game.player.selected.energy = 3000 + * ``` + */ + energy: double + /** + * The temperature of this entities heat energy source if this entity uses a heat energy source or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.temperature View documentation} + */ + temperature: double | undefined + /** + * The previous recipe this furnace was using or nil if the furnace had no previous recipe. + * + * *Can only be used if this is Furnace* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.previous_recipe View documentation} + */ + readonly previous_recipe: LuaRecipe | undefined + /** + * The item stack currently held in an inserter's hand. + * + * *Can only be used if this is Inserter* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.held_stack View documentation} + */ + readonly held_stack: LuaItemStack + /** + * Current position of the inserter's "hand". + * + * *Can only be used if this is Inserter* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.held_stack_position View documentation} + */ + readonly held_stack_position: PositionTable + /** + * The train this rolling stock belongs to or nil if not rolling stock. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.train View documentation} + */ + readonly train: LuaTrain | undefined + /** + * - When called on an electric pole, this is a dictionary of all connections, indexed by the strings `"copper"`, + * `"red"`, and `"green"`. + * - When called on a pipe-connectable entity, this is an array of entity arrays of all entities a given fluidbox is + * connected to. + * - When called on an underground transport belt, this is the other end of the underground belt connection, or `nil` if none. + * - When called on a wall-connectable entity or reactor, this is a dictionary of all connections indexed by the + * connection direction "north", "south", "east", and "west". + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.neighbours View documentation} + */ + readonly neighbours: Record | LuaEntity[][] | LuaEntity | undefined + /** + * The belt connectable neighbours of this belt connectable entity. Only entities that input to or are outputs of + * this entity. Does not contain the other end of an underground belt, see + * {@link LuaEntity.neighbours LuaEntity::neighbours} for that. This is a dictionary with `"inputs"`, `"outputs"` + * entries that are arrays of transport belt connectable entities, or empty tables if no entities. + * + * *Can only be used if this is TransportBeltConnectable* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.belt_neighbours View documentation} + */ + readonly belt_neighbours: Record + /** + * Fluidboxes of this entity. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.fluidbox View documentation} + */ + fluidbox: LuaFluidBox + /** + * The backer name assigned to this entity, or `nil` if this entity doesn't support backer names. Entities that + * support backer names are labs, locomotives, radars, roboports, and train stops. + * + * **Note**: While train stops get the name of a backer when placed down, players can rename them if they want to. + * In this case, `backer_name` returns the player-given name of the entity. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.backer_name View documentation} + */ + backer_name: string | undefined + /** + * The label of this entity if it has one or `nil`. Changing the value will trigger on_entity_renamed event + * + * **Note**: only usable on entities that have labels (currently only spider-vehicles). + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.entity_label View documentation} + */ + entity_label: string | undefined + /** + * The ticks left before a ghost, combat robot, highlight box or smoke with trigger is destroyed. + * + * - For ghosts set to uint32 max (4,294,967,295) to never expire. + * - For ghosts Cannot be set higher than {@link LuaForce.ghost_time_to_live LuaForce::ghost_time_to_live} of the entity's force. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.time_to_live View documentation} + */ + time_to_live: uint + /** + * The character, rolling stock, train stop, car, spider-vehicle, flying text, corpse or simple-entity-with-owner + * color. Returns `nil` if this entity doesn't use custom colors. + * + * **Note**: Car color is overridden by the color of the current driver/passenger, if there is one. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.color View documentation} + */ + color: Color | undefined + /** + * The text of this flying-text entity. + * + * *Can only be used if this is FlyingText* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.text View documentation} + */ + text: LocalisedString + /** + * The state of this rail signal. + * + * *Can only be used if this is RailSignal* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.signal_state View documentation} + */ + readonly signal_state: defines.signal_state + /** + * The state of this chain signal. + * + * *Can only be used if this is RailChainSignal* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.chain_signal_state View documentation} + */ + readonly chain_signal_state: defines.chain_signal_state + /** + * Will this entity be picked up automatically when the player walks over it? + * + * *Can only be used if this is ItemEntity* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.to_be_looted View documentation} + */ + to_be_looted: boolean + /** + * The current crafting speed, including speed bonuses from modules and beacons. + * + * *Can only be used if this is CraftingMachine* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.crafting_speed View documentation} + */ + readonly crafting_speed: double + /** + * The current crafting progress, as a number in range [0, 1]. + * + * *Can only be used if this is CraftingMachine* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.crafting_progress View documentation} + */ + crafting_progress: float + /** + * The current productivity bonus progress, as a number in range [0, 1]. + * + * *Can only be used if this is CraftingMachine* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.bonus_progress View documentation} + */ + bonus_progress: double + /** + * The productivity bonus of this entity. + * + * **Note**: This includes force based bonuses as well as beacon/module bonuses. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.productivity_bonus View documentation} + */ + readonly productivity_bonus: double + /** + * The pollution bonus of this entity. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.pollution_bonus View documentation} + */ + readonly pollution_bonus: double + /** + * The speed bonus of this entity. + * + * **Note**: This includes force based bonuses as well as beacon/module bonuses. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.speed_bonus View documentation} + */ + readonly speed_bonus: double + /** + * The consumption bonus of this entity. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.consumption_bonus View documentation} + */ + readonly consumption_bonus: double + /** + * `"input"` or `"output"`, depending on whether this underground belt goes down or up. + * + * *Can only be used if this is TransportBeltToGround* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.belt_to_ground_type View documentation} + */ + readonly belt_to_ground_type: "input" | "output" + /** + * `"input"` or `"output"`, depending on whether this loader puts to or gets from a container. + * + * *Can only be used if this is Loader* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.loader_type View documentation} + */ + loader_type: "input" | "output" + /** + * Number of rocket parts in the silo. + * + * *Can only be used if this is RocketSilo* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.rocket_parts View documentation} + */ + rocket_parts: uint + /** + * The logistic network this entity is a part of. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.logistic_network View documentation} + */ + logistic_network: LuaLogisticNetwork + /** + * The logistic cell this entity is a part of. Will be `nil` if this entity is not a part of any logistic cell. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.logistic_cell View documentation} + */ + readonly logistic_cell: LuaLogisticCell | undefined + /** + * Items this ghost will request when revived or items this item request proxy is requesting. Result is a dictionary + * mapping each item prototype name to the required count. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.item_requests View documentation} + */ + item_requests: Record + /** + * The player connected to this character or `nil` if none. + * + * *Can only be used if this is Character* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.player View documentation} + */ + readonly player: LuaPlayer | undefined + /** + * The unit group this unit is a member of, or `nil` if none. + * + * *Can only be used if this is Unit* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.unit_group View documentation} + */ + readonly unit_group: LuaUnitGroup | undefined + /** + * The damage dealt by this turret, artillery turret, or artillery wagon. + * + * *Can only be used if this is Turret* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.damage_dealt View documentation} + */ + damage_dealt: double + /** + * The number of units killed by this turret, artillery turret, or artillery wagon. + * + * *Can only be used if this is Turret* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.kills View documentation} + */ + kills: uint + /** + * The last player that changed any setting on this entity. This includes building the entity, changing its color, + * or configuring its circuit network. Can be `nil` if the last user is not part of the save anymore. Mods can + * overwrite it if desired. + * + * *Can only be used if this is EntityWithOwner* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.last_user View documentation} + */ + last_user: LuaPlayer | undefined + /** + * The buffer size for the electric energy source or nil if the entity doesn't have an electric energy source. + * + * **Note**: Write access is limited to the ElectricEnergyInterface type + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.electric_buffer_size View documentation} + */ + electric_buffer_size: double | undefined + /** + * The input flow limit for the electric energy source or nil if the entity doesn't have an electric energy source. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.electric_input_flow_limit View documentation} + */ + readonly electric_input_flow_limit: double | undefined + /** + * The output flow limit for the electric energy source or nil if the entity doesn't have an electric energy source. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.electric_output_flow_limit View documentation} + */ + readonly electric_output_flow_limit: double | undefined + /** + * The electric drain for the electric energy source or nil if the entity doesn't have an electric energy source. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.electric_drain View documentation} + */ + readonly electric_drain: double | undefined + /** + * The emissions for the electric energy source or nil if the entity doesn't have an electric energy source. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.electric_emissions View documentation} + */ + readonly electric_emissions: double | undefined + /** + * The unit number or nil if the entity doesn't have one. This is universally unique for every entity that has one, + * for the lifetime of a whole game. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.unit_number View documentation} + */ + readonly unit_number: uint | undefined + /** + * The unit number of the entity contained in this ghost or nil if the entity doesn't have one. + * + * *Can only be used if this is EntityGhost* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.ghost_unit_number View documentation} + */ + readonly ghost_unit_number: uint | undefined + /** + * The mining progress for this mining drill or `nil` if this isn't a mining drill. Is a number in range [0, + * mining_target.prototype.mineable_properties.mining_time] + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.mining_progress View documentation} + */ + mining_progress: double | undefined + /** + * The bonus mining progress for this mining drill or `nil` if this isn't a mining drill. Read yields a number in + * range [0, mining_target.prototype.mineable_properties.mining_time] + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.bonus_mining_progress View documentation} + */ + bonus_mining_progress: double | undefined + /** + * The power production specific to the ElectricEnergyInterface entity type. + * + * *Can only be used if this is ElectricEnergyInterface* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.power_production View documentation} + */ + power_production: double + /** + * The power usage specific to the ElectricEnergyInterface entity type. + * + * *Can only be used if this is ElectricEnergyInterface* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.power_usage View documentation} + */ + power_usage: double + /** + * {@link LuaEntityPrototype.collision_box LuaEntityPrototype::collision_box} around entity's given position and + * respecting the current entity orientation. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.bounding_box View documentation} + */ + readonly bounding_box: BoundingBoxTable + /** + * The secondary bounding box of this entity or `nil` if it doesn't have one. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.secondary_bounding_box View documentation} + */ + readonly secondary_bounding_box: BoundingBoxTable | undefined + /** + * {@link LuaEntityPrototype.selection_box LuaEntityPrototype::selection_box} around entity's given position and + * respecting the current entity orientation. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.selection_box View documentation} + */ + readonly selection_box: BoundingBoxTable + /** + * The secondary selection box of this entity or `nil` if it doesn't have one. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.secondary_selection_box View documentation} + */ + readonly secondary_selection_box: BoundingBoxTable | undefined + /** + * The mining target or `nil` if none + * + * *Can only be used if this is MiningDrill* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.mining_target View documentation} + */ + readonly mining_target: LuaEntity | undefined + /** + * Entities that are directly connected to this entity via the circuit network. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.circuit_connected_entities View documentation} + */ + readonly circuit_connected_entities: { + /** Entities connected via the red wire. */ + readonly red: LuaEntity[] + /** Entities connected via the green wire. */ + readonly green: LuaEntity[] + } + /** + * The connection definition for entities that are directly connected to this entity via the circuit network. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.circuit_connection_definitions View documentation} + */ + readonly circuit_connection_definitions: CircuitConnectionDefinition[] + /** + * The index of the configured request with the highest index for this entity. This means 0 if no requests are set + * and e.g. 20 if the 20th request slot is configured. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.request_slot_count View documentation} + */ + readonly request_slot_count: uint + /** + * The number of filter slots this inserter, loader, or logistic storage container has. 0 if not one of those entities. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.filter_slot_count View documentation} + */ + readonly filter_slot_count: uint + /** + * The container entity this loader is pointing at/pulling from depending on the + * {@link LuaEntity.loader_type LuaEntity::loader_type}. + * + * *Can only be used if this is Loader* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.loader_container View documentation} + */ + readonly loader_container: LuaEntity + /** + * The equipment grid or `nil` if this entity doesn't have an equipment grid. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.grid View documentation} + */ + readonly grid: LuaEquipmentGrid | undefined + /** + * The graphics variation for this entity or `nil` if this entity doesn't use graphics variations. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.graphics_variation View documentation} + */ + graphics_variation: uint8 | undefined + /** + * Index of the tree color. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.tree_color_index View documentation} + */ + tree_color_index: uint8 + /** + * Maximum index of the tree colors. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.tree_color_index_max View documentation} + */ + readonly tree_color_index_max: uint8 + /** + * Index of the tree stage. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.tree_stage_index View documentation} + */ + tree_stage_index: uint8 + /** + * Maximum index of the tree stages. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.tree_stage_index_max View documentation} + */ + readonly tree_stage_index_max: uint8 + /** + * Index of the tree gray stage + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.tree_gray_stage_index View documentation} + */ + tree_gray_stage_index: uint8 + /** + * Maximum index of the tree gray stages. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.tree_gray_stage_index_max View documentation} + */ + readonly tree_gray_stage_index_max: uint8 + /** + * The burner energy source for this entity or `nil` if there isn't one. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.burner View documentation} + */ + readonly burner: LuaBurner | undefined + /** + * The shooting target for this turret or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.shooting_target View documentation} + */ + shooting_target: LuaEntity | undefined + /** + * The target entity for this item-request-proxy or `nil` + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.proxy_target View documentation} + */ + readonly proxy_target: LuaEntity | undefined + /** + * The sticker entities attached to this entity or `nil` if none. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.stickers View documentation} + */ + readonly stickers: LuaEntity[] | undefined + /** + * The entity this sticker is sticked to. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.sticked_to View documentation} + */ + readonly sticked_to: LuaEntity + /** + * *Can only be used if this is ProgrammableSpeaker* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.parameters View documentation} + */ + parameters: ProgrammableSpeakerParameters + /** + * *Can only be used if this is ProgrammableSpeaker* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.alert_parameters View documentation} + */ + alert_parameters: ProgrammableSpeakerAlertParameters + /** + * The electric network statistics for this electric pole. + * + * *Can only be used if this is ElectricPole* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.electric_network_statistics View documentation} + */ + readonly electric_network_statistics: LuaFlowStatistics + /** + * Sets the stack size limit on this inserter. If the stack size is > than the force stack size limit the value is ignored. + * + * **Note**: Set to 0 to reset. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.inserter_stack_size_override View documentation} + */ + inserter_stack_size_override: uint + /** + * The number of products this machine finished crafting in its lifetime. + * + * *Can only be used if this is CraftingMachine* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.products_finished View documentation} + */ + products_finished: uint + /** + * The spawner associated with this unit entity or `nil` if the unit has no associated spawner. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.spawner View documentation} + */ + readonly spawner: LuaEntity | undefined + /** + * The units associated with this spawner entity. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.units View documentation} + */ + readonly units: LuaEntity[] + /** + * The state of this power switch. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.power_switch_state View documentation} + */ + power_switch_state: boolean + /** + * The effects being applied to this entity or `nil`. For beacons this is the effect the beacon is broadcasting. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.effects View documentation} + */ + readonly effects: ModuleEffects | undefined + /** + * The filters for this infinity container. + * + * *Can only be used if this is InfinityContainer* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.infinity_container_filters View documentation} + */ + infinity_container_filters: InfinityInventoryFilter[] + /** + * If items not included in this infinity container filters should be removed from the container. + * + * *Can only be used if this is InfinityContainer* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.remove_unfiltered_items View documentation} + */ + remove_unfiltered_items: boolean + /** + * The player index associated with this character corpse. + * + * **Note**: The index is not guaranteed to be valid so it should always be checked first if a player with that + * index actually exists. + * + * *Can only be used if this is CharacterCorpse* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.character_corpse_player_index View documentation} + */ + character_corpse_player_index: uint + /** + * The tick this character corpse died at. + * + * *Can only be used if this is CharacterCorpse* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.character_corpse_tick_of_death View documentation} + */ + character_corpse_tick_of_death: uint + /** + * The reason this character corpse character died (if any). + * + * *Can only be used if this is CharacterCorpse* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.character_corpse_death_cause View documentation} + */ + character_corpse_death_cause: LocalisedString + /** + * The player this character is associated with or `nil` if none. When the player logs off in multiplayer all of the + * associated characters will be logged off with him. + * + * **Note**: A character associated with a player is not directly controlled by any player. + * + * **Note**: Set to `nil` to clear. The player will be automatically disassociated when a controller is set on the character. + * + * *Can only be used if this is Character* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.associated_player View documentation} + */ + associated_player: LuaPlayer | undefined + /** + * The last tick this character entity was attacked. + * + * *Can only be used if this is Character* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.tick_of_last_attack View documentation} + */ + tick_of_last_attack: uint + /** + * The last tick this character entity was damaged. + * + * *Can only be used if this is Character* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.tick_of_last_damage View documentation} + */ + tick_of_last_damage: uint + /** + * The filter for this splitter or `nil` if no filter is set. + * + * *Can only be used if this is Splitter* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.splitter_filter View documentation} + */ + splitter_filter: LuaItemPrototype | undefined + /** + * The filter mode for this filter inserter: "whitelist", "blacklist", or `nil` if this inserter doesn't use filters. + * + * *Can only be used if this is Inserter* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.inserter_filter_mode View documentation} + */ + inserter_filter_mode: "whitelist" | "blacklist" | undefined + /** + * The input priority for this splitter : "left", "none", or "right". + * + * *Can only be used if this is Splitter* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.splitter_input_priority View documentation} + */ + splitter_input_priority: "left" | "none" | "right" + /** + * The output priority for this splitter : "left", "none", or "right". + * + * *Can only be used if this is Splitter* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.splitter_output_priority View documentation} + */ + splitter_output_priority: "left" | "none" | "right" + /** + * If this land mine is armed. + * + * *Can only be used if this is LandMine* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.armed View documentation} + */ + readonly armed: boolean + /** + * When locked; the recipe in this assembling machine can't be changed by the player. + * + * *Can only be used if this is AssemblingMachine* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.recipe_locked View documentation} + */ + recipe_locked: boolean + /** + * The rail entity this train stop is connected to or `nil` if there is none. + * + * *Can only be used if this is TrainStop* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.connected_rail View documentation} + */ + readonly connected_rail: LuaEntity | undefined + /** + * The number of trains in this rail block for this rail entity. + * + * *Can only be used if this is Rail* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.trains_in_block View documentation} + */ + readonly trains_in_block: uint + /** + * The timeout that's left on this landmine in ticks. It describes the time between the landmine being placed and it + * being armed. + * + * *Can only be used if this is LandMine* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.timeout View documentation} + */ + timeout: uint + /** + * The current total neighbour bonus of this reactor. + * + * *Can only be used if this is Reactor* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.neighbour_bonus View documentation} + */ + readonly neighbour_bonus: double + /** + * The ai settings of this unit. + * + * *Can only be used if this is Unit* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.ai_settings View documentation} + */ + readonly ai_settings: LuaAISettings + /** + * The hightlight box type of this highlight box entity. + * + * *Can only be used if this is HighlightBox* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.highlight_box_type View documentation} + */ + highlight_box_type: string + /** + * The blink interval of this highlight box entity. 0 indicates no blink. + * + * *Can only be used if this is HighlightBox* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.highlight_box_blink_interval View documentation} + */ + highlight_box_blink_interval: uint + /** + * The status of this entity or `nil` if no status. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.status View documentation} + */ + readonly status: defines.entity_status | undefined + /** + * If equipment grid logistics are enabled while this vehicle is moving. + * + * *Can only be used if this is Vehicle* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.enable_logistics_while_moving View documentation} + */ + enable_logistics_while_moving: boolean + /** + * The player that this `simple-entity-with-owner`, `simple-entity-with-force`, `flying-text`, or `highlight-box` is + * visible to. `nil` means it is rendered for every player. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.render_player View documentation} + */ + render_player: LuaPlayer | undefined + /** + * The forces that this `simple-entity-with-owner`, `simple-entity-with-force`, or `flying-text` is visible to. + * `nil` or an empty array means it is rendered for every force. + * + * **Note**: Reading will always give an array of {@link LuaForce} + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.render_to_forces View documentation} + */ + render_to_forces: ForceIdentification[] | undefined + /** + * The rail target of this pump or `nil`. + * + * *Can only be used if this is Pump* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.pump_rail_target View documentation} + */ + readonly pump_rail_target: LuaEntity | undefined + /** + * Returns true if this unit is moving. + * + * *Can only be used if this is Unit* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.moving View documentation} + */ + readonly moving: boolean + /** + * Returns the id of the electric network that this entity is connected to or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.electric_network_id View documentation} + */ + readonly electric_network_id: uint | undefined + /** + * Whether this character's personal roboports are allowed to dispatch robots. + * + * *Can only be used if this is Character* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.allow_dispatching_robots View documentation} + */ + allow_dispatching_robots: boolean + /** + * Whether this rocket silo automatically launches the rocket when cargo is inserted. + * + * *Can only be used if this is RocketSilo* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.auto_launch View documentation} + */ + auto_launch: boolean + /** + * How much energy this generator generated in the last tick. + * + * *Can only be used if this is Generator* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.energy_generated_last_tick View documentation} + */ + readonly energy_generated_last_tick: double + /** + * The storage filter for this logistic storage container. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.storage_filter View documentation} + */ + storage_filter: LuaItemPrototype + /** + * Whether this requester chest is set to also request from buffer chests. + * + * **Note**: Useable only on entities that have requester slots. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.request_from_buffers View documentation} + */ + request_from_buffers: boolean + /** + * Whether this corpse will ever fade away. + * + * **Note**: Useable only on corpses. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.corpse_expires View documentation} + */ + corpse_expires: boolean + /** + * If true, corpse won't be destroyed when entities are placed over it. If false, whether corpse will be removed or + * not depends on value of CorpsePrototype::remove_on_entity_placement. + * + * **Note**: Useable only on corpses. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.corpse_immune_to_entity_placement View documentation} + */ + corpse_immune_to_entity_placement: boolean + /** + * The tags associated with this entity ghost or `nil` if not an entity ghost. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.tags View documentation} + */ + tags: Tags | undefined + /** + * The command given to this unit or `nil` is the unit has no command. + * + * *Can only be used if this is Unit* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.command View documentation} + */ + readonly command: Command | undefined + /** + * The distraction command given to this unit or `nil` is the unit currently isn't distracted. + * + * *Can only be used if this is Unit* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.distraction_command View documentation} + */ + readonly distraction_command: Command | undefined + /** + * The ticks until the next trigger effect of this smoke-with-trigger. + * + * *Can only be used if this is SmokeWithTrigger* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.time_to_next_effect View documentation} + */ + time_to_next_effect: uint + /** + * Destination position of spidertron's autopilot. Returns `nil` if autopilot doesn't have destination set. + * + * *Can only be used if this is SpiderVehicle* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.autopilot_destination View documentation} + */ + autopilot_destination: Position | undefined + /** + * The queued destination positions of spidertron's autopilot. + * + * *Can only be used if this is SpiderVehicle* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.autopilot_destinations View documentation} + */ + readonly autopilot_destinations: PositionTable[] + /** + * Amount of trains related to this particular train stop. Includes train stopped at this train stop (until it finds + * a path to next target) and trains having this train stop as goal or waypoint. Writing nil will disable the limit + * (will set a maximum possible value). + * + * **Note**: Train may be included multiple times when braking distance covers this train stop multiple times + * + * **Note**: Value may be read even when train stop has no control behavior + * + * *Can only be used if this is TrainStop* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.trains_count View documentation} + */ + readonly trains_count: uint | undefined + /** + * Amount of trains above which no new trains will be sent to this train stop. + * + * **Note**: When a train stop has a control behavior with wire connected and set_trains_limit enabled, this value + * will be overwritten by it + * + * *Can only be used if this is TrainStop* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.trains_limit View documentation} + */ + trains_limit: uint + /** + * If this entity is EntityWithForce + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.is_entity_with_force View documentation} + */ + readonly is_entity_with_force: boolean + /** + * If this entity is EntityWithOwner + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.is_entity_with_owner View documentation} + */ + readonly is_entity_with_owner: boolean + /** + * If this entity is EntityWithHealth + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.is_entity_with_health View documentation} + */ + readonly is_entity_with_health: boolean + /** + * The owner of this combat robot if any. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.combat_robot_owner View documentation} + */ + combat_robot_owner: LuaEntity + /** + * The link ID this linked container is using. + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.link_id View documentation} + */ + link_id: uint + /** + * The follow target of this spidertron if any. + * + * *Can only be used if this is SpiderVehicle* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.follow_target View documentation} + */ + follow_target: LuaEntity + /** + * The follow offset of this spidertron if any. If it is not following an entity this will be nil. This is + * randomized each time the follow entity is set. + * + * *Can only be used if this is SpiderVehicle* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.follow_offset View documentation} + */ + follow_offset: Position | undefined + /** + * Type of linked belt: it is either `"input"` or `"output"`. Changing type will also flip direction so the belt is + * out of the same side + * + * **Note**: Can only be changed when linked belt is disconnected (has no neighbour set) + * + * **Note**: Can also be used on entity ghost if it contains linked-belt + * + * *Can only be used if this is LinkedBelt* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.linked_belt_type View documentation} + */ + linked_belt_type: "input" | "output" + /** + * Neighbour to which this linked belt is connected to. Returns nil if not connected. + * + * **Note**: Can also be used on entity ghost if it contains linked-belt + * + * **Note**: May return entity ghost which contains linked belt to which connection is made + * + * *Can only be used if this is LinkedBelt* + * + * {@link https://lua-api.factorio.com/next/LuaEntity.html#LuaEntity.linked_belt_neighbour View documentation} + */ + readonly linked_belt_neighbour: LuaEntity | undefined + /** + * 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: "LuaEntity" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * Prototype of an entity. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html View documentation} + * + * @noSelf + */ +interface LuaEntityPrototype { + /** + * Does this prototype have a flag enabled? + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.has_flag View documentation} + * + * @param flag - The flag to check. Must be one of - `"not-rotatable"` - `"placeable-neutral"` - + * `"placeable-player"` - `"placeable-enemy"` - `"placeable-off-grid"` - `"player-creation"` - + * `"building-direction-8-way"` - `"filter-directions"` - `"fast-replaceable-no-build-while-moving"` - + * `"breaths-air"` - `"not-repairable"` - `"not-on-map"` - `"not-deconstructable"` - `"not-blueprintable"` - + * `"hide-from-bonus-gui"` - `"hide-alt-info"` - `"fast-replaceable-no-cross-type-while-moving"` - + * `"no-gap-fill-while-building"` - `"not-flammable"` - `"no-automated-item-removal"` - + * `"no-automated-item-insertion"` - `"not-upgradable"` + */ + has_flag( + flag: + | "not-rotatable" + | "placeable-neutral" + | "placeable-player" + | "placeable-enemy" + | "placeable-off-grid" + | "player-creation" + | "filter-directions" + | "fast-replaceable-no-build-while-moving" + | "breaths-air" + | "not-repairable" + | "not-on-map" + | "not-deconstructable" + | "not-blueprintable" + | "hide-from-bonus-gui" + | "hide-alt-info" + | "fast-replaceable-no-cross-type-while-moving" + | "no-gap-fill-while-building" + | "not-flammable" + | "no-automated-item-removal" + | "no-automated-item-insertion" + | "not-upgradable" + ): boolean + /** + * Gets the base size of the given inventory on this entity or `nil` if the given inventory doesn't exist. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.get_inventory_size View documentation} + * + * @param index + */ + get_inventory_size(index: defines.inventory): uint | undefined + /** + * Type of this prototype. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.type View documentation} + */ + readonly type: string + /** + * Name of this prototype. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.name View documentation} + */ + readonly name: string + readonly localised_name: LocalisedString + readonly localised_description: LocalisedString + /** + * Max health of this entity. Will be `0` if this is not an entity with health. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.max_health View documentation} + */ + readonly max_health: float + /** + * Is this resource infinite? Will be `nil` when used on a non-resource. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.infinite_resource View documentation} + */ + readonly infinite_resource: boolean | undefined + /** + * Minimum amount of this resource. Will be `nil` when used on a non-resource. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.minimum_resource_amount View documentation} + */ + readonly minimum_resource_amount: uint | undefined + /** + * The normal amount for this resource. `nil` when not a resource. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.normal_resource_amount View documentation} + */ + readonly normal_resource_amount: uint | undefined + /** + * Every time this infinite resource 'ticks' down it is reduced by this amount. `nil` when not a resource. + * Meaningless if this isn't an infinite type resource. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.infinite_depletion_resource_amount View documentation} + */ + readonly infinite_depletion_resource_amount: uint | undefined + /** + * Name of the category of this resource or `nil` when not a resource. + * + * **Note**: During data stage this property is named "category". + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.resource_category View documentation} + */ + readonly resource_category: string | undefined + /** + * Whether this entity is minable and what can be obtained by mining it. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.mineable_properties View documentation} + */ + readonly mineable_properties: { + /** Is this entity mineable at all? */ + readonly minable: boolean + /** Energy required to mine an entity. */ + readonly mining_time: double + /** + * Prototype name of the particle produced when mining this entity. Will only be present if this entity produces + * any particle during mining. + */ + readonly mining_particle?: string + /** Products obtained by mining this entity. */ + readonly products?: Product[] + /** The required fluid amount if any. */ + readonly fluid_amount?: double + /** The prototype name of the required fluid if any. */ + readonly required_fluid?: string + /** The mining trigger if any. */ + readonly mining_trigger?: TriggerItem[] + } + /** + * Items that, when placed, will produce this entity. It is an array of items, or `nil` if no items place this + * entity. Construction bots will always choose the first item in this list to build this entity. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.items_to_place_this View documentation} + */ + readonly items_to_place_this: SimpleItemStack[] | undefined + /** + * The bounding box used for collision checking. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.collision_box View documentation} + */ + readonly collision_box: BoundingBoxTable + /** + * The secondary bounding box used for collision checking, or `nil` if it doesn't have one. This is only used in + * rails and rail remnants. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.secondary_collision_box View documentation} + */ + readonly secondary_collision_box: BoundingBoxTable | undefined + /** + * The bounding box used for map generator collision checking. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.map_generator_bounding_box View documentation} + */ + readonly map_generator_bounding_box: BoundingBoxTable + /** + * The bounding box used for drawing selection. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.selection_box View documentation} + */ + readonly selection_box: BoundingBoxTable + /** + * The bounding box used for drawing the entity icon. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.drawing_box View documentation} + */ + readonly drawing_box: BoundingBoxTable + /** + * The bounding box used to attach sticker type entities. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.sticker_box View documentation} + */ + readonly sticker_box: BoundingBoxTable + /** + * The collision masks this entity uses + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.collision_mask View documentation} + */ + readonly collision_mask: CollisionMask + readonly collision_mask_with_flags: CollisionMaskWithFlags + /** + * The hardcoded default collision mask (with flags) for this entity prototype type. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.default_collision_mask_with_flags View documentation} + */ + readonly default_collision_mask_with_flags: CollisionMaskWithFlags + /** + * Order string of this prototype. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.order View documentation} + */ + readonly order: string + /** + * Group of this entity. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.group View documentation} + */ + readonly group: LuaGroup + /** + * Subgroup of this entity. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.subgroup View documentation} + */ + readonly subgroup: LuaGroup + /** + * Amount this entity can heal per tick. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.healing_per_tick View documentation} + */ + readonly healing_per_tick: float + /** + * Amount of pollution emissions per second this entity will create. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.emissions_per_second View documentation} + */ + readonly emissions_per_second: double + /** + * Corpses used when this entity is destroyed. It is a dictionary indexed by the corpse's prototype name. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.corpses View documentation} + */ + readonly corpses: Record + /** + * Is this entity selectable? + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.selectable_in_game View documentation} + */ + readonly selectable_in_game: boolean + /** + * The selection priority of this entity - a value between 0 and 255 + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.selection_priority View documentation} + */ + readonly selection_priority: uint + /** + * The weight of this vehicle prototype or `nil` if not a vehicle prototype. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.weight View documentation} + */ + readonly weight: double | undefined + /** + * List of resistances towards each damage type. It is a dictionary indexed by damage type names (see + * `data/base/prototypes/damage-type.lua`). + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.resistances View documentation} + */ + readonly resistances: Record + /** + * The group of mutually fast-replaceable entities. Possibly `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.fast_replaceable_group View documentation} + */ + readonly fast_replaceable_group: string | undefined + /** + * The next upgrade for this entity or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.next_upgrade View documentation} + */ + readonly next_upgrade: LuaEntityPrototype | undefined + /** + * Loot that will be dropped when this entity is killed. `nil` if there is no loot. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.loot View documentation} + */ + readonly loot: Loot[] | undefined + /** + * Repair-speed modifier for this entity. Actual repair speed will be `tool_repair_speed * + * entity_repair_speed_modifier`. May be `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.repair_speed_modifier View documentation} + */ + readonly repair_speed_modifier: uint | undefined + /** + * The range of this turret or `nil` if this isn't a turret related prototype. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.turret_range View documentation} + */ + readonly turret_range: uint | undefined + /** + * Autoplace specification for this entity prototype. `nil` if none. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.autoplace_specification View documentation} + */ + readonly autoplace_specification: AutoplaceSpecification | undefined + /** + * The speed of this transport belt or `nil` if this isn't a transport belt related prototype. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.belt_speed View documentation} + */ + readonly belt_speed: double | undefined + /** + * The result units and spawn points with weight and evolution factor for a biter spawner entity. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.result_units View documentation} + */ + readonly result_units: UnitSpawnDefinition[] + /** + * The attack result of this entity if the entity has one, else `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.attack_result View documentation} + */ + readonly attack_result: TriggerItem[] | undefined + /** + * The final attack result for projectiles `nil` if not a projectile + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.final_attack_result View documentation} + */ + readonly final_attack_result: TriggerItem[] | undefined + /** + * The attack parameters for this entity or `nil` if the entity doesn't use attack parameters. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.attack_parameters View documentation} + */ + readonly attack_parameters: AttackParameters | undefined + /** + * The spawning cooldown for this enemy spawner prototype or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.spawn_cooldown View documentation} + */ + readonly spawn_cooldown: + | { + readonly min: double + readonly max: double + } + | undefined + /** + * The mining radius of this mining drill prototype or `nil` if this isn't a mining drill prototype. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.mining_drill_radius View documentation} + */ + readonly mining_drill_radius: double | undefined + /** + * The mining speed of this mining drill/character prototype or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.mining_speed View documentation} + */ + readonly mining_speed: double | undefined + /** + * The logistic mode of this logistic container or `nil` if this isn't a logistic container prototype. One of + * `"requester"`, `"active-provider"`, `"passive-provider"`, `"buffer"`, `"storage"`, `"none"`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.logistic_mode View documentation} + */ + readonly logistic_mode: + | "requester" + | "active-provider" + | "passive-provider" + | "buffer" + | "storage" + | "none" + | undefined + /** + * The max underground distance for underground belts and underground pipes or `nil` if this isn't one of those prototypes. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.max_underground_distance View documentation} + */ + readonly max_underground_distance: uint8 | undefined + /** + * The entity prototype flags for this entity. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.flags View documentation} + */ + readonly flags: EntityPrototypeFlags + /** + * The remains left behind when this entity is mined. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.remains_when_mined View documentation} + */ + readonly remains_when_mined: LuaEntityPrototype[] + /** + * Entities this entity can be pasted onto in addition to the normal allowed ones. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.additional_pastable_entities View documentation} + */ + readonly additional_pastable_entities: LuaEntityPrototype[] + /** + * When false copy-paste is not allowed for this entity. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.allow_copy_paste View documentation} + */ + readonly allow_copy_paste: boolean + /** + * The cursor size used when shooting at this entity. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.shooting_cursor_size View documentation} + */ + readonly shooting_cursor_size: double + /** + * The smoke trigger run when this entity is built or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.created_smoke View documentation} + */ + readonly created_smoke: + | { + readonly smoke_name: string + readonly offsets: Vector[] + readonly offset_deviation: BoundingBox + readonly initial_height: float + readonly max_radius?: float + readonly speed: Vector + readonly speed_multiplier: float + readonly speed_multiplier_deviation: float + readonly starting_frame: float + readonly starting_frame_deviation: float + readonly starting_frame_speed: float + readonly starting_frame_speed_deviation: float + readonly speed_from_center: float + readonly speed_from_center_deviation: float + } + | undefined + /** + * The trigger run when this entity is created or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.created_effect View documentation} + */ + readonly created_effect: TriggerItem[] | undefined + /** + * The map color used when charting this entity if a friendly or enemy color isn't defined or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.map_color View documentation} + */ + readonly map_color: ColorTable | undefined + /** + * The friendly map color used when charting this entity. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.friendly_map_color View documentation} + */ + readonly friendly_map_color: ColorTable + /** + * The enemy map color used when charting this entity. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.enemy_map_color View documentation} + */ + readonly enemy_map_color: ColorTable + /** + * The evolution requirement to build this entity as a base when expanding enemy bases. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.build_base_evolution_requirement View documentation} + */ + readonly build_base_evolution_requirement: double + /** + * The instruments for this programmable speaker or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.instruments View documentation} + */ + readonly instruments: ProgrammableSpeakerInstrument[] | undefined + /** + * The maximum polyphony for this programmable speaker or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.max_polyphony View documentation} + */ + readonly max_polyphony: uint | undefined + /** + * The module inventory size or `nil` if this entity doesn't support modules. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.module_inventory_size View documentation} + */ + readonly module_inventory_size: uint | undefined + /** + * The max number of ingredients this crafting-machine prototype supports or `nil` if this isn't a crafting-machine prototype. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.ingredient_count View documentation} + */ + readonly ingredient_count: uint | undefined + /** + * The crafting speed of this crafting-machine or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.crafting_speed View documentation} + */ + readonly crafting_speed: double | undefined + /** + * The crafting categories this entity supports. Only meaningful when this is a crafting-machine or player entity type. + * + * **Note**: The value in the dictionary is meaningless and exists just to allow the dictionary type for easy lookup. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.crafting_categories View documentation} + */ + readonly crafting_categories: Record + /** + * The resource categories this character or mining drill supports, or `nil` if not a character or mining dill. + * + * **Note**: The value in the dictionary is meaningless and exists just to allow the dictionary type for easy lookup. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.resource_categories View documentation} + */ + readonly resource_categories: Record | undefined + /** + * The supply area of this electric pole, beacon, or `nil` if this is neither. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.supply_area_distance View documentation} + */ + readonly supply_area_distance: double | undefined + /** + * The maximum wire distance for this entity. 0 when the entity doesn't support wires. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.max_wire_distance View documentation} + */ + readonly max_wire_distance: double + /** + * The maximum circuit wire distance for this entity. 0 when the entity doesn't support circuit wires. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.max_circuit_wire_distance View documentation} + */ + readonly max_circuit_wire_distance: double + /** + * The direct energy usage of this entity or `nil` if this entity doesn't have a direct energy usage. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.energy_usage View documentation} + */ + readonly energy_usage: double | undefined + /** + * The theoretical maximum energy usage for this entity. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.max_energy_usage View documentation} + */ + readonly max_energy_usage: double + /** + * The theoretical maximum energy production for this this entity. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.max_energy_production View documentation} + */ + readonly max_energy_production: double + /** + * The effectivity of this car prototype, generator prototype or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.effectivity View documentation} + */ + readonly effectivity: double | undefined + /** + * The energy consumption of this car prototype or `nil` if not a car prototype. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.consumption View documentation} + */ + readonly consumption: double | undefined + /** + * The friction of this vehicle prototype or `nil` if not a vehicle prototype. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.friction_force View documentation} + */ + readonly friction_force: double | undefined + /** + * The braking force of this vehicle prototype or `nil` if not a vehicle prototype. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.braking_force View documentation} + */ + readonly braking_force: double | undefined + /** + * The air resistance of this rolling stock prototype or `nil` if not a rolling stock prototype. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.air_resistance View documentation} + */ + readonly air_resistance: double | undefined + /** + * If this car prototype uses tank controls to drive or `nil` if this is not a car prototype. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.tank_driving View documentation} + */ + readonly tank_driving: boolean | undefined + /** + * The rotation speed of this car prototype or `nil` if not a car prototype. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.rotation_speed View documentation} + */ + readonly rotation_speed: double | undefined + /** + * The turret rotation speed of this car prototype or `nil` if not a car prototype. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.turret_rotation_speed View documentation} + */ + readonly turret_rotation_speed: double | undefined + /** + * The guns this prototype uses or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.guns View documentation} + */ + readonly guns: Record | undefined + /** + * The default speed of this flying robot, rolling stock or unit, `nil` if not one of these. + * + * **Note**: For rolling stocks, this is their `max_speed`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.speed View documentation} + */ + readonly speed: double | undefined + /** + * The speed multiplier when this flying robot is out of energy or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.speed_multiplier_when_out_of_energy View documentation} + */ + readonly speed_multiplier_when_out_of_energy: float | undefined + /** + * The max payload size of this logistics or construction robot or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.max_payload_size View documentation} + */ + readonly max_payload_size: uint | undefined + /** + * Whether this logistics or construction robot renders its cargo when flying or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.draw_cargo View documentation} + */ + readonly draw_cargo: boolean | undefined + /** + * The energy consumed per tile moved for this flying robot or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.energy_per_move View documentation} + */ + readonly energy_per_move: double | undefined + /** + * The energy consumed per tick for this flying robot or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.energy_per_tick View documentation} + */ + readonly energy_per_tick: double | undefined + /** + * The max energy for this flying robot or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.max_energy View documentation} + */ + readonly max_energy: double | undefined + /** + * The minimum energy for this flying robot before it tries to recharge or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.min_to_charge View documentation} + */ + readonly min_to_charge: float | undefined + /** + * The maximum energy for this flying robot above which it won't try to recharge when stationing or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.max_to_charge View documentation} + */ + readonly max_to_charge: float | undefined + /** + * The burner energy source prototype this entity uses or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.burner_prototype View documentation} + */ + readonly burner_prototype: LuaBurnerPrototype | undefined + /** + * The electric energy source prototype this entity uses or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.electric_energy_source_prototype View documentation} + */ + readonly electric_energy_source_prototype: LuaElectricEnergySourcePrototype | undefined + /** + * The heat energy source prototype this entity uses or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.heat_energy_source_prototype View documentation} + */ + readonly heat_energy_source_prototype: LuaHeatEnergySourcePrototype | undefined + /** + * The fluid energy source prototype this entity uses or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.fluid_energy_source_prototype View documentation} + */ + readonly fluid_energy_source_prototype: LuaFluidEnergySourcePrototype | undefined + /** + * The void energy source prototype this entity uses or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.void_energy_source_prototype View documentation} + */ + readonly void_energy_source_prototype: LuaVoidEnergySourcePrototype | undefined + /** + * The log2 of grid size of the building + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.building_grid_bit_shift View documentation} + */ + readonly building_grid_bit_shift: uint + /** + * The fluid usage of this generator prototype or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.fluid_usage_per_tick View documentation} + */ + readonly fluid_usage_per_tick: double | undefined + /** + * The maximum fluid temperature of this generator prototype or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.maximum_temperature View documentation} + */ + readonly maximum_temperature: double | undefined + /** + * The target temperature of this boiler prototype or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.target_temperature View documentation} + */ + readonly target_temperature: double | undefined + /** + * The fluid this offshore pump produces or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.fluid View documentation} + */ + readonly fluid: LuaFluidPrototype | undefined + /** + * The fluid capacity of this entity or 0 if this entity doesn't support fluids. + * + * **Note**: Crafting machines will report 0 due to their fluid capacity being what ever a given recipe needs. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.fluid_capacity View documentation} + */ + readonly fluid_capacity: double + /** + * The pumping speed of this offshore pump, normal pump, or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.pumping_speed View documentation} + */ + readonly pumping_speed: double | undefined + /** + * If this inserter is a stack-type. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.stack View documentation} + */ + readonly stack: boolean + /** + * If this inserter allows custom pickup and drop vectors. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.allow_custom_vectors View documentation} + */ + readonly allow_custom_vectors: boolean + /** + * If this inserter allows burner leeching. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.allow_burner_leech View documentation} + */ + readonly allow_burner_leech: boolean + /** + * The extension speed of this inserter or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.inserter_extension_speed View documentation} + */ + readonly inserter_extension_speed: double | undefined + /** + * The rotation speed of this inserter or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.inserter_rotation_speed View documentation} + */ + readonly inserter_rotation_speed: double | undefined + /** + * The pickup position for this inserter or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.inserter_pickup_position View documentation} + */ + readonly inserter_pickup_position: Vector | undefined + /** + * The drop position for this inserter or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.inserter_drop_position View documentation} + */ + readonly inserter_drop_position: Vector | undefined + /** + * True if this inserter chases items on belts for pickup or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.inserter_chases_belt_items View documentation} + */ + readonly inserter_chases_belt_items: boolean | undefined + /** + * If this simple-entity is counted as a rock for the deconstruction planner "trees and rocks only" filter. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.count_as_rock_for_filtered_deconstruction View documentation} + */ + readonly count_as_rock_for_filtered_deconstruction: boolean + /** + * The filter count of this inserter, loader, or logistic chest or `nil`. For logistic containers, `nil` means no limit. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.filter_count View documentation} + */ + readonly filter_count: uint | undefined + /** + * The time to live for this prototype or `0` if prototype doesn't have time_to_live or time_before_removed. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.time_to_live View documentation} + */ + readonly time_to_live: uint + /** + * The distribution effectivity for this beacon prototype or `nil` if not a beacon prototype. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.distribution_effectivity View documentation} + */ + readonly distribution_effectivity: double | undefined + /** + * Does this explosion have a beam or `nil` if not an explosion prototype. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.explosion_beam View documentation} + */ + readonly explosion_beam: double | undefined + /** + * Does this explosion rotate or `nil` if not an explosion prototype. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.explosion_rotate View documentation} + */ + readonly explosion_rotate: double | undefined + /** + * If it is a tree, return the number of colors it supports. `nil` otherwise. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.tree_color_count View documentation} + */ + readonly tree_color_count: uint8 | undefined + /** + * Does this entity with health prototype alert when damaged? or `nil` if not entity with health prototype. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.alert_when_damaged View documentation} + */ + readonly alert_when_damaged: boolean | undefined + /** + * Does this turret prototype alert when attacking? or `nil` if not turret prototype. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.alert_when_attacking View documentation} + */ + readonly alert_when_attacking: boolean | undefined + /** + * The color of the prototype, or `nil` if the prototype doesn't have color. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.color View documentation} + */ + readonly color: ColorTable | undefined + /** + * Does this prototype collision mask collide with itself? + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.collision_mask_collides_with_self View documentation} + */ + readonly collision_mask_collides_with_self: boolean + /** + * Does this prototype collision mask collide with tiles only? + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.collision_mask_collides_with_tiles_only View documentation} + */ + readonly collision_mask_collides_with_tiles_only: boolean + /** + * Does this prototype collision mask consider tile transitions? + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.collision_mask_considers_tile_transitions View documentation} + */ + readonly collision_mask_considers_tile_transitions: boolean + /** + * The allowed module effects for this entity or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.allowed_effects View documentation} + */ + readonly allowed_effects: Record | undefined + /** + * The rocket parts required for this rocket silo prototype or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.rocket_parts_required View documentation} + */ + readonly rocket_parts_required: uint | undefined + /** + * The rocket rising delay for this rocket silo prototype or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.rocket_rising_delay View documentation} + */ + readonly rocket_rising_delay: uint8 | undefined + /** + * The rocket launch delay for this rocket silo prototype or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.launch_wait_time View documentation} + */ + readonly launch_wait_time: uint8 | undefined + /** + * The light blinking speed for this rocket silo prototype or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.light_blinking_speed View documentation} + */ + readonly light_blinking_speed: double | undefined + /** + * The door opening speed for this rocket silo prototype or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.door_opening_speed View documentation} + */ + readonly door_opening_speed: double | undefined + /** + * The rising speed for this rocket silo rocket prototype or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.rising_speed View documentation} + */ + readonly rising_speed: double | undefined + /** + * The engine starting speed for this rocket silo rocket prototype or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.engine_starting_speed View documentation} + */ + readonly engine_starting_speed: double | undefined + /** + * The flying speed for this rocket silo rocket prototype or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.flying_speed View documentation} + */ + readonly flying_speed: double | undefined + /** + * The flying acceleration for this rocket silo rocket prototype or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.flying_acceleration View documentation} + */ + readonly flying_acceleration: double | undefined + /** + * The fixed recipe name for this assembling machine prototype or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.fixed_recipe View documentation} + */ + readonly fixed_recipe: string | undefined + /** + * The construction radius for this roboport prototype or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.construction_radius View documentation} + */ + readonly construction_radius: double | undefined + /** + * The logistic radius for this roboport prototype or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.logistic_radius View documentation} + */ + readonly logistic_radius: double | undefined + /** + * The energy used per hitpoint taken for this vehicle during collisions or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.energy_per_hit_point View documentation} + */ + readonly energy_per_hit_point: double | undefined + /** + * If this prototype will attempt to create a ghost of itself on death. + * + * **Note**: If this is false then a ghost will never be made, if it's true a ghost may be made. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.create_ghost_on_death View documentation} + */ + readonly create_ghost_on_death: boolean + /** + * The time it takes this land mine to arm. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.timeout View documentation} + */ + readonly timeout: uint + /** + * The fluidbox prototypes for this entity. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.fluidbox_prototypes View documentation} + */ + readonly fluidbox_prototypes: LuaFluidBoxPrototype[] + /** + * *Can only be used if this is Reactor* + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.neighbour_bonus View documentation} + */ + readonly neighbour_bonus: double + /** + * Controls how much a reactor extends when connected to other reactors. + * + * *Can only be used if this is Reactor* + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.neighbour_collision_increase View documentation} + */ + readonly neighbour_collision_increase: double + /** + * *Can only be used if this is Loader* + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.container_distance View documentation} + */ + readonly container_distance: double + /** + * *Can only be used if this is Loader* + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.belt_distance View documentation} + */ + readonly belt_distance: double + /** + * *Can only be used if this is Loader* + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.belt_length View documentation} + */ + readonly belt_length: double + readonly is_building: boolean + /** + * The amount of ammo that inserters automatically insert into this ammo-turret or artillery-turret or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.automated_ammo_count View documentation} + */ + readonly automated_ammo_count: uint | undefined + /** + * The max speed of this projectile prototype or flying robot prototype or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.max_speed View documentation} + */ + readonly max_speed: double | undefined + /** + * Value between 0 and 1 darkness where all lamps of this lamp prototype are on or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.darkness_for_all_lamps_on View documentation} + */ + readonly darkness_for_all_lamps_on: float | undefined + /** + * Value between 0 and 1 darkness where all lamps of this lamp prototype are off or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.darkness_for_all_lamps_off View documentation} + */ + readonly darkness_for_all_lamps_off: float | undefined + /** + * Whether the lamp is always on (except when out of power or turned off by the circuit network) or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.always_on View documentation} + */ + readonly always_on: boolean | undefined + /** + * The minimum darkness at which this unit spawner can spawn entities. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.min_darkness_to_spawn View documentation} + */ + readonly min_darkness_to_spawn: float + /** + * The maximum darkness at which this unit spawner can spawn entities. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.max_darkness_to_spawn View documentation} + */ + readonly max_darkness_to_spawn: float + readonly call_for_help_radius: double + /** + * Count of enemies this spawner can sustain. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.max_count_of_owned_units View documentation} + */ + readonly max_count_of_owned_units: double + /** + * How many friendly units are required within the spawning_radius of this spawner for it to stop producing more units. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.max_friends_around_to_spawn View documentation} + */ + readonly max_friends_around_to_spawn: double + /** + * How far from the spawner can the units be spawned. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.spawning_radius View documentation} + */ + readonly spawning_radius: double + /** + * What spaces should be between the spawned units. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.spawning_spacing View documentation} + */ + readonly spawning_spacing: double + /** + * The radius of this entity prototype. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.radius View documentation} + */ + readonly radius: double + /** + * The item prototype name used to destroy this cliff or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.cliff_explosive_prototype View documentation} + */ + readonly cliff_explosive_prototype: string | undefined + /** + * The rocket entity prototype associated with this rocket silo prototype or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.rocket_entity_prototype View documentation} + */ + readonly rocket_entity_prototype: LuaEntityPrototype | undefined + /** + * Whether this unit, car, or character prototype has belt immunity, `nil` if not car, unit, or character prototype. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.has_belt_immunity View documentation} + */ + readonly has_belt_immunity: boolean | undefined + /** + * The vision distance of this unit prototype or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.vision_distance View documentation} + */ + readonly vision_distance: double | undefined + /** + * The amount of pollution that has to be absorbed by the unit's spawner before the unit will leave the spawner and + * attack the source of the pollution. `nil` when prototype is not a unit prototype. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.pollution_to_join_attack View documentation} + */ + readonly pollution_to_join_attack: float | undefined + /** + * The minimum pursue time of this unit prototype or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.min_pursue_time View documentation} + */ + readonly min_pursue_time: uint | undefined + /** + * The maximum pursue distance of this unit prototype or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.max_pursue_distance View documentation} + */ + readonly max_pursue_distance: double | undefined + /** + * The radar range of this unit prototype or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.radar_range View documentation} + */ + readonly radar_range: uint | undefined + /** + * Whether this unit prototype can move while shooting or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.move_while_shooting View documentation} + */ + readonly move_while_shooting: boolean | undefined + /** + * Whether this unit prototype can open gates or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.can_open_gates View documentation} + */ + readonly can_open_gates: boolean | undefined + /** + * Whether this unit prototype is affected by tile walking speed modifiers or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.affected_by_tiles View documentation} + */ + readonly affected_by_tiles: boolean | undefined + /** + * The distraction cooldown of this unit prototype or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.distraction_cooldown View documentation} + */ + readonly distraction_cooldown: uint | undefined + /** + * The spawning time modifier of this unit prototype or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.spawning_time_modifier View documentation} + */ + readonly spawning_time_modifier: double | undefined + /** + * The alert icon shift of this entity prototype. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.alert_icon_shift View documentation} + */ + readonly alert_icon_shift: Vector + /** + * The item prototype names that are the inputs of this lab prototype or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.lab_inputs View documentation} + */ + readonly lab_inputs: string[] | undefined + /** + * The base researching speed of this lab prototype or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.researching_speed View documentation} + */ + readonly researching_speed: double | undefined + /** + * The item slot count of this constant combinator prototype or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.item_slot_count View documentation} + */ + readonly item_slot_count: uint | undefined + /** + * The base productivity of this crafting machine, lab, or mining drill, or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.base_productivity View documentation} + */ + readonly base_productivity: double | undefined + /** + * If this market allows access to all forces or just friendly ones. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.allow_access_to_all_forces View documentation} + */ + readonly allow_access_to_all_forces: boolean + /** + * If this entity prototype could possibly ever be rotated. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.supports_direction View documentation} + */ + readonly supports_direction: boolean + /** + * The terrain friction modifier for this vehicle. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.terrain_friction_modifier View documentation} + */ + readonly terrain_friction_modifier: float + /** + * If this vehicle allows passengers. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.allow_passengers View documentation} + */ + readonly allow_passengers: boolean + /** + * The radius of the area this radar can chart, in chunks. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.max_distance_of_sector_revealed View documentation} + */ + readonly max_distance_of_sector_revealed: uint + /** + * The radius of the area constantly revealed by this radar, in chunks. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.max_distance_of_nearby_sector_revealed View documentation} + */ + readonly max_distance_of_nearby_sector_revealed: uint + /** + * The bounding box that specifies which tiles adjacent to the offshore pump should be checked. + * + * *Can only be used if this is OffshorePump* + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.adjacent_tile_collision_box View documentation} + */ + readonly adjacent_tile_collision_box: BoundingBoxTable + /** + * Tiles adjacent to the offshore pump must not collide with this collision mask. + * + * *Can only be used if this is OffshorePump* + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.adjacent_tile_collision_mask View documentation} + */ + readonly adjacent_tile_collision_mask: CollisionMask + /** + * If this mask is not empty, tiles adjacent to the offshore pump must not collide with this collision mask. + * + * *Can only be used if this is OffshorePump* + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.adjacent_tile_collision_test View documentation} + */ + readonly adjacent_tile_collision_test: CollisionMask + /** + * The collision mask used only for collision test with tile directly at offshore pump position. + * + * *Can only be used if this is OffshorePump* + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.center_collision_mask View documentation} + */ + readonly center_collision_mask: CollisionMask + /** + * The equipment grid prototype for this entity or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.grid_prototype View documentation} + */ + readonly grid_prototype: LuaEquipmentGridPrototype | undefined + readonly remove_decoratives: string + /** + * *Can only be used if this is TransportBelt* + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.related_underground_belt View documentation} + */ + readonly related_underground_belt: LuaEntityPrototype + /** + * Gets the current movement speed of this character, including effects from exoskeletons, tiles, stickers and shooting. + * + * *Can only be used if this is Character* + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.running_speed View documentation} + */ + readonly running_speed: double + /** + * *Can only be used if this is Character* + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.maximum_corner_sliding_distance View documentation} + */ + readonly maximum_corner_sliding_distance: double + /** + * *Can only be used if this is Character* + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.build_distance View documentation} + */ + readonly build_distance: uint + /** + * *Can only be used if this is Character* + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.drop_item_distance View documentation} + */ + readonly drop_item_distance: uint + /** + * *Can only be used if this is Character* + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.reach_distance View documentation} + */ + readonly reach_distance: uint + /** + * *Can only be used if this is Character* + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.reach_resource_distance View documentation} + */ + readonly reach_resource_distance: double + /** + * *Can only be used if this is Character* + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.item_pickup_distance View documentation} + */ + readonly item_pickup_distance: double + /** + * *Can only be used if this is Character* + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.loot_pickup_distance View documentation} + */ + readonly loot_pickup_distance: double + /** + * *Can only be used if this is Character* + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.enter_vehicle_distance View documentation} + */ + readonly enter_vehicle_distance: double + /** + * *Can only be used if this is Character* + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.ticks_to_keep_gun View documentation} + */ + readonly ticks_to_keep_gun: uint + /** + * *Can only be used if this is Character* + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.ticks_to_keep_aiming_direction View documentation} + */ + readonly ticks_to_keep_aiming_direction: uint + /** + * *Can only be used if this is Character* + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.ticks_to_stay_in_combat View documentation} + */ + readonly ticks_to_stay_in_combat: uint + /** + * *Can only be used if this is Character* + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.respawn_time View documentation} + */ + readonly respawn_time: uint + /** + * *Can only be used if this is Character* + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.damage_hit_tint View documentation} + */ + readonly damage_hit_tint: ColorTable + /** + * *Can only be used if this is Character* + * + * {@link https://lua-api.factorio.com/next/LuaEntityPrototype.html#LuaEntityPrototype.character_corpse View documentation} + */ + readonly character_corpse: LuaEntityPrototype + /** + * 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: "LuaEntityPrototype" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * An item in a {@link LuaEquipmentGrid}, for example one's power armor. + * + * **Note**: An equipment reference becomes invalid once the equipment is removed or the equipment grid it resides in is + * destroyed. + * + * {@link https://lua-api.factorio.com/next/LuaEquipment.html View documentation} + * + * @noSelf + */ +interface LuaEquipment { + /** + * Name of this equipment. + * + * {@link https://lua-api.factorio.com/next/LuaEquipment.html#LuaEquipment.name View documentation} + */ + readonly name: string + /** + * Type of this equipment. + * + * {@link https://lua-api.factorio.com/next/LuaEquipment.html#LuaEquipment.type View documentation} + */ + readonly type: string + /** + * Position of this equipment in the equipment grid. + * + * {@link https://lua-api.factorio.com/next/LuaEquipment.html#LuaEquipment.position View documentation} + */ + readonly position: PositionTable + /** + * Shape of this equipment. + * + * {@link https://lua-api.factorio.com/next/LuaEquipment.html#LuaEquipment.shape View documentation} + */ + readonly shape: { + readonly width: uint + readonly height: uint + } + /** + * Current shield value of the equipment. + * + * **Note**: Can't be set higher than {@link LuaEquipment.max_shield LuaEquipment::max_shield}. + * + * {@link https://lua-api.factorio.com/next/LuaEquipment.html#LuaEquipment.shield View documentation} + */ + shield: double + /** + * Maximum shield value. + * + * {@link https://lua-api.factorio.com/next/LuaEquipment.html#LuaEquipment.max_shield View documentation} + */ + readonly max_shield: double + /** + * Maximum solar power generated. + * + * {@link https://lua-api.factorio.com/next/LuaEquipment.html#LuaEquipment.max_solar_power View documentation} + */ + readonly max_solar_power: double + /** + * Movement speed bonus. + * + * {@link https://lua-api.factorio.com/next/LuaEquipment.html#LuaEquipment.movement_bonus View documentation} + */ + readonly movement_bonus: double + /** + * Energy generated per tick. + * + * {@link https://lua-api.factorio.com/next/LuaEquipment.html#LuaEquipment.generator_power View documentation} + */ + readonly generator_power: double + /** + * Current available energy. + * + * {@link https://lua-api.factorio.com/next/LuaEquipment.html#LuaEquipment.energy View documentation} + */ + energy: double + /** + * Maximum amount of energy that can be stored in this equipment. + * + * {@link https://lua-api.factorio.com/next/LuaEquipment.html#LuaEquipment.max_energy View documentation} + */ + readonly max_energy: double + readonly prototype: LuaEquipmentPrototype + /** + * The burner energy source for this equipment or `nil` if there isn't one. + * + * {@link https://lua-api.factorio.com/next/LuaEquipment.html#LuaEquipment.burner View documentation} + */ + readonly burner: LuaBurner | undefined + /** + * 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: "LuaEquipment" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * Prototype of an equipment category. + * + * {@link https://lua-api.factorio.com/next/LuaEquipmentCategoryPrototype.html View documentation} + * + * @noSelf + */ +interface LuaEquipmentCategoryPrototype { + /** + * Name of this prototype. + * + * {@link https://lua-api.factorio.com/next/LuaEquipmentCategoryPrototype.html#LuaEquipmentCategoryPrototype.name View documentation} + */ + readonly name: string + /** + * Order string of this prototype. + * + * {@link https://lua-api.factorio.com/next/LuaEquipmentCategoryPrototype.html#LuaEquipmentCategoryPrototype.order View documentation} + */ + readonly order: string + readonly localised_name: LocalisedString + readonly localised_description: LocalisedString + /** + * 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: "LuaEquipmentCategoryPrototype" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * An equipment grid is for example the inside of a power armor. + * + * {@link https://lua-api.factorio.com/next/LuaEquipmentGrid.html View documentation} + * + * @noSelf + */ +interface LuaEquipmentGrid { + /** + * Remove an equipment from the grid. + * + * {@link https://lua-api.factorio.com/next/LuaEquipmentGrid.html#LuaEquipmentGrid.take View documentation} + * + * @returns The removed equipment, or `nil` if no equipment was removed. + */ + take(params: { + /** Take the equipment that contains this position in the grid. */ + readonly position?: Position + /** Take this exact equipment. */ + readonly equipment?: LuaEquipment + /** + * If provided the action is done 'as' this player and + * {@link OnPlayerRemovedEquipmentEvent on_player_removed_equipment} is triggered. + */ + readonly by_player?: PlayerIdentification + }): SimpleItemStack | undefined + /** + * Remove all equipment from the grid. + * + * {@link https://lua-api.factorio.com/next/LuaEquipmentGrid.html#LuaEquipmentGrid.take_all View documentation} + * + * @param by_player - If provided, the action is done 'as' this player and + * {@link OnPlayerRemovedEquipmentEvent on_player_removed_equipment} is triggered. + * @returns Count of each removed equipment, indexed by their prototype names. + */ + take_all(by_player?: PlayerIdentification): Record + /** + * Clear all equipment from the grid, removing it without actually returning it. + * + * {@link https://lua-api.factorio.com/next/LuaEquipmentGrid.html#LuaEquipmentGrid.clear View documentation} + * + * @param by_player - If provided, the action is done 'as' this player and + * {@link OnPlayerRemovedEquipmentEvent on_player_removed_equipment} is triggered. + */ + clear(by_player?: PlayerIdentification): void + /** + * Insert an equipment into the grid. + * + * {@link https://lua-api.factorio.com/next/LuaEquipmentGrid.html#LuaEquipmentGrid.put View documentation} + * + * @returns The newly-added equipment, or `nil` if the equipment could not be added. + */ + put(params: { + /** Equipment prototype name */ + readonly name: string + /** Grid position to put the equipment in. */ + readonly position?: Position + /** + * If provided the action is done 'as' this player and + * {@link OnPlayerPlacedEquipmentEvent on_player_placed_equipment} is triggered. + */ + readonly by_player?: PlayerIdentification + }): LuaEquipment | undefined + /** + * Check whether moving an equipment would succeed. + * + * {@link https://lua-api.factorio.com/next/LuaEquipmentGrid.html#LuaEquipmentGrid.can_move View documentation} + */ + can_move(params: { + /** The equipment to move */ + readonly equipment: LuaEquipment + /** Where to put it */ + readonly position: Position + }): boolean + /** + * Move an equipment within this grid. + * + * {@link https://lua-api.factorio.com/next/LuaEquipmentGrid.html#LuaEquipmentGrid.move View documentation} + * + * @returns `true` if the equipment was successfully moved. + */ + move(params: { + /** The equipment to move */ + readonly equipment: LuaEquipment + /** Where to put it */ + readonly position: Position + }): boolean + /** + * Find equipment in the Equipment Grid based off a position. + * + * {@link https://lua-api.factorio.com/next/LuaEquipmentGrid.html#LuaEquipmentGrid.get View documentation} + * + * @param position - The position + * @returns The found equipment, or `nil` if equipment could not be found at the given position. + */ + get(position: Position): LuaEquipment | undefined + /** + * Get counts of all equipment in this grid. + * + * {@link https://lua-api.factorio.com/next/LuaEquipmentGrid.html#LuaEquipmentGrid.get_contents View documentation} + * + * @returns The counts, indexed by equipment names. + */ + get_contents(): Record + readonly prototype: LuaEquipmentGridPrototype + /** + * Width of the equipment grid. + * + * {@link https://lua-api.factorio.com/next/LuaEquipmentGrid.html#LuaEquipmentGrid.width View documentation} + */ + readonly width: uint + /** + * Height of the equipment grid. + * + * {@link https://lua-api.factorio.com/next/LuaEquipmentGrid.html#LuaEquipmentGrid.height View documentation} + */ + readonly height: uint + /** + * All the equipment in this grid. + * + * {@link https://lua-api.factorio.com/next/LuaEquipmentGrid.html#LuaEquipmentGrid.equipment View documentation} + */ + readonly equipment: LuaEquipment[] + /** + * Total energy per tick generated by the equipment inside this grid. + * + * {@link https://lua-api.factorio.com/next/LuaEquipmentGrid.html#LuaEquipmentGrid.generator_energy View documentation} + */ + readonly generator_energy: double + /** + * Maximum energy per tick that can be created by any solar panels in the equipment grid. Actual generated energy + * varies depending on the daylight levels. + * + * {@link https://lua-api.factorio.com/next/LuaEquipmentGrid.html#LuaEquipmentGrid.max_solar_energy View documentation} + */ + readonly max_solar_energy: double + /** + * The total energy stored in all batteries in the equipment grid. + * + * {@link https://lua-api.factorio.com/next/LuaEquipmentGrid.html#LuaEquipmentGrid.available_in_batteries View documentation} + */ + readonly available_in_batteries: double + /** + * Total energy storage capacity of all batteries in the equipment grid. + * + * {@link https://lua-api.factorio.com/next/LuaEquipmentGrid.html#LuaEquipmentGrid.battery_capacity View documentation} + */ + readonly battery_capacity: double + /** + * The amount of shields this equipment grid has. + * + * {@link https://lua-api.factorio.com/next/LuaEquipmentGrid.html#LuaEquipmentGrid.shield View documentation} + */ + readonly shield: float + /** + * The maximum amount of shields this equipment grid has. + * + * {@link https://lua-api.factorio.com/next/LuaEquipmentGrid.html#LuaEquipmentGrid.max_shield View documentation} + */ + readonly max_shield: float + /** + * True if this movement bonus equipment is turned off, otherwise false. + * + * {@link https://lua-api.factorio.com/next/LuaEquipmentGrid.html#LuaEquipmentGrid.inhibit_movement_bonus View documentation} + */ + inhibit_movement_bonus: 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: "LuaEquipmentGrid" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * Prototype of an equipment grid. + * + * {@link https://lua-api.factorio.com/next/LuaEquipmentGridPrototype.html View documentation} + * + * @noSelf + */ +interface LuaEquipmentGridPrototype { + /** + * Name of this prototype. + * + * {@link https://lua-api.factorio.com/next/LuaEquipmentGridPrototype.html#LuaEquipmentGridPrototype.name View documentation} + */ + readonly name: string + /** + * Order string of this prototype. + * + * {@link https://lua-api.factorio.com/next/LuaEquipmentGridPrototype.html#LuaEquipmentGridPrototype.order View documentation} + */ + readonly order: string + readonly localised_name: LocalisedString + readonly localised_description: LocalisedString + /** + * Equipment category names for the categories that may be inserted into this equipment grid. The grid will accept + * any equipment that has at least one category in this list. + * + * {@link https://lua-api.factorio.com/next/LuaEquipmentGridPrototype.html#LuaEquipmentGridPrototype.equipment_categories View documentation} + * + * @see {@link LuaEquipmentPrototype.equipment_categories} + */ + readonly equipment_categories: string[] + readonly width: uint + readonly height: uint + /** + * If the player can move equipment into or out of this grid. + * + * {@link https://lua-api.factorio.com/next/LuaEquipmentGridPrototype.html#LuaEquipmentGridPrototype.locked View documentation} + */ + readonly locked: 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: "LuaEquipmentGridPrototype" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * Prototype of a modular equipment. + * + * {@link https://lua-api.factorio.com/next/LuaEquipmentPrototype.html View documentation} + * + * @noSelf + */ +interface LuaEquipmentPrototype { + /** + * Name of this prototype. + * + * {@link https://lua-api.factorio.com/next/LuaEquipmentPrototype.html#LuaEquipmentPrototype.name View documentation} + */ + readonly name: string + /** + * Type of this equipment prototype. + * + * {@link https://lua-api.factorio.com/next/LuaEquipmentPrototype.html#LuaEquipmentPrototype.type View documentation} + */ + readonly type: string + /** + * Order string of this prototype. + * + * {@link https://lua-api.factorio.com/next/LuaEquipmentPrototype.html#LuaEquipmentPrototype.order View documentation} + */ + readonly order: string + readonly localised_name: LocalisedString + readonly localised_description: LocalisedString + /** + * Shape of this equipment prototype. + * + * {@link https://lua-api.factorio.com/next/LuaEquipmentPrototype.html#LuaEquipmentPrototype.shape View documentation} + */ + readonly shape: { + readonly width: uint + readonly height: uint + /** Only set when the shape is "manual" */ + readonly points?: EquipmentPoint[] + } + /** + * The result item when taking this equipment out of an equipment grid. `nil` if there is no result item. + * + * {@link https://lua-api.factorio.com/next/LuaEquipmentPrototype.html#LuaEquipmentPrototype.take_result View documentation} + */ + readonly take_result: LuaItemPrototype | undefined + /** + * The max power generated by this equipment. + * + * {@link https://lua-api.factorio.com/next/LuaEquipmentPrototype.html#LuaEquipmentPrototype.energy_production View documentation} + */ + readonly energy_production: double + /** + * The shield value of this equipment. 0 for non-shield equipment. + * + * {@link https://lua-api.factorio.com/next/LuaEquipmentPrototype.html#LuaEquipmentPrototype.shield View documentation} + */ + readonly shield: float + /** + * The energy per shield point restored. 0 for non-shield equipment. + * + * {@link https://lua-api.factorio.com/next/LuaEquipmentPrototype.html#LuaEquipmentPrototype.energy_per_shield View documentation} + */ + readonly energy_per_shield: double + /** + * The logistic parameters for this roboport equipment. + * + * **Note**: Both the `charging_station_shift` and `stationing_offset` vectors are tables with `x` and `y` keys + * instead of an array. + * + * {@link https://lua-api.factorio.com/next/LuaEquipmentPrototype.html#LuaEquipmentPrototype.logistic_parameters View documentation} + */ + readonly logistic_parameters: { + readonly spawn_and_station_height: float + readonly spawn_and_station_shadow_height_offset: float + readonly charge_approach_distance: float + readonly logistic_radius: float + readonly construction_radius: float + readonly charging_station_count: uint + readonly charging_distance: float + readonly charging_station_shift: Vector + readonly charging_energy: double + readonly charging_threshold_distance: float + readonly robot_vertical_acceleration: float + readonly stationing_offset: Vector + readonly robot_limit: uint + readonly logistics_connection_distance: float + readonly robots_shrink_when_entering_and_exiting: boolean + } + readonly energy_consumption: double + /** + * *Can only be used if this is MovementBonusEquipmentPrototype* + * + * {@link https://lua-api.factorio.com/next/LuaEquipmentPrototype.html#LuaEquipmentPrototype.movement_bonus View documentation} + */ + readonly movement_bonus: float + /** + * The energy source prototype for the equipment. + * + * {@link https://lua-api.factorio.com/next/LuaEquipmentPrototype.html#LuaEquipmentPrototype.energy_source View documentation} + */ + readonly energy_source: LuaElectricEnergySourcePrototype + /** + * Category names for this equipment. These categories will be used to determine whether this equipment is allowed + * in a particular equipment grid. + * + * {@link https://lua-api.factorio.com/next/LuaEquipmentPrototype.html#LuaEquipmentPrototype.equipment_categories View documentation} + * + * @see {@link LuaEquipmentGridPrototype.equipment_categories} + */ + readonly equipment_categories: string[] + /** + * The burner energy source prototype this equipment uses or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEquipmentPrototype.html#LuaEquipmentPrototype.burner_prototype View documentation} + */ + readonly burner_prototype: LuaBurnerPrototype | undefined + /** + * The electric energy source prototype this equipment uses or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEquipmentPrototype.html#LuaEquipmentPrototype.electric_energy_source_prototype View documentation} + */ + readonly electric_energy_source_prototype: LuaElectricEnergySourcePrototype | undefined + /** + * The background color of this equipment prototype. + * + * {@link https://lua-api.factorio.com/next/LuaEquipmentPrototype.html#LuaEquipmentPrototype.background_color View documentation} + */ + readonly background_color: ColorTable + /** + * The equipment attack parameters or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaEquipmentPrototype.html#LuaEquipmentPrototype.attack_parameters View documentation} + */ + readonly attack_parameters: AttackParameters | undefined + /** + * Is this active defense equipment automatic. Returns false if not active defense equipment. + * + * {@link https://lua-api.factorio.com/next/LuaEquipmentPrototype.html#LuaEquipmentPrototype.automatic View documentation} + */ + readonly automatic: 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: "LuaEquipmentPrototype" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * Encapsulates statistic data for different parts of the game. In the context of flow statistics, `input` and `output` + * describe on which side of the associated GUI the values are shown. Input values are shown on the left side, output + * values on the right side. + * + * Examples: + * + * - The item production GUI shows "consumption" on the right, thus `output` describes the item consumption numbers. The + * same goes for fluid consumption. + * - The kills gui shows "losses" on the right, so `output` describes how many of the force's entities were killed by enemies. + * - The electric network GUI shows "power consumption" on the left side, so in this case `input` describes the power + * consumption numbers. + * + * {@link https://lua-api.factorio.com/next/LuaFlowStatistics.html View documentation} + * + * @noSelf + */ +interface LuaFlowStatistics { + /** + * Gets the total input count for a given prototype. + * + * {@link https://lua-api.factorio.com/next/LuaFlowStatistics.html#LuaFlowStatistics.get_input_count View documentation} + * + * @param name - The prototype name. + */ + get_input_count(name: string): uint64 | double + /** + * Sets the total input count for a given prototype. + * + * {@link https://lua-api.factorio.com/next/LuaFlowStatistics.html#LuaFlowStatistics.set_input_count View documentation} + * + * @param name - The prototype name. + * @param count - The new count. The type depends on the instance of the statistics. + */ + set_input_count(name: string, count: uint64 | double): void + /** + * Gets the total output count for a given prototype. + * + * {@link https://lua-api.factorio.com/next/LuaFlowStatistics.html#LuaFlowStatistics.get_output_count View documentation} + * + * @param name - The prototype name. + */ + get_output_count(name: string): uint64 | double + /** + * Sets the total output count for a given prototype. + * + * {@link https://lua-api.factorio.com/next/LuaFlowStatistics.html#LuaFlowStatistics.set_output_count View documentation} + * + * @param name - The prototype name. + * @param count - The new count. The type depends on the instance of the statistics. + */ + set_output_count(name: string, count: uint64 | double): void + /** + * Gets the flow count value for the given time frame. + * + * {@link https://lua-api.factorio.com/next/LuaFlowStatistics.html#LuaFlowStatistics.get_flow_count View documentation} + */ + get_flow_count(params: { + /** The prototype name. */ + readonly name: string + /** Read the input values or the output values */ + readonly input: boolean + /** The precision to read. */ + readonly precision_index: defines.flow_precision_index + /** If true, the count is returned instead of the per-time-frame value. */ + readonly count?: boolean + }): double + /** + * Adds a value to this flow statistics. + * + * {@link https://lua-api.factorio.com/next/LuaFlowStatistics.html#LuaFlowStatistics.on_flow View documentation} + * + * @param name - The prototype name. + * @param count - The count: positive or negative determines if the value goes in the input or output statistics. + */ + on_flow(name: string, count: float): void + /** + * Reset all the statistics data to 0. + * + * {@link https://lua-api.factorio.com/next/LuaFlowStatistics.html#LuaFlowStatistics.clear View documentation} + */ + clear(): void + /** + * List of input counts indexed by prototype name. Represents the data that is shown on the left side of the GUI for + * the given statistics. + * + * {@link https://lua-api.factorio.com/next/LuaFlowStatistics.html#LuaFlowStatistics.input_counts View documentation} + */ + readonly input_counts: Record + /** + * List of output counts indexed by prototype name. Represents the data that is shown on the right side of the GUI + * for the given statistics. + * + * {@link https://lua-api.factorio.com/next/LuaFlowStatistics.html#LuaFlowStatistics.output_counts View documentation} + */ + readonly output_counts: Record + /** + * The force these statistics belong to or `nil` for pollution statistics. + * + * {@link https://lua-api.factorio.com/next/LuaFlowStatistics.html#LuaFlowStatistics.force View documentation} + */ + readonly force: LuaForce | undefined + /** + * 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: "LuaFlowStatistics" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * An array of fluid boxes of an entity. Entities may contain more than one fluid box, and some can change the number of + * fluid boxes -- for instance, an assembling machine will change its number of fluid boxes depending on its active recipe. + * + * See {@link Fluid} + * + * Do note that reading from a {@link LuaFluidBox} creates a new table and writing will copy the given fields from the + * table into the engine's own fluid box structure. Therefore, the correct way to update a fluidbox of an entity is to + * read it first, modify the table, then write the modified table back. Directly accessing the returned table's + * attributes won't have the desired effect. + * + * {@link https://lua-api.factorio.com/next/LuaFluidBox.html View documentation} + * + * @example + * Double the temperature of the fluid in `entity`'s first fluid box. + * + * ```lua + * fluid = entity.fluidbox[1] + * fluid.temperature = fluid.temperature * 2 + * entity.fluidbox[1] = fluid + * ``` + * + * @noSelf + */ +interface LuaFluidBox extends Array { + /** + * The prototype of this fluidbox index. + * + * {@link https://lua-api.factorio.com/next/LuaFluidBox.html#LuaFluidBox.get_prototype View documentation} + * + * @param index + */ + get_prototype(index: uint): LuaFluidBoxPrototype + /** + * The capacity of the given fluidbox index. + * + * {@link https://lua-api.factorio.com/next/LuaFluidBox.html#LuaFluidBox.get_capacity View documentation} + * + * @param index + */ + get_capacity(index: uint): double + /** + * The fluidbox connections for the given fluidbox index. + * + * {@link https://lua-api.factorio.com/next/LuaFluidBox.html#LuaFluidBox.get_connections View documentation} + * + * @param index + */ + get_connections(index: uint): LuaFluidBox[] + /** + * Get a fluid box filter + * + * {@link https://lua-api.factorio.com/next/LuaFluidBox.html#LuaFluidBox.get_filter View documentation} + * + * @param index - The index of the filter to get. + * @returns The filter at the requested index. `nil` if there isn't one. + */ + get_filter(index: uint): FluidBoxFilter | undefined + /** + * Set a fluid box filter. + * + * **Note**: Some entities cannot have their fluidbox filter set, notably fluid wagons and crafting machines. + * + * {@link https://lua-api.factorio.com/next/LuaFluidBox.html#LuaFluidBox.set_filter View documentation} + * + * @param index - The index of the filter to set. + * @param filter - The filter to set. Setting `nil` clears the filter. + * @returns Whether the filter was set successfully. + */ + set_filter(index: uint, filter?: FluidBoxFilterSpec): boolean + /** + * Flow through the fluidbox in the last tick. It is the larger of in-flow and out-flow. + * + * **Note**: Fluid wagons do not track it and will return 0. + * + * {@link https://lua-api.factorio.com/next/LuaFluidBox.html#LuaFluidBox.get_flow View documentation} + * + * @param index + */ + get_flow(index: uint): double + /** + * Returns the fluid the fluidbox is locked onto Returns 'nil' for no lock + * + * {@link https://lua-api.factorio.com/next/LuaFluidBox.html#LuaFluidBox.get_locked_fluid View documentation} + * + * @param index + */ + get_locked_fluid(index: uint): string | undefined + /** + * Flushes all fluid from this fluidbox and its fluid system. + * + * {@link https://lua-api.factorio.com/next/LuaFluidBox.html#LuaFluidBox.flush View documentation} + * + * @param index + * @param fluid - If provided, only this fluid is flushed. + * @returns The fluid removed. + */ + flush(index: uint, fluid?: FluidIdentification): Record + /** + * Number of fluid boxes. + * + * {@link https://lua-api.factorio.com/next/LuaFluidBox.html#LuaFluidBox.operator%20# View documentation} + */ + readonly length: uint + /** + * The entity that owns this fluidbox. + * + * {@link https://lua-api.factorio.com/next/LuaFluidBox.html#LuaFluidBox.owner View documentation} + */ + readonly owner: LuaEntity + /** + * Access, set or clear a fluid box. The index must always be in bounds (see + * {@link LuaFluidBox.length LuaFluidBox::operator #}). New fluidboxes may not be added or removed using this + * operator. If the given fluid box doesn't contain any fluid, `nil` is returned. Similarly, `nil` can be written to + * a fluid box to remove all fluid from it. + * + * {@link https://lua-api.factorio.com/next/LuaFluidBox.html#LuaFluidBox.operator%20[] View documentation} + */ + [index: number]: Fluid | undefined + /** + * 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: "LuaFluidBox" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * A prototype of a fluidbox owned by some {@link LuaEntityPrototype}. + * + * {@link https://lua-api.factorio.com/next/LuaFluidBoxPrototype.html View documentation} + * + * @noSelf + */ +interface LuaFluidBoxPrototype { + /** + * The entity that this belongs to. + * + * {@link https://lua-api.factorio.com/next/LuaFluidBoxPrototype.html#LuaFluidBoxPrototype.entity View documentation} + */ + readonly entity: LuaEntityPrototype + /** + * The index of this fluidbox prototype in the owning entity. + * + * {@link https://lua-api.factorio.com/next/LuaFluidBoxPrototype.html#LuaFluidBoxPrototype.index View documentation} + */ + readonly index: uint + /** + * The pipe connection points. + * + * {@link https://lua-api.factorio.com/next/LuaFluidBoxPrototype.html#LuaFluidBoxPrototype.pipe_connections View documentation} + */ + readonly pipe_connections: FluidBoxConnection[] + /** + * The production type. "input", "output", "input-output", or "none". + * + * {@link https://lua-api.factorio.com/next/LuaFluidBoxPrototype.html#LuaFluidBoxPrototype.production_type View documentation} + */ + readonly production_type: "input" | "output" | "input-output" | "none" + readonly base_area: double + readonly base_level: double + readonly height: double + readonly volume: double + /** + * The filter or `nil` if no filter is set. + * + * {@link https://lua-api.factorio.com/next/LuaFluidBoxPrototype.html#LuaFluidBoxPrototype.filter View documentation} + */ + readonly filter: LuaFluidPrototype | undefined + /** + * The minimum temperature or `nil` if none is set. + * + * {@link https://lua-api.factorio.com/next/LuaFluidBoxPrototype.html#LuaFluidBoxPrototype.minimum_temperature View documentation} + */ + readonly minimum_temperature: double | undefined + /** + * The maximum temperature or `nil` if none is set. + * + * {@link https://lua-api.factorio.com/next/LuaFluidBoxPrototype.html#LuaFluidBoxPrototype.maximum_temperature View documentation} + */ + readonly maximum_temperature: double | undefined + /** + * The secondary draw orders for the 4 possible connection directions. + * + * {@link https://lua-api.factorio.com/next/LuaFluidBoxPrototype.html#LuaFluidBoxPrototype.secondary_draw_orders View documentation} + */ + readonly secondary_draw_orders: int[] + /** + * The render layer. + * + * {@link https://lua-api.factorio.com/next/LuaFluidBoxPrototype.html#LuaFluidBoxPrototype.render_layer View documentation} + */ + readonly render_layer: 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: "LuaFluidBoxPrototype" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * Prototype of a fluid energy source. + * + * {@link https://lua-api.factorio.com/next/LuaFluidEnergySourcePrototype.html View documentation} + * + * @noSelf + */ +interface LuaFluidEnergySourcePrototype { + readonly emissions: double + readonly render_no_network_icon: boolean + readonly render_no_power_icon: boolean + readonly effectivity: double + readonly burns_fluid: boolean + readonly scale_fluid_usage: boolean + readonly fluid_usage_per_tick: double + /** + * The smoke sources for this prototype if any. + * + * {@link https://lua-api.factorio.com/next/LuaFluidEnergySourcePrototype.html#LuaFluidEnergySourcePrototype.smoke View documentation} + */ + readonly smoke: SmokeSource[] + readonly maximum_temperature: double + /** + * The fluid box for this energy source. + * + * {@link https://lua-api.factorio.com/next/LuaFluidEnergySourcePrototype.html#LuaFluidEnergySourcePrototype.fluid_box View documentation} + */ + readonly fluid_box: LuaFluidBoxPrototype + /** + * 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: "LuaFluidEnergySourcePrototype" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * Prototype of a fluid. + * + * {@link https://lua-api.factorio.com/next/LuaFluidPrototype.html View documentation} + * + * @noSelf + */ +interface LuaFluidPrototype { + /** + * Name of this prototype. + * + * {@link https://lua-api.factorio.com/next/LuaFluidPrototype.html#LuaFluidPrototype.name View documentation} + */ + readonly name: string + readonly localised_name: LocalisedString + readonly localised_description: LocalisedString + /** + * Default temperature of this fluid. + * + * {@link https://lua-api.factorio.com/next/LuaFluidPrototype.html#LuaFluidPrototype.default_temperature View documentation} + */ + readonly default_temperature: double + /** + * Maximum temperature this fluid can reach. + * + * {@link https://lua-api.factorio.com/next/LuaFluidPrototype.html#LuaFluidPrototype.max_temperature View documentation} + */ + readonly max_temperature: double + /** + * The amount of energy in Joules required to heat one unit of this fluid by 1°C. + * + * {@link https://lua-api.factorio.com/next/LuaFluidPrototype.html#LuaFluidPrototype.heat_capacity View documentation} + */ + readonly heat_capacity: double + /** + * Order string for this prototype. + * + * {@link https://lua-api.factorio.com/next/LuaFluidPrototype.html#LuaFluidPrototype.order View documentation} + */ + readonly order: string + /** + * Group of this prototype. + * + * {@link https://lua-api.factorio.com/next/LuaFluidPrototype.html#LuaFluidPrototype.group View documentation} + */ + readonly group: LuaGroup + /** + * Subgroup of this prototype. + * + * {@link https://lua-api.factorio.com/next/LuaFluidPrototype.html#LuaFluidPrototype.subgroup View documentation} + */ + readonly subgroup: LuaGroup + readonly base_color: ColorTable + readonly flow_color: ColorTable + /** + * The temperature above which this fluid will be shown as gaseous inside tanks and pipes. + * + * {@link https://lua-api.factorio.com/next/LuaFluidPrototype.html#LuaFluidPrototype.gas_temperature View documentation} + */ + readonly gas_temperature: double + /** + * A multiplier on the amount of emissions produced when this fluid is burnt in a generator. A value above `1.0` + * increases emissions and vice versa. The multiplier can't be negative. + * + * {@link https://lua-api.factorio.com/next/LuaFluidPrototype.html#LuaFluidPrototype.emissions_multiplier View documentation} + */ + readonly emissions_multiplier: double + /** + * The amount of energy in Joules one unit of this fluid will produce when burnt in a generator. A value of `0` + * means this fluid can't be used for energy generation. The value can't be negative. + * + * {@link https://lua-api.factorio.com/next/LuaFluidPrototype.html#LuaFluidPrototype.fuel_value View documentation} + */ + readonly fuel_value: double + /** + * Whether this fluid is hidden from the fluid and signal selectors. + * + * {@link https://lua-api.factorio.com/next/LuaFluidPrototype.html#LuaFluidPrototype.hidden View documentation} + */ + 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: "LuaFluidPrototype" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * Prototype of a font. + * + * {@link https://lua-api.factorio.com/next/LuaFontPrototype.html View documentation} + * + * @noSelf + */ +interface LuaFontPrototype { + /** + * Name of this prototype. + * + * {@link https://lua-api.factorio.com/next/LuaFontPrototype.html#LuaFontPrototype.name View documentation} + */ + readonly name: string + readonly from: string + readonly size: int + readonly spacing: float + readonly border: boolean + readonly filtered: boolean + /** + * The border color or `nil` if not set. + * + * {@link https://lua-api.factorio.com/next/LuaFontPrototype.html#LuaFontPrototype.border_color View documentation} + */ + readonly border_color: ColorTable | undefined + /** + * 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: "LuaFontPrototype" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * `LuaForce` encapsulates data local to each "force" or "faction" of the game. Default forces are player, enemy and + * neutral. Players and mods can create additional forces (up to 64 total). + * + * {@link https://lua-api.factorio.com/next/LuaForce.html View documentation} + * + * @noSelf + */ +interface LuaForce { + /** + * Count entities of given type. + * + * **Note**: This function has O(1) time complexity as entity counts are kept and maintained in the game engine. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.get_entity_count View documentation} + * + * @param name - Prototype name of the entity. + * @returns Number of entities of given prototype belonging to this force. + */ + get_entity_count(name: string): uint + /** + * Disable research for this force. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.disable_research View documentation} + */ + disable_research(): void + /** + * Enable research for this force. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.enable_research View documentation} + */ + enable_research(): void + /** + * Disable all recipes and technologies. Only recipes and technologies enabled explicitly will be useable from this point. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.disable_all_prototypes View documentation} + */ + disable_all_prototypes(): void + /** + * Enables all recipes and technologies. The opposite of + * {@link LuaForce.disable_all_prototypes LuaForce::disable_all_prototypes} + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.enable_all_prototypes View documentation} + */ + enable_all_prototypes(): void + /** + * Load the original version of all recipes from the prototypes. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.reset_recipes View documentation} + */ + reset_recipes(): void + /** + * Unlock all recipes. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.enable_all_recipes View documentation} + */ + enable_all_recipes(): void + /** + * Unlock all technologies. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.enable_all_technologies View documentation} + */ + enable_all_technologies(): void + /** + * Research all technologies. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.research_all_technologies View documentation} + * + * @param include_disabled_prototypes - Whether technologies that are explicitly disabled in the prototype should + * also be researched. Defaults to `false`. + */ + research_all_technologies(include_disabled_prototypes?: boolean): void + /** + * Load the original versions of technologies from prototypes. Preserves research state of technologies. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.reset_technologies View documentation} + */ + reset_technologies(): void + /** + * Reset everything. All technologies are set to not researched, all modifiers are set to default values. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.reset View documentation} + */ + reset(): void + /** + * Reapplies all possible research effects, including unlocked recipes. Any custom changes are lost. Preserves + * research state of technologies. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.reset_technology_effects View documentation} + */ + reset_technology_effects(): void + /** + * Chart a portion of the map. The chart for the given area is refreshed; it creates chart for any parts of the + * given area that haven't been charted yet. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.chart View documentation} + * + * @example + * Charts a 2048x2048 rectangle centered around the origin. + * + * ```lua + * game.player.force.chart(game.player.surface, {{x = -1024, y = -1024}, {x = 1024, y = 1024}}) + * ``` + * + * @param surface + * @param area - The area on the given surface to chart. + */ + chart(surface: SurfaceIdentification, area: BoundingBox): void + /** + * Erases chart data for this force. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.clear_chart View documentation} + * + * @param surface - Which surface to erase chart data for or if not provided all surfaces charts are erased. + */ + clear_chart(surface?: SurfaceIdentification): void + /** + * Force a rechart of the whole chart. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.rechart View documentation} + */ + rechart(): void + /** + * Chart all generated chunks. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.chart_all View documentation} + * + * @param surface - Which surface to chart or all if not given. + */ + chart_all(surface?: SurfaceIdentification): void + /** + * Has a chunk been charted? + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.is_chunk_charted View documentation} + * + * @param surface + * @param position - Position of the chunk. + */ + is_chunk_charted(surface: SurfaceIdentification, position: ChunkPosition): boolean + /** + * Is the given chunk currently charted and visible (not covered by fog of war) on the map. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.is_chunk_visible View documentation} + * + * @param surface + * @param position + */ + is_chunk_visible(surface: SurfaceIdentification, position: ChunkPosition): boolean + /** + * Cancels pending chart requests for the given surface or all surfaces. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.cancel_charting View documentation} + * + * @param surface + */ + cancel_charting(surface?: SurfaceIdentification): void + /** + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.get_ammo_damage_modifier View documentation} + * + * @param ammo - Ammo category + */ + get_ammo_damage_modifier(ammo: string): double + /** + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.set_ammo_damage_modifier View documentation} + * + * @param ammo - Ammo category + * @param modifier + */ + set_ammo_damage_modifier(ammo: string, modifier: double): void + /** + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.get_gun_speed_modifier View documentation} + * + * @param ammo - Ammo category + */ + get_gun_speed_modifier(ammo: string): double + /** + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.set_gun_speed_modifier View documentation} + * + * @param ammo - Ammo category + * @param modifier + */ + set_gun_speed_modifier(ammo: string, modifier: double): void + /** + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.get_turret_attack_modifier View documentation} + * + * @param turret - Turret prototype name + */ + get_turret_attack_modifier(turret: string): double + /** + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.set_turret_attack_modifier View documentation} + * + * @param turret - Turret prototype name + * @param modifier + */ + set_turret_attack_modifier(turret: string, modifier: double): void + /** + * Add `other` force to this force's cease fire list. Forces on the cease fire list won't be targeted for attack. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.set_cease_fire View documentation} + * + * @param other + * @param cease_fire + */ + set_cease_fire(other: ForceIdentification, cease_fire: boolean): void + /** + * Is `other` force in this force's cease fire list? + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.get_cease_fire View documentation} + * + * @param other + */ + get_cease_fire(other: ForceIdentification): boolean + /** + * Add `other` force to this force's friends list. Friends have unrestricted access to buildings and turrets won't + * fire at them. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.set_friend View documentation} + * + * @param other + * @param friend + */ + set_friend(other: ForceIdentification, friend: boolean): void + /** + * Is `other` force in this force's friends list. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.get_friend View documentation} + * + * @param other + */ + get_friend(other: ForceIdentification): boolean + /** + * Is pathfinder busy? When the pathfinder is busy, it won't accept any more pathfinding requests. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.is_pathfinder_busy View documentation} + */ + is_pathfinder_busy(): boolean + /** + * Kill all units and flush the pathfinder. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.kill_all_units View documentation} + */ + kill_all_units(): void + /** + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.find_logistic_network_by_position View documentation} + * + * @param position - Position to find a network for + * @param surface - Surface to search on + * @returns The found network or `nil`. + */ + find_logistic_network_by_position(position: Position, surface: SurfaceIdentification): LuaLogisticNetwork | undefined + /** + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.set_spawn_position View documentation} + * + * @param position - The new position on the given surface. + * @param surface - Surface to set the spawn position for. + */ + set_spawn_position(position: Position, surface: SurfaceIdentification): void + /** + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.get_spawn_position View documentation} + * + * @param surface + */ + get_spawn_position(surface: SurfaceIdentification): PositionTable + /** + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.unchart_chunk View documentation} + * + * @param position - The chunk position to unchart. + * @param surface - Surface to unchart on. + */ + unchart_chunk(position: ChunkPosition, surface: SurfaceIdentification): void + /** + * Gets the count of a given item launched in rockets. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.get_item_launched View documentation} + * + * @param item - The item to get + * @returns The count of the item that has been launched. + */ + get_item_launched(item: string): uint + /** + * Sets the count of a given item launched in rockets. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.set_item_launched View documentation} + * + * @param item - The item to set + * @param count - The count to set + */ + set_item_launched(item: string, count: uint): void + /** + * Print text to the chat console of all players on this force. + * + * **Note**: Messages that are identical to a message sent in the last 60 ticks are not printed again. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.print View documentation} + * + * @param message + * @param color + */ + print(message: LocalisedString, color?: Color): void + /** + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.get_trains View documentation} + * + * @param surface - If given only trains on the surface are returned. + */ + get_trains(surface?: SurfaceIdentification): LuaTrain[] + /** + * Adds a custom chart tag to the given surface and returns the new tag or `nil` if the given position isn't valid + * for a chart tag. + * + * **Note**: The chunk must be charted for a tag to be valid at that location. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.add_chart_tag View documentation} + * + * @param surface - Which surface to add the tag to. + * @param tag - The tag to add. + */ + add_chart_tag(surface: SurfaceIdentification, tag: ChartTagSpec): LuaCustomChartTag | undefined + /** + * Finds all custom chart tags within the given bounding box on the given surface. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.find_chart_tags View documentation} + * + * @param surface + * @param area + */ + find_chart_tags(surface: SurfaceIdentification, area?: BoundingBox): LuaCustomChartTag[] + /** + * Gets the saved progress for the given technology or `nil` if there is no saved progress. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.get_saved_technology_progress View documentation} + * + * @param technology - The technology + * @returns The progress as a percent. + */ + get_saved_technology_progress(technology: TechnologyIdentification): double | undefined + /** + * Sets the saved progress for the given technology. The technology must not be in progress, must not be completed, + * and the new progress must be < 100%. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.set_saved_technology_progress View documentation} + * + * @param technology - The technology + * @param progress - Progress as a percent. Set to `nil` to remove the saved progress. + */ + set_saved_technology_progress(technology: TechnologyIdentification, progress: double | undefined): void + /** + * Resets evolution for this force to zero. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.reset_evolution View documentation} + */ + reset_evolution(): void + /** + * Play a sound for every player in this force. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.play_sound View documentation} + */ + play_sound(params: { + /** The sound to play. */ + readonly path: SoundPath + /** Where the sound should be played. If not given, it's played at the current position of each player. */ + readonly position?: Position + /** The volume of the sound to play. Must be between 0 and 1 inclusive. */ + readonly volume_modifier?: double + /** The volume mixer to play the sound through. Defaults to the default mixer for the given sound type. */ + readonly override_sound_type?: SoundType + }): void + /** + * Gets train stops matching the given filters. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.get_train_stops View documentation} + */ + get_train_stops(params?: { readonly name?: string | string[]; readonly surface?: SurfaceIdentification }): LuaEntity[] + /** + * Gets if the given recipe is explicitly disabled from being hand crafted. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.get_hand_crafting_disabled_for_recipe View documentation} + * + * @param recipe + */ + get_hand_crafting_disabled_for_recipe(recipe: string | LuaRecipe): boolean + /** + * Sets if the given recipe can be hand-crafted. This is used to explicitly disable hand crafting a recipe - it + * won't allow hand-crafting otherwise not hand-craftable recipes. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.set_hand_crafting_disabled_for_recipe View documentation} + * + * @param recipe + * @param hand_crafting_disabled + */ + set_hand_crafting_disabled_for_recipe(recipe: string | LuaRecipe, hand_crafting_disabled: boolean): void + /** + * Add this technology to the back of the research queue if the queue is enabled. Otherwise, set this technology to + * be researched now. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.add_research View documentation} + * + * @param technology + * @returns If the technology was added. + */ + add_research(technology: TechnologyIdentification): boolean + /** + * Stop the research currently in progress. This will remove any dependent technologies from the research queue. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.cancel_current_research View documentation} + */ + cancel_current_research(): void + /** + * Gets the linked inventory for the given prototype and link ID if it exists or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.get_linked_inventory View documentation} + * + * @param prototype + * @param link_id + */ + get_linked_inventory(prototype: EntityPrototypeIdentification, link_id: uint): LuaInventory | undefined + /** + * Is this force a friend? This differs from `get_friend` in that it is always true for neutral force. This is + * equivalent to checking the `friend` ForceCondition. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.is_friend View documentation} + * + * @param other + */ + is_friend(other: ForceIdentification): boolean + /** + * Is this force an enemy? This differs from `get_cease_fire` in that it is always false for neutral force. This is + * equivalent to checking the `enemy` ForceCondition. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.is_enemy View documentation} + * + * @param other + */ + is_enemy(other: ForceIdentification): boolean + /** + * Name of the force. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.name View documentation} + * + * @example + * Prints "`player`" + * + * ```lua + * game.player.print(game.player.force.name) + * ``` + */ + readonly name: string + /** + * Technologies owned by this force, indexed by `name`. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.technologies View documentation} + * + * @example + * Researches the technology for the player's force + * + * ```lua + * game.player.force.technologies["steel-processing"].researched = true + * ``` + */ + readonly technologies: LuaCustomTable + /** + * Recipes available to this force, indexed by `name`. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.recipes View documentation} + * + * @example + * Prints the category of the given recipe + * + * ```lua + * game.player.print(game.player.force.recipes["transport-belt"].category) + * ``` + */ + readonly recipes: LuaCustomTable + /** + * Multiplier of the manual mining speed. Default value is `0`. The actual mining speed will be multiplied by `1 + + * manual_mining_speed_modifier`. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.manual_mining_speed_modifier View documentation} + * + * @example + * Double the player's mining speed + * + * ```lua + * game.player.force.manual_mining_speed_modifier = 1 + * ``` + */ + manual_mining_speed_modifier: double + /** + * Multiplier of the manual crafting speed. Default value is `0`. The actual crafting speed will be multiplied by `1 + * + manual_crafting_speed_modifier`. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.manual_crafting_speed_modifier View documentation} + * + * @example + * Double the player's crafting speed + * + * ```lua + * game.player.force.manual_crafting_speed_modifier = 1 + * ``` + */ + manual_crafting_speed_modifier: double + laboratory_speed_modifier: double + laboratory_productivity_bonus: double + worker_robots_speed_modifier: double + worker_robots_battery_modifier: double + worker_robots_storage_bonus: double + /** + * The current technology in research, or `nil` if no research is currently ongoing. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.current_research View documentation} + */ + readonly current_research: LuaTechnology | undefined + /** + * Progress of current research, as a number in range [0, 1]. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.research_progress View documentation} + */ + research_progress: double + /** + * The previous research if any. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.previous_research View documentation} + */ + previous_research: LuaTechnology + /** + * The inserter stack size bonus for non stack inserters + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.inserter_stack_size_bonus View documentation} + */ + inserter_stack_size_bonus: double + /** + * Number of items that can be transferred by stack inserters. When writing to this value, it must be >= 0 and <= 254. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.stack_inserter_capacity_bonus View documentation} + */ + stack_inserter_capacity_bonus: uint + /** + * Number of character trash slots. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.character_trash_slot_count View documentation} + */ + character_trash_slot_count: double + /** + * Maximum number of follower robots. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.maximum_following_robot_count View documentation} + */ + maximum_following_robot_count: uint + /** + * Additional lifetime for following robots. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.following_robots_lifetime_modifier View documentation} + */ + following_robots_lifetime_modifier: double + /** + * The time, in ticks, before a placed ghost disappears. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.ghost_time_to_live View documentation} + */ + ghost_time_to_live: uint + /** + * Players belonging to this force. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.players View documentation} + */ + readonly players: LuaPlayer[] + /** + * Enables some higher-level AI behaviour for this force. When set to `true`, biters belonging to this force will + * automatically expand into new territories, build new spawners, and form unit groups. By default, this value is + * `true` for the enemy force and `false` for all others. + * + * **Note**: Setting this to `false` does not turn off biters' AI. They will still move around and attack players + * who come close. + * + * **Note**: It is necessary for a force to be AI controllable in order to be able to create unit groups or build + * bases from scripts. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.ai_controllable View documentation} + */ + ai_controllable: boolean + /** + * List of logistic networks, grouped by surface. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.logistic_networks View documentation} + */ + readonly logistic_networks: Record + /** + * The item production statistics for this force. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.item_production_statistics View documentation} + */ + readonly item_production_statistics: LuaFlowStatistics + /** + * The fluid production statistics for this force. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.fluid_production_statistics View documentation} + */ + readonly fluid_production_statistics: LuaFlowStatistics + /** + * The kill counter statistics for this force. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.kill_count_statistics View documentation} + */ + readonly kill_count_statistics: LuaFlowStatistics + /** + * The entity build statistics for this force (built and mined) + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.entity_build_count_statistics View documentation} + */ + readonly entity_build_count_statistics: LuaFlowStatistics + /** + * Modifies the running speed of all characters in this force by the given value as a percentage. Setting the + * running modifier to `0.5` makes the character run 50% faster. The minimum value of `-1` reduces the movement + * speed by 100%, resulting in a speed of `0`. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.character_running_speed_modifier View documentation} + */ + character_running_speed_modifier: double + artillery_range_modifier: double + character_build_distance_bonus: uint + character_item_drop_distance_bonus: uint + character_reach_distance_bonus: uint + character_resource_reach_distance_bonus: double + character_item_pickup_distance_bonus: double + character_loot_pickup_distance_bonus: double + /** + * The number of additional inventory slots the character main inventory has. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.character_inventory_slots_bonus View documentation} + */ + character_inventory_slots_bonus: uint + /** + * The time, in ticks, before a deconstruction order is removed. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.deconstruction_time_to_live View documentation} + */ + deconstruction_time_to_live: uint + character_health_bonus: double + max_successful_attempts_per_tick_per_construction_queue: uint + max_failed_attempts_per_tick_per_construction_queue: uint + /** + * Ability to use zoom-to-world on map. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.zoom_to_world_enabled View documentation} + */ + zoom_to_world_enabled: boolean + /** + * Ability to build ghosts through blueprint or direct ghost placement, or "mine" ghosts when using zoom-to-world. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.zoom_to_world_ghost_building_enabled View documentation} + */ + zoom_to_world_ghost_building_enabled: boolean + /** + * Ability to create new blueprints using empty blueprint item when using zoom-to-world. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.zoom_to_world_blueprint_enabled View documentation} + */ + zoom_to_world_blueprint_enabled: boolean + /** + * Ability to use deconstruction planner when using zoom-to-world. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.zoom_to_world_deconstruction_planner_enabled View documentation} + */ + zoom_to_world_deconstruction_planner_enabled: boolean + /** + * Ability to use custom selection tools when using zoom-to-world. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.zoom_to_world_selection_tool_enabled View documentation} + */ + zoom_to_world_selection_tool_enabled: boolean + /** + * `true` if character requester logistics is enabled. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.character_logistic_requests View documentation} + */ + character_logistic_requests: boolean + /** + * The number of rockets launched. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.rockets_launched View documentation} + */ + rockets_launched: uint + /** + * All of the items that have been launched in rockets. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.items_launched View documentation} + */ + readonly items_launched: Record + /** + * The connected players belonging to this force. + * + * This is primarily useful when you want to do some action against all online players of this force. + * + * **Note**: This does *not* index using player index. See {@link LuaPlayer.index LuaPlayer::index} on each player + * instance for the player index. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.connected_players View documentation} + */ + readonly connected_players: LuaPlayer[] + mining_drill_productivity_bonus: double + train_braking_force_bonus: double + /** + * Evolution factor of this force. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.evolution_factor View documentation} + */ + evolution_factor: double + evolution_factor_by_pollution: double + evolution_factor_by_time: double + evolution_factor_by_killing_spawners: double + /** + * If friendly fire is enabled for this force. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.friendly_fire View documentation} + */ + friendly_fire: boolean + /** + * If sharing chart data is enabled for this force. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.share_chart View documentation} + */ + share_chart: boolean + /** + * Whether the research queue is available for this force. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.research_queue_enabled View documentation} + */ + research_queue_enabled: boolean + /** + * Unique ID associated with this force. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.index View documentation} + */ + readonly index: uint + /** + * The research queue of this force. The first technology in the array is the currently active one. Reading this + * attribute gives an array of {@link LuaTechnology}. + * + * To write to this, the entire table must be written. Providing an empty table or `nil` will empty the research + * queue and cancel the current research. Writing to this when the research queue is disabled will simply set the + * last research in the table as the current research. + * + * **Note**: This only allows mods to queue research that this force is able to research in the first place. As an + * example, an already researched technology or one whose prerequisites are not fulfilled will not be queued, but + * dropped silently instead. + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.research_queue View documentation} + */ + research_queue: TechnologyIdentification[] | undefined + /** + * Whether research is enabled for this force, see {@link LuaForce.enable_research LuaForce::enable_research} and + * {@link LuaForce.disable_research LuaForce::disable_research} + * + * {@link https://lua-api.factorio.com/next/LuaForce.html#LuaForce.research_enabled View documentation} + */ + readonly research_enabled: 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: "LuaForce" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * Prototype of a fuel category. + * + * {@link https://lua-api.factorio.com/next/LuaFuelCategoryPrototype.html View documentation} + * + * @noSelf + */ +interface LuaFuelCategoryPrototype { + /** + * Name of this prototype. + * + * {@link https://lua-api.factorio.com/next/LuaFuelCategoryPrototype.html#LuaFuelCategoryPrototype.name View documentation} + */ + readonly name: string + /** + * Order string of this prototype. + * + * {@link https://lua-api.factorio.com/next/LuaFuelCategoryPrototype.html#LuaFuelCategoryPrototype.order View documentation} + */ + readonly order: string + readonly localised_name: LocalisedString + readonly localised_description: LocalisedString + /** + * 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: "LuaFuelCategoryPrototype" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * Main toplevel type, provides access to most of the API though its members. An instance of LuaGameScript is available + * as the global object named `game`. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html View documentation} + * + * @noSelf + */ +interface LuaGameScript { + /** + * Set scenario state. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.set_game_state View documentation} + */ + set_game_state(params: { + readonly game_finished: boolean + readonly player_won: boolean + readonly next_level: string + readonly can_continue: boolean + readonly victorious_force: ForceIdentification + }): void + /** + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.get_entity_by_tag View documentation} + * + * @param tag + */ + get_entity_by_tag(tag: string): LuaEntity + /** + * Show an in-game message dialog. + * + * **Note**: Can only be used when the map contains exactly one player. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.show_message_dialog View documentation} + */ + show_message_dialog(params: { + /** What the dialog should say */ + readonly text: LocalisedString + /** Path to an image to show on the dialog */ + readonly image?: string + /** + * If specified, dialog will show an arrow pointing to this place. When not specified, the arrow will point to + * the player's position. (Use `point_to={type="nowhere"}` to remove the arrow entirely.) The dialog itself will + * be placed near the arrow's target. + */ + readonly point_to?: GuiArrowSpecification + /** The gui style to use for this speech bubble. Must be of type speech_bubble. */ + readonly style?: string + /** Must be of type flow_style. */ + readonly wrapper_frame_style?: string + }): void + /** + * Is this the demo version of Factorio? + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.is_demo View documentation} + */ + is_demo(): boolean + /** + * Forces a reload of the scenario script from the original scenario location. + * + * **Note**: This disables the replay if replay is enabled. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.reload_script View documentation} + */ + reload_script(): void + /** + * Forces a reload of all mods. + * + * **Note**: This will act like saving and loading from the mod(s) perspective. + * + * **Note**: This will do nothing if run in multiplayer. + * + * **Note**: This disables the replay if replay is enabled. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.reload_mods View documentation} + */ + reload_mods(): void + /** + * Saves the current configuration of Atlas to a file. This will result in huge file containing all of the game + * graphics moved to as small space as possible. + * + * **Note**: Exists mainly for debugging reasons. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.save_atlas View documentation} + */ + save_atlas(): void + /** + * Run internal consistency checks. Allegedly prints any errors it finds. + * + * **Note**: Exists mainly for debugging reasons. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.check_consistency View documentation} + */ + check_consistency(): void + /** + * Regenerate autoplacement of some entities on all surfaces. This can be used to autoplace newly-added entities. + * + * **Note**: All specified entity prototypes must be autoplacable. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.regenerate_entity View documentation} + * + * @param entities - Prototype names of entity or entities to autoplace. + */ + regenerate_entity(entities: string | string[]): void + /** + * Take a screenshot and save it to a file. + * + * **Note**: If Factorio is running headless, this function will do nothing. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.take_screenshot View documentation} + */ + take_screenshot(params: { + readonly player?: PlayerIdentification + /** If defined, the screenshot will only be taken for this player. */ + readonly by_player?: PlayerIdentification + /** If defined, the screenshot will be taken on this surface. */ + readonly surface?: SurfaceIdentification + /** If defined, the screenshot will be centered on this position. */ + readonly position?: Position + /** + * Maximum allowed resolution is 16384x16384 (resp. 8192x8192 when anti_alias is true), but maximum recommended + * resolution is 4096x4096 (resp. 2048x2048). + */ + readonly resolution?: Position + readonly zoom?: double + /** Path to save the screenshot in */ + readonly path?: string + /** Include game GUI in the screenshot? */ + readonly show_gui?: boolean + /** Include entity info (alt-mode)? */ + readonly show_entity_info?: boolean + /** When true, and player is specified, building preview for item in player's cursor will be rendered also. */ + readonly show_cursor_building_preview?: boolean + /** Render in double resolution and scale down (including GUI)? */ + readonly anti_alias?: boolean + /** The render quality if using jpg format (0-100 inclusive). */ + readonly quality?: int + /** + * If true, the screenshot will be saved even during replay playback, otherwise this function call does nothing + * in replays. + */ + readonly allow_in_replay?: boolean + /** Overrides current surface daytime for duration of screenshot rendering. */ + readonly daytime?: double + /** Overrides tick of water animation (if animated water is enabled). */ + readonly water_tick?: uint + /** + * Screenshot requests are processed in between update and render. The game may skip rendering (drop frames) if + * previous frame has not finished rendering or the game simulation starts to fall under 60 updates per second. + * If force_render is set to true, the game won't drop frames and process the screenshot request at the end of + * the update in which the request was created. This is not honored on multiplayer clients that are catching up + * to server. + */ + readonly force_render?: boolean + }): void + /** + * Forces the screenshot saving system to wait until all queued screenshots have been written to disk. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.set_wait_for_screenshots_to_finish View documentation} + */ + set_wait_for_screenshots_to_finish(): void + take_technology_screenshot(params: { + /** The force to use. If not given the `"player`" force is used. */ + readonly force?: ForceIdentification + /** Path to save the screenshot in. */ + readonly path?: string + /** If defined, the screenshot will only be taken for this player. */ + readonly by_player?: PlayerIdentification + /** The technology to highlight. */ + readonly selected_technology?: TechnologyIdentification + /** + * If `true`, disabled technologies will be skipped. Their successors will be attached to the disabled + * technology's parents. Defaults to `false`. + */ + readonly skip_disabled?: boolean + /** The render quality if using jpg format (0-100 inclusive). */ + readonly quality?: int + }): void + /** + * Convert a table to a JSON string + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.table_to_json View documentation} + * + * @param data + */ + table_to_json(data: table): string + /** + * Convert a JSON string to a table. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.json_to_table View documentation} + * + * @param json - The string to convert. + * @returns The returned object, or `nil` if the json was invalid. + */ + json_to_table(json: string): AnyBasic | undefined + /** + * Write a string to a file. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.write_file View documentation} + * + * @param filename - Path to the file to write to. + * @param data - File content + * @param append - When `true`, this will append to the end of the file. Defaults to `false`, which will overwrite + * any pre-existing file with the new data. + * @param for_player - If given, the file will only be written for this player_index. 0 means only the server if one exists. + */ + write_file(filename: string, data: LocalisedString, append?: boolean, for_player?: uint): void + /** + * Remove file or directory. Given path is taken relative to the script output directory. Can be used to remove + * files created by {@link LuaGameScript.write_file LuaGameScript::write_file}. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.remove_path View documentation} + * + * @param path - Path to remove, relative to the script output directory + */ + remove_path(path: string): void + /** + * Remove players who are currently not connected from the map. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.remove_offline_players View documentation} + * + * @param players - List of players to remove. If not specified, remove all offline players. + */ + remove_offline_players(players?: (LuaPlayer | string)[]): void + /** + * Force a CRC check. Tells all peers to calculate their current map CRC; these CRC are then compared against each + * other. If a mismatch is detected, the game is desynced and some peers are forced to reconnect. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.force_crc View documentation} + */ + force_crc(): void + /** + * Create a new force. + * + * **Note**: The game currently supports a maximum of 64 forces, including the three built-in forces. This means + * that a maximum of 61 new forces may be created. + * + * **Note**: Force names must be unique. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.create_force View documentation} + * + * @param force - Name of the new force + * @returns The force that was just created + */ + create_force(force: string): LuaForce + /** + * Marks two forces to be merge together. All entities in the source force will be reassigned to the target force. + * The source force will then be destroyed. + * + * **Note**: The three built-in forces -- player, enemy and neutral -- can't be destroyed. I.e. they can't be used + * as the source argument to this function. + * + * **Note**: The source force is not merged until the end of the current tick or if called during the + * {@link OnForcesMergingEvent on_forces_merging} event or {@link OnForcesMergedEvent on_forces_merged} event the end + * of the next tick. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.merge_forces View documentation} + * + * @param source - The force to remove + * @param destination - The force to reassign all entities to + */ + merge_forces(source: ForceIdentification, destination: ForceIdentification): void + /** + * Create a new surface + * + * **Note**: The game currently supports a maximum of 4,294,967,295 surfaces, including the default surface. + * + * **Note**: Surface names must be unique + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.create_surface View documentation} + * + * @param name - Name of the new surface + * @param settings - Map generation settings + * @returns The surface that was just created + */ + create_surface(name: string, settings?: MapGenSettings): LuaSurface + /** + * Instruct the server to save the map. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.server_save View documentation} + * + * @param name - Save name. If not specified, writes into the currently-running save. + */ + server_save(name?: string): void + /** + * Instruct the game to perform an auto-save. + * + * **Note**: Only the server will save in multiplayer. In single player a standard auto-save is triggered. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.auto_save View documentation} + * + * @param name - The autosave name if any. Saves will be named _autosave-*name* when provided. + */ + auto_save(name?: string): void + /** + * Deletes the given surface and all entities on it. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.delete_surface View documentation} + * + * @param surface - The surface to be deleted. Currently the primary surface (1, 'nauvis') cannot be deleted. + */ + delete_surface(surface: string | LuaSurface): void + /** + * Disables replay saving for the current save file. Once done there's no way to re-enable replay saving for the + * save file without loading an old save. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.disable_replay View documentation} + */ + disable_replay(): void + /** + * Disables tutorial triggers, that unlock new tutorials and show notices about unlocked tutorials. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.disable_tutorial_triggers View documentation} + */ + disable_tutorial_triggers(): void + /** + * Converts the given direction into the string version of the direction. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.direction_to_string View documentation} + * + * @param direction + */ + direction_to_string(direction: defines.direction): void + /** + * Print text to the chat console all players. + * + * **Note**: Messages that are identical to a message sent in the last 60 ticks are not printed again. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.print View documentation} + * + * @param message + * @param color + */ + print(message: LocalisedString, color?: Color): void + /** + * Creates a deterministic standalone random generator with the given seed or if a seed is not provided the initial + * map seed is used. + * + * **Note**: *Make sure* you actually want to use this over math.random(...) as this provides entirely different + * functionality over math.random(...). + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.create_random_generator View documentation} + * + * @param seed + */ + create_random_generator(seed?: uint): LuaRandomGenerator + /** + * Goes over all items, entities, tiles, recipes, technologies among other things and logs if the locale is incorrect. + * + * **Note**: Also prints true/false if called from the console. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.check_prototype_translations View documentation} + */ + check_prototype_translations(): void + /** + * Play a sound for every player in the game. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.play_sound View documentation} + */ + play_sound(params: { + /** The sound to play. */ + readonly path: SoundPath + /** Where the sound should be played. If not given, it's played at the current position of each player. */ + readonly position?: Position + /** The volume of the sound to play. Must be between 0 and 1 inclusive. */ + readonly volume_modifier?: double + /** The volume mixer to play the sound through. Defaults to the default mixer for the given sound type. */ + readonly override_sound_type?: SoundType + }): void + /** + * Checks if the given SoundPath is valid. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.is_valid_sound_path View documentation} + * + * @param sound_path - Path to the sound. + */ + is_valid_sound_path(sound_path: SoundPath): boolean + /** + * Checks if the given SpritePath is valid and contains a loaded sprite. + * + * **Note**: The existence of the image is not checked for paths of type `file`. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.is_valid_sprite_path View documentation} + * + * @param sprite_path - Path to the image. + */ + is_valid_sprite_path(sprite_path: SpritePath): boolean + /** + * Kicks the given player from this multiplayer game. Does nothing if this is a single player game or if the player + * running this isn't an admin. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.kick_player View documentation} + * + * @param player - The player to kick. + * @param reason - The reason given if any. + */ + kick_player(player: PlayerIdentification, reason?: LocalisedString): void + /** + * Bans the given player from this multiplayer game. Does nothing if this is a single player game of if the player + * running this isn't an admin. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.ban_player View documentation} + * + * @param player - The player to ban. + * @param reason - The reason given if any. + */ + ban_player(player: PlayerIdentification, reason?: LocalisedString): void + /** + * Unbans the given player from this multiplayer game. Does nothing if this is a single player game of if the player + * running this isn't an admin. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.unban_player View documentation} + * + * @param player - The player to unban. + */ + unban_player(player: PlayerIdentification): void + /** + * Purges the given players messages from the game. Does nothing if the player running this isn't an admin. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.purge_player View documentation} + * + * @param player - The player to purge. + */ + purge_player(player: PlayerIdentification): void + /** + * Mutes the given player. Does nothing if the player running this isn't an admin. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.mute_player View documentation} + * + * @param player - The player to mute. + */ + mute_player(player: PlayerIdentification): void + /** + * Unmutes the given player. Does nothing if the player running this isn't an admin. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.unmute_player View documentation} + * + * @param player - The player to unmute. + */ + unmute_player(player: PlayerIdentification): void + /** + * Counts how many distinct groups of pipes exist in the world. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.count_pipe_groups View documentation} + */ + count_pipe_groups(): void + /** + * Is the map loaded is multiplayer? + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.is_multiplayer View documentation} + */ + is_multiplayer(): boolean + /** + * Gets the number of entities that are active (updated each tick). + * + * **Note**: This is very expensive to calculate. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.get_active_entities_count View documentation} + * + * @param surface - If give, only the entities active on this surface are counted. + */ + get_active_entities_count(surface?: SurfaceIdentification): uint + /** + * Gets the map exchange string for the map generation settings that were used to create this map. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.get_map_exchange_string View documentation} + */ + get_map_exchange_string(): string + /** + * Convert a map exchange string to map gen settings and map settings. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.parse_map_exchange_string View documentation} + * + * @param map_exchange_string + */ + parse_map_exchange_string(map_exchange_string: string): MapExchangeStringData + /** + * Gets train stops matching the given filters. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.get_train_stops View documentation} + */ + get_train_stops(params?: { + readonly name?: string | string[] + readonly surface?: SurfaceIdentification + readonly force?: ForceIdentification + }): LuaEntity[] + /** + * Gets the given player or returns `nil` if no player is found. + * + * **Note**: This is a shortcut for game.players[...] + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.get_player View documentation} + * + * @param player - The player index or name. + */ + get_player(player: uint | string): LuaPlayer | undefined + /** + * Gets the given surface or returns `nil` if no surface is found. + * + * **Note**: This is a shortcut for game.surfaces[...] + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.get_surface View documentation} + * + * @param surface - The surface index or name. + */ + get_surface(surface: uint | string): LuaSurface | undefined + /** + * Creates a {@link LuaProfiler}, which is used for measuring script performance. + * + * **Note**: LuaProfiler cannot be serialized. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.create_profiler View documentation} + * + * @param stopped - Create the timer stopped + */ + create_profiler(stopped?: boolean): LuaProfiler + /** + * Evaluate an expression, substituting variables as provided. For details on the formula, see the relevant page on + * the {@link https://wiki.factorio.com/Prototype/Technology#unit Factorio wiki}. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.evaluate_expression View documentation} + * + * @example + * Calculate the number of research units required to unlock mining productivity level 10. + * + * ```lua + * local formula = game.forces["player"].technologies["mining-productivity-4"].research_unit_count_formula + * local units = game.evaluate_expression(formula, { L = 10, l = 10 }) + * ``` + * + * @param expression - The expression to evaluate. + * @param variables - Variables to be substituted. + */ + evaluate_expression(expression: string, variables?: Record): double + /** + * Returns a dictionary of all LuaEntityPrototypes that fit the given filters. The prototypes are indexed by `name`. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.get_filtered_entity_prototypes View documentation} + * + * @example + * Get every entity prototype that can craft recipes involving fluids in the way some assembling machines can. + * + * ```lua + * local prototypes = game.get_filtered_entity_prototypes{{filter="crafting-category", crafting_category="crafting-with-fluid"}} + * ``` + * + * @param filters + */ + get_filtered_entity_prototypes(filters: EntityPrototypeFilter[]): LuaCustomTable + /** + * Returns a dictionary of all LuaItemPrototypes that fit the given filters. The prototypes are indexed by `name`. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.get_filtered_item_prototypes View documentation} + * + * @example + * Get every item prototype that, when launched with a rocket, produces a result. + * + * ```lua + * local prototypes = game.get_filtered_item_prototypes{{filter="has-rocket-launch-products"}} + * ``` + * + * @param filters + */ + get_filtered_item_prototypes(filters: ItemPrototypeFilter[]): LuaCustomTable + /** + * Returns a dictionary of all LuaEquipmentPrototypes that fit the given filters. The prototypes are indexed by `name`. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.get_filtered_equipment_prototypes View documentation} + * + * @example + * Get every equipment prototype that functions as a battery. + * + * ```lua + * local prototypes = game.get_filtered_equipment_prototypes{{filter="type", type="battery-equipment"}} + * ``` + * + * @param filters + */ + get_filtered_equipment_prototypes(filters: EquipmentPrototypeFilter[]): LuaCustomTable + /** + * Returns a dictionary of all LuaModSettingPrototypes that fit the given filters. The prototypes are indexed by `name`. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.get_filtered_mod_setting_prototypes View documentation} + * + * @example + * Get every mod setting prototype that belongs to the specified mod. + * + * ```lua + * local prototypes = game.get_filtered_mod_setting_prototypes{{filter="mod", mod="space-exploration"}} + * ``` + * + * @param filters + */ + get_filtered_mod_setting_prototypes( + filters: ModSettingPrototypeFilter[] + ): LuaCustomTable + /** + * Returns a dictionary of all LuaAchievementPrototypes that fit the given filters. The prototypes are indexed by `name`. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.get_filtered_achievement_prototypes View documentation} + * + * @example + * Get every achievement prototype that is not allowed to be completed on the peaceful difficulty setting. + * + * ```lua + * local prototypes = game.get_filtered_achievement_prototypes{{filter="allowed-without-fight", invert=true}} + * ``` + * + * @param filters + */ + get_filtered_achievement_prototypes( + filters: AchievementPrototypeFilter[] + ): LuaCustomTable + /** + * Returns a dictionary of all LuaTilePrototypes that fit the given filters. The prototypes are indexed by `name`. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.get_filtered_tile_prototypes View documentation} + * + * @example + * Get every tile prototype that improves a player's walking speed by at least 50%. + * + * ```lua + * local prototypes = game.get_filtered_tile_prototypes{{filter="walking-speed-modifier", comparison="≥", value=1.5}} + * ``` + * + * @param filters + */ + get_filtered_tile_prototypes(filters: TilePrototypeFilter[]): LuaCustomTable + /** + * Returns a dictionary of all LuaDecorativePrototypes that fit the given filters. The prototypes are indexed by `name`. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.get_filtered_decorative_prototypes View documentation} + * + * @example + * Get every decorative prototype that is auto-placed. + * + * ```lua + * local prototypes = game.get_filtered_decorative_prototypes{{filter="autoplace"}} + * ``` + * + * @param filters + */ + get_filtered_decorative_prototypes( + filters: DecorativePrototypeFilter[] + ): LuaCustomTable + /** + * Returns a dictionary of all LuaFluidPrototypes that fit the given filters. The prototypes are indexed by `name`. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.get_filtered_fluid_prototypes View documentation} + * + * @example + * Get every fluid prototype that has a heat capacity of exactly `100`. + * + * ```lua + * local prototypes = game.get_filtered_fluid_prototypes{{filter="heat-capacity", comparison="=", value=100}} + * ``` + * + * @param filters + */ + get_filtered_fluid_prototypes(filters: FluidPrototypeFilter[]): LuaCustomTable + /** + * Returns a dictionary of all LuaRecipePrototypes that fit the given filters. The prototypes are indexed by `name`. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.get_filtered_recipe_prototypes View documentation} + * + * @example + * Get every recipe prototype that takes less than half a second to craft (at crafting speed `1`). + * + * ```lua + * local prototypes = game.get_filtered_recipe_prototypes{{filter="energy", comparison="<", value=0.5}} + * ``` + * + * @param filters + */ + get_filtered_recipe_prototypes(filters: RecipePrototypeFilter[]): LuaCustomTable + /** + * Returns a dictionary of all LuaTechnologyPrototypes that fit the given filters. The prototypes are indexed by `name`. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.get_filtered_technology_prototypes View documentation} + * + * @example + * Get every technology prototype that can be researched at the start of the game. + * + * ```lua + * local prototypes = game.get_filtered_technology_prototypes{{filter="has-prerequisites", invert=true}} + * ``` + * + * @param filters + */ + get_filtered_technology_prototypes( + filters: TechnologyPrototypeFilter[] + ): LuaCustomTable + /** + * Creates an inventory that is not owned by any game object. It can be resized later with + * {@link LuaInventory.resize LuaInventory::resize}. + * + * **Note**: Make sure to destroy it when you are done with it with {@link LuaInventory.destroy LuaInventory::destroy}. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.create_inventory View documentation} + * + * @param size - The number of slots the inventory initially has. + */ + create_inventory(size: uint16): LuaInventory + /** + * Gets the inventories created through {@link LuaGameScript.create_inventory LuaGameScript::create_inventory} + * + * **Note**: Inventories created through console commands will be owned by `"core"`. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.get_script_inventories View documentation} + * + * @param mod - The mod who's inventories to get. If not provided all inventories are returned. + * @returns A mapping of mod name to array of inventories owned by that mod. + */ + get_script_inventories(mod?: string): Record + /** + * Resets the amount of time played for this map. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.reset_time_played View documentation} + */ + reset_time_played(): void + /** + * Deflates and base64 encodes the given string. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.encode_string View documentation} + * + * @param string - The string to encode. + * @returns The encoded string or `nil` if the encode failed. + */ + encode_string(string: string): string | undefined + /** + * Base64 decodes and inflates the given string. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.decode_string View documentation} + * + * @param string - The string to decode. + * @returns The decoded string or `nil` if the decode failed. + */ + decode_string(string: string): string | undefined + /** + * The player typing at the console - `nil` in all other instances. See + * {@link LuaGameScript.players LuaGameScript::players} for accessing all players. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.player View documentation} + */ + readonly player: LuaPlayer | undefined + /** + * Get a table of all the players that currently exist. This sparse table allows you to find players by indexing it + * with either their `name` or `index`. Iterating this table with `pairs()` will only iterate the array part of the + * table. Iterating with `ipairs()` will not work at all. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.players View documentation} + */ + readonly players: LuaCustomTable + /** + * The currently active set of map settings. Even though this property is marked as read-only, the members of the + * dictionary that is returned can be modified mid-game. + * + * **Note**: This does not contain difficulty settings, use + * {@link LuaGameScript.difficulty_settings LuaGameScript::difficulty_settings} instead. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.map_settings View documentation} + */ + readonly map_settings: MapSettings + /** + * The currently active set of difficulty settings. Even though this property is marked as read-only, the members of + * the dictionary that is returned can be modified mid-game. This is however not recommended as different + * difficulties can have differing technology and recipe trees, which can cause problems for players. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.difficulty_settings View documentation} + * + * @example + * This will set the technology price multiplier to 12. + * + * ```lua + * game.difficulty_settings.technology_price_multiplier = 12 + * ``` + */ + readonly difficulty_settings: DifficultySettings + /** + * Current scenario difficulty. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.difficulty View documentation} + */ + readonly difficulty: defines.difficulty + /** + * Get a table of all the forces that currently exist. This sparse table allows you to find forces by indexing it + * with either their `name` or `index`. Iterating this table with `pairs()` will only iterate the array part of the + * table. Iterating with `ipairs()` will not work at all. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.forces View documentation} + */ + readonly forces: LuaCustomTable + /** + * A dictionary containing every LuaEntityPrototype indexed by `name`. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.entity_prototypes View documentation} + */ + readonly entity_prototypes: LuaCustomTable + /** + * A dictionary containing every LuaItemPrototype indexed by `name`. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.item_prototypes View documentation} + */ + readonly item_prototypes: LuaCustomTable + /** + * A dictionary containing every LuaFluidPrototype indexed by `name`. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.fluid_prototypes View documentation} + */ + readonly fluid_prototypes: LuaCustomTable + /** + * A dictionary containing every LuaTilePrototype indexed by `name`. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.tile_prototypes View documentation} + */ + readonly tile_prototypes: LuaCustomTable + /** + * A dictionary containing every LuaEquipmentPrototype indexed by `name`. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.equipment_prototypes View documentation} + */ + readonly equipment_prototypes: LuaCustomTable + /** + * A dictionary containing every LuaDamagePrototype indexed by `name`. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.damage_prototypes View documentation} + */ + readonly damage_prototypes: LuaCustomTable + /** + * A dictionary containing every LuaVirtualSignalPrototype indexed by `name`. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.virtual_signal_prototypes View documentation} + */ + readonly virtual_signal_prototypes: LuaCustomTable + /** + * A dictionary containing every LuaEquipmentGridPrototype indexed by `name`. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.equipment_grid_prototypes View documentation} + */ + readonly equipment_grid_prototypes: LuaCustomTable + /** + * A dictionary containing every LuaRecipePrototype indexed by `name`. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.recipe_prototypes View documentation} + */ + readonly recipe_prototypes: LuaCustomTable + /** + * A dictionary containing every {@link LuaTechnologyPrototype} indexed by `name`. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.technology_prototypes View documentation} + */ + readonly technology_prototypes: LuaCustomTable + /** + * A dictionary containing every LuaDecorativePrototype indexed by `name`. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.decorative_prototypes View documentation} + */ + readonly decorative_prototypes: LuaCustomTable + /** + * A dictionary containing every LuaParticlePrototype indexed by `name`. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.particle_prototypes View documentation} + */ + readonly particle_prototypes: LuaCustomTable + /** + * A dictionary containing every LuaAutoplaceControlPrototype indexed by `name`. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.autoplace_control_prototypes View documentation} + */ + readonly autoplace_control_prototypes: LuaCustomTable + /** + * A dictionary containing every LuaNoiseLayerPrototype indexed by `name`. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.noise_layer_prototypes View documentation} + */ + readonly noise_layer_prototypes: LuaCustomTable + /** + * A dictionary containing every LuaModSettingPrototype indexed by `name`. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.mod_setting_prototypes View documentation} + */ + readonly mod_setting_prototypes: LuaCustomTable + /** + * A dictionary containing every LuaCustomInputPrototype indexed by `name`. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.custom_input_prototypes View documentation} + */ + readonly custom_input_prototypes: LuaCustomTable + /** + * A dictionary containing every LuaAmmoCategoryPrototype indexed by `name`. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.ammo_category_prototypes View documentation} + */ + readonly ammo_category_prototypes: LuaCustomTable + /** + * A dictionary containing every LuaNamedNoiseExpression indexed by `name`. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.named_noise_expressions View documentation} + */ + readonly named_noise_expressions: LuaCustomTable + /** + * A dictionary containing every ItemSubgroup indexed by `name`. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.item_subgroup_prototypes View documentation} + */ + readonly item_subgroup_prototypes: LuaCustomTable + /** + * A dictionary containing every ItemGroup indexed by `name`. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.item_group_prototypes View documentation} + */ + readonly item_group_prototypes: LuaCustomTable + /** + * A dictionary containing every LuaFuelCategoryPrototype indexed by `name`. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.fuel_category_prototypes View documentation} + */ + readonly fuel_category_prototypes: LuaCustomTable + /** + * A dictionary containing every LuaResourceCategoryPrototype indexed by `name`. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.resource_category_prototypes View documentation} + */ + readonly resource_category_prototypes: LuaCustomTable + /** + * A dictionary containing every LuaAchievementPrototype indexed by `name`. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.achievement_prototypes View documentation} + */ + readonly achievement_prototypes: LuaCustomTable + /** + * A dictionary containing every LuaModuleCategoryPrototype indexed by `name`. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.module_category_prototypes View documentation} + */ + readonly module_category_prototypes: LuaCustomTable + /** + * A dictionary containing every LuaEquipmentCategoryPrototype indexed by `name`. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.equipment_category_prototypes View documentation} + */ + readonly equipment_category_prototypes: LuaCustomTable + /** + * A dictionary containing every LuaTrivialSmokePrototype indexed by `name`. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.trivial_smoke_prototypes View documentation} + */ + readonly trivial_smoke_prototypes: LuaCustomTable + /** + * A dictionary containing every LuaShortcutPrototype indexed by `name`. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.shortcut_prototypes View documentation} + */ + readonly shortcut_prototypes: LuaCustomTable + /** + * A dictionary containing every LuaRecipeCategoryPrototype indexed by `name`. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.recipe_category_prototypes View documentation} + */ + readonly recipe_category_prototypes: LuaCustomTable + /** + * A dictionary containing every LuaFontPrototype indexed by `name`. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.font_prototypes View documentation} + */ + readonly font_prototypes: LuaCustomTable + /** + * A dictionary containing every MapGenPreset indexed by `name`. + * + * **Note**: A MapGenPreset is an exact copy of the prototype table provided from the data stage. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.map_gen_presets View documentation} + */ + readonly map_gen_presets: LuaCustomTable + /** + * The styles that {@link LuaGuiElement} can use, indexed by `name`. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.styles View documentation} + */ + readonly styles: LuaCustomTable + /** + * Current map tick. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.tick View documentation} + */ + readonly tick: uint + /** + * The number of ticks since this game was 'created'. A game is 'created' either by using "new game" or "new game + * from scenario". + * + * **Note**: This differs over {@link LuaGameScript.tick LuaGameScript::tick} in that making a game from a scenario + * always starts with ticks_played value at 0 even if the scenario has its own level data where the + * {@link LuaGameScript.tick LuaGameScript::tick} is > 0. + * + * **Note**: This value has no relation with {@link LuaGameScript.tick LuaGameScript::tick} and can be completely + * different values. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.ticks_played View documentation} + */ + readonly ticks_played: uint + /** + * If the tick has been paused. This means that entity update has been paused. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.tick_paused View documentation} + */ + tick_paused: boolean + /** + * The number of ticks to be run while the tick is paused. When + * {@link LuaGameScript.tick_paused LuaGameScript::tick_paused} is true, ticks_to_run behaves the following way: + * While this is > 0, the entity update is running normally and this value is decremented every tick. When this + * reaches 0, the game will pause again. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.ticks_to_run View documentation} + */ + ticks_to_run: uint + /** + * Is the scenario finished? + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.finished View documentation} + */ + readonly finished: boolean + /** + * Speed to update the map at. 1.0 is normal speed -- 60 UPS. + * + * **Note**: Minimum value is 0.01. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.speed View documentation} + */ + speed: float + /** + * Get a table of all the surfaces that currently exist. This sparse table allows you to find surfaces by indexing + * it with either their `name` or `index`. Iterating this table with `pairs()` will only iterate the array part of + * the table. Iterating with `ipairs()` will not work at all. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.surfaces View documentation} + */ + readonly surfaces: LuaCustomTable + /** + * The active mods versions. The keys are mod names, the values are the versions. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.active_mods View documentation} + * + * @example + * This will print the names and versions of active mods to player p's console. + * + * ```lua + * for name, version in pairs(game.active_mods) do + * p.print(name .. " version " .. version) + * end + * ``` + */ + readonly active_mods: Record + /** + * The players that are currently online. + * + * This is primarily useful when you want to do some action against all online players. + * + * **Note**: This does *not* index using player index. See {@link LuaPlayer.index LuaPlayer::index} on each player + * instance for the player index. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.connected_players View documentation} + */ + readonly connected_players: LuaPlayer[] + readonly permissions: LuaPermissionGroups + /** + * Array of the names of all the backers that supported the game development early on. These are used as names for + * labs, locomotives, radars, roboports, and train stops. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.backer_names View documentation} + */ + readonly backer_names: LuaCustomTable + /** + * The default map gen settings for this save. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.default_map_gen_settings View documentation} + */ + readonly default_map_gen_settings: MapGenSettings + /** + * Determines if enemy land mines are completely invisible or not. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.enemy_has_vision_on_land_mines View documentation} + */ + enemy_has_vision_on_land_mines: boolean + /** + * True by default. Can be used to disable autosaving. Make sure to turn it back on soon after. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.autosave_enabled View documentation} + */ + autosave_enabled: boolean + /** + * True by default. Can be used to disable the highlighting of resource patches when they are hovered on the map. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.draw_resource_selection View documentation} + */ + draw_resource_selection: boolean + /** + * The pollution statistics for this map. + * + * {@link https://lua-api.factorio.com/next/LuaGameScript.html#LuaGameScript.pollution_statistics View documentation} + */ + readonly pollution_statistics: LuaFlowStatistics + readonly max_force_distraction_distance: double + readonly max_force_distraction_chunk_distance: uint + readonly max_electric_pole_supply_area_distance: float + readonly max_electric_pole_connection_distance: double + readonly max_beacon_supply_area_distance: double + readonly max_gate_activation_distance: double + readonly max_inserter_reach_distance: double + readonly max_pipe_to_ground_distance: uint8 + readonly max_underground_belt_distance: uint8 + /** This object's name. */ + readonly object_name: "LuaGameScript" +} + +/** + * An abstract base class for behaviors that support switching the entity on or off based on some condition. + * + * {@link https://lua-api.factorio.com/next/LuaGenericOnOffControlBehavior.html View documentation} + * + * @noSelf + */ +interface LuaGenericOnOffControlBehavior extends LuaControlBehavior { + /** + * If the entity is currently disabled because of the control behavior. + * + * {@link https://lua-api.factorio.com/next/LuaGenericOnOffControlBehavior.html#LuaGenericOnOffControlBehavior.disabled View documentation} + */ + readonly disabled: boolean + /** + * The circuit condition. + * + * **Note**: `condition` may be `nil` in order to clear the circuit condition. + * + * {@link https://lua-api.factorio.com/next/LuaGenericOnOffControlBehavior.html#LuaGenericOnOffControlBehavior.circuit_condition View documentation} + * + * @example + * Tell an entity to be active (e.g. a lamp to be lit) when it receives a circuit signal of more than 4 chain signals. + * + * ```lua + * a_behavior.circuit_condition = {condition={comparator=">", + * first_signal={type="item", name="rail-chain-signal"}, + * constant=4}} + * ``` + */ + circuit_condition: CircuitConditionDefinition + /** + * The logistic condition. + * + * **Note**: `condition` may be `nil` in order to clear the logistic condition. + * + * {@link https://lua-api.factorio.com/next/LuaGenericOnOffControlBehavior.html#LuaGenericOnOffControlBehavior.logistic_condition View documentation} + * + * @example + * Tell an entity to be active (e.g. a lamp to be lit) when the logistics network it's connected to has more than four chain signals. + * + * ```lua + * a_behavior.logistic_condition = {condition={comparator=">", + * first_signal={type="item", name="rail-chain-signal"}, + * constant=4}} + * ``` + */ + logistic_condition: CircuitConditionDefinition + /** + * `true` if this should connect to the logistic network. + * + * {@link https://lua-api.factorio.com/next/LuaGenericOnOffControlBehavior.html#LuaGenericOnOffControlBehavior.connect_to_logistic_network View documentation} + */ + connect_to_logistic_network: 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: string + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * Item group or subgroup. + * + * {@link https://lua-api.factorio.com/next/LuaGroup.html View documentation} + * + * @noSelf + */ +interface LuaGroup { + readonly name: string + /** + * Localised name of the group. + * + * {@link https://lua-api.factorio.com/next/LuaGroup.html#LuaGroup.localised_name View documentation} + */ + readonly localised_name: LocalisedString + readonly type: string + /** + * The parent group if any; `nil` if none. + * + * {@link https://lua-api.factorio.com/next/LuaGroup.html#LuaGroup.group View documentation} + */ + readonly group: LuaGroup | undefined + /** + * Subgroups of this group. + * + * **Note**: Can only be used on groups, not on subgroups. + * + * {@link https://lua-api.factorio.com/next/LuaGroup.html#LuaGroup.subgroups View documentation} + */ + readonly subgroups: LuaGroup[] + /** + * The additional order value used in recipe ordering. + * + * **Note**: Can only be used on groups, not on subgroups. + * + * {@link https://lua-api.factorio.com/next/LuaGroup.html#LuaGroup.order_in_recipe View documentation} + */ + readonly order_in_recipe: string + readonly 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: "LuaGroup" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * The root of the GUI. This type houses the root elements, `top`, `left`, `center`, `goal`, and `screen`, to which + * other elements can be added to be displayed on screen. + * + * **Note**: Every player can have a different GUI state. + * + * {@link https://lua-api.factorio.com/next/LuaGui.html View documentation} + * + * @noSelf + */ +interface LuaGui { + /** + * Returns `true` if sprite_path is valid and contains loaded sprite, otherwise `false`. Sprite path of type `file` + * doesn't validate if file exists. + * + * {@link https://lua-api.factorio.com/next/LuaGui.html#LuaGui.is_valid_sprite_path View documentation} + * + * @param sprite_path - Path to a image. + */ + is_valid_sprite_path(sprite_path: SpritePath): boolean + /** + * The player who owns this gui. + * + * {@link https://lua-api.factorio.com/next/LuaGui.html#LuaGui.player View documentation} + */ + readonly player: LuaPlayer + /** + * The children GUI elements mapped by name <> element. + * + * {@link https://lua-api.factorio.com/next/LuaGui.html#LuaGui.children View documentation} + */ + readonly children: Record + /** + * The top part of the GUI. It is a flow element inside a scroll pane element. + * + * {@link https://lua-api.factorio.com/next/LuaGui.html#LuaGui.top View documentation} + */ + readonly top: LuaGuiElement + /** + * The left part of the GUI. It is a flow element inside a scroll pane element. + * + * {@link https://lua-api.factorio.com/next/LuaGui.html#LuaGui.left View documentation} + */ + readonly left: LuaGuiElement + /** + * The center part of the GUI. It is a flow element. + * + * {@link https://lua-api.factorio.com/next/LuaGui.html#LuaGui.center View documentation} + */ + readonly center: LuaGuiElement + /** + * The flow used in the objectives window. It is a flow element. The objectives window is only visible when the flow + * is not empty or the objective text is set. + * + * {@link https://lua-api.factorio.com/next/LuaGui.html#LuaGui.goal View documentation} + */ + readonly goal: LuaGuiElement + /** + * For showing a GUI somewhere on the entire screen. It is an empty-widget element. + * + * {@link https://lua-api.factorio.com/next/LuaGui.html#LuaGui.screen View documentation} + */ + readonly screen: LuaGuiElement + /** + * For showing a GUI somewhere relative to one of the game GUIs. It is an empty-widget element. + * + * {@link https://lua-api.factorio.com/next/LuaGui.html#LuaGui.relative View documentation} + */ + readonly relative: LuaGuiElement + /** + * 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: "LuaGui" + /** All methods and properties that this object supports. */ + help(): string +} + +type GuiElementType = + | "choose-elem-button" + | "drop-down" + | "empty-widget" + | "entity-preview" + | "list-box" + | "scroll-pane" + | "sprite-button" + | "tabbed-pane" + | "text-box" + | "button" + | "camera" + | "checkbox" + | "flow" + | "frame" + | "label" + | "line" + | "minimap" + | "progressbar" + | "radiobutton" + | "slider" + | "sprite" + | "switch" + | "tab" + | "table" + | "textfield" + +interface BaseGuiSpec { + /** The kind of element to add. Has to be one of the GUI element types listed at the top of this page. */ + readonly type: GuiElementType + /** Name of the child element. */ + readonly name?: string + /** + * Text displayed on the child element. For frames, this is their title. For other elements, like buttons or labels, + * this is the content. Whilst this attribute may be used on all elements, it doesn't make sense for tables and + * flows as they won't display it. + */ + readonly caption?: LocalisedString + /** Tooltip of the child element. */ + readonly tooltip?: LocalisedString + /** Whether the child element is enabled. Defaults to `true`. */ + readonly enabled?: boolean + /** Whether the child element is visible. Defaults to `true`. */ + readonly visible?: boolean + /** Whether the child element is ignored by interaction. Defaults to `false`. */ + readonly ignored_by_interaction?: boolean + /** Style of the child element. */ + readonly style?: string + /** {@link Tags} associated with the child element. */ + readonly tags?: Tags + /** Location in its parent that the child element should slot into. By default, the child will be appended onto the end. */ + readonly index?: uint + /** Where to position the child element when in the `relative` element. */ + readonly anchor?: GuiAnchor +} + +interface ButtonGuiSpec extends BaseGuiSpec { + readonly type: "button" + /** Which mouse buttons the button responds to. Defaults to `"left-and-right"`. */ + readonly mouse_button_filter?: MouseButtonFlags +} + +interface FlowGuiSpec extends BaseGuiSpec { + readonly type: "flow" + /** + * The initial direction of the flow's layout. See {@link LuaGuiElement.direction LuaGuiElement::direction}. Defaults + * to `"horizontal"`. + */ + readonly direction?: "horizontal" | "vertical" +} + +interface FrameGuiSpec extends BaseGuiSpec { + readonly type: "frame" + /** + * The initial direction of the frame's layout. See {@link LuaGuiElement.direction LuaGuiElement::direction}. + * Defaults to `"horizontal"`. + */ + readonly direction?: "horizontal" | "vertical" +} + +interface TableGuiSpec extends BaseGuiSpec { + readonly type: "table" + /** Number of columns. This can't be changed after the table is created. */ + readonly column_count: uint + /** Whether the table should draw vertical grid lines. Defaults to `false`. */ + readonly draw_vertical_lines?: boolean + /** Whether the table should draw horizontal grid lines. Defaults to `false`. */ + readonly draw_horizontal_lines?: boolean + /** Whether the table should draw a single horizontal grid line after the headers. Defaults to `false`. */ + readonly draw_horizontal_line_after_headers?: boolean + /** Whether the content of the table should be vertically centered. Defaults to `true`. */ + readonly vertical_centering?: boolean +} + +interface TextfieldGuiSpec extends BaseGuiSpec { + readonly type: "textfield" + /** The initial text contained in the textfield. */ + readonly text?: string + /** Defaults to `false`. */ + readonly numeric?: boolean + /** Defaults to `false`. */ + readonly allow_decimal?: boolean + /** Defaults to `false`. */ + readonly allow_negative?: boolean + /** Defaults to `false`. */ + readonly is_password?: boolean + /** Defaults to `false`. */ + readonly lose_focus_on_confirm?: boolean + /** Defaults to `false`. */ + readonly clear_and_focus_on_right_click?: boolean +} + +interface ProgressbarGuiSpec extends BaseGuiSpec { + readonly type: "progressbar" + /** The initial value of the progressbar, in the range [0, 1]. Defaults to `0`. */ + readonly value?: double +} + +interface CheckboxGuiSpec extends BaseGuiSpec { + readonly type: "checkbox" + /** The initial checked-state of the checkbox. */ + readonly state: boolean +} + +interface RadiobuttonGuiSpec extends BaseGuiSpec { + readonly type: "radiobutton" + /** The initial checked-state of the radiobutton. */ + readonly state: boolean +} + +interface SpriteButtonGuiSpec extends BaseGuiSpec { + readonly type: "sprite-button" + /** Path to the image to display on the button. */ + readonly sprite?: SpritePath + /** Path to the image to display on the button when it is hovered. */ + readonly hovered_sprite?: SpritePath + /** Path to the image to display on the button when it is clicked. */ + readonly clicked_sprite?: SpritePath + /** The number shown on the button. */ + readonly number?: double + /** Formats small numbers as percentages. Defaults to `false`. */ + readonly show_percent_for_small_numbers?: boolean + /** The mouse buttons that the button responds to. Defaults to `"left-and-right"`. */ + readonly mouse_button_filter?: MouseButtonFlags +} + +interface SpriteGuiSpec extends BaseGuiSpec { + readonly type: "sprite" + /** Path to the image to display. */ + readonly sprite?: SpritePath + /** Whether the widget should resize according to the sprite in it. Defaults to `true`. */ + readonly resize_to_sprite?: boolean +} + +interface ScrollPaneGuiSpec extends BaseGuiSpec { + readonly type: "scroll-pane" + /** + * Policy of the horizontal scroll bar. Possible values are `"auto"`, `"never"`, `"always"`, + * `"auto-and-reserve-space"`, `"dont-show-but-allow-scrolling"`. Defaults to `"auto"`. + */ + readonly horizontal_scroll_policy?: + | "auto" + | "never" + | "always" + | "auto-and-reserve-space" + | "dont-show-but-allow-scrolling" + /** + * Policy of the vertical scroll bar. Possible values are `"auto"`, `"never"`, `"always"`, + * `"auto-and-reserve-space"`, `"dont-show-but-allow-scrolling"`. Defaults to `"auto"`. + */ + readonly vertical_scroll_policy?: + | "auto" + | "never" + | "always" + | "auto-and-reserve-space" + | "dont-show-but-allow-scrolling" +} + +interface DropDownGuiSpec extends BaseGuiSpec { + readonly type: "drop-down" + /** The initial items in the dropdown. */ + readonly items?: LocalisedString[] + /** The index of the initially selected item. Defaults to 0. */ + readonly selected_index?: uint +} + +interface LineGuiSpec extends BaseGuiSpec { + readonly type: "line" + /** The initial direction of the line. Defaults to `"horizontal"`. */ + readonly direction?: "horizontal" | "vertical" +} + +interface ListBoxGuiSpec extends BaseGuiSpec { + readonly type: "list-box" + /** The initial items in the listbox. */ + readonly items?: LocalisedString[] + /** The index of the initially selected item. Defaults to 0. */ + readonly selected_index?: uint +} + +interface CameraGuiSpec extends BaseGuiSpec { + readonly type: "camera" + /** The position the camera centers on. */ + readonly position: Position + /** The surface that the camera will render. Defaults to the player's current surface. */ + readonly surface_index?: uint + /** The initial camera zoom. Defaults to `0.75`. */ + readonly zoom?: double +} + +type ChooseElemButtonType = + | "item" + | "tile" + | "entity" + | "signal" + | "fluid" + | "recipe" + | "decorative" + | "item-group" + | "achievement" + | "equipment" + | "technology" + +interface ChooseElemButtonFilters { + item: ItemPrototypeFilter[] + tile: TilePrototypeFilter[] + entity: EntityPrototypeFilter[] + signal: never + fluid: FluidPrototypeFilter[] + recipe: RecipePrototypeFilter[] + decorative: DecorativePrototypeFilter[] + "item-group": never + achievement: AchievementPrototypeFilter[] + equipment: EquipmentPrototypeFilter[] + technology: TechnologyPrototypeFilter[] +} + +interface BaseChooseElemButtonSpec extends BaseGuiSpec { + readonly type: "choose-elem-button" + /** The type of the button - one of the following values. */ + readonly elem_type: ChooseElemButtonType + /** Filters describing what to show in the selection window. See {@link LuaGuiElement.elem_filters LuaGuiElement::elem_filters}. */ + readonly filters?: ChooseElemButtonFilters[this["elem_type"]] +} + +interface ItemChooseElemButtonSpec extends BaseChooseElemButtonSpec { + readonly elem_type: "item" + /** If type is `"item"` - the default value for the button. */ + readonly item?: string +} + +interface TileChooseElemButtonSpec extends BaseChooseElemButtonSpec { + readonly elem_type: "tile" + /** If type is `"tile"` - the default value for the button. */ + readonly tile?: string +} + +interface EntityChooseElemButtonSpec extends BaseChooseElemButtonSpec { + readonly elem_type: "entity" + /** If type is `"entity"` - the default value for the button. */ + readonly entity?: string +} + +interface SignalChooseElemButtonSpec extends BaseChooseElemButtonSpec { + readonly elem_type: "signal" + /** If type is `"signal"` - the default value for the button. */ + readonly signal?: SignalID +} + +interface FluidChooseElemButtonSpec extends BaseChooseElemButtonSpec { + readonly elem_type: "fluid" + /** If type is `"fluid"` - the default value for the button. */ + readonly fluid?: string +} + +interface RecipeChooseElemButtonSpec extends BaseChooseElemButtonSpec { + readonly elem_type: "recipe" + /** If type is `"recipe"` - the default value for the button. */ + readonly recipe?: string +} + +interface DecorativeChooseElemButtonSpec extends BaseChooseElemButtonSpec { + readonly elem_type: "decorative" + /** If type is `"decorative"` - the default value for the button. */ + readonly decorative?: string +} + +interface ItemGroupChooseElemButtonSpec extends BaseChooseElemButtonSpec { + readonly elem_type: "item-group" + /** If type is `"item-group"` - the default value for the button. */ + readonly "item-group"?: string +} + +interface AchievementChooseElemButtonSpec extends BaseChooseElemButtonSpec { + readonly elem_type: "achievement" + /** If type is `"achievement"` - the default value for the button. */ + readonly achievement?: string +} + +interface EquipmentChooseElemButtonSpec extends BaseChooseElemButtonSpec { + readonly elem_type: "equipment" + /** If type is `"equipment"` - the default value for the button. */ + readonly equipment?: string +} + +interface TechnologyChooseElemButtonSpec extends BaseChooseElemButtonSpec { + readonly elem_type: "technology" + /** If type is `"technology"` - the default value for the button. */ + readonly technology?: string +} + +type ChooseElemButtonGuiSpec = + | ItemChooseElemButtonSpec + | TileChooseElemButtonSpec + | EntityChooseElemButtonSpec + | SignalChooseElemButtonSpec + | FluidChooseElemButtonSpec + | RecipeChooseElemButtonSpec + | DecorativeChooseElemButtonSpec + | ItemGroupChooseElemButtonSpec + | AchievementChooseElemButtonSpec + | EquipmentChooseElemButtonSpec + | TechnologyChooseElemButtonSpec + +interface TextBoxGuiSpec extends BaseGuiSpec { + readonly type: "text-box" + /** The initial text contained in the text-box. */ + readonly text?: string + /** Defaults to `false`. */ + readonly clear_and_focus_on_right_click?: boolean +} + +interface SliderGuiSpec extends BaseGuiSpec { + readonly type: "slider" + /** The minimum value for the slider. Defaults to `0`. */ + readonly minimum_value?: double + /** The maximum value for the slider. Defaults to `30`. */ + readonly maximum_value?: double + /** The initial value for the slider. Defaults to `minimum_value`. */ + readonly value?: double + /** The minimum value the slider can move. Defaults to `1`. */ + readonly value_step?: double + /** Defaults to `false`. */ + readonly discrete_slider?: boolean + /** Defaults to `true`. */ + readonly discrete_values?: boolean +} + +interface MinimapGuiSpec extends BaseGuiSpec { + readonly type: "minimap" + /** The position the minimap centers on. Defaults to the player's current position. */ + readonly position?: Position + /** The surface the camera will render. Defaults to the player's current surface. */ + readonly surface_index?: uint + /** The player index the map should use. Defaults to the current player. */ + readonly chart_player_index?: uint + /** The force this minimap should use. Defaults to the player's current force. */ + readonly force?: string + /** The initial camera zoom. Defaults to `0.75`. */ + readonly zoom?: double +} + +interface TabGuiSpec extends BaseGuiSpec { + readonly type: "tab" + /** The text to display after the normal tab text (designed to work with numbers). */ + readonly badge_text?: LocalisedString +} + +interface SwitchGuiSpec extends BaseGuiSpec { + readonly type: "switch" + /** + * Possible values are `"left"`, `"right"`, or `"none"`. If set to "none", `allow_none_state` must be `true`. + * Defaults to `"left"`. + */ + readonly switch_state?: "left" | "right" | "none" + /** Whether the switch can be set to a middle state. Defaults to `false`. */ + readonly allow_none_state?: boolean + readonly left_label_caption?: LocalisedString + readonly left_label_tooltip?: LocalisedString + readonly right_label_caption?: LocalisedString + readonly right_label_tooltip?: LocalisedString +} + +interface OtherGuiSpec extends BaseGuiSpec { + readonly type: "empty-widget" | "entity-preview" | "tabbed-pane" | "label" +} + +type GuiSpec = + | ButtonGuiSpec + | FlowGuiSpec + | FrameGuiSpec + | TableGuiSpec + | TextfieldGuiSpec + | ProgressbarGuiSpec + | CheckboxGuiSpec + | RadiobuttonGuiSpec + | SpriteButtonGuiSpec + | SpriteGuiSpec + | ScrollPaneGuiSpec + | DropDownGuiSpec + | LineGuiSpec + | ListBoxGuiSpec + | CameraGuiSpec + | ChooseElemButtonGuiSpec + | TextBoxGuiSpec + | SliderGuiSpec + | MinimapGuiSpec + | TabGuiSpec + | SwitchGuiSpec + | OtherGuiSpec + +interface GuiElementIndex { + /** + * The indexing operator. Gets children by name. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.operator%20[] View documentation} + */ + readonly [name: string]: LuaGuiElement | undefined +} + +/** @noSelf */ +interface BaseGuiElement { + /** + * Add a new child element to this GuiElement. + * + * Other attributes may be specified depending on `type`: + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.add View documentation} + * + * @returns The added GUI element. + */ + add( + element: GuiSpec & { + type: Type + } + ): Extract< + LuaGuiElement, + { + type: Type + } + > + /** + * Remove children of this element. Any {@link LuaGuiElement} objects referring to the destroyed elements become + * invalid after this operation. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.clear View documentation} + * + * @example + * ```lua + * game.player.gui.top.clear() + * ``` + */ + clear(): void + /** + * Remove this element, along with its children. Any {@link LuaGuiElement} objects referring to the destroyed + * elements become invalid after this operation. + * + * **Note**: The top-level GUI elements - {@link LuaGui.top LuaGui::top}, {@link LuaGui.left LuaGui::left}, + * {@link LuaGui.center LuaGui::center} and {@link LuaGui.screen LuaGui::screen} - can't be destroyed. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.destroy View documentation} + * + * @example + * ```lua + * game.player.gui.top.greeting.destroy() + * ``` + */ + destroy(): void + /** + * The mod that owns this Gui element or `nil` if it's owned by the scenario script. + * + * **Note**: This has a not-super-expensive, but non-free cost to get. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.get_mod View documentation} + */ + get_mod(): string | undefined + /** + * Gets the index that this element has in its parent element. + * + * **Note**: This iterates through the children of the parent of this element, meaning this has a non-free cost to + * get, but is faster than doing the equivalent in Lua. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.get_index_in_parent View documentation} + */ + get_index_in_parent(): uint + /** + * Removes the items in this dropdown or listbox. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.clear_items View documentation} + */ + clear_items(): void + /** + * Gets the item at the given index from this dropdown or listbox. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.get_item View documentation} + * + * @param index - The index to get + */ + get_item(index: uint): LocalisedString + /** + * Sets the given string at the given index in this dropdown or listbox. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.set_item View documentation} + * + * @param index - The index whose text to replace. + * @param string - The text to set at the given index. + */ + set_item(index: uint, string: LocalisedString): void + /** + * Inserts a string at the end or at the given index of this dropdown or listbox. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.add_item View documentation} + * + * @param string - The text to insert. + * @param index - The index at which to insert the item. + */ + add_item(string: LocalisedString, index?: uint): void + /** + * Removes the item at the given index from this dropdown or listbox. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.remove_item View documentation} + * + * @param index - The index + */ + remove_item(index: uint): void + /** + * Gets this sliders minimum value. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.get_slider_minimum View documentation} + */ + get_slider_minimum(): double + /** + * Gets this sliders maximum value. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.get_slider_maximum View documentation} + */ + get_slider_maximum(): double + /** + * Sets this sliders minimum and maximum values. + * + * **Note**: The minimum can't be >= the maximum. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.set_slider_minimum_maximum View documentation} + * + * @param minimum + * @param maximum + */ + set_slider_minimum_maximum(minimum: double, maximum: double): void + /** + * Gets the minimum distance this slider can move. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.get_slider_value_step View documentation} + */ + get_slider_value_step(): double + /** + * Returns whether this slider only allows being moved to discrete positions. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.get_slider_discrete_slider View documentation} + */ + get_slider_discrete_slider(): boolean + /** + * Returns whether this slider only allows discrete values. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.get_slider_discrete_values View documentation} + */ + get_slider_discrete_values(): boolean + /** + * Sets the minimum distance this slider can move. + * + * **Note**: The minimum distance can't be > (max - min). + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.set_slider_value_step View documentation} + * + * @param value + */ + set_slider_value_step(value: double): void + /** + * Sets whether this slider only allows being moved to discrete positions. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.set_slider_discrete_slider View documentation} + * + * @param value + */ + set_slider_discrete_slider(value: boolean): void + /** + * Sets whether this slider only allows discrete values. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.set_slider_discrete_values View documentation} + * + * @param value + */ + set_slider_discrete_values(value: boolean): void + /** + * Focuses this GUI element if possible. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.focus View documentation} + */ + focus(): void + /** + * Moves this GUI element to the "front" so it will draw over other elements. + * + * **Note**: Only works for elements in {@link LuaGui.screen LuaGui::screen} + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.bring_to_front View documentation} + */ + bring_to_front(): void + /** + * The index of this GUI element (unique amongst the GUI elements of a LuaPlayer). + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.index View documentation} + */ + readonly index: uint + /** + * The GUI this element is a child of. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.gui View documentation} + */ + readonly gui: LuaGui + /** + * The direct parent of this element; `nil` if this is a top-level element. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.parent View documentation} + */ + readonly parent: LuaGuiElement | undefined + /** + * The name of this element. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.name View documentation} + * + * @example + * ```lua + * game.player.gui.top.greeting.name == "greeting" + * ``` + */ + name: string + /** + * The text displayed on this element. For frames, this is the "heading". For other elements, like buttons or + * labels, this is the content. + * + * **Note**: Whilst this attribute may be used on all elements without producing an error, it doesn't make sense for + * tables and flows as they won't display it. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.caption View documentation} + */ + caption: LocalisedString + /** + * The style of this element. When read, this evaluates to a {@link LuaStyle}. For writing, it only accepts a string + * that specifies the textual identifier (prototype name) of the desired style. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.style View documentation} + */ + style: LuaStyle | string + /** + * Sets whether this GUI element is visible or completely hidden, taking no space in the layout. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.visible View documentation} + */ + visible: boolean + /** + * Names of all the children of this element. These are the identifiers that can be used to access the child as an + * attribute of this element. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.children_names View documentation} + */ + readonly children_names: string[] + /** + * Index into {@link LuaGameScript.players LuaGameScript::players} specifying the player who owns this element. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.player_index View documentation} + */ + readonly player_index: uint + /** + * The image to display on this sprite-button or sprite in the default state. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.sprite View documentation} + */ + sprite: SpritePath + /** + * Whether the image widget should resize according to the sprite in it. Defaults to `true`. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.resize_to_sprite View documentation} + */ + resize_to_sprite: boolean + /** + * The image to display on this sprite-button when it is clicked. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.clicked_sprite View documentation} + */ + clicked_sprite: SpritePath + tooltip: LocalisedString + /** + * The type of this GUI element. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.type View documentation} + */ + readonly type: GuiElementType + /** + * The child-elements of this GUI element. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.children View documentation} + */ + readonly children: LuaGuiElement[] + /** + * The items in this dropdown or listbox. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.items View documentation} + */ + items: LocalisedString[] + /** + * The selected index for this dropdown or listbox. Returns `0` if none is selected. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.selected_index View documentation} + */ + selected_index: uint + /** + * The number to be shown in the bottom right corner of this sprite-button. Set this to `nil` to show nothing. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.number View documentation} + */ + number: double | undefined + /** + * Related to the number to be shown in the bottom right corner of this sprite-button. When set to `true`, numbers + * that are non-zero and smaller than one are shown as a percentage rather than the value. For example, `0.5` will + * be shown as `50%` instead. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.show_percent_for_small_numbers View documentation} + */ + show_percent_for_small_numbers: boolean + /** + * The location of this widget when stored in {@link LuaGui.screen LuaGui::screen} or `nil` if not not set or not in + * {@link LuaGui.screen LuaGui::screen}. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.location View documentation} + */ + location: GuiLocation | undefined + /** + * The position this camera or minimap is focused on, if any. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.position View documentation} + */ + position: Position + /** + * The surface index this camera or minimap is using. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.surface_index View documentation} + */ + surface_index: uint + /** + * The zoom this camera or minimap is using. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.zoom View documentation} + */ + zoom: double + /** + * The force this minimap is using or `nil` if no force is set. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.force View documentation} + */ + force: string | undefined + /** + * Whether this GUI element is enabled. Disabled GUI elements don't trigger events when clicked. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.enabled View documentation} + */ + enabled: boolean + /** + * Whether this GUI element is ignored by interaction. This makes clicks on this element 'go through' to the GUI + * element or even the game surface below it. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.ignored_by_interaction View documentation} + */ + ignored_by_interaction: boolean + /** + * The mouse button filters for this button or sprite-button. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.mouse_button_filter View documentation} + */ + mouse_button_filter: MouseButtonFlags + /** + * The frame drag target for this flow, frame, label, table, or empty-widget. + * + * **Note**: drag_target can only be set to a frame stored directly in {@link LuaGui.screen LuaGui::screen} or `nil`. + * + * **Note**: drag_target can only be set on child elements in {@link LuaGui.screen LuaGui::screen}. + * + * **Note**: drag_target can only be set to a higher level parent element (this element must be owned at some nested + * level by the drag_target). + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.drag_target View documentation} + */ + drag_target: LuaGuiElement | undefined + /** + * The tabs and contents being shown in this tabbed-pane. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.tabs View documentation} + */ + readonly tabs: TabAndContent[] + /** + * The entity associated with this entity-preview, camera, minimap or `nil` if no entity is associated. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.entity View documentation} + */ + entity: LuaEntity | undefined + /** + * Sets the anchor for this relative widget. Setting `nil` clears the anchor. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.anchor View documentation} + */ + anchor: GuiAnchor | undefined + /** + * The tags associated with this LuaGuiElement. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.tags View documentation} + */ + tags: Tags + /** + * 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: "LuaGuiElement" + /** All methods and properties that this object supports. */ + help(): string +} + +/** @noSelf */ +interface ChooseElemButtonGuiElementMembers extends BaseGuiElement { + /** + * The type of this GUI element. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.type View documentation} + */ + readonly type: "choose-elem-button" + /** + * The elem type of this choose-elem-button. + * + * *Can only be used if this is choose-elem-button* + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.elem_type View documentation} + */ + readonly elem_type: ChooseElemButtonType + /** + * The elem value of this choose-elem-button or `nil` if there is no value. + * + * **Note**: The `"signal"` type operates with {@link SignalID}, while all other types use strings. + * + * *Can only be used if this is choose-elem-button* + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.elem_value View documentation} + */ + elem_value: (this["elem_type"] extends "signal" ? SignalID : string) | undefined + /** + * The elem filters of this choose-elem-button or `nil` if there are no filters. + * + * The compatible type of filter is determined by elem_type: + * + * - Type `"item"` - {@link ItemPrototypeFilter} + * - Type `"tile"` - {@link TilePrototypeFilter} + * - Type `"entity"` - {@link EntityPrototypeFilter} + * - Type `"signal"` - Does not support filters + * - Type `"fluid"` - {@link FluidPrototypeFilter} + * - Type `"recipe"` - {@link RecipePrototypeFilter} + * - Type `"decorative"` - {@link DecorativePrototypeFilter} + * - Type `"item-group"` - Does not support filters + * - Type `"achievement"` - {@link AchievementPrototypeFilter} + * - Type `"equipment"` - {@link EquipmentPrototypeFilter} + * - Type `"technology"` - {@link TechnologyPrototypeFilter} + * + * **Note**: Writing to this field does not change or clear the currently selected element. + * + * *Can only be used if this is choose-elem-button* + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.elem_filters View documentation} + * + * @example + * This will configure a choose-elem-button of type `"entity"` to only show items of type `"furnace"`. + * + * ```lua + * button.elem_filters = {{filter = "type", type = "furnace"}} + * ``` + * + * @example + * Then, there are some types of filters that work on a specific kind of attribute. The following will configure a choose-elem-button of type `"entity"` to only show entities that have their `"hidden"` {@link EntityPrototypeFlags flags} set. + * + * ```lua + * button.elem_filters = {{filter = "hidden"}} + * ``` + * + * @example + * Lastly, these filters can be combined at will, taking care to specify how they should be combined (either `"and"` or `"or"`. The following will filter for any `"entities"` that are `"furnaces"` and that are not `"hidden"`. + * + * ```lua + * button.elem_filters = {{filter = "type", type = "furnace"}, {filter = "hidden", invert = true, mode = "and"}} + * ``` + */ + elem_filters: ChooseElemButtonFilters[this["elem_type"]] | undefined + /** + * Whether this choose-elem-button can be changed by the player. + * + * *Can only be used if this is choose-elem-button* + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.locked View documentation} + */ + locked: boolean +} + +type ChooseElemButtonGuiElement = ChooseElemButtonGuiElementMembers & GuiElementIndex + +/** @noSelf */ +interface DropDownGuiElementMembers extends BaseGuiElement { + /** + * The type of this GUI element. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.type View documentation} + */ + readonly type: "drop-down" +} + +type DropDownGuiElement = DropDownGuiElementMembers & GuiElementIndex + +/** @noSelf */ +interface EmptyWidgetGuiElementMembers extends BaseGuiElement { + /** + * The type of this GUI element. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.type View documentation} + */ + readonly type: "empty-widget" +} + +type EmptyWidgetGuiElement = EmptyWidgetGuiElementMembers & GuiElementIndex + +/** @noSelf */ +interface EntityPreviewGuiElementMembers extends BaseGuiElement { + /** + * The type of this GUI element. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.type View documentation} + */ + readonly type: "entity-preview" +} + +type EntityPreviewGuiElement = EntityPreviewGuiElementMembers & GuiElementIndex + +/** @noSelf */ +interface ListBoxGuiElementMembers extends BaseGuiElement { + /** + * The type of this GUI element. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.type View documentation} + */ + readonly type: "list-box" + /** + * Scrolls the scroll bar such that the specified listbox item is visible to the player. + * + * *Can only be used if this is list-box* + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.scroll_to_item View documentation} + * + * @param index - The item index to scroll to. + * @param scroll_mode - Where the item should be positioned in the scroll-pane. Must be either `"in-view"` or + * `"top-third"`. Defaults to `"in-view"`. + */ + scroll_to_item(index: int, scroll_mode?: "in-view" | "top-third"): void +} + +type ListBoxGuiElement = ListBoxGuiElementMembers & GuiElementIndex + +/** @noSelf */ +interface ScrollPaneGuiElementMembers extends BaseGuiElement { + /** + * The type of this GUI element. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.type View documentation} + */ + readonly type: "scroll-pane" + /** + * Scrolls this scroll bar to the top. + * + * *Can only be used if this is scroll-pane or text-box* + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.scroll_to_top View documentation} + */ + scroll_to_top(): void + /** + * Scrolls this scroll bar to the bottom. + * + * *Can only be used if this is scroll-pane or text-box* + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.scroll_to_bottom View documentation} + */ + scroll_to_bottom(): void + /** + * Scrolls this scroll bar to the left. + * + * *Can only be used if this is scroll-pane or text-box* + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.scroll_to_left View documentation} + */ + scroll_to_left(): void + /** + * Scrolls this scroll bar to the right. + * + * *Can only be used if this is scroll-pane or text-box* + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.scroll_to_right View documentation} + */ + scroll_to_right(): void + /** + * Scrolls this scroll bar such that the specified GUI element is visible to the player. + * + * *Can only be used if this is scroll-pane* + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.scroll_to_element View documentation} + * + * @param element - The element to scroll to. + * @param scroll_mode - Where the element should be positioned in the scroll-pane. Must be either `"in-view"` or + * `"top-third"`. Defaults to `"in-view"`. + */ + scroll_to_element(element: LuaGuiElement, scroll_mode?: "in-view" | "top-third"): void + /** + * Policy of the horizontal scroll bar. Possible values are `"auto"`, `"never"`, `"always"`, + * `"auto-and-reserve-space"`, `"dont-show-but-allow-scrolling"`. + * + * *Can only be used if this is scroll-pane* + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.horizontal_scroll_policy View documentation} + */ + horizontal_scroll_policy: "auto" | "never" | "always" | "auto-and-reserve-space" | "dont-show-but-allow-scrolling" + /** + * Policy of the vertical scroll bar. Possible values are `"auto"`, `"never"`, `"always"`, + * `"auto-and-reserve-space"`, `"dont-show-but-allow-scrolling"`. + * + * *Can only be used if this is scroll-pane* + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.vertical_scroll_policy View documentation} + */ + vertical_scroll_policy: "auto" | "never" | "always" | "auto-and-reserve-space" | "dont-show-but-allow-scrolling" +} + +type ScrollPaneGuiElement = ScrollPaneGuiElementMembers & GuiElementIndex + +/** @noSelf */ +interface SpriteButtonGuiElementMembers extends BaseGuiElement { + /** + * The type of this GUI element. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.type View documentation} + */ + readonly type: "sprite-button" + /** + * The image to display on this sprite-button when it is hovered. + * + * *Can only be used if this is sprite-button* + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.hovered_sprite View documentation} + */ + hovered_sprite: SpritePath +} + +type SpriteButtonGuiElement = SpriteButtonGuiElementMembers & GuiElementIndex + +/** @noSelf */ +interface TabbedPaneGuiElementMembers extends BaseGuiElement { + /** + * The type of this GUI element. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.type View documentation} + */ + readonly type: "tabbed-pane" + /** + * Adds the given tab and content widgets to this tabbed pane as a new tab. + * + * *Can only be used if this is tabbed-pane* + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.add_tab View documentation} + * + * @param tab - The tab to add, must be a GUI element of type "tab". + * @param content - The content to show when this tab is selected. Can be any type of GUI element. + */ + add_tab(tab: LuaGuiElement, content: LuaGuiElement): void + /** + * Removes the given tab and its associated content from this tabbed pane. + * + * **Note**: Removing a tab does not destroy the tab or the tab contents. It just removes them from the view. + * + * **Note**: When removing tabs, {@link LuaGuiElement.selected_tab_index LuaGuiElement::selected_tab_index} needs to + * be manually updated. + * + * *Can only be used if this is tabbed-pane* + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.remove_tab View documentation} + * + * @param tab - The tab to remove. If not given, it removes all tabs. + */ + remove_tab(tab: LuaGuiElement): void + /** + * The selected tab index for this tabbed pane or `nil` if no tab is selected. + * + * *Can only be used if this is tabbed-pane* + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.selected_tab_index View documentation} + */ + selected_tab_index: uint | undefined +} + +type TabbedPaneGuiElement = TabbedPaneGuiElementMembers & GuiElementIndex + +/** @noSelf */ +interface TextBoxGuiElementMembers extends BaseGuiElement { + /** + * The type of this GUI element. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.type View documentation} + */ + readonly type: "text-box" + /** + * Scrolls this scroll bar to the top. + * + * *Can only be used if this is scroll-pane or text-box* + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.scroll_to_top View documentation} + */ + scroll_to_top(): void + /** + * Scrolls this scroll bar to the bottom. + * + * *Can only be used if this is scroll-pane or text-box* + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.scroll_to_bottom View documentation} + */ + scroll_to_bottom(): void + /** + * Scrolls this scroll bar to the left. + * + * *Can only be used if this is scroll-pane or text-box* + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.scroll_to_left View documentation} + */ + scroll_to_left(): void + /** + * Scrolls this scroll bar to the right. + * + * *Can only be used if this is scroll-pane or text-box* + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.scroll_to_right View documentation} + */ + scroll_to_right(): void + /** + * Selects all the text in this textbox. + * + * *Can only be used if this is textfield or text-box* + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.select_all View documentation} + */ + select_all(): void + /** + * Selects a range of text in this textbox. + * + * *Can only be used if this is textfield or text-box* + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.select View documentation} + * + * @example + * Select the characters `amp` from `example`: + * + * ```lua + * textbox.select(3, 5) + * ``` + * + * @example + * Move the cursor to the start of the text box: + * + * ```lua + * textbox.select(1, 0) + * ``` + * + * @param start - The index of the first character to select + * @param end - The index of the last character to select + */ + select(start: int, end: int): void + /** + * The text contained in this textfield or text-box. + * + * *Can only be used if this is textfield or text-box* + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.text View documentation} + */ + text: string + /** + * Whether the contents of this text-box are selectable. Defaults to `true`. + * + * *Can only be used if this is text-box* + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.selectable View documentation} + */ + selectable: boolean + /** + * Whether this text-box will word-wrap automatically. Defaults to `false`. + * + * *Can only be used if this is text-box* + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.word_wrap View documentation} + */ + word_wrap: boolean + /** + * Whether this text-box is read-only. Defaults to `false`. + * + * *Can only be used if this is text-box* + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.read_only View documentation} + */ + read_only: boolean + /** + * Makes it so right-clicking on this textfield clears and focuses it. + * + * *Can only be used if this is textfield or text-box* + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.clear_and_focus_on_right_click View documentation} + */ + clear_and_focus_on_right_click: boolean +} + +type TextBoxGuiElement = TextBoxGuiElementMembers & GuiElementIndex + +/** @noSelf */ +interface ButtonGuiElementMembers extends BaseGuiElement { + /** + * The type of this GUI element. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.type View documentation} + */ + readonly type: "button" +} + +type ButtonGuiElement = ButtonGuiElementMembers & GuiElementIndex + +/** @noSelf */ +interface CameraGuiElementMembers extends BaseGuiElement { + /** + * The type of this GUI element. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.type View documentation} + */ + readonly type: "camera" +} + +type CameraGuiElement = CameraGuiElementMembers & GuiElementIndex + +/** @noSelf */ +interface CheckboxGuiElementMembers extends BaseGuiElement { + /** + * The type of this GUI element. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.type View documentation} + */ + readonly type: "checkbox" + /** + * Is this checkbox or radiobutton checked? + * + * *Can only be used if this is CheckBox or RadioButton* + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.state View documentation} + */ + state: boolean +} + +type CheckboxGuiElement = CheckboxGuiElementMembers & GuiElementIndex + +/** @noSelf */ +interface FlowGuiElementMembers extends BaseGuiElement { + /** + * The type of this GUI element. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.type View documentation} + */ + readonly type: "flow" + /** + * Direction of this element's layout. May be either `"horizontal"` or `"vertical"`. + * + * *Can only be used if this is frame, flow or line* + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.direction View documentation} + */ + readonly direction: "horizontal" | "vertical" +} + +type FlowGuiElement = FlowGuiElementMembers & GuiElementIndex + +/** @noSelf */ +interface FrameGuiElementMembers extends BaseGuiElement { + /** + * The type of this GUI element. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.type View documentation} + */ + readonly type: "frame" + /** + * Forces this frame to re-auto-center. Only works on frames stored directly in {@link LuaGui.screen LuaGui::screen}. + * + * *Can only be used if this is frame* + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.force_auto_center View documentation} + */ + force_auto_center(): void + /** + * Direction of this element's layout. May be either `"horizontal"` or `"vertical"`. + * + * *Can only be used if this is frame, flow or line* + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.direction View documentation} + */ + readonly direction: "horizontal" | "vertical" + /** + * Whether this frame auto-centers on window resize when stored in {@link LuaGui.screen LuaGui::screen}. + * + * *Can only be used if this is frame* + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.auto_center View documentation} + */ + auto_center: boolean +} + +type FrameGuiElement = FrameGuiElementMembers & GuiElementIndex + +/** @noSelf */ +interface LabelGuiElementMembers extends BaseGuiElement { + /** + * The type of this GUI element. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.type View documentation} + */ + readonly type: "label" +} + +type LabelGuiElement = LabelGuiElementMembers & GuiElementIndex + +/** @noSelf */ +interface LineGuiElementMembers extends BaseGuiElement { + /** + * The type of this GUI element. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.type View documentation} + */ + readonly type: "line" + /** + * Direction of this element's layout. May be either `"horizontal"` or `"vertical"`. + * + * *Can only be used if this is frame, flow or line* + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.direction View documentation} + */ + readonly direction: "horizontal" | "vertical" +} + +type LineGuiElement = LineGuiElementMembers & GuiElementIndex + +/** @noSelf */ +interface MinimapGuiElementMembers extends BaseGuiElement { + /** + * The type of this GUI element. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.type View documentation} + */ + readonly type: "minimap" + /** + * The player index this minimap is using. + * + * *Can only be used if this is minimap* + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.minimap_player_index View documentation} + */ + minimap_player_index: uint +} + +type MinimapGuiElement = MinimapGuiElementMembers & GuiElementIndex + +/** @noSelf */ +interface ProgressbarGuiElementMembers extends BaseGuiElement { + /** + * The type of this GUI element. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.type View documentation} + */ + readonly type: "progressbar" + /** + * How much this progress bar is filled. It is a value in the range [0, 1]. + * + * *Can only be used if this is progressbar* + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.value View documentation} + */ + value: double +} + +type ProgressbarGuiElement = ProgressbarGuiElementMembers & GuiElementIndex + +/** @noSelf */ +interface RadiobuttonGuiElementMembers extends BaseGuiElement { + /** + * The type of this GUI element. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.type View documentation} + */ + readonly type: "radiobutton" + /** + * Is this checkbox or radiobutton checked? + * + * *Can only be used if this is CheckBox or RadioButton* + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.state View documentation} + */ + state: boolean +} + +type RadiobuttonGuiElement = RadiobuttonGuiElementMembers & GuiElementIndex + +/** @noSelf */ +interface SliderGuiElementMembers extends BaseGuiElement { + /** + * The type of this GUI element. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.type View documentation} + */ + readonly type: "slider" + /** + * The value of this slider element. + * + * *Can only be used if this is slider* + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.slider_value View documentation} + */ + slider_value: double +} + +type SliderGuiElement = SliderGuiElementMembers & GuiElementIndex + +/** @noSelf */ +interface SpriteGuiElementMembers extends BaseGuiElement { + /** + * The type of this GUI element. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.type View documentation} + */ + readonly type: "sprite" +} + +type SpriteGuiElement = SpriteGuiElementMembers & GuiElementIndex + +/** @noSelf */ +interface SwitchGuiElementMembers extends BaseGuiElement { + /** + * The type of this GUI element. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.type View documentation} + */ + readonly type: "switch" + /** + * The switch state (left, none, right) for this switch. + * + * **Note**: If {@link LuaGuiElement.allow_none_state LuaGuiElement::allow_none_state} is false this can't be set to `"none"`. + * + * *Can only be used if this is switch* + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.switch_state View documentation} + */ + switch_state: string + /** + * Whether the `"none"` state is allowed for this switch. + * + * **Note**: This can't be set to false if the current switch_state is 'none'. + * + * *Can only be used if this is switch* + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.allow_none_state View documentation} + */ + allow_none_state: boolean + /** + * The text shown for the left switch label. + * + * *Can only be used if this is switch* + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.left_label_caption View documentation} + */ + left_label_caption: LocalisedString + /** + * The tooltip shown on the left switch label. + * + * *Can only be used if this is switch* + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.left_label_tooltip View documentation} + */ + left_label_tooltip: LocalisedString + /** + * The text shown for the right switch label. + * + * *Can only be used if this is switch* + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.right_label_caption View documentation} + */ + right_label_caption: LocalisedString + /** + * The tooltip shown on the right switch label. + * + * *Can only be used if this is switch* + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.right_label_tooltip View documentation} + */ + right_label_tooltip: LocalisedString +} + +type SwitchGuiElement = SwitchGuiElementMembers & GuiElementIndex + +/** @noSelf */ +interface TabGuiElementMembers extends BaseGuiElement { + /** + * The type of this GUI element. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.type View documentation} + */ + readonly type: "tab" + /** + * The text to display after the normal tab text (designed to work with numbers) + * + * *Can only be used if this is tab* + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.badge_text View documentation} + */ + badge_text: LocalisedString +} + +type TabGuiElement = TabGuiElementMembers & GuiElementIndex + +/** @noSelf */ +interface TableGuiElementMembers extends BaseGuiElement { + /** + * The type of this GUI element. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.type View documentation} + */ + readonly type: "table" + /** + * Whether this table should draw vertical grid lines. + * + * *Can only be used if this is table* + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.draw_vertical_lines View documentation} + */ + draw_vertical_lines: boolean + /** + * Whether this table should draw horizontal grid lines. + * + * *Can only be used if this is table* + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.draw_horizontal_lines View documentation} + */ + draw_horizontal_lines: boolean + /** + * Whether this table should draw a horizontal grid line below the first table row. + * + * *Can only be used if this is table* + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.draw_horizontal_line_after_headers View documentation} + */ + draw_horizontal_line_after_headers: boolean + /** + * The number of columns in this table. + * + * *Can only be used if this is table* + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.column_count View documentation} + */ + readonly column_count: uint + /** + * Whether the content of this table should be vertically centered. Overrides + * {@link LuaStyle.column_alignments LuaStyle::column_alignments}. Defaults to `true`. + * + * *Can only be used if this is table* + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.vertical_centering View documentation} + */ + vertical_centering: boolean +} + +type TableGuiElement = TableGuiElementMembers & GuiElementIndex + +/** @noSelf */ +interface TextfieldGuiElementMembers extends BaseGuiElement { + /** + * The type of this GUI element. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.type View documentation} + */ + readonly type: "textfield" + /** + * Selects all the text in this textbox. + * + * *Can only be used if this is textfield or text-box* + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.select_all View documentation} + */ + select_all(): void + /** + * Selects a range of text in this textbox. + * + * *Can only be used if this is textfield or text-box* + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.select View documentation} + * + * @example + * Select the characters `amp` from `example`: + * + * ```lua + * textbox.select(3, 5) + * ``` + * + * @example + * Move the cursor to the start of the text box: + * + * ```lua + * textbox.select(1, 0) + * ``` + * + * @param start - The index of the first character to select + * @param end - The index of the last character to select + */ + select(start: int, end: int): void + /** + * The text contained in this textfield or text-box. + * + * *Can only be used if this is textfield or text-box* + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.text View documentation} + */ + text: string + /** + * Whether this textfield is limited to only numberic characters. + * + * *Can only be used if this is textfield* + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.numeric View documentation} + */ + numeric: boolean + /** + * Whether this textfield (when in numeric mode) allows decimal numbers. + * + * *Can only be used if this is textfield* + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.allow_decimal View documentation} + */ + allow_decimal: boolean + /** + * Whether this textfield (when in numeric mode) allows negative numbers. + * + * *Can only be used if this is textfield* + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.allow_negative View documentation} + */ + allow_negative: boolean + /** + * Whether this textfield displays as a password field, which renders all characters as `*`. + * + * *Can only be used if this is textfield* + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.is_password View documentation} + */ + is_password: boolean + /** + * Whether this textfield loses focus after {@link defines.events.on_gui_confirmed} is fired. + * + * *Can only be used if this is textfield* + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.lose_focus_on_confirm View documentation} + */ + lose_focus_on_confirm: boolean + /** + * Makes it so right-clicking on this textfield clears and focuses it. + * + * *Can only be used if this is textfield or text-box* + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html#LuaGuiElement.clear_and_focus_on_right_click View documentation} + */ + clear_and_focus_on_right_click: boolean +} + +type TextfieldGuiElement = TextfieldGuiElementMembers & GuiElementIndex + +type GuiElementMembers = + | ChooseElemButtonGuiElementMembers + | DropDownGuiElementMembers + | EmptyWidgetGuiElementMembers + | EntityPreviewGuiElementMembers + | ListBoxGuiElementMembers + | ScrollPaneGuiElementMembers + | SpriteButtonGuiElementMembers + | TabbedPaneGuiElementMembers + | TextBoxGuiElementMembers + | ButtonGuiElementMembers + | CameraGuiElementMembers + | CheckboxGuiElementMembers + | FlowGuiElementMembers + | FrameGuiElementMembers + | LabelGuiElementMembers + | LineGuiElementMembers + | MinimapGuiElementMembers + | ProgressbarGuiElementMembers + | RadiobuttonGuiElementMembers + | SliderGuiElementMembers + | SpriteGuiElementMembers + | SwitchGuiElementMembers + | TabGuiElementMembers + | TableGuiElementMembers + | TextfieldGuiElementMembers + +/** + * An element of a custom GUI. This type is used to represent any kind of a GUI element - labels, buttons and frames are + * all instances of this type. Just like {@link LuaEntity}, different kinds of elements support different attributes; + * attempting to access an attribute on an element that doesn't support it (for instance, trying to access the + * `column_count` of a `textfield`) will result in a runtime error. + * + * The following types of GUI element are supported: + * + * - `"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"`: A clickable element that is functionally identical to a `checkbox`, but has a circular appearance. + * 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} + * + * Each GUI element allows access to its children by having them as attributes. Thus, one can use the `parent.child` + * syntax to refer to children. Lua also supports the `parent["child"]` syntax to refer to the same element. This can be + * used in cases where the child has a name that isn't a valid Lua identifier. + * + * {@link https://lua-api.factorio.com/next/LuaGuiElement.html View documentation} + * + * @example + * This will add a label called `greeting` to the top flow. Immediately after, it will change its text to illustrate accessing child elements. + * + * ```lua + * game.player.gui.top.add{type="label", name="greeting", caption="Hi"} + * game.player.gui.top.greeting.caption = "Hello there!" + * game.player.gui.top["greeting"].caption = "Actually, never mind, I don't like your face" + * ``` + * + * @example + * This will add a tabbed-pane and 2 tabs with contents. + * + * ```lua + * local tabbed_pane = game.player.gui.top.add{type="tabbed-pane"} + * local tab1 = tabbed_pane.add{type="tab", caption="Tab 1"} + * local tab2 = tabbed_pane.add{type="tab", caption="Tab 2"} + * local label1 = tabbed_pane.add{type="label", caption="Label 1"} + * local label2 = tabbed_pane.add{type="label", caption="Label 2"} + * tabbed_pane.add_tab(tab1, label1) + * tabbed_pane.add_tab(tab2, label2) + * ``` + */ +type LuaGuiElement = GuiElementMembers & GuiElementIndex + +/** + * Prototype of a heat energy source. + * + * {@link https://lua-api.factorio.com/next/LuaHeatEnergySourcePrototype.html View documentation} + * + * @noSelf + */ +interface LuaHeatEnergySourcePrototype { + readonly emissions: double + readonly render_no_network_icon: boolean + readonly render_no_power_icon: boolean + readonly max_temperature: double + readonly default_temperature: double + readonly specific_heat: double + readonly max_transfer: double + readonly min_temperature_gradient: double + readonly min_working_temperature: double + readonly minimum_glow_temperature: double + readonly connections: HeatConnection[] + /** + * 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: "LuaHeatEnergySourcePrototype" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * Control behavior for inserters. + * + * {@link https://lua-api.factorio.com/next/LuaInserterControlBehavior.html View documentation} + * + * @noSelf + */ +interface LuaInserterControlBehavior extends LuaGenericOnOffControlBehavior { + /** + * `true` if the contents of the inserter hand should be sent to the circuit network + * + * {@link https://lua-api.factorio.com/next/LuaInserterControlBehavior.html#LuaInserterControlBehavior.circuit_read_hand_contents View documentation} + */ + circuit_read_hand_contents: boolean + /** + * The circuit mode of operations for the inserter. + * + * {@link https://lua-api.factorio.com/next/LuaInserterControlBehavior.html#LuaInserterControlBehavior.circuit_mode_of_operation View documentation} + */ + circuit_mode_of_operation: defines.control_behavior.inserter.circuit_mode_of_operation + /** + * The hand read mode for the inserter. + * + * {@link https://lua-api.factorio.com/next/LuaInserterControlBehavior.html#LuaInserterControlBehavior.circuit_hand_read_mode View documentation} + */ + circuit_hand_read_mode: defines.control_behavior.inserter.hand_read_mode + /** + * If the stack size of the inserter is set through the circuit network or not. + * + * {@link https://lua-api.factorio.com/next/LuaInserterControlBehavior.html#LuaInserterControlBehavior.circuit_set_stack_size View documentation} + */ + circuit_set_stack_size: boolean + /** + * The signal used to set the stack size of the inserter. + * + * {@link https://lua-api.factorio.com/next/LuaInserterControlBehavior.html#LuaInserterControlBehavior.circuit_stack_control_signal View documentation} + */ + circuit_stack_control_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: "LuaInserterControlBehavior" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * A storage of item stacks. + * + * {@link https://lua-api.factorio.com/next/LuaInventory.html View documentation} + * + * @noSelf + */ +interface LuaInventory extends ReadonlyArray { + /** + * Make this inventory empty. + * + * {@link https://lua-api.factorio.com/next/LuaInventory.html#LuaInventory.clear View documentation} + */ + clear(): void + /** + * Can at least some items be inserted? + * + * {@link https://lua-api.factorio.com/next/LuaInventory.html#LuaInventory.can_insert View documentation} + * + * @param items - Items that would be inserted. + * @returns `true` if at least a part of the given items could be inserted into this inventory. + */ + can_insert(items: ItemStackIdentification): boolean + /** + * Insert items into this inventory. + * + * {@link https://lua-api.factorio.com/next/LuaInventory.html#LuaInventory.insert View documentation} + * + * @param items - Items to insert. + * @returns Number of items actually inserted. + */ + insert(items: ItemStackIdentification): uint + /** + * Remove items from this inventory. + * + * {@link https://lua-api.factorio.com/next/LuaInventory.html#LuaInventory.remove View documentation} + * + * @param items - Items to remove. + * @returns Number of items actually removed. + */ + remove(items: ItemStackIdentification): uint + /** + * Get the number of all or some items in this inventory. + * + * {@link https://lua-api.factorio.com/next/LuaInventory.html#LuaInventory.get_item_count View documentation} + * + * @param item - Prototype name of the item to count. If not specified, count all items. + */ + get_item_count(item?: string): uint + /** + * Does this inventory contain nothing? + * + * {@link https://lua-api.factorio.com/next/LuaInventory.html#LuaInventory.is_empty View documentation} + */ + is_empty(): boolean + /** + * Get counts of all items in this inventory. + * + * {@link https://lua-api.factorio.com/next/LuaInventory.html#LuaInventory.get_contents View documentation} + * + * @returns The counts, indexed by item names. + */ + get_contents(): Record + /** + * Does this inventory support a bar? Bar is the draggable red thing, found for example on chests, that limits the + * portion of the inventory that may be manipulated by machines. + * + * **Note**: "Supporting a bar" doesn't mean that the bar is set to some nontrivial value. Supporting a bar means + * the inventory supports having this limit at all. The character's inventory is an example of an inventory without + * a bar; the wooden chest's inventory is an example of one with a bar. + * + * {@link https://lua-api.factorio.com/next/LuaInventory.html#LuaInventory.supports_bar View documentation} + */ + supports_bar(): boolean + /** + * Get the current bar. This is the index at which the red area starts. + * + * **Note**: Only useable if this inventory supports having a bar. + * + * {@link https://lua-api.factorio.com/next/LuaInventory.html#LuaInventory.get_bar View documentation} + */ + get_bar(): uint + /** + * Set the current bar. + * + * **Note**: Only useable if this inventory supports having a bar. + * + * {@link https://lua-api.factorio.com/next/LuaInventory.html#LuaInventory.set_bar View documentation} + * + * @param bar - The new limit. Omitting this parameter will clear the limit. + */ + set_bar(bar?: uint): void + /** + * If this inventory supports filters. + * + * {@link https://lua-api.factorio.com/next/LuaInventory.html#LuaInventory.supports_filters View documentation} + */ + supports_filters(): boolean + /** + * If this inventory supports filters and has at least 1 filter set. + * + * {@link https://lua-api.factorio.com/next/LuaInventory.html#LuaInventory.is_filtered View documentation} + */ + is_filtered(): boolean + /** + * If the given inventory slot filter can be set to the given filter. + * + * {@link https://lua-api.factorio.com/next/LuaInventory.html#LuaInventory.can_set_filter View documentation} + * + * @param index - The item stack index + * @param filter - The item name of the filter + */ + can_set_filter(index: uint, filter: string): boolean + /** + * Gets the filter for the given item stack index. + * + * {@link https://lua-api.factorio.com/next/LuaInventory.html#LuaInventory.get_filter View documentation} + * + * @param index - The item stack index + * @returns The current filter or nil if none. + */ + get_filter(index: uint): string | undefined + /** + * Sets the filter for the given item stack index. + * + * **Note**: Some inventory slots don't allow some filters (gun ammo can't be filtered for non-ammo). + * + * {@link https://lua-api.factorio.com/next/LuaInventory.html#LuaInventory.set_filter View documentation} + * + * @param index - The item stack index + * @param filter - The new filter or nil to erase the filter + * @returns If the filter was allowed to be set. + */ + set_filter(index: uint, filter: string | undefined): boolean + /** + * Gets the first LuaItemStack in the inventory that matches the given item name. + * + * **Note**: This will also return the stack index if one is found that matches as a second return value. + * + * {@link https://lua-api.factorio.com/next/LuaInventory.html#LuaInventory.find_item_stack View documentation} + * + * @param item - The item name to find + * @returns The first matching stack, or `nil` if none match. + */ + find_item_stack(item: string): LuaMultiReturn<[undefined] | [LuaItemStack, uint]> + /** + * Finds the first empty stack. Filtered slots are excluded unless a filter item is given. + * + * **Note**: This will also return the stack index if one is found that matches as a second return value. + * + * {@link https://lua-api.factorio.com/next/LuaInventory.html#LuaInventory.find_empty_stack View documentation} + * + * @param item - If given, empty stacks that are filtered for this item will be included. + * @returns The first empty stack, or `nil` if there aren't any empty stacks. + */ + find_empty_stack(item?: string): LuaMultiReturn<[undefined] | [LuaItemStack, uint]> + /** + * Counts the number of empty stacks. + * + * {@link https://lua-api.factorio.com/next/LuaInventory.html#LuaInventory.count_empty_stacks View documentation} + * + * @param include_filtered - If true, filtered slots will be included. Defaults to false. + */ + count_empty_stacks(include_filtered?: boolean): uint + /** + * Gets the number of the given item that can be inserted into this inventory. + * + * **Note**: This is a "best guess" number; things like assembling machine filtered slots, module slots, items with + * durability, and items with mixed health will cause the result to be inaccurate. + * + * **Note**: The main use for this is in checking how many of a basic item can fit into a basic inventory. + * + * **Note**: This accounts for the 'bar' on the inventory. + * + * {@link https://lua-api.factorio.com/next/LuaInventory.html#LuaInventory.get_insertable_count View documentation} + * + * @param item - The item to check. + */ + get_insertable_count(item: string): void + /** + * Sorts and merges the items in this inventory. + * + * {@link https://lua-api.factorio.com/next/LuaInventory.html#LuaInventory.sort_and_merge View documentation} + */ + sort_and_merge(): void + /** + * Resizes the inventory. + * + * **Note**: Items in slots beyond the new capacity are deleted. + * + * **Note**: Only inventories created by {@link LuaGameScript.create_inventory LuaGameScript::create_inventory} can be resized. + * + * {@link https://lua-api.factorio.com/next/LuaInventory.html#LuaInventory.resize View documentation} + * + * @param size - New size of a inventory + */ + resize(size: uint16): void + /** + * Destroys this inventory. + * + * **Note**: Only inventories created by {@link LuaGameScript.create_inventory LuaGameScript::create_inventory} can + * be destroyed this way. + * + * {@link https://lua-api.factorio.com/next/LuaInventory.html#LuaInventory.destroy View documentation} + */ + destroy(): void + /** + * Get the number of slots in this inventory. + * + * {@link https://lua-api.factorio.com/next/LuaInventory.html#LuaInventory.operator%20# View documentation} + * + * @example + * Will print the number of slots in the player's main inventory. + * + * ```lua + * game.player.print(#game.player.get_main_inventory()) + * ``` + */ + readonly length: uint + /** + * The inventory index this inventory uses, or `nil` if the inventory doesn't have an index. + * + * {@link https://lua-api.factorio.com/next/LuaInventory.html#LuaInventory.index View documentation} + */ + readonly index: defines.inventory | undefined + /** + * The entity that owns this inventory or `nil` if this isn't owned by an entity. + * + * {@link https://lua-api.factorio.com/next/LuaInventory.html#LuaInventory.entity_owner View documentation} + */ + readonly entity_owner: LuaEntity | undefined + /** + * The player that owns this inventory or `nil` if this isn't owned by a player. + * + * {@link https://lua-api.factorio.com/next/LuaInventory.html#LuaInventory.player_owner View documentation} + */ + readonly player_owner: LuaPlayer | undefined + /** + * The equipment that owns this inventory or `nil` if this isn't owned by an equipment. + * + * {@link https://lua-api.factorio.com/next/LuaInventory.html#LuaInventory.equipment_owner View documentation} + */ + readonly equipment_owner: LuaEquipment | undefined + /** + * The mod that owns this inventory or `nil` if this isn't owned by a mod. + * + * {@link https://lua-api.factorio.com/next/LuaInventory.html#LuaInventory.mod_owner View documentation} + */ + readonly mod_owner: string | undefined + /** + * The indexing operator. + * + * {@link https://lua-api.factorio.com/next/LuaInventory.html#LuaInventory.operator%20[] View documentation} + * + * @example + * Will get the first item in the player's inventory. + * + * ```lua + * game.player.get_main_inventory()[1] + * ``` + */ + readonly [index: number]: LuaItemStack + /** + * 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: "LuaInventory" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * Prototype of an item. + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html View documentation} + * + * @example + * ```lua + * game.item_prototypes["iron-plate"] + * ``` + * + * @noSelf + */ +interface LuaItemPrototype { + /** + * Does this prototype have a flag enabled? + * + * Any other value will cause an error. + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.has_flag View documentation} + * + * @param flag - The flag to check. Can be one of {@link ItemPrototypeFlags} + */ + has_flag(flag: string): boolean + /** + * Type of this ammo prototype or `nil` if this is not an ammo prototype. + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.get_ammo_type View documentation} + * + * @param ammo_source_type - "default", "player", "turret", or "vehicle" + */ + get_ammo_type(ammo_source_type?: "default" | "player" | "turret" | "vehicle"): AmmoType | undefined + /** + * Type of this prototype. E.g. `"gun"` or `"mining-tool"`. + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.type View documentation} + */ + readonly type: "gun" | "mining-tool" + /** + * Name of this prototype. + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.name View documentation} + */ + readonly name: string + readonly localised_name: LocalisedString + readonly localised_description: LocalisedString + /** + * Order string. + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.order View documentation} + */ + readonly order: string + /** + * Prototype of the entity that will be created by placing this item, or `nil` if there is no such entity. + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.place_result View documentation} + */ + readonly place_result: LuaEntityPrototype | undefined + /** + * Prototype of the equipment that will be created by placing this item in an equipment grid or `nil` if there is no + * equipment defined. + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.place_as_equipment_result View documentation} + */ + readonly place_as_equipment_result: LuaEquipmentPrototype | undefined + /** + * The place-as-tile result if one is defined, else `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.place_as_tile_result View documentation} + */ + readonly place_as_tile_result: PlaceAsTileResult | undefined + /** + * Is this item allowed to stack at all? + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.stackable View documentation} + */ + readonly stackable: boolean + /** + * The default request value. + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.default_request_amount View documentation} + */ + readonly default_request_amount: uint + /** + * Maximum stack size of the item specified by this prototype. + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.stack_size View documentation} + */ + readonly stack_size: uint + /** + * The number of items needed to connect 2 entities with this as wire. + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.wire_count View documentation} + */ + readonly wire_count: uint + /** + * The fuel category or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.fuel_category View documentation} + */ + readonly fuel_category: string | undefined + /** + * The result of burning this item as fuel or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.burnt_result View documentation} + */ + readonly burnt_result: LuaItemPrototype | undefined + /** + * Fuel value when burned. + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.fuel_value View documentation} + */ + readonly fuel_value: float + /** + * The acceleration multiplier when this item is used as fuel in a vehicle. + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.fuel_acceleration_multiplier View documentation} + */ + readonly fuel_acceleration_multiplier: double + /** + * The fuel top speed multiplier when this item is used as fuel in a vehicle. + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.fuel_top_speed_multiplier View documentation} + */ + readonly fuel_top_speed_multiplier: double + /** + * The emissions multiplier if this is used as fuel. + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.fuel_emissions_multiplier View documentation} + */ + readonly fuel_emissions_multiplier: double + /** + * The subgroup this prototype belongs to. + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.subgroup View documentation} + */ + readonly subgroup: LuaGroup + /** + * The group this prototype belongs to. + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.group View documentation} + */ + readonly group: LuaGroup + /** + * The item prototype flags for this item prototype. + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.flags View documentation} + */ + readonly flags: ItemPrototypeFlags + /** + * The results from launching this item in a rocket. + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.rocket_launch_products View documentation} + */ + readonly rocket_launch_products: Product[] + /** + * If this item can be mod-opened. + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.can_be_mod_opened View documentation} + */ + readonly can_be_mod_opened: boolean + /** + * Size of full magazine; `nil` if this is not an ammo item. + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.magazine_size View documentation} + */ + readonly magazine_size: float | undefined + /** + * Amount of extra time (in ticks) it takes to reload the weapon after depleting the magazine or `nil` if this is + * not an ammo item. + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.reload_time View documentation} + */ + readonly reload_time: float | undefined + /** + * The prototype of this armor equipment grid or `nil` if none or this is not an armor item. + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.equipment_grid View documentation} + */ + readonly equipment_grid: LuaEquipmentGridPrototype | undefined + /** + * Resistances of this armour item, indexed by damage type name. `nil` if not an armor or the armor has no resistances. + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.resistances View documentation} + */ + readonly resistances: Record | undefined + /** + * The inventory size bonus for this armor prototype. `nil` if this isn't an armor prototype. + * + * *Can only be used if this is ArmorPrototype* + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.inventory_size_bonus View documentation} + */ + readonly inventory_size_bonus: uint | undefined + /** + * The capsule action for this capsule item prototype or `nil` if this isn't a capsule item prototype. + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.capsule_action View documentation} + */ + readonly capsule_action: CapsuleAction | undefined + /** + * The gun attack parameters or `nil` if not a gun item prototype. + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.attack_parameters View documentation} + */ + readonly attack_parameters: AttackParameters | undefined + /** + * The main inventory size for item-with-inventory-prototype. `nil` if not an item-with-inventory-prototype. + * + * *Can only be used if this is ItemWithInventoryPrototype* + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.inventory_size View documentation} + */ + readonly inventory_size: uint | undefined + /** + * *Can only be used if this is ItemWithInventory* + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.item_filters View documentation} + */ + readonly item_filters: Record + /** + * *Can only be used if this is ItemWithInventory* + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.item_group_filters View documentation} + */ + readonly item_group_filters: Record + /** + * *Can only be used if this is ItemWithInventory* + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.item_subgroup_filters View documentation} + */ + readonly item_subgroup_filters: Record + /** + * The filter mode used by this item with inventory. + * + * *Can only be used if this is ItemWithInventory* + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.filter_mode View documentation} + */ + readonly filter_mode: string + /** + * The insertion priority mode used by this item with inventory. + * + * *Can only be used if this is ItemWithInventory* + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.insertion_priority_mode View documentation} + */ + readonly insertion_priority_mode: string + /** + * The localised string used when the player attempts to put items into this item with inventory that aren't allowed. + * + * *Can only be used if this is ItemWithInventory* + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.localised_filter_message View documentation} + */ + readonly localised_filter_message: LocalisedString + /** + * If this item with inventory extends the inventory it resides in by default. + * + * *Can only be used if this is ItemWithInventory* + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.extend_inventory_by_default View documentation} + */ + readonly extend_inventory_by_default: boolean + /** + * The default label color used for this item with label. `nil` if not defined or if this isn't an item with label. + * + * *Can only be used if this is ItemWithLabel* + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.default_label_color View documentation} + */ + readonly default_label_color: ColorTable | undefined + /** + * If true, and this item with label has a label it is drawn in place of the normal number when held in the cursor. + * + * *Can only be used if this is ItemWithLabel* + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.draw_label_for_cursor_render View documentation} + */ + readonly draw_label_for_cursor_render: boolean + /** + * The repairing speed if this is a repairing tool; otherwise `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.speed View documentation} + */ + readonly speed: float | undefined + /** + * Effects of this module; `nil` if this is not a module. + * + * *Can only be used if this is ModuleItem* + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.module_effects View documentation} + */ + readonly module_effects: ModuleEffects | undefined + /** + * The name of a {@link LuaModuleCategoryPrototype}. Used when upgrading modules: Ctrl + click modules into an entity + * and it will replace lower tier modules of the same category with higher tier modules. + * + * *Can only be used if this is ModuleItem* + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.category View documentation} + */ + readonly category: string + /** + * Tier of the module inside its category. Used when upgrading modules: Ctrl + click modules into an entity and it + * will replace lower tier modules with higher tier modules if they have the same category. + * + * *Can only be used if this is ModuleItem* + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.tier View documentation} + */ + readonly tier: uint + /** + * An array of recipe names this module is allowed to work with. Empty when all recipes are allowed. + * + * *Can only be used if this is ModuleItem* + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.limitations View documentation} + */ + readonly limitations: string[] + /** + * The limitation message key used when the player attempts to use this modules in some place it's not allowed. + * + * *Can only be used if this is ModuleItem* + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.limitation_message_key View documentation} + */ + readonly limitation_message_key: string + /** + * The straight rail prototype used for this rail planner prototype. + * + * *Can only be used if this is RailPlanner* + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.straight_rail View documentation} + */ + readonly straight_rail: LuaEntityPrototype + /** + * The curved rail prototype used for this rail planner prototype. + * + * *Can only be used if this is RailPlanner* + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.curved_rail View documentation} + */ + readonly curved_rail: LuaEntityPrototype + /** + * The repair result of this repair tool prototype or `nil` if this isn't a repair tool prototype. + * + * *Can only be used if this is RepairTool* + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.repair_result View documentation} + */ + readonly repair_result: TriggerItem[] | undefined + /** + * The color used when doing normal selection with this selection tool prototype. + * + * *Can only be used if this is SelectionTool* + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.selection_border_color View documentation} + */ + readonly selection_border_color: ColorTable + /** + * The color used when doing alt selection with this selection tool prototype. + * + * *Can only be used if this is SelectionTool* + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.alt_selection_border_color View documentation} + */ + readonly alt_selection_border_color: ColorTable + /** + * Flags that affect which entities will be selected. + * + * *Can only be used if this is SelectionTool* + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.selection_mode_flags View documentation} + */ + readonly selection_mode_flags: SelectionModeFlags + /** + * Flags that affect which entities will be selected during alternate selection. + * + * *Can only be used if this is SelectionTool* + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.alt_selection_mode_flags View documentation} + */ + readonly alt_selection_mode_flags: SelectionModeFlags + /** + * *Can only be used if this is SelectionTool* + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.selection_cursor_box_type View documentation} + */ + readonly selection_cursor_box_type: string + /** + * *Can only be used if this is SelectionTool* + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.alt_selection_cursor_box_type View documentation} + */ + readonly alt_selection_cursor_box_type: string + /** + * If tiles area always included when doing selection with this selection tool prototype. + * + * *Can only be used if this is SelectionTool* + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.always_include_tiles View documentation} + */ + readonly always_include_tiles: boolean + /** + * The entity filter mode used by this selection tool. + * + * *Can only be used if this is SelectionTool* + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.entity_filter_mode View documentation} + */ + readonly entity_filter_mode: string + /** + * The alt entity filter mode used by this selection tool. + * + * *Can only be used if this is SelectionTool* + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.alt_entity_filter_mode View documentation} + */ + readonly alt_entity_filter_mode: string + /** + * The tile filter mode used by this selection tool. + * + * *Can only be used if this is SelectionTool* + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.tile_filter_mode View documentation} + */ + readonly tile_filter_mode: string + /** + * The alt tile filter mode used by this selection tool. + * + * *Can only be used if this is SelectionTool* + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.alt_tile_filter_mode View documentation} + */ + readonly alt_tile_filter_mode: string + /** + * The entity filters used by this selection tool indexed by entity name. + * + * *Can only be used if this is SelectionTool* + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.entity_filters View documentation} + */ + readonly entity_filters: Record + /** + * The alt entity filters used by this selection tool indexed by entity name. + * + * *Can only be used if this is SelectionTool* + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.alt_entity_filters View documentation} + */ + readonly alt_entity_filters: Record + /** + * The entity type filters used by this selection tool indexed by entity type. + * + * **Note**: The boolean value is meaningless and is used to allow easy lookup if a type exists in the dictionary. + * + * *Can only be used if this is SelectionTool* + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.entity_type_filters View documentation} + */ + readonly entity_type_filters: Record + /** + * The alt entity type filters used by this selection tool indexed by entity type. + * + * **Note**: The boolean value is meaningless and is used to allow easy lookup if a type exists in the dictionary. + * + * *Can only be used if this is SelectionTool* + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.alt_entity_type_filters View documentation} + */ + readonly alt_entity_type_filters: Record + /** + * The tile filters used by this selection tool indexed by tile name. + * + * *Can only be used if this is SelectionTool* + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.tile_filters View documentation} + */ + readonly tile_filters: Record + /** + * The alt tile filters used by this selection tool indexed by tile name. + * + * *Can only be used if this is SelectionTool* + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.alt_tile_filters View documentation} + */ + readonly alt_tile_filters: Record + /** + * The number of entity filters this deconstruction item has or `nil` if this isn't a deconstruction item prototype. + * + * *Can only be used if this is DeconstructionItem* + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.entity_filter_slots View documentation} + */ + readonly entity_filter_slots: uint | undefined + /** + * The number of tile filters this deconstruction item has or `nil` if this isn't a deconstruction item prototype. + * + * *Can only be used if this is DeconstructionItem* + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.tile_filter_slots View documentation} + */ + readonly tile_filter_slots: uint | undefined + /** + * The durability message key used when displaying the durability of this tool. + * + * *Can only be used if this is ToolItem* + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.durability_description_key View documentation} + */ + readonly durability_description_key: string + /** + * The durability of this tool item or `nil` if not a tool item. + * + * *Can only be used if this is ToolItem* + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.durability View documentation} + */ + readonly durability: double | undefined + /** + * If this tool item has infinite durability. `nil` if not a tool type item. + * + * *Can only be used if this is ToolItem* + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.infinite View documentation} + */ + readonly infinite: boolean | undefined + /** + * How many filters an upgrade item has. `nil` if not a upgrade item. + * + * *Can only be used if this is UpgradeItem* + * + * {@link https://lua-api.factorio.com/next/LuaItemPrototype.html#LuaItemPrototype.mapper_count View documentation} + */ + readonly mapper_count: uint | undefined + /** + * 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: "LuaItemPrototype" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * A reference to an item and count owned by some external entity. + * + * **Note**: In most instances this is a simple reference as in: it points at a specific slot in an inventory and not + * the item in the slot. + * + * **Note**: In the instance this references an item on a {@link LuaTransportLine} the reference is only guaranteed to + * stay valid (and refer to the same item) as long as nothing changes the transport line. + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html View documentation} + * + * @noSelf + */ +interface LuaItemStack { + /** + * Is this blueprint item setup? I.e. is it a non-empty blueprint? + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.is_blueprint_setup View documentation} + */ + is_blueprint_setup(): boolean + /** + * The entities in this blueprint. + * + * *Can only be used if this is BlueprintItem* + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.get_blueprint_entities View documentation} + */ + get_blueprint_entities(): BlueprintEntity[] + /** + * Set new entities to be a part of this blueprint. + * + * *Can only be used if this is BlueprintItem* + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.set_blueprint_entities View documentation} + * + * @param entities - The new blueprint entities. + */ + set_blueprint_entities(entities: BlueprintEntity[]): void + /** + * Add ammo to this ammo item. + * + * *Can only be used if this is AmmoItem* + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.add_ammo View documentation} + * + * @param amount - Amount of ammo to add. + */ + add_ammo(amount: float): void + /** + * Remove ammo from this ammo item. + * + * *Can only be used if this is AmmoItem* + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.drain_ammo View documentation} + * + * @param amount - Amount of ammo to remove. + */ + drain_ammo(amount: float): void + /** + * Add durability to this tool item. + * + * *Can only be used if this is ToolItem* + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.add_durability View documentation} + * + * @param amount - Amount of durability to add. + */ + add_durability(amount: double): void + /** + * Remove durability from this tool item. + * + * *Can only be used if this is ToolItem* + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.drain_durability View documentation} + * + * @param amount - Amount of durability to remove. + */ + drain_durability(amount: double): void + /** + * Would a call to {@link LuaItemStack.set_stack LuaItemStack::set_stack} succeed? + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.can_set_stack View documentation} + * + * @param stack - Stack that would be set, possibly `nil`. + */ + can_set_stack(stack?: ItemStackIdentification): boolean + /** + * Set this item stack to another item stack. + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.set_stack View documentation} + * + * @param stack - Item stack to set this one to. Omitting this parameter or passing `nil` will clear this item + * stack, as if by calling {@link LuaItemStack.clear LuaItemStack::clear}. + * @returns Was the stack set successfully? + */ + set_stack(stack?: ItemStackIdentification): boolean + /** + * Transfers the given item stack into this item stack. + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.transfer_stack View documentation} + * + * @param stack + * @returns True if the full stack was transferred. + */ + transfer_stack(stack: ItemStackIdentification): boolean + /** + * Export a supported item (blueprint, blueprint-book, deconstruction-planner, upgrade-planner, item-with-tags) to a string + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.export_stack View documentation} + * + * @returns The exported string + */ + export_stack(): string + /** + * Import a supported item (blueprint, blueprint-book, deconstruction-planner, upgrade-planner, item-with-tags) from a string + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.import_stack View documentation} + * + * @param data - The string to import + * @returns 0 if the import succeeded with no errors. -1 if the import succeeded with errors. 1 if the import failed. + */ + import_stack(data: string): int + /** + * Swaps this item stack with the given item stack if allowed. + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.swap_stack View documentation} + * + * @param stack + * @returns If the 2 stacks were swapped successfully. + */ + swap_stack(stack: LuaItemStack): boolean + /** + * Clear this item stack. + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.clear View documentation} + */ + clear(): void + /** + * A list of the tiles in this blueprint. + * + * *Can only be used if this is BlueprintItem* + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.get_blueprint_tiles View documentation} + */ + get_blueprint_tiles(): Tile[] + /** + * Set specific tiles in this blueprint. + * + * *Can only be used if this is BlueprintItem* + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.set_blueprint_tiles View documentation} + * + * @param tiles - Tiles to be a part of the blueprint. + */ + set_blueprint_tiles(tiles: Tile[]): void + /** + * Access the inner inventory of an item. + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.get_inventory View documentation} + * + * @param inventory - Index of the inventory to access -- currently can only be {@link defines.inventory.item_main}. + * @returns Or `nil` if there is no inventory with the given index. + */ + get_inventory(inventory: defines.inventory): LuaInventory | undefined + /** + * Build this blueprint + * + * **Note**: Built entities can be come invalid between the building of the blueprint and the function returning if + * by_player or raise_built is used and one of those events invalidates the entity. + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.build_blueprint View documentation} + * + * @returns Array of created ghosts + */ + build_blueprint(params: { + /** Surface to build on */ + readonly surface: SurfaceIdentification + /** Force to use for the building */ + readonly force: ForceIdentification + /** The position to build at */ + readonly position: Position + /** When true, anything that can be built is else nothing is built if any one thing can't be built */ + readonly force_build?: boolean + /** The direction to use when building */ + readonly direction?: defines.direction + /** If chunks covered by fog-of-war are skipped. */ + readonly skip_fog_of_war?: boolean + /** + * The player to use if any. If provided {@link defines.events.on_built_entity} will also be fired on successful + * entity creation. + */ + readonly by_player?: PlayerIdentification + /** + * If true; {@link defines.events.script_raised_built} will be fired on successful entity creation. Note: this is + * ignored if by_player is provided. + */ + readonly raise_built?: boolean + }): LuaEntity[] + /** + * Deconstruct the given area with this deconstruction item. + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.deconstruct_area View documentation} + */ + deconstruct_area(params: { + /** Surface to deconstruct on */ + readonly surface: SurfaceIdentification + /** Force to use for the deconstruction */ + readonly force: ForceIdentification + /** The area to deconstruct */ + readonly area: BoundingBox + /** If chunks covered by fog-of-war are skipped. */ + readonly skip_fog_of_war?: boolean + /** The player to use if any. */ + readonly by_player?: PlayerIdentification + }): void + /** + * Cancel deconstruct the given area with this deconstruction item. + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.cancel_deconstruct_area View documentation} + */ + cancel_deconstruct_area(params: { + /** Surface to cancel deconstruct on */ + readonly surface: SurfaceIdentification + /** Force to use for canceling deconstruction */ + readonly force: ForceIdentification + /** The area to deconstruct */ + readonly area: BoundingBox + /** If chunks covered by fog-of-war are skipped. */ + readonly skip_fog_of_war?: boolean + /** The player to use if any. */ + readonly by_player?: PlayerIdentification + }): void + /** + * Sets up this blueprint using the found blueprintable entities/tiles on the surface. + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.create_blueprint View documentation} + * + * @returns The blueprint entity index to source entity mapping. + */ + create_blueprint(params: { + /** Surface to create from */ + readonly surface: SurfaceIdentification + /** Force to use for the creation */ + readonly force: ForceIdentification + /** The bounding box */ + readonly area: BoundingBox + /** + * When true, blueprintable tiles are always included in the blueprint. When false they're only included if no + * entities exist in the setup area. + */ + readonly always_include_tiles?: boolean + /** When true, entities are included in the blueprint. Defaults to true. */ + readonly include_entities?: boolean + /** When true, modules are included in the blueprint. Defaults to true. */ + readonly include_modules?: boolean + /** When true, station names are included in the blueprint. Defaults to false. */ + readonly include_station_names?: boolean + /** When true, trains are included in the blueprint. Defaults to false. */ + readonly include_trains?: boolean + /** When true, train fuel is included in the blueprint, Defaults to true. */ + readonly include_fuel?: boolean + }): Record + /** + * Gets the tag with the given name or returns `nil` if it doesn't exist. + * + * *Can only be used if this is ItemWithTags* + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.get_tag View documentation} + * + * @param tag_name + */ + get_tag(tag_name: string): AnyBasic | undefined + /** + * Sets the tag with the given name and value. + * + * *Can only be used if this is ItemWithTags* + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.set_tag View documentation} + * + * @param tag_name + * @param tag + */ + set_tag(tag_name: string, tag: AnyBasic): AnyBasic + /** + * Removes a tag with the given name. + * + * *Can only be used if this is ItemWithTags* + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.remove_tag View documentation} + * + * @param tag + * @returns If the tag existed and was removed. + */ + remove_tag(tag: string): boolean + /** + * Clears this blueprint item. + * + * *Can only be used if this is BlueprintItem* + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.clear_blueprint View documentation} + */ + clear_blueprint(): void + /** + * Gets the entity filter at the given index for this deconstruction item. + * + * *Can only be used if this is DeconstructionItem* + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.get_entity_filter View documentation} + * + * @param index + */ + get_entity_filter(index: uint): string + /** + * Sets the entity filter at the given index for this deconstruction item. + * + * *Can only be used if this is DeconstructionItem* + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.set_entity_filter View documentation} + * + * @param index + * @param filter - Setting to nil erases the filter. + * @returns If the new filter was set (was valid.) + */ + set_entity_filter(index: uint, filter: string | LuaEntityPrototype | LuaEntity | undefined): boolean + /** + * Gets the tile filter at the given index for this deconstruction item. + * + * *Can only be used if this is DeconstructionItem* + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.get_tile_filter View documentation} + * + * @param index + */ + get_tile_filter(index: uint): string + /** + * Sets the tile filter at the given index for this deconstruction item. + * + * *Can only be used if this is DeconstructionItem* + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.set_tile_filter View documentation} + * + * @param index + * @param filter - Setting to nil erases the filter. + * @returns If the new filter was set (was valid.) + */ + set_tile_filter(index: uint, filter: string | LuaTilePrototype | LuaTile | undefined): boolean + /** + * Clears all settings/filters on this deconstruction item resetting it to default values. + * + * *Can only be used if this is DeconstructionItem* + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.clear_deconstruction_item View documentation} + */ + clear_deconstruction_item(): void + /** + * Clears all settings/filters on this upgrade item resetting it to default values. + * + * *Can only be used if this is UpgradeItem* + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.clear_upgrade_item View documentation} + */ + clear_upgrade_item(): void + /** + * Gets the filter at the given index for this upgrade item. + * + * *Can only be used if this is UpgradeItem* + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.get_mapper View documentation} + * + * @param index - The index of the mapper to read. + * @param type - 'from' or 'to'. + */ + get_mapper(index: uint, type: "from" | "to"): UpgradeFilter + /** + * Sets the module filter at the given index for this upgrade item. + * + * *Can only be used if this is UpgradeItem* + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.set_mapper View documentation} + * + * @param index - The index of the mapper to set. + * @param type - `from` or `to`. + * @param filter - The filter to set or `nil` + */ + set_mapper(index: uint, type: string, filter: UpgradeFilter | undefined): void + /** + * Gets the number of entities in this blueprint item. + * + * *Can only be used if this is BlueprintItem* + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.get_blueprint_entity_count View documentation} + */ + get_blueprint_entity_count(): uint + /** + * Gets the tags for the given blueprint entity index in this blueprint item. + * + * *Can only be used if this is BlueprintItem* + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.get_blueprint_entity_tags View documentation} + * + * @param index + */ + get_blueprint_entity_tags(index: uint): Tags + /** + * Sets the tags on the given blueprint entity index in this blueprint item. + * + * *Can only be used if this is BlueprintItem* + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.set_blueprint_entity_tags View documentation} + * + * @param index - The entity index + * @param tags + */ + set_blueprint_entity_tags(index: uint, tags: Tags): void + /** + * Gets the given tag on the given blueprint entity index in this blueprint item. + * + * *Can only be used if this is BlueprintItem* + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.get_blueprint_entity_tag View documentation} + * + * @param index - The entity index. + * @param tag - The tag to get. + */ + get_blueprint_entity_tag(index: uint, tag: string): AnyBasic + /** + * Sets the given tag on the given blueprint entity index in this blueprint item. + * + * *Can only be used if this is BlueprintItem* + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.set_blueprint_entity_tag View documentation} + * + * @param index - The entity index. + * @param tag - The tag to set. + * @param value - The tag value to set or `nil` to clear the tag. + */ + set_blueprint_entity_tag(index: uint, tag: string, value: AnyBasic | undefined): void + /** + * Creates the equipment grid for this item if it doesn't exist and this is an item-with-entity-data that supports + * equipment grids. + * + * *Can only be used if this is ItemWithEntityData* + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.create_grid View documentation} + */ + create_grid(): LuaEquipmentGrid + /** + * Is this valid for reading? Differs from the usual `valid` in that `valid` will be `true` even if the item stack + * is blank but the entity that holds it is still valid. + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.valid_for_read View documentation} + */ + readonly valid_for_read: boolean + /** + * Prototype of the item held in this stack. + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.prototype View documentation} + */ + readonly prototype: LuaItemPrototype + /** + * Prototype name of the item held in this stack. + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.name View documentation} + */ + readonly name: string + /** + * Type of the item prototype. + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.type View documentation} + */ + readonly type: string + /** + * Number of items in this stack. + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.count View documentation} + */ + count: uint + /** + * The equipment grid of this item or `nil` if this item doesn't have a grid. + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.grid View documentation} + */ + readonly grid: LuaEquipmentGrid | undefined + /** + * How much health the item has, as a number in range [0, 1]. + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.health View documentation} + */ + health: float + /** + * Durability of the contained item. Automatically capped at the item's maximum durability. + * + * **Note**: When used on a non-tool item, the value of this attribute is `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.durability View documentation} + */ + durability: double | undefined + /** + * Number of bullets left in the magazine. + * + * *Can only be used if this is AmmoItem* + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.ammo View documentation} + */ + ammo: uint + /** + * Icons of a blueprint item, blueprint book, deconstruction item or upgrade planner. An item that doesn't have + * icons returns nil on read and throws error on write. + * + * *Can only be used if this is BlueprintItem* + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.blueprint_icons View documentation} + */ + blueprint_icons: BlueprintSignalIcon[] | undefined + /** + * The snapping grid size in this blueprint item or nil if snapping is not enabled. + * + * *Can only be used if this is BlueprintItem* + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.blueprint_snap_to_grid View documentation} + */ + blueprint_snap_to_grid: Position | undefined + /** + * The offset from the absolute grid or nil if absolute snapping is not enabled. + * + * *Can only be used if this is BlueprintItem* + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.blueprint_position_relative_to_grid View documentation} + */ + blueprint_position_relative_to_grid: Position | undefined + /** + * If absolute snapping is enabled on this blueprint item. + * + * *Can only be used if this is BlueprintItem* + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.blueprint_absolute_snapping View documentation} + */ + blueprint_absolute_snapping: boolean + /** + * The current label for this item. Nil when none. + * + * *Can only be used if this is ItemWithLabel* + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.label View documentation} + */ + label: string | undefined + /** + * The current label color for this item. Nil when none. + * + * *Can only be used if this is ItemWithLabel* + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.label_color View documentation} + */ + label_color: Color | undefined + /** + * If the label for this item can be manually changed. When false the label can only be changed through the API. + * + * *Can only be used if this is ItemWithLabel* + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.allow_manual_label_change View documentation} + */ + allow_manual_label_change: boolean + /** + * Raw materials required to build this blueprint. Result is a dictionary mapping each item prototype name to the + * required count. + * + * *Can only be used if this is BlueprintItem* + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.cost_to_build View documentation} + */ + readonly cost_to_build: Record + /** + * If this item extends the inventory it resides in (provides its contents for counts, crafting, insertion). Only + * callable on items with inventories. + * + * *Can only be used if this is ItemWithInventory* + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.extends_inventory View documentation} + */ + extends_inventory: boolean + /** + * The insertion mode priority this ItemWithInventory uses when items are inserted into an inventory it resides in. + * Only callable on items with inventories. + * + * *Can only be used if this is ItemWithInventory* + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.prioritize_insertion_mode View documentation} + */ + prioritize_insertion_mode: string + /** + * The default icons for a blueprint item. + * + * *Can only be used if this is BlueprintItem* + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.default_icons View documentation} + */ + readonly default_icons: BlueprintItemIcon[] + /** + * *Can only be used if this is ItemWithTags* + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.tags View documentation} + */ + tags: Tags + /** + * The custom description this item-with-tags. This is shown over the normal item description if this is set to a + * non-empty value. + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.custom_description View documentation} + */ + custom_description: LocalisedString + /** + * The entity filters for this deconstruction item. The attribute is a sparse array with the keys representing the + * index of the filter. All strings in this array must be entity prototype names that don't have the + * `"not-deconstructable"` flag set and are either a `cliff` or marked as `minable`. + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.entity_filters View documentation} + */ + entity_filters: string[] + /** + * The tile filters for this deconstruction item. The attribute is a sparse array with the keys representing the + * index of the filter. All strings in this array must be tile prototype names. + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.tile_filters View documentation} + */ + tile_filters: string[] + /** + * The blacklist/whitelist entity filter mode for this deconstruction item. + * + * *Can only be used if this is DeconstructionItem* + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.entity_filter_mode View documentation} + */ + entity_filter_mode: defines.deconstruction_item.entity_filter_mode + /** + * The blacklist/whitelist tile filter mode for this deconstruction item. + * + * *Can only be used if this is DeconstructionItem* + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.tile_filter_mode View documentation} + */ + tile_filter_mode: defines.deconstruction_item.tile_filter_mode + /** + * The tile selection mode for this deconstruction item. + * + * *Can only be used if this is DeconstructionItem* + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.tile_selection_mode View documentation} + */ + tile_selection_mode: defines.deconstruction_item.tile_selection_mode + /** + * If this deconstruction item is set to allow trees and rocks only. + * + * *Can only be used if this is DeconstructionItem* + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.trees_and_rocks_only View documentation} + */ + trees_and_rocks_only: boolean + /** + * The number of entity filters this deconstruction item supports. + * + * *Can only be used if this is DeconstructionItem* + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.entity_filter_count View documentation} + */ + readonly entity_filter_count: uint + /** + * The number of tile filters this deconstruction item supports. + * + * *Can only be used if this is DeconstructionItem* + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.tile_filter_count View documentation} + */ + readonly tile_filter_count: uint + /** + * The active blueprint index for this blueprint book. May be `nil`. + * + * *Can only be used if this is BlueprintBookItem* + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.active_index View documentation} + */ + active_index: uint | undefined + /** + * The unique identifier for this item if it has one, `nil` otherwise. Note that this ID stays the same no matter + * where the item is moved to. + * + * Only these types of items have unique IDs: + * + * - `"armor"` + * - `"spidertron-remote"` + * - `"selection-tool"` + * - `"copy-paste-tool"` + * - `"upgrade-item"` + * - `"deconstruction-item"` + * - `"blueprint"` + * - `"blueprint-book"` + * - `"item-with-entity-data"` + * - `"item-with-inventory"` + * - `"item-with-tags"` + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.item_number View documentation} + */ + readonly item_number: uint | undefined + /** + * If this item is a spidertron remote that has a spidertron bound to it, it returns the connected spider-vehicle + * entity, `nil` otherwise. + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.connected_entity View documentation} + */ + connected_entity: LuaEntity | undefined + /** + * If this is a blueprint item. + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.is_blueprint View documentation} + */ + readonly is_blueprint: boolean + /** + * If this is a blueprint book item. + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.is_blueprint_book View documentation} + */ + readonly is_blueprint_book: boolean + /** + * If this is a module item. + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.is_module View documentation} + */ + readonly is_module: boolean + /** + * If this is a tool item. + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.is_tool View documentation} + */ + readonly is_tool: boolean + /** + * If this is a mining tool item. + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.is_mining_tool View documentation} + */ + readonly is_mining_tool: boolean + /** + * If this is an armor item. + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.is_armor View documentation} + */ + readonly is_armor: boolean + /** + * If this is a repair tool item. + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.is_repair_tool View documentation} + */ + readonly is_repair_tool: boolean + /** + * If this is an item with label item. + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.is_item_with_label View documentation} + */ + readonly is_item_with_label: boolean + /** + * If this is an item with inventory item. + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.is_item_with_inventory View documentation} + */ + readonly is_item_with_inventory: boolean + /** + * If this is an item with entity data item. + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.is_item_with_entity_data View documentation} + */ + readonly is_item_with_entity_data: boolean + /** + * If this is a selection tool item. + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.is_selection_tool View documentation} + */ + readonly is_selection_tool: boolean + /** + * If this is an item with tags item. + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.is_item_with_tags View documentation} + */ + readonly is_item_with_tags: boolean + /** + * If this is a deconstruction tool item. + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.is_deconstruction_item View documentation} + */ + readonly is_deconstruction_item: boolean + /** + * If this is a upgrade item. + * + * {@link https://lua-api.factorio.com/next/LuaItemStack.html#LuaItemStack.is_upgrade_item View documentation} + */ + readonly is_upgrade_item: 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: "LuaItemStack" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * Control behavior for lamps. + * + * {@link https://lua-api.factorio.com/next/LuaLampControlBehavior.html View documentation} + * + * @noSelf + */ +interface LuaLampControlBehavior extends LuaGenericOnOffControlBehavior { + /** + * `true` if the lamp should set the color from the circuit network signals. + * + * {@link https://lua-api.factorio.com/next/LuaLampControlBehavior.html#LuaLampControlBehavior.use_colors View documentation} + */ + use_colors: boolean + /** + * The color the lamp is showing or `nil` if not using any color. + * + * {@link https://lua-api.factorio.com/next/LuaLampControlBehavior.html#LuaLampControlBehavior.color View documentation} + */ + readonly color: ColorTable | undefined + /** + * 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: "LuaLampControlBehavior" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * A lazily loaded value. For performance reasons, we sometimes return a custom lazily-loaded value type instead of the + * native Lua value. This custom type lazily constructs the necessary value when + * {@link LuaLazyLoadedValue.get LuaLazyLoadedValue::get} is called, therefore preventing its unnecessary construction in + * some cases. + * + * An instance of LuaLazyLoadedValue is only valid during the event it was created from and cannot be saved. + * + * {@link https://lua-api.factorio.com/next/LuaLazyLoadedValue.html View documentation} + * + * @noSelf + */ +interface LuaLazyLoadedValue { + /** + * Gets the value of this lazy loaded value. + * + * {@link https://lua-api.factorio.com/next/LuaLazyLoadedValue.html#LuaLazyLoadedValue.get View documentation} + */ + get(): T + /** + * 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: "LuaLazyLoadedValue" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * Logistic cell of a particular {@link LuaEntity}. A "Logistic Cell" is the given name for settings and properties used + * by what would normally be seen as a "Roboport". A logistic cell however doesn't have to be attached to the roboport + * entity (the character has one for the personal roboport). + * + * {@link https://lua-api.factorio.com/next/LuaLogisticCell.html View documentation} + * + * @noSelf + */ +interface LuaLogisticCell { + /** + * Is a given position within the logistic range of this cell? + * + * {@link https://lua-api.factorio.com/next/LuaLogisticCell.html#LuaLogisticCell.is_in_logistic_range View documentation} + * + * @param position + */ + is_in_logistic_range(position: Position): boolean + /** + * Is a given position within the construction range of this cell? + * + * {@link https://lua-api.factorio.com/next/LuaLogisticCell.html#LuaLogisticCell.is_in_construction_range View documentation} + * + * @param position + */ + is_in_construction_range(position: Position): boolean + /** + * Are two cells neighbours? + * + * {@link https://lua-api.factorio.com/next/LuaLogisticCell.html#LuaLogisticCell.is_neighbour_with View documentation} + * + * @param other + */ + is_neighbour_with(other: LuaLogisticCell): boolean + /** + * Logistic radius of this cell. + * + * {@link https://lua-api.factorio.com/next/LuaLogisticCell.html#LuaLogisticCell.logistic_radius View documentation} + */ + readonly logistic_radius: float + /** + * Logistic connection distance of this cell. + * + * {@link https://lua-api.factorio.com/next/LuaLogisticCell.html#LuaLogisticCell.logistics_connection_distance View documentation} + */ + readonly logistics_connection_distance: float + /** + * Construction radius of this cell. + * + * {@link https://lua-api.factorio.com/next/LuaLogisticCell.html#LuaLogisticCell.construction_radius View documentation} + */ + readonly construction_radius: float + /** + * Number of stationed logistic robots in this cell. + * + * {@link https://lua-api.factorio.com/next/LuaLogisticCell.html#LuaLogisticCell.stationed_logistic_robot_count View documentation} + */ + readonly stationed_logistic_robot_count: uint + /** + * Number of stationed construction robots in this cell. + * + * {@link https://lua-api.factorio.com/next/LuaLogisticCell.html#LuaLogisticCell.stationed_construction_robot_count View documentation} + */ + readonly stationed_construction_robot_count: uint + /** + * `true` if this is a mobile cell. In vanilla, only the logistic cell created by a character's personal roboport is mobile. + * + * {@link https://lua-api.factorio.com/next/LuaLogisticCell.html#LuaLogisticCell.mobile View documentation} + */ + readonly mobile: boolean + /** + * `true` if this cell is active. + * + * {@link https://lua-api.factorio.com/next/LuaLogisticCell.html#LuaLogisticCell.transmitting View documentation} + */ + readonly transmitting: boolean + /** + * Radius at which the robots hover when waiting to be charged. + * + * {@link https://lua-api.factorio.com/next/LuaLogisticCell.html#LuaLogisticCell.charge_approach_distance View documentation} + */ + readonly charge_approach_distance: float + /** + * Number of robots currently charging. + * + * {@link https://lua-api.factorio.com/next/LuaLogisticCell.html#LuaLogisticCell.charging_robot_count View documentation} + */ + readonly charging_robot_count: uint + /** + * Number of robots waiting to charge. + * + * {@link https://lua-api.factorio.com/next/LuaLogisticCell.html#LuaLogisticCell.to_charge_robot_count View documentation} + */ + readonly to_charge_robot_count: uint + /** + * This cell's owner. + * + * {@link https://lua-api.factorio.com/next/LuaLogisticCell.html#LuaLogisticCell.owner View documentation} + */ + readonly owner: LuaEntity + /** + * The network that owns this cell or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaLogisticCell.html#LuaLogisticCell.logistic_network View documentation} + */ + readonly logistic_network: LuaLogisticNetwork | undefined + /** + * Neighbouring cells. + * + * {@link https://lua-api.factorio.com/next/LuaLogisticCell.html#LuaLogisticCell.neighbours View documentation} + */ + readonly neighbours: LuaLogisticCell[] + /** + * Robots currently being charged. + * + * {@link https://lua-api.factorio.com/next/LuaLogisticCell.html#LuaLogisticCell.charging_robots View documentation} + */ + readonly charging_robots: LuaEntity[] + /** + * Robots waiting to charge. + * + * {@link https://lua-api.factorio.com/next/LuaLogisticCell.html#LuaLogisticCell.to_charge_robots View documentation} + */ + readonly to_charge_robots: LuaEntity[] + /** + * 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: "LuaLogisticCell" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * Control behavior for logistic chests. + * + * {@link https://lua-api.factorio.com/next/LuaLogisticContainerControlBehavior.html View documentation} + * + * @noSelf + */ +interface LuaLogisticContainerControlBehavior extends LuaControlBehavior { + /** + * The circuit mode of operations for the logistic container. + * + * {@link https://lua-api.factorio.com/next/LuaLogisticContainerControlBehavior.html#LuaLogisticContainerControlBehavior.circuit_mode_of_operation View documentation} + */ + circuit_mode_of_operation: defines.control_behavior.logistic_container.circuit_mode_of_operation + /** + * 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: "LuaLogisticContainerControlBehavior" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * A single logistic network of a given force on a given surface. + * + * {@link https://lua-api.factorio.com/next/LuaLogisticNetwork.html View documentation} + * + * @noSelf + */ +interface LuaLogisticNetwork { + /** + * Count given or all items in the network or given members. + * + * {@link https://lua-api.factorio.com/next/LuaLogisticNetwork.html#LuaLogisticNetwork.get_item_count View documentation} + * + * @param item - Item name to count. If not given, gives counts of all items in the network. + * @param member - Logistic members to check, must be either `"storage"` or `"providers"`. If not given, gives count + * in the entire network. + */ + get_item_count(item?: string, member?: "storage" | "providers"): int + /** + * Get item counts for the entire network. + * + * {@link https://lua-api.factorio.com/next/LuaLogisticNetwork.html#LuaLogisticNetwork.get_contents View documentation} + * + * @returns A mapping of item prototype names to the number available in the network. + * @see {@link LuaInventory.get_contents} + */ + get_contents(): Record + /** + * Remove items from the logistic network. This will actually remove the items from some logistic chests. + * + * {@link https://lua-api.factorio.com/next/LuaLogisticNetwork.html#LuaLogisticNetwork.remove_item View documentation} + * + * @param item - What to remove. + * @param members - Which logistic members to remove from. Must be `"storage"`, `"passive-provider"`, `"buffer"`, or + * `"active-provider"`. If not specified, removes from the network in the usual order. + * @returns Number of items removed. + */ + remove_item( + item: ItemStackIdentification, + members?: "storage" | "passive-provider" | "buffer" | "active-provider" + ): uint + /** + * Insert items into the logistic network. This will actually insert the items into some logistic chests. + * + * {@link https://lua-api.factorio.com/next/LuaLogisticNetwork.html#LuaLogisticNetwork.insert View documentation} + * + * @param item - What to insert. + * @param members - Which logistic members to insert the items to. Must be `"storage"`, `"storage-empty"` (storage + * chests that are completely empty), `"storage-empty-slot"` (storage chests that have an empty slot), or + * `"requester"`. If not specified, inserts items into the logistic network in the usual order. + * @returns Number of items actually inserted. + */ + insert( + item: ItemStackIdentification, + members?: "storage" | "storage-empty" | "storage-empty-slot" | "requester" + ): uint + /** + * Find logistic cell closest to a given position. + * + * {@link https://lua-api.factorio.com/next/LuaLogisticNetwork.html#LuaLogisticNetwork.find_cell_closest_to View documentation} + * + * @param position + * @returns May be `nil` if no cell was found. + */ + find_cell_closest_to(position: Position): LuaLogisticCell | undefined + /** + * Find the 'best' logistic point with this item ID and from the given position or from given chest type. + * + * {@link https://lua-api.factorio.com/next/LuaLogisticNetwork.html#LuaLogisticNetwork.select_pickup_point View documentation} + * + * @returns May be `nil` if no point was found. + */ + select_pickup_point(params: { + /** Name of the item to select. */ + readonly name: string + /** When given, it will find the storage 'best' storage point from this position. */ + readonly position?: Position + /** Whether to consider buffer chests or not. Defaults to false. Only considered if selecting with position. */ + readonly include_buffers?: boolean + /** + * When given, it will find from only the specific type of member. Must be `"storage"`, `"passive-provider"`, + * `"buffer"` or `"active-provider"`. If not specified, selects with normal priorities. Not considered if + * position is specified. + */ + readonly members?: "storage" | "passive-provider" | "buffer" | "active-provider" + }): LuaLogisticPoint | undefined + /** + * Find a logistic point to drop the specific item stack. + * + * {@link https://lua-api.factorio.com/next/LuaLogisticNetwork.html#LuaLogisticNetwork.select_drop_point View documentation} + * + * @returns May be `nil` if no point was found. + */ + select_drop_point(params: { + /** Name of the item to select. */ + readonly stack: ItemStackIdentification + /** + * When given, it will find from only the specific type of member. Must be `"storage"`, `"storage-empty"`, + * `"storage-empty-slot"` or `"requester"`. If not specified, selects with normal priorities. + */ + readonly members?: "storage" | "storage-empty" | "storage-empty-slot" | "requester" + }): LuaLogisticPoint | undefined + /** + * The force this logistic network belongs to. + * + * {@link https://lua-api.factorio.com/next/LuaLogisticNetwork.html#LuaLogisticNetwork.force View documentation} + */ + readonly force: LuaForce + /** + * Number of logistic robots available for a job. + * + * {@link https://lua-api.factorio.com/next/LuaLogisticNetwork.html#LuaLogisticNetwork.available_logistic_robots View documentation} + */ + readonly available_logistic_robots: uint + /** + * The total number of logistic robots in the network (idle and active + in roboports). + * + * {@link https://lua-api.factorio.com/next/LuaLogisticNetwork.html#LuaLogisticNetwork.all_logistic_robots View documentation} + */ + readonly all_logistic_robots: uint + /** + * Number of construction robots available for a job. + * + * {@link https://lua-api.factorio.com/next/LuaLogisticNetwork.html#LuaLogisticNetwork.available_construction_robots View documentation} + */ + readonly available_construction_robots: uint + /** + * The total number of construction robots in the network (idle and active + in roboports). + * + * {@link https://lua-api.factorio.com/next/LuaLogisticNetwork.html#LuaLogisticNetwork.all_construction_robots View documentation} + */ + readonly all_construction_robots: uint + /** + * Maximum number of robots the network can work with. Currently only used for the personal roboport. + * + * {@link https://lua-api.factorio.com/next/LuaLogisticNetwork.html#LuaLogisticNetwork.robot_limit View documentation} + */ + readonly robot_limit: uint + /** + * All cells in this network. + * + * {@link https://lua-api.factorio.com/next/LuaLogisticNetwork.html#LuaLogisticNetwork.cells View documentation} + */ + readonly cells: LuaLogisticCell[] + /** + * All entities that have logistic provider points in this network. + * + * {@link https://lua-api.factorio.com/next/LuaLogisticNetwork.html#LuaLogisticNetwork.providers View documentation} + */ + readonly providers: LuaEntity[] + /** + * All entities that have empty logistic provider points in this network. + * + * {@link https://lua-api.factorio.com/next/LuaLogisticNetwork.html#LuaLogisticNetwork.empty_providers View documentation} + */ + readonly empty_providers: LuaEntity[] + /** + * All entities that have logistic requester points in this network. + * + * {@link https://lua-api.factorio.com/next/LuaLogisticNetwork.html#LuaLogisticNetwork.requesters View documentation} + */ + readonly requesters: LuaEntity[] + /** + * All entities that have logistic storage points in this network. + * + * {@link https://lua-api.factorio.com/next/LuaLogisticNetwork.html#LuaLogisticNetwork.storages View documentation} + */ + readonly storages: LuaEntity[] + /** + * All other entities that have logistic points in this network (inserters mostly). + * + * {@link https://lua-api.factorio.com/next/LuaLogisticNetwork.html#LuaLogisticNetwork.logistic_members View documentation} + */ + readonly logistic_members: LuaEntity[] + /** + * All things that have provider points in this network. + * + * {@link https://lua-api.factorio.com/next/LuaLogisticNetwork.html#LuaLogisticNetwork.provider_points View documentation} + */ + readonly provider_points: LuaLogisticPoint[] + /** + * All passive provider points in this network. + * + * {@link https://lua-api.factorio.com/next/LuaLogisticNetwork.html#LuaLogisticNetwork.passive_provider_points View documentation} + */ + readonly passive_provider_points: LuaLogisticPoint[] + /** + * All active provider points in this network. + * + * {@link https://lua-api.factorio.com/next/LuaLogisticNetwork.html#LuaLogisticNetwork.active_provider_points View documentation} + */ + readonly active_provider_points: LuaLogisticPoint[] + /** + * All things that have empty provider points in this network. + * + * {@link https://lua-api.factorio.com/next/LuaLogisticNetwork.html#LuaLogisticNetwork.empty_provider_points View documentation} + */ + readonly empty_provider_points: LuaLogisticPoint[] + /** + * All things that have requester points in this network. + * + * {@link https://lua-api.factorio.com/next/LuaLogisticNetwork.html#LuaLogisticNetwork.requester_points View documentation} + */ + readonly requester_points: LuaLogisticPoint[] + /** + * All things that have storage points in this network. + * + * {@link https://lua-api.factorio.com/next/LuaLogisticNetwork.html#LuaLogisticNetwork.storage_points View documentation} + */ + readonly storage_points: LuaLogisticPoint[] + /** + * All robots in this logistic network. + * + * {@link https://lua-api.factorio.com/next/LuaLogisticNetwork.html#LuaLogisticNetwork.robots View documentation} + */ + readonly robots: LuaEntity[] + /** + * All construction robots in this logistic network. + * + * {@link https://lua-api.factorio.com/next/LuaLogisticNetwork.html#LuaLogisticNetwork.construction_robots View documentation} + */ + readonly construction_robots: LuaEntity[] + /** + * All logistic robots in this logistic network. + * + * {@link https://lua-api.factorio.com/next/LuaLogisticNetwork.html#LuaLogisticNetwork.logistic_robots View documentation} + */ + readonly logistic_robots: LuaEntity[] + /** + * 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: "LuaLogisticNetwork" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * Logistic point of a particular {@link LuaEntity}. A "Logistic point" is the name given for settings and properties + * used by requester, provider, and storage points in a given logistic network. These "points" don't have to be a + * logistic container but often are. One other entity that can own several points is the "character" character type entity. + * + * {@link https://lua-api.factorio.com/next/LuaLogisticPoint.html View documentation} + * + * @noSelf + */ +interface LuaLogisticPoint { + /** + * The {@link LuaEntity} owner of this {@link LuaLogisticPoint}. + * + * {@link https://lua-api.factorio.com/next/LuaLogisticPoint.html#LuaLogisticPoint.owner View documentation} + */ + readonly owner: LuaEntity + readonly logistic_network: LuaLogisticNetwork + /** + * The Logistic member index of this logistic point. + * + * {@link https://lua-api.factorio.com/next/LuaLogisticPoint.html#LuaLogisticPoint.logistic_member_index View documentation} + */ + readonly logistic_member_index: uint + /** + * The logistic filters for this logistic point or `nil` if this doesn't use logistic filters. + * + * **Note**: The returned array will always have an entry for each filter and will be indexed in sequence when not nil. + * + * {@link https://lua-api.factorio.com/next/LuaLogisticPoint.html#LuaLogisticPoint.filters View documentation} + */ + readonly filters: LogisticFilter[] | undefined + /** + * The logistic mode. + * + * {@link https://lua-api.factorio.com/next/LuaLogisticPoint.html#LuaLogisticPoint.mode View documentation} + */ + readonly mode: defines.logistic_mode + /** + * The force of this logistic point. + * + * **Note**: This will always be the same as the {@link LuaLogisticPoint.owner LuaLogisticPoint::owner} force. + * + * {@link https://lua-api.factorio.com/next/LuaLogisticPoint.html#LuaLogisticPoint.force View documentation} + */ + readonly force: LuaForce + /** + * Items targeted to be picked up from this logistic point by robots. + * + * {@link https://lua-api.factorio.com/next/LuaLogisticPoint.html#LuaLogisticPoint.targeted_items_pickup View documentation} + */ + readonly targeted_items_pickup: Record + /** + * Items targeted to be dropped off into this logistic point by robots. + * + * {@link https://lua-api.factorio.com/next/LuaLogisticPoint.html#LuaLogisticPoint.targeted_items_deliver View documentation} + */ + readonly targeted_items_deliver: Record + /** + * If this logistic point is using the exact mode. In exact mode robots never over-deliver requests. + * + * {@link https://lua-api.factorio.com/next/LuaLogisticPoint.html#LuaLogisticPoint.exact View documentation} + */ + readonly exact: 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: "LuaLogisticPoint" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * Control behavior for mining drills. + * + * {@link https://lua-api.factorio.com/next/LuaMiningDrillControlBehavior.html View documentation} + * + * @noSelf + */ +interface LuaMiningDrillControlBehavior extends LuaGenericOnOffControlBehavior { + /** + * `true` if this drill is enabled or disabled using the logistics or circuit condition. + * + * {@link https://lua-api.factorio.com/next/LuaMiningDrillControlBehavior.html#LuaMiningDrillControlBehavior.circuit_enable_disable View documentation} + */ + circuit_enable_disable: boolean + /** + * `true` if this drill should send the resources in the field to the circuit network. Which resources depends on + * {@link LuaMiningDrillControlBehavior.resource_read_mode LuaMiningDrillControlBehavior::resource_read_mode} + * + * {@link https://lua-api.factorio.com/next/LuaMiningDrillControlBehavior.html#LuaMiningDrillControlBehavior.circuit_read_resources View documentation} + */ + circuit_read_resources: boolean + /** + * If the mining drill should send just the resources in its area or the entire field it's on to the circuit network. + * + * {@link https://lua-api.factorio.com/next/LuaMiningDrillControlBehavior.html#LuaMiningDrillControlBehavior.resource_read_mode View documentation} + */ + resource_read_mode: defines.control_behavior.mining_drill.resource_read_mode + /** + * The resource entities that the mining drill will send information about to the circuit network or an empty array. + * + * {@link https://lua-api.factorio.com/next/LuaMiningDrillControlBehavior.html#LuaMiningDrillControlBehavior.resource_read_targets View documentation} + */ + readonly resource_read_targets: LuaEntity[] + /** + * 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: "LuaMiningDrillControlBehavior" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * Prototype of a mod setting. + * + * {@link https://lua-api.factorio.com/next/LuaModSettingPrototype.html View documentation} + * + * @noSelf + */ +interface LuaModSettingPrototype { + /** + * Name of this prototype. + * + * {@link https://lua-api.factorio.com/next/LuaModSettingPrototype.html#LuaModSettingPrototype.name View documentation} + */ + readonly name: string + /** + * Order string of this prototype. + * + * {@link https://lua-api.factorio.com/next/LuaModSettingPrototype.html#LuaModSettingPrototype.order View documentation} + */ + readonly order: string + readonly localised_name: LocalisedString + readonly localised_description: LocalisedString + /** + * The mod that owns this setting. + * + * {@link https://lua-api.factorio.com/next/LuaModSettingPrototype.html#LuaModSettingPrototype.mod View documentation} + */ + readonly mod: string + readonly setting_type: string + /** + * The default value of this setting. + * + * {@link https://lua-api.factorio.com/next/LuaModSettingPrototype.html#LuaModSettingPrototype.default_value View documentation} + */ + readonly default_value: boolean | double | int | string + /** + * The minimum value for this setting or `nil` if this setting type doesn't support a minimum. + * + * {@link https://lua-api.factorio.com/next/LuaModSettingPrototype.html#LuaModSettingPrototype.minimum_value View documentation} + */ + readonly minimum_value: double | int | undefined + /** + * The maximum value for this setting or `nil` if this setting type doesn't support a maximum. + * + * {@link https://lua-api.factorio.com/next/LuaModSettingPrototype.html#LuaModSettingPrototype.maximum_value View documentation} + */ + readonly maximum_value: double | int | undefined + /** + * The allowed values for this setting or `nil` if this setting doesn't use the a fixed set of values. + * + * {@link https://lua-api.factorio.com/next/LuaModSettingPrototype.html#LuaModSettingPrototype.allowed_values View documentation} + */ + readonly allowed_values: string[] | int[] | double[] | undefined + /** + * If this string setting allows blank values or `nil` if not a string setting. + * + * {@link https://lua-api.factorio.com/next/LuaModSettingPrototype.html#LuaModSettingPrototype.allow_blank View documentation} + */ + readonly allow_blank: boolean | undefined + /** + * If this string setting auto-trims values or `nil` if not a string setting. + * + * {@link https://lua-api.factorio.com/next/LuaModSettingPrototype.html#LuaModSettingPrototype.auto_trim View documentation} + */ + readonly auto_trim: boolean | undefined + /** + * If this setting is hidden from the GUI. + * + * {@link https://lua-api.factorio.com/next/LuaModSettingPrototype.html#LuaModSettingPrototype.hidden View documentation} + */ + 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: "LuaModSettingPrototype" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * Prototype of a module category. + * + * {@link https://lua-api.factorio.com/next/LuaModuleCategoryPrototype.html View documentation} + * + * @noSelf + */ +interface LuaModuleCategoryPrototype { + /** + * Name of this prototype. + * + * {@link https://lua-api.factorio.com/next/LuaModuleCategoryPrototype.html#LuaModuleCategoryPrototype.name View documentation} + */ + readonly name: string + /** + * Order string of this prototype. + * + * {@link https://lua-api.factorio.com/next/LuaModuleCategoryPrototype.html#LuaModuleCategoryPrototype.order View documentation} + */ + readonly order: string + readonly localised_name: LocalisedString + readonly localised_description: LocalisedString + /** + * 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: "LuaModuleCategoryPrototype" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * Prototype of a named noise expression. + * + * {@link https://lua-api.factorio.com/next/LuaNamedNoiseExpression.html View documentation} + * + * @noSelf + */ +interface LuaNamedNoiseExpression { + /** + * Name of this prototype. + * + * {@link https://lua-api.factorio.com/next/LuaNamedNoiseExpression.html#LuaNamedNoiseExpression.name View documentation} + */ + readonly name: string + /** + * Order string of this prototype. + * + * {@link https://lua-api.factorio.com/next/LuaNamedNoiseExpression.html#LuaNamedNoiseExpression.order View documentation} + */ + readonly order: string + readonly localised_name: LocalisedString + readonly localised_description: LocalisedString + /** + * Name of the property that this expression is intended to provide a value for, if any. + * + * {@link https://lua-api.factorio.com/next/LuaNamedNoiseExpression.html#LuaNamedNoiseExpression.intended_property View documentation} + */ + readonly intended_property: string + /** + * The expression itself. + * + * {@link https://lua-api.factorio.com/next/LuaNamedNoiseExpression.html#LuaNamedNoiseExpression.expression View documentation} + */ + readonly expression: NoiseExpression + /** + * 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: "LuaNamedNoiseExpression" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * Prototype of a noise layer. + * + * {@link https://lua-api.factorio.com/next/LuaNoiseLayerPrototype.html View documentation} + * + * @noSelf + */ +interface LuaNoiseLayerPrototype { + /** + * Name of this prototype. + * + * {@link https://lua-api.factorio.com/next/LuaNoiseLayerPrototype.html#LuaNoiseLayerPrototype.name View documentation} + */ + readonly name: string + /** + * Order string of this prototype. + * + * {@link https://lua-api.factorio.com/next/LuaNoiseLayerPrototype.html#LuaNoiseLayerPrototype.order View documentation} + */ + readonly order: string + readonly localised_name: LocalisedString + readonly localised_description: LocalisedString + /** + * 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: "LuaNoiseLayerPrototype" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * Prototype of an optimized particle. + * + * {@link https://lua-api.factorio.com/next/LuaParticlePrototype.html View documentation} + * + * @noSelf + */ +interface LuaParticlePrototype { + /** + * Name of this prototype. + * + * {@link https://lua-api.factorio.com/next/LuaParticlePrototype.html#LuaParticlePrototype.name View documentation} + */ + readonly name: string + /** + * Order string of this prototype. + * + * {@link https://lua-api.factorio.com/next/LuaParticlePrototype.html#LuaParticlePrototype.order View documentation} + */ + readonly order: string + readonly localised_name: LocalisedString + readonly localised_description: LocalisedString + readonly regular_trigger_effect: TriggerEffectItem + readonly ended_in_water_trigger_effect: TriggerEffectItem + readonly render_layer: RenderLayer + readonly render_layer_when_on_ground: RenderLayer + readonly life_time: uint + readonly regular_trigger_effect_frequency: uint + readonly movement_modifier_when_on_ground: float + readonly movement_modifier: float + readonly mining_particle_frame_speed: float + /** + * 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: "LuaParticlePrototype" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * A permission group that defines what players in this group are allowed to do. + * + * {@link https://lua-api.factorio.com/next/LuaPermissionGroup.html View documentation} + * + * @noSelf + */ +interface LuaPermissionGroup { + /** + * Adds the given player to this group. + * + * {@link https://lua-api.factorio.com/next/LuaPermissionGroup.html#LuaPermissionGroup.add_player View documentation} + * + * @param player + * @returns If the player was added. + */ + add_player(player: PlayerIdentification): boolean + /** + * Removes the given player from this group. + * + * {@link https://lua-api.factorio.com/next/LuaPermissionGroup.html#LuaPermissionGroup.remove_player View documentation} + * + * @param player + * @returns If the player was removed. + */ + remove_player(player: PlayerIdentification): boolean + /** + * Whether this group allows the given action. + * + * {@link https://lua-api.factorio.com/next/LuaPermissionGroup.html#LuaPermissionGroup.allows_action View documentation} + * + * @param action - The action in question. + */ + allows_action(action: defines.input_action): boolean + /** + * Sets whether this group allows the performance the given action. + * + * {@link https://lua-api.factorio.com/next/LuaPermissionGroup.html#LuaPermissionGroup.set_allows_action View documentation} + * + * @param action - The action in question. + * @param allow_action - Whether to allow the specified action. + * @returns Whether the value was successfully applied. + */ + set_allows_action(action: defines.input_action, allow_action: boolean): boolean + /** + * Destroys this group. + * + * {@link https://lua-api.factorio.com/next/LuaPermissionGroup.html#LuaPermissionGroup.destroy View documentation} + * + * @returns Whether the group was successfully destroyed. + */ + destroy(): boolean + /** + * The name of this group. + * + * **Note**: Setting the name to `nil` or an empty string sets the name to the default value. + * + * {@link https://lua-api.factorio.com/next/LuaPermissionGroup.html#LuaPermissionGroup.name View documentation} + */ + name: string + /** + * The players in this group. + * + * {@link https://lua-api.factorio.com/next/LuaPermissionGroup.html#LuaPermissionGroup.players View documentation} + */ + readonly players: LuaPlayer[] + /** + * The group ID + * + * {@link https://lua-api.factorio.com/next/LuaPermissionGroup.html#LuaPermissionGroup.group_id View documentation} + */ + readonly group_id: 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: "LuaPermissionGroup" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * All permission groups. + * + * {@link https://lua-api.factorio.com/next/LuaPermissionGroups.html View documentation} + * + * @noSelf + */ +interface LuaPermissionGroups { + /** + * Creates a new permission group. + * + * **Note**: May return nil if the calling player doesn't have permission to make groups. + * + * {@link https://lua-api.factorio.com/next/LuaPermissionGroups.html#LuaPermissionGroups.create_group View documentation} + * + * @param name + */ + create_group(name?: string): LuaPermissionGroup | undefined + /** + * Gets the permission group with the given name or group ID or `nil` if there is no matching group. + * + * {@link https://lua-api.factorio.com/next/LuaPermissionGroups.html#LuaPermissionGroups.get_group View documentation} + * + * @param group + */ + get_group(group: string | uint): LuaPermissionGroup | undefined + /** + * All of the permission groups. + * + * {@link https://lua-api.factorio.com/next/LuaPermissionGroups.html#LuaPermissionGroups.groups View documentation} + */ + readonly groups: LuaPermissionGroup[] + /** + * 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: "LuaPermissionGroups" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * A player in the game. Pay attention that a player may or may not have a character, which is the {@link LuaEntity} of + * the little guy running around the world doing things. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html View documentation} + * + * @noSelf + */ +interface LuaPlayer extends LuaControl { + /** + * Setup the screen to be shown when the game is finished. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.set_ending_screen_data View documentation} + * + * @param message - Message to be shown. + * @param file - Path to image to be shown. + */ + set_ending_screen_data(message: LocalisedString, file?: string): void + /** + * Print text to the chat console. + * + * **Note**: Messages that are identical to a message sent in the last 60 ticks are not printed again. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.print View documentation} + * + * @param message + * @param color + */ + print(message: LocalisedString, color?: Color): void + /** + * Clear the chat console. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.clear_console View documentation} + */ + clear_console(): void + /** + * Get the current goal description, as a localised string. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.get_goal_description View documentation} + */ + get_goal_description(): LocalisedString + /** + * Set the text in the goal window (top left). + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.set_goal_description View documentation} + * + * @param text - The text to display. Lines can be delimited with `\n`. Passing an empty string or omitting this + * parameter entirely will make the goal window disappear. + * @param only_update - When `true`, won't play the "goal updated" sound. + */ + set_goal_description(text?: LocalisedString, only_update?: boolean): void + /** + * Set the controller type of the player. + * + * **Note**: Setting a player to {@link defines.controllers.editor} auto promotes the player to admin and enables cheat mode. + * + * **Note**: Setting a player to {@link defines.controllers.editor} also requires the calling player be an admin. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.set_controller View documentation} + */ + set_controller(params: { + /** Which controller to use. */ + readonly type: defines.controllers + /** Entity to control. Mandatory when `type` is {@link defines.controllers.character}, ignored otherwise. */ + readonly character?: LuaEntity + /** + * List of waypoints for the cutscene controller. This parameter is mandatory when `type` is + * {@link defines.controllers.cutscene}. + */ + readonly waypoints?: CutsceneWaypoint + /** + * If specified and `type` is {@link defines.controllers.cutscene}, the cutscene will start at this position. If + * not given the start position will be the player position. + */ + readonly start_position?: Position + /** + * If specified and `type` is {@link defines.controllers.cutscene}, the cutscene will start at this zoom level. + * If not given the start zoom will be the players zoom. + */ + readonly start_zoom?: double + /** + * If specified and `type` is {@link defines.controllers.cutscene}, it is the time in ticks it will take for the + * camera to pan from the final waypoint back to the starting position. If not given the camera will not pan + * back to the start position/zoom. + */ + readonly final_transition_time?: uint + /** + * If specified and `type` is {@link defines.controllers.cutscene}, the game will switch to chart-mode (map + * zoomed out) rendering when the zoom level is less than this value. + */ + readonly chart_mode_cutoff?: double + }): void + /** + * Start/end wire dragging at the specified location, wire type is based on the cursor contents + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.drag_wire View documentation} + * + * @returns `true` if the action did something + */ + drag_wire(params: { + /** + * Position at which cursor was clicked. Used only to decide which side of arithmetic combinator, decider + * combinator or power switch is to be connected. Entity itself to be connected is based on the player's selected entity. + */ + readonly position: Position + }): boolean + /** + * Disable recipe groups. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.disable_recipe_groups View documentation} + */ + disable_recipe_groups(): void + /** + * Enable recipe groups. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.enable_recipe_groups View documentation} + */ + enable_recipe_groups(): void + /** + * Disable recipe subgroups. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.disable_recipe_subgroups View documentation} + */ + disable_recipe_subgroups(): void + /** + * Enable recipe subgroups. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.enable_recipe_subgroups View documentation} + */ + enable_recipe_subgroups(): void + /** + * Print entity statistics to the player's console. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.print_entity_statistics View documentation} + * + * @param entities - Entity prototypes to get statistics for. If not specified or empty, display statistics for all entities. + */ + print_entity_statistics(entities?: string[]): void + /** + * Print construction robot job counts to the players console. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.print_robot_jobs View documentation} + */ + print_robot_jobs(): void + /** + * Print LuaObject counts per mod. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.print_lua_object_statistics View documentation} + */ + print_lua_object_statistics(): void + /** + * Logs a dictionary of chunks -> active entities for the surface this player is on. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.log_active_entity_chunk_counts View documentation} + */ + log_active_entity_chunk_counts(): void + /** + * Logs a dictionary of active entities -> count for the surface this player is on. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.log_active_entity_counts View documentation} + */ + log_active_entity_counts(): void + /** + * Unlock the achievements of the given player. This has any effect only when this is the local player, the + * achievement isn't unlocked so far and the achievement is of the type "achievement". + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.unlock_achievement View documentation} + * + * @param name - Name of the achievement to unlock + */ + unlock_achievement(name: string): void + /** + * Invokes the "clear cursor" action on the player as if the user pressed it. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.clear_cursor View documentation} + * + * @returns If the cursor is now empty. + */ + clear_cursor(): boolean + /** + * Creates and attaches a character entity to this player. + * + * **Note**: The player must not have a character already connected and must be online (see + * {@link LuaPlayer.connected LuaPlayer::connected}). + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.create_character View documentation} + * + * @param character - The character to create else the default is used. + * @returns Whether the character was created. + */ + create_character(character?: string): boolean + /** + * Adds an alert to this player for the given entity of the given alert type. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.add_alert View documentation} + * + * @param entity + * @param type + */ + add_alert(entity: LuaEntity, type: defines.alert_type): void + /** + * Adds a custom alert to this player. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.add_custom_alert View documentation} + * + * @param entity - If the alert is clicked, the map will open at the position of this entity. + * @param icon + * @param message + * @param show_on_map + */ + add_custom_alert(entity: LuaEntity, icon: SignalID, message: LocalisedString, show_on_map: boolean): void + /** + * Removes all alerts matching the given filters or if an empty filters table is given all alerts are removed. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.remove_alert View documentation} + */ + remove_alert(params: { + readonly entity?: LuaEntity + readonly prototype?: LuaEntityPrototype + readonly position?: Position + readonly type?: defines.alert_type + readonly surface?: SurfaceIdentification + readonly icon?: SignalID + readonly message?: LocalisedString + }): void + /** + * Get all alerts matching the given filters, or all alerts if no filters are given. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.get_alerts View documentation} + * + * @returns A mapping of surface index to an array of arrays of {@link Alert alerts} indexed by the + * {@link defines.alert_type alert type}. + */ + get_alerts(params: { + readonly entity?: LuaEntity + readonly prototype?: LuaEntityPrototype + readonly position?: Position + readonly type?: defines.alert_type + readonly surface?: SurfaceIdentification + }): Record> + /** + * Mutes alerts for the given alert category. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.mute_alert View documentation} + * + * @param alert_type + * @returns If the alert type was muted (false if it was already muted). + */ + mute_alert(alert_type: defines.alert_type): boolean + /** + * Unmutes alerts for the given alert category. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.unmute_alert View documentation} + * + * @param alert_type + * @returns If the alert type was unmuted (false if it was wasn't muted). + */ + unmute_alert(alert_type: defines.alert_type): boolean + /** + * If the given alert type is currently muted. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.is_alert_muted View documentation} + * + * @param alert_type + */ + is_alert_muted(alert_type: defines.alert_type): boolean + /** + * Enables alerts for the given alert category. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.enable_alert View documentation} + * + * @param alert_type + * @returns If the alert type was enabled (false if it was already enabled). + */ + enable_alert(alert_type: defines.alert_type): boolean + /** + * Disables alerts for the given alert category. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.disable_alert View documentation} + * + * @param alert_type + * @returns If the alert type was disabled (false if it was already disabled). + */ + disable_alert(alert_type: defines.alert_type): boolean + /** + * If the given alert type is currently enabled. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.is_alert_enabled View documentation} + * + * @param alert_type + */ + is_alert_enabled(alert_type: defines.alert_type): boolean + /** + * Invokes the "smart pipette" action on the player as if the user pressed it. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.pipette_entity View documentation} + * + * @param entity + * @returns If the smart pipette found something to place + */ + pipette_entity(entity: string | LuaEntity | LuaEntityPrototype): boolean + /** + * Checks if this player can build the give entity at the given location on the surface the player is on. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.can_place_entity View documentation} + */ + can_place_entity(params: { + /** Name of the entity to check */ + readonly name: string + /** Where the entity would be placed */ + readonly position: Position + /** Direction the entity would be placed */ + readonly direction?: defines.direction + }): boolean + /** + * Checks if this player can build what ever is in the cursor on the surface the player is on. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.can_build_from_cursor View documentation} + */ + can_build_from_cursor(params: { + /** Where the entity would be placed */ + readonly position: Position + /** Direction the entity would be placed */ + readonly direction?: defines.direction + /** If alt build should be used instead of normal build. Defaults to normal. */ + readonly alt?: boolean + /** The size for building terrain if building terrain. Defaults to 2. */ + readonly terrain_building_size?: uint + /** If chunks covered by fog-of-war are skipped. */ + readonly skip_fog_of_war?: boolean + }): boolean + /** + * Builds what ever is in the cursor on the surface the player is on. + * + * **Note**: Anything built will fire normal player-built events. + * + * **Note**: The cursor stack will automatically be reduced as if the player built normally. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.build_from_cursor View documentation} + */ + build_from_cursor(params: { + /** Where the entity would be placed */ + readonly position: Position + /** Direction the entity would be placed */ + readonly direction?: defines.direction + /** If alt build should be used instead of normal build. Defaults to normal. */ + readonly alt?: boolean + /** The size for building terrain if building terrain. Defaults to 2. */ + readonly terrain_building_size?: uint + /** If chunks covered by fog-of-war are skipped. */ + readonly skip_fog_of_war?: boolean + }): void + /** + * Uses the current item in the cursor if it's a capsule or does nothing if not. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.use_from_cursor View documentation} + * + * @param position - Where the item would be used. + */ + use_from_cursor(position: Position): void + /** + * Play a sound for this player. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.play_sound View documentation} + */ + play_sound(params: { + /** The sound to play. */ + readonly path: SoundPath + /** Where the sound should be played. If not given, it's played at the current position of the player. */ + readonly position?: Position + /** The volume of the sound to play. Must be between 0 and 1 inclusive. */ + readonly volume_modifier?: double + /** The volume mixer to play the sound through. Defaults to the default mixer for the given sound type. */ + readonly override_sound_type?: SoundType + }): void + /** + * The characters associated with this player. + * + * **Note**: The array will always be empty when the player is disconnected (see + * {@link LuaPlayer.connected LuaPlayer::connected}) regardless of there being associated characters. + * + * **Note**: Characters associated with this player will be logged off when this player disconnects but are not + * controlled by any player. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.get_associated_characters View documentation} + */ + get_associated_characters(): LuaEntity[] + /** + * Associates a character with this player. + * + * **Note**: The character must not be connected to any controller. + * + * **Note**: If this player is currently disconnected (see {@link LuaPlayer.connected LuaPlayer::connected}) the + * character will be immediately "logged off". + * + * **Note**: See {@link LuaPlayer.get_associated_characters LuaPlayer::get_associated_characters} for more information. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.associate_character View documentation} + * + * @param character - The character entity. + */ + associate_character(character: LuaEntity): void + /** + * Disassociates a character from this player. This is functionally the same as setting + * {@link LuaEntity.associated_player LuaEntity::associated_player} to `nil`. + * + * **Note**: See {@link LuaPlayer.get_associated_characters LuaPlayer::get_associated_characters} for more information. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.disassociate_character View documentation} + * + * @param character - The character entity + */ + disassociate_character(character: LuaEntity): void + /** + * Spawn flying text that is only visible to this player. Either `position` or `create_at_cursor` are required. When + * `create_at_cursor` is `true`, all parameters other than `text` are ignored. + * + * **Note**: If no custom `speed` is set and the text is longer than 25 characters, its `time_to_live` and `speed` + * are dynamically adjusted to give players more time to read it. + * + * **Note**: Local flying text is not saved, which means it will disappear after a save/load-cycle. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.create_local_flying_text View documentation} + */ + create_local_flying_text(params: { + /** The flying text to show. */ + readonly text: LocalisedString + /** The location on the map at which to show the flying text. */ + readonly position?: Position + /** If `true`, the flying text is created at the player's cursor. Defaults to `false`. */ + readonly create_at_cursor?: boolean + /** The color of the flying text. Defaults to white text. */ + readonly color?: Color + /** The amount of ticks that the flying text will be shown for. Defaults to `80`. */ + readonly time_to_live?: uint + /** The speed at which the text rises upwards in tiles/second. Can't be a negative value. */ + readonly speed?: double + }): void + /** + * Gets the quick bar filter for the given slot or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.get_quick_bar_slot View documentation} + * + * @param index - The slot index. 1 for the first slot of page one, 2 for slot two of page one, 11 for the first + * slot of page 2, etc. + */ + get_quick_bar_slot(index: uint): LuaItemPrototype | undefined + /** + * Sets the quick bar filter for the given slot. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.set_quick_bar_slot View documentation} + * + * @param index - The slot index. 1 for the first slot of page one, 2 for slot two of page one, 11 for the first + * slot of page 2, etc. + * @param filter - The filter or `nil`. + */ + set_quick_bar_slot(index: uint, filter: string | LuaItemPrototype | LuaItemStack | undefined): void + /** + * Gets which quick bar page is being used for the given screen page or `nil` if not known. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.get_active_quick_bar_page View documentation} + * + * @param index - The screen page. Index 1 is the top row in the gui. Index can go beyond the visible number of bars + * on the screen to account for the interface config setting change. + */ + get_active_quick_bar_page(index: uint): uint8 | undefined + /** + * Sets which quick bar page is being used for the given screen page. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.set_active_quick_bar_page View documentation} + * + * @param screen_index - The screen page. Index 1 is the top row in the gui. Index can go beyond the visible number + * of bars on the screen to account for the interface config setting change. + * @param page_index - The new quick bar page. + */ + set_active_quick_bar_page(screen_index: uint, page_index: uint): void + /** + * Jump to the specified cutscene waypoint. Only works when the player is viewing a cutscene. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.jump_to_cutscene_waypoint View documentation} + * + * @param waypoint_index + */ + jump_to_cutscene_waypoint(waypoint_index: uint): void + /** + * Exit the current cutscene. Errors if not in a cutscene. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.exit_cutscene View documentation} + */ + exit_cutscene(): void + /** + * Queues a request to open the map at the specified position. If the map is already opened, the request will simply + * set the position (and scale). Render mode change requests are processed before rendering of the next frame. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.open_map View documentation} + * + * @param position + * @param scale + */ + open_map(position: Position, scale?: double): void + /** + * Queues a request to zoom to world at the specified position. If the player is already zooming to world, the + * request will simply set the position (and scale). Render mode change requests are processed before rendering of + * the next frame. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.zoom_to_world View documentation} + * + * @param position + * @param scale + */ + zoom_to_world(position: Position, scale?: double): void + /** + * Queues request to switch to the normal game view from the map or zoom to world view. Render mode change requests + * are processed before rendering of the next frame. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.close_map View documentation} + */ + close_map(): void + /** + * Is a custom Lua shortcut currently toggled? + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.is_shortcut_toggled View documentation} + * + * @param prototype_name - Prototype name of the custom shortcut. + */ + is_shortcut_toggled(prototype_name: string): boolean + /** + * Is a custom Lua shortcut currently available? + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.is_shortcut_available View documentation} + * + * @param prototype_name - Prototype name of the custom shortcut. + */ + is_shortcut_available(prototype_name: string): boolean + /** + * Toggle or untoggle a custom Lua shortcut + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.set_shortcut_toggled View documentation} + * + * @param prototype_name - Prototype name of the custom shortcut. + * @param toggled + */ + set_shortcut_toggled(prototype_name: string, toggled: boolean): void + /** + * Make a custom Lua shortcut available or unavailable. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.set_shortcut_available View documentation} + * + * @param prototype_name - Prototype name of the custom shortcut. + * @param available + */ + set_shortcut_available(prototype_name: string, available: boolean): void + /** + * Asks the player if they would like to connect to the given server. + * + * **Note**: This only does anything when used on a multiplayer peer. Single player and server hosts will ignore the prompt. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.connect_to_server View documentation} + */ + connect_to_server(params: { + /** The server (address:port) if port is not given the default Factorio port is used. */ + readonly address: string + /** The name of the server. */ + readonly name?: LocalisedString + readonly description?: LocalisedString + /** + * The password if different from the one used to join this game. Note, if the current password is not empty but + * the one required to join the new server is an empty string should be given for this field. + */ + readonly password?: string + }): void + /** + * Toggles this player into or out of the map editor. Does nothing if this player isn't an admin or if the player + * doesn't have permission to use the map editor. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.toggle_map_editor View documentation} + */ + toggle_map_editor(): void + /** + * Requests a translation for the given localised string. If the request is successful the + * {@link OnStringTranslatedEvent on_string_translated} event will be fired at a later time with the results. + * + * **Note**: Does nothing if this player is not connected. (see {@link LuaPlayer.connected LuaPlayer::connected}). + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.request_translation View documentation} + * + * @param localised_string + * @returns If the request was sent or not. + */ + request_translation(localised_string: LocalisedString): boolean + /** + * Gets the filter for this map editor infinity filters at the given index or `nil` if the filter index doesn't + * exist or is empty. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.get_infinity_inventory_filter View documentation} + * + * @param index - The index to get. + */ + get_infinity_inventory_filter(index: uint): InfinityInventoryFilter | undefined + /** + * Sets the filter for this map editor infinity filters at the given index. + * + * *Can only be used if this is InfinityContainer* + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.set_infinity_inventory_filter View documentation} + * + * @param index - The index to set. + * @param filter - The new filter or `nil` to clear the filter. + */ + set_infinity_inventory_filter(index: uint, filter: InfinityInventoryFilter | undefined): void + /** + * Clears all recipe notifications for this player. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.clear_recipe_notifications View documentation} + */ + clear_recipe_notifications(): void + /** + * Adds the given recipe to the list of recipe notifications for this player. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.add_recipe_notification View documentation} + * + * @param recipe - Name of the recipe prototype to add. + */ + add_recipe_notification(recipe: string): void + /** + * Adds the given blueprint to this player's clipboard queue. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.add_to_clipboard View documentation} + * + * @param blueprint - The blueprint to add. + */ + add_to_clipboard(blueprint: LuaItemStack): void + /** + * Gets a copy of the currently selected blueprint in the clipboard queue into the player's cursor, as if the player + * activated Paste. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.activate_paste View documentation} + */ + activate_paste(): void + /** + * Starts selection with selection tool from the specified position. Does nothing if the players cursor is not a + * selection tool. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.start_selection View documentation} + * + * @param position - The position to start selection from. + * @param selection_mode - The type of selection to start. Can be `select`, `alternative-select`, `reverse-select`. + */ + start_selection(position: Position, selection_mode: string): void + /** + * Clears the players selection tool selection position. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.clear_selection View documentation} + */ + clear_selection(): void + /** + * The character attached to this player, or `nil` if no character. + * + * **Note**: Will also return `nil` when the player is disconnected (see {@link LuaPlayer.connected LuaPlayer::connected}). + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.character View documentation} + */ + character: LuaEntity | undefined + /** + * When in a cutscene; the character this player would be using once the cutscene is over. + * + * **Note**: Will also return `nil` when the player is disconnected (see {@link LuaPlayer.connected LuaPlayer::connected}). + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.cutscene_character View documentation} + */ + readonly cutscene_character: LuaEntity | undefined + /** + * This player's index in {@link LuaGameScript.players LuaGameScript::players}. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.index View documentation} + */ + readonly index: uint + readonly gui: LuaGui + /** + * `true` if the player opened itself. I.e. if they opened the character or god-controller GUI. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.opened_self View documentation} + */ + readonly opened_self: boolean + readonly controller_type: defines.controllers + /** + * The stashed controller type or `nil` if no controller is stashed. + * + * **Note**: This is mainly useful when a player is in the map editor. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.stashed_controller_type View documentation} + */ + readonly stashed_controller_type: defines.controllers | undefined + /** + * The player's game view settings. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.game_view_settings View documentation} + */ + game_view_settings: GameViewSettings + /** + * `true` if the minimap is visible. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.minimap_enabled View documentation} + */ + minimap_enabled: boolean + /** + * The color associated with the player. This will be used to tint the player's character as well as their buildings + * and vehicles. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.color View documentation} + */ + color: Color + /** + * The color used when this player talks in game. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.chat_color View documentation} + */ + chat_color: Color + /** + * The player's username. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.name View documentation} + */ + readonly name: string + /** + * The tag that is shown after the player in chat and on the map. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.tag View documentation} + */ + tag: string + /** + * `true` if the player is currently connected to the game. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.connected View documentation} + */ + readonly connected: boolean + /** + * `true` if the player is an admin. + * + * **Note**: Trying to change player admin status from the console when you aren't an admin does nothing. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.admin View documentation} + */ + admin: boolean + /** + * The source entity used during entity settings copy-paste if any. + * + * `nil` if there isn't currently a source entity. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.entity_copy_source View documentation} + */ + readonly entity_copy_source: LuaEntity | undefined + /** + * How many ticks since the last action of this player + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.afk_time View documentation} + */ + readonly afk_time: uint + /** + * How many ticks did this player spend playing this save (all sessions combined) + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.online_time View documentation} + */ + readonly online_time: uint + /** + * At what tick this player was last online. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.last_online View documentation} + */ + readonly last_online: uint + /** + * The permission group this player is part of or `nil` if not part of any group. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.permission_group View documentation} + */ + permission_group: LuaPermissionGroup | undefined + /** + * Gets the current per-player settings for the this player, indexed by prototype name. Returns the same structure + * as {@link LuaSettings.get_player_settings LuaSettings::get_player_settings}. + * + * **Note**: This can become invalid if during operation this player becomes invalid. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.mod_settings View documentation} + */ + readonly mod_settings: LuaCustomTable + /** + * The number of ticks until this player will respawn or `nil` if not waiting to respawn. + * + * **Note**: Set to `nil` to immediately respawn the player. + * + * **Note**: Set to any positive value to trigger the respawn state for this player. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.ticks_to_respawn View documentation} + */ + ticks_to_respawn: uint | undefined + /** + * The display resolution for this player. + * + * **Note**: During {@link OnPlayerCreatedEvent on_player_created}, this attribute will always return a resolution of + * `{width=1920, height=1080}`. To get the actual resolution, listen to the + * {@link OnPlayerDisplayResolutionChangedEvent on_player_display_resolution_changed} event raised shortly afterwards. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.display_resolution View documentation} + */ + readonly display_resolution: DisplayResolution + /** + * The display scale for this player. + * + * **Note**: During {@link OnPlayerCreatedEvent on_player_created}, this attribute will always return a scale of `1`. + * To get the actual scale, listen to the {@link OnPlayerDisplayScaleChangedEvent on_player_display_scale_changed} + * event raised shortly afterwards. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.display_scale View documentation} + */ + readonly display_scale: double + /** + * The item stack containing a blueprint to be setup. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.blueprint_to_setup View documentation} + */ + readonly blueprint_to_setup: LuaItemStack + /** + * The render mode of the player, like map or zoom to world. The render mode can be set using + * {@link LuaPlayer.open_map LuaPlayer::open_map}, {@link LuaPlayer.zoom_to_world LuaPlayer::zoom_to_world} and + * {@link LuaPlayer.close_map LuaPlayer::close_map}. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.render_mode View documentation} + */ + readonly render_mode: defines.render_mode + /** + * If `true`, zoom-to-world noise effect will be disabled and environmental sounds will be based on zoom-to-world + * view instead of position of player's character. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.spectator View documentation} + */ + spectator: boolean + /** + * If items not included in this map editor infinity inventory filters should be removed. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.remove_unfiltered_items View documentation} + */ + remove_unfiltered_items: boolean + /** + * The filters for this map editor infinity inventory settings. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.infinity_inventory_filters View documentation} + */ + infinity_inventory_filters: InfinityInventoryFilter[] + /** + * If the main inventory will be auto sorted. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.auto_sort_main_inventory View documentation} + */ + readonly auto_sort_main_inventory: boolean + /** + * The original location of the item in the cursor, marked with a hand. When writing, the specified inventory slot + * must be empty and the cursor stack must not be empty. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.hand_location View documentation} + */ + hand_location: ItemStackLocation + /** + * The player's zoom-level. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.zoom View documentation} + */ + set zoom(value: double) + /** + * The player's map view settings. To write to this, use a table containing the fields that should be changed. + * + * {@link https://lua-api.factorio.com/next/LuaPlayer.html#LuaPlayer.map_view_settings View documentation} + */ + set map_view_settings(value: MapViewSettings) + /** + * 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: "LuaPlayer" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * An object used to measure script performance. + * + * **Note**: Since performance is non-deterministic these objects don't allow reading the raw time values from lua. They + * can be used anywhere a {@link LocalisedString} is used. + * + * {@link https://lua-api.factorio.com/next/LuaProfiler.html View documentation} + * + * @noSelf + */ +interface LuaProfiler { + /** + * Resets the clock, also restarting it. + * + * {@link https://lua-api.factorio.com/next/LuaProfiler.html#LuaProfiler.reset View documentation} + */ + reset(): void + /** + * Stops the clock. + * + * {@link https://lua-api.factorio.com/next/LuaProfiler.html#LuaProfiler.stop View documentation} + */ + stop(): void + /** + * Start the clock again, without resetting it. + * + * {@link https://lua-api.factorio.com/next/LuaProfiler.html#LuaProfiler.restart View documentation} + */ + restart(): void + /** + * Add the duration of another timer to this timer. Useful to reduce start/stop overhead when accumulating time onto + * many timers at once. + * + * **Note**: If other is running, the time to now will be added. + * + * {@link https://lua-api.factorio.com/next/LuaProfiler.html#LuaProfiler.add View documentation} + * + * @param other - The timer to add to this timer. + */ + add(other: LuaProfiler): void + /** + * Divides the current duration by a set value. Useful for calculating the average of many iterations. + * + * **Note**: Does nothing if this isn't stopped. + * + * {@link https://lua-api.factorio.com/next/LuaProfiler.html#LuaProfiler.divide View documentation} + * + * @param number - The number to divide by. Must be > 0. + */ + divide(number: double): void + /** + * 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: "LuaProfiler" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * Control behavior for programmable speakers. + * + * {@link https://lua-api.factorio.com/next/LuaProgrammableSpeakerControlBehavior.html View documentation} + * + * @noSelf + */ +interface LuaProgrammableSpeakerControlBehavior extends LuaControlBehavior { + circuit_parameters: ProgrammableSpeakerCircuitParameters + circuit_condition: CircuitConditionDefinition + /** + * 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: "LuaProgrammableSpeakerControlBehavior" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * An interface to send messages to the calling RCON interface. + * + * {@link https://lua-api.factorio.com/next/LuaRCON.html View documentation} + * + * @noSelf + */ +interface LuaRCON { + /** + * Print text to the calling RCON interface if any. + * + * {@link https://lua-api.factorio.com/next/LuaRCON.html#LuaRCON.print View documentation} + * + * @param message + */ + print(message: LocalisedString): void + /** This object's name. */ + readonly object_name: "LuaRCON" +} + +/** + * Control behavior for rail chain signals. + * + * {@link https://lua-api.factorio.com/next/LuaRailChainSignalControlBehavior.html View documentation} + * + * @noSelf + */ +interface LuaRailChainSignalControlBehavior extends LuaControlBehavior { + red_signal: SignalID + orange_signal: SignalID + green_signal: SignalID + blue_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: "LuaRailChainSignalControlBehavior" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * A rail path. + * + * {@link https://lua-api.factorio.com/next/LuaRailPath.html View documentation} + * + * @noSelf + */ +interface LuaRailPath { + /** + * The total number of rails in this path. + * + * {@link https://lua-api.factorio.com/next/LuaRailPath.html#LuaRailPath.size View documentation} + */ + readonly size: uint + /** + * The current rail index. + * + * {@link https://lua-api.factorio.com/next/LuaRailPath.html#LuaRailPath.current View documentation} + */ + readonly current: uint + /** + * The total path distance. + * + * {@link https://lua-api.factorio.com/next/LuaRailPath.html#LuaRailPath.total_distance View documentation} + */ + readonly total_distance: double + /** + * The total distance travelled. + * + * {@link https://lua-api.factorio.com/next/LuaRailPath.html#LuaRailPath.travelled_distance View documentation} + */ + readonly travelled_distance: double + /** + * Array of the rails that this path travels over. + * + * {@link https://lua-api.factorio.com/next/LuaRailPath.html#LuaRailPath.rails View documentation} + */ + readonly rails: LuaCustomTable + /** + * 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: "LuaRailPath" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * Control behavior for rail signals. + * + * {@link https://lua-api.factorio.com/next/LuaRailSignalControlBehavior.html View documentation} + * + * @noSelf + */ +interface LuaRailSignalControlBehavior extends LuaControlBehavior { + red_signal: SignalID + orange_signal: SignalID + green_signal: SignalID + /** + * If this will close the rail signal based off the circuit condition. + * + * {@link https://lua-api.factorio.com/next/LuaRailSignalControlBehavior.html#LuaRailSignalControlBehavior.close_signal View documentation} + */ + close_signal: boolean + /** + * If this will read the rail signal state. + * + * {@link https://lua-api.factorio.com/next/LuaRailSignalControlBehavior.html#LuaRailSignalControlBehavior.read_signal View documentation} + */ + read_signal: boolean + /** + * The circuit condition when controlling the signal through the circuit network. + * + * {@link https://lua-api.factorio.com/next/LuaRailSignalControlBehavior.html#LuaRailSignalControlBehavior.circuit_condition View documentation} + */ + circuit_condition: CircuitConditionDefinition + /** + * 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: "LuaRailSignalControlBehavior" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * A deterministic random generator independent from the core games random generator that can be seeded and re-seeded at + * will. This random generator can be saved and loaded and will maintain its state. Note this is entirely different from + * calling {@link https://lua-api.factorio.com/next/Libraries.html#math.random math.random}() and you should be sure you + * actually want to use this over calling `math.random()`. If you aren't sure if you need to use this over calling + * `math.random()` then you probably don't need to use this. + * + * {@link https://lua-api.factorio.com/next/LuaRandomGenerator.html View documentation} + * + * @example + * Create a generator and use it to print a random number. + * + * ```lua + * global.generator = game.create_random_generator() + * game.player.print(global.generator()) + * ``` + * + * @noSelf + */ +interface LuaRandomGenerator { + /** + * Re-seeds the random generator with the given value. + * + * **Note**: Seeds that are close together will produce similar results. Seeds from 0 to 341 will produce the same results. + * + * {@link https://lua-api.factorio.com/next/LuaRandomGenerator.html#LuaRandomGenerator.re_seed View documentation} + * + * @param seed + */ + re_seed(seed: uint): void + /** + * Generates a random number. If no parameters are given a number in the [0, 1) range is returned. If a single + * parameter is given a floored number in the [1, N] range is returned. If 2 parameters are given a floored number + * in the [N1, N2] range is returned. + * + * {@link https://lua-api.factorio.com/next/LuaRandomGenerator.html#LuaRandomGenerator.operator%20() View documentation} + * + * @param lower - Inclusive lower bound on the result + * @param upper - Inclusive upper bound on the result + */ + (lower?: int, upper?: int): double + /** + * 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: "LuaRandomGenerator" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * A crafting recipe. Recipes belong to forces (see {@link LuaForce}) because some recipes are unlocked by research, and + * researches are per-force. + * + * {@link https://lua-api.factorio.com/next/LuaRecipe.html View documentation} + * + * @noSelf + */ +interface LuaRecipe { + /** + * Reload the recipe from the prototype. + * + * {@link https://lua-api.factorio.com/next/LuaRecipe.html#LuaRecipe.reload View documentation} + */ + reload(): void + /** + * Name of the recipe. This can be different than the name of the result items as there could be more recipes to + * make the same item. + * + * {@link https://lua-api.factorio.com/next/LuaRecipe.html#LuaRecipe.name View documentation} + */ + readonly name: string + /** + * Localised name of the recipe. + * + * {@link https://lua-api.factorio.com/next/LuaRecipe.html#LuaRecipe.localised_name View documentation} + */ + readonly localised_name: LocalisedString + readonly localised_description: LocalisedString + /** + * The prototype for this recipe. + * + * {@link https://lua-api.factorio.com/next/LuaRecipe.html#LuaRecipe.prototype View documentation} + */ + readonly prototype: LuaRecipePrototype + /** + * Can the recipe be used? + * + * {@link https://lua-api.factorio.com/next/LuaRecipe.html#LuaRecipe.enabled View documentation} + */ + enabled: boolean + /** + * Category of the recipe. + * + * {@link https://lua-api.factorio.com/next/LuaRecipe.html#LuaRecipe.category View documentation} + */ + readonly category: string + /** + * Ingredients for this recipe. + * + * {@link https://lua-api.factorio.com/next/LuaRecipe.html#LuaRecipe.ingredients View documentation} + * + * @example + * What the "steel-chest" recipe would return + * + * ```lua + * {{type="item", name="steel-plate", amount=8}} + * ``` + * + * @example + * What the "advanced-oil-processing" recipe would return + * + * ```lua + * {{type="fluid", name="crude-oil", amount=10}, {type="fluid", name="water", amount=5}} + * ``` + */ + readonly ingredients: Ingredient[] + /** + * The results of this recipe. + * + * {@link https://lua-api.factorio.com/next/LuaRecipe.html#LuaRecipe.products View documentation} + */ + readonly products: Product[] + /** + * Is the recipe hidden? Hidden recipe don't show up in the crafting menu. + * + * {@link https://lua-api.factorio.com/next/LuaRecipe.html#LuaRecipe.hidden View documentation} + */ + readonly hidden: boolean + /** + * Is the recipe hidden from flow statistics? + * + * {@link https://lua-api.factorio.com/next/LuaRecipe.html#LuaRecipe.hidden_from_flow_stats View documentation} + */ + hidden_from_flow_stats: boolean + /** + * Energy required to execute this recipe. This directly affects the crafting time: Recipe's energy is exactly its + * crafting time in seconds, when crafted in an assembling machine with crafting speed exactly equal to one. + * + * {@link https://lua-api.factorio.com/next/LuaRecipe.html#LuaRecipe.energy View documentation} + */ + readonly energy: double + /** + * Order string. This is used to sort the crafting menu. + * + * {@link https://lua-api.factorio.com/next/LuaRecipe.html#LuaRecipe.order View documentation} + */ + readonly order: string + /** + * Group of this recipe. + * + * {@link https://lua-api.factorio.com/next/LuaRecipe.html#LuaRecipe.group View documentation} + */ + readonly group: LuaGroup + /** + * Subgroup of this recipe. + * + * {@link https://lua-api.factorio.com/next/LuaRecipe.html#LuaRecipe.subgroup View documentation} + */ + readonly subgroup: LuaGroup + /** + * The force that owns this recipe. + * + * {@link https://lua-api.factorio.com/next/LuaRecipe.html#LuaRecipe.force View documentation} + */ + readonly force: LuaForce + /** + * 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: "LuaRecipe" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * Prototype of a recipe category. + * + * {@link https://lua-api.factorio.com/next/LuaRecipeCategoryPrototype.html View documentation} + * + * @noSelf + */ +interface LuaRecipeCategoryPrototype { + /** + * Name of this prototype. + * + * {@link https://lua-api.factorio.com/next/LuaRecipeCategoryPrototype.html#LuaRecipeCategoryPrototype.name View documentation} + */ + readonly name: string + /** + * Order string of this prototype. + * + * {@link https://lua-api.factorio.com/next/LuaRecipeCategoryPrototype.html#LuaRecipeCategoryPrototype.order View documentation} + */ + readonly order: string + readonly localised_name: LocalisedString + readonly localised_description: LocalisedString + /** + * 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: "LuaRecipeCategoryPrototype" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * A crafting recipe prototype. + * + * {@link https://lua-api.factorio.com/next/LuaRecipePrototype.html View documentation} + * + * @noSelf + */ +interface LuaRecipePrototype { + /** + * If this recipe prototype is enabled by default (enabled at the beginning of a game). + * + * {@link https://lua-api.factorio.com/next/LuaRecipePrototype.html#LuaRecipePrototype.enabled View documentation} + */ + readonly enabled: boolean + /** + * Name of the recipe. This can be different than the name of the result items as there could be more recipes to + * make the same item. + * + * {@link https://lua-api.factorio.com/next/LuaRecipePrototype.html#LuaRecipePrototype.name View documentation} + */ + readonly name: string + /** + * Localised name of the recipe. + * + * {@link https://lua-api.factorio.com/next/LuaRecipePrototype.html#LuaRecipePrototype.localised_name View documentation} + */ + readonly localised_name: LocalisedString + readonly localised_description: LocalisedString + /** + * Category of the recipe. + * + * {@link https://lua-api.factorio.com/next/LuaRecipePrototype.html#LuaRecipePrototype.category View documentation} + */ + readonly category: string + /** + * Ingredients for this recipe. + * + * {@link https://lua-api.factorio.com/next/LuaRecipePrototype.html#LuaRecipePrototype.ingredients View documentation} + */ + readonly ingredients: Ingredient[] + /** + * The results of this recipe. + * + * {@link https://lua-api.factorio.com/next/LuaRecipePrototype.html#LuaRecipePrototype.products View documentation} + */ + readonly products: Product[] + /** + * The main product of this recipe, `nil` if no main product is defined. + * + * {@link https://lua-api.factorio.com/next/LuaRecipePrototype.html#LuaRecipePrototype.main_product View documentation} + */ + readonly main_product: Product | undefined + /** + * Is the recipe hidden? Hidden recipe don't show up in the crafting menu. + * + * {@link https://lua-api.factorio.com/next/LuaRecipePrototype.html#LuaRecipePrototype.hidden View documentation} + */ + readonly hidden: boolean + /** + * Is the recipe hidden from flow statistics (item/fluid production statistics)? + * + * {@link https://lua-api.factorio.com/next/LuaRecipePrototype.html#LuaRecipePrototype.hidden_from_flow_stats View documentation} + */ + readonly hidden_from_flow_stats: boolean + /** + * Is the recipe hidden from player crafting? The recipe will still show up for selection in machines. + * + * {@link https://lua-api.factorio.com/next/LuaRecipePrototype.html#LuaRecipePrototype.hidden_from_player_crafting View documentation} + */ + readonly hidden_from_player_crafting: boolean + /** + * Should this recipe always show "Made in" in the tooltip? + * + * {@link https://lua-api.factorio.com/next/LuaRecipePrototype.html#LuaRecipePrototype.always_show_made_in View documentation} + */ + readonly always_show_made_in: boolean + /** + * Energy required to execute this recipe. This directly affects the crafting time: Recipe's energy is exactly its + * crafting time in seconds, when crafted in an assembling machine with crafting speed exactly equal to one. + * + * {@link https://lua-api.factorio.com/next/LuaRecipePrototype.html#LuaRecipePrototype.energy View documentation} + */ + readonly energy: double + /** + * Order string. This is used to sort the crafting menu. + * + * {@link https://lua-api.factorio.com/next/LuaRecipePrototype.html#LuaRecipePrototype.order View documentation} + */ + readonly order: string + /** + * Group of this recipe. + * + * {@link https://lua-api.factorio.com/next/LuaRecipePrototype.html#LuaRecipePrototype.group View documentation} + */ + readonly group: LuaGroup + /** + * Subgroup of this recipe. + * + * {@link https://lua-api.factorio.com/next/LuaRecipePrototype.html#LuaRecipePrototype.subgroup View documentation} + */ + readonly subgroup: LuaGroup + /** + * The multiplier used when this recipe is copied from an assembling machine to a requester chest. For each item in + * the recipe the item count * this value is set in the requester chest. + * + * {@link https://lua-api.factorio.com/next/LuaRecipePrototype.html#LuaRecipePrototype.request_paste_multiplier View documentation} + */ + readonly request_paste_multiplier: uint + /** + * Used to determine how many extra items are put into an assembling machine before it's considered "full enough". + * + * {@link https://lua-api.factorio.com/next/LuaRecipePrototype.html#LuaRecipePrototype.overload_multiplier View documentation} + */ + readonly overload_multiplier: uint + /** + * If the recipe is allowed to have the extra inserter overload bonus applied (4 * stack inserter stack size). + * + * {@link https://lua-api.factorio.com/next/LuaRecipePrototype.html#LuaRecipePrototype.allow_inserter_overload View documentation} + */ + readonly allow_inserter_overload: boolean + /** + * If this recipe is enabled for the purpose of intermediate hand-crafting. + * + * {@link https://lua-api.factorio.com/next/LuaRecipePrototype.html#LuaRecipePrototype.allow_as_intermediate View documentation} + */ + readonly allow_as_intermediate: boolean + /** + * If this recipe is allowed to use intermediate recipes when hand-crafting. + * + * {@link https://lua-api.factorio.com/next/LuaRecipePrototype.html#LuaRecipePrototype.allow_intermediates View documentation} + */ + readonly allow_intermediates: boolean + /** + * If the amount is shown in the recipe tooltip title when the recipe produces more than 1 product. + * + * {@link https://lua-api.factorio.com/next/LuaRecipePrototype.html#LuaRecipePrototype.show_amount_in_title View documentation} + */ + readonly show_amount_in_title: boolean + /** + * If the products are always shown in the recipe tooltip. + * + * {@link https://lua-api.factorio.com/next/LuaRecipePrototype.html#LuaRecipePrototype.always_show_products View documentation} + */ + readonly always_show_products: boolean + /** + * The emissions multiplier for this recipe. + * + * {@link https://lua-api.factorio.com/next/LuaRecipePrototype.html#LuaRecipePrototype.emissions_multiplier View documentation} + */ + readonly emissions_multiplier: double + /** + * Is this recipe allowed to be broken down for the recipe tooltip "Total raw" calculations? + * + * {@link https://lua-api.factorio.com/next/LuaRecipePrototype.html#LuaRecipePrototype.allow_decomposition View documentation} + */ + readonly allow_decomposition: boolean + /** + * Is this recipe unlocks the result item(s) so they're shown in filter-select GUIs. + * + * {@link https://lua-api.factorio.com/next/LuaRecipePrototype.html#LuaRecipePrototype.unlock_results View documentation} + */ + readonly unlock_results: 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: "LuaRecipePrototype" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * Registry of interfaces between scripts. An interface is simply a dictionary mapping names to functions. A script or + * mod can then register an interface with {@link LuaRemote}, after that any script can call the registered functions, + * provided it knows the interface name and the desired function name. An instance of LuaRemote is available through the + * global object named `remote`. + * + * {@link https://lua-api.factorio.com/next/LuaRemote.html View documentation} + * + * @example + * Will register a remote interface containing two functions. Later, it will call these functions through `remote`. + * + * ```lua + * remote.add_interface("human interactor", + * {hello = function() game.player.print("Hi!") end, + * bye = function(name) game.player.print("Bye " .. name) end}) + * -- Some time later, possibly in a different mod... + * remote.call("human interactor", "hello") + * remote.call("human interactor", "bye", "dear reader") + * ``` + * + * @noSelf + */ +interface LuaRemote { + /** + * Add a remote interface. + * + * **Note**: It is an error if the given interface `name` is already registered. + * + * {@link https://lua-api.factorio.com/next/LuaRemote.html#LuaRemote.add_interface View documentation} + * + * @param name - Name of the interface. + * @param functions - List of functions that are members of the new interface. + */ + add_interface(name: string, functions: Record void>): void + /** + * Removes an interface with the given name. + * + * {@link https://lua-api.factorio.com/next/LuaRemote.html#LuaRemote.remove_interface View documentation} + * + * @param name - Name of the interface. + * @returns If the interface was removed. `False` if the interface didn't exist. + */ + remove_interface(name: string): boolean + /** + * Call a function of an interface. + * + * {@link https://lua-api.factorio.com/next/LuaRemote.html#LuaRemote.call View documentation} + * + * @param _interface - Interface to look up `function` in. + * @param _function - Function name that belongs to `interface`. + * @param args - Arguments to pass to the called function. + */ + call(_interface: string, _function: string, ...args: Any[]): Any + /** + * List of all registered interfaces. For each interface name, `remote.interfaces[name]` is a dictionary mapping the + * interface's registered functions to the value `true`. + * + * {@link https://lua-api.factorio.com/next/LuaRemote.html#LuaRemote.interfaces View documentation} + * + * @example + * Assuming the "human interactor" interface is registered as above + * + * ```lua + * game.player.print(tostring(remote.interfaces["human interactor"]["hello"])) -- prints true + * game.player.print(tostring(remote.interfaces["human interactor"]["nonexistent"])) -- prints nil + * ``` + */ + readonly interfaces: Record> + /** This object's name. */ + readonly object_name: "LuaRemote" +} + +/** + * Allows rendering of geometric shapes, text and sprites in the game world. Each render object is identified by an id + * that is universally unique for the lifetime of a whole game. + * + * **Note**: If an entity target of an object is destroyed or changes surface, then the object is also destroyed. + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html View documentation} + * + * @noSelf + */ +interface LuaRendering { + /** + * Create a line. + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.draw_line View documentation} + * + * @example + * Draw a white and 2 pixel wide line from {0, 0} to {2, 2}. + * + * ```lua + * rendering.draw_line{surface = game.player.surface, from = {0, 0}, to = {2, 2}, color = {1, 1, 1}, width = 2} + * ``` + * + * @example + * Draw a red and 3 pixel wide line from {0, 0} to {0, 5}. The line has 1 tile long dashes and gaps. + * + * ```lua + * rendering.draw_line{surface = game.player.surface, from = {0, 0}, to = {0, 5}, color = {r = 1}, width = 3, gap_length = 1, dash_length = 1} + * ``` + * + * @returns Id of the render object + */ + draw_line(params: { + readonly color: Color + /** In pixels (32 per tile). */ + readonly width: float + /** Length of the gaps that this line has, in tiles. Default is 0. */ + readonly gap_length?: double + /** Length of the dashes that this line has. Used only if gap_length > 0. Default is 0. */ + readonly dash_length?: double + readonly from: Position | LuaEntity + /** Only used if `from` is a LuaEntity. */ + readonly from_offset?: Vector + readonly to: Position | LuaEntity + /** Only used if `to` is a LuaEntity. */ + readonly to_offset?: Vector + readonly surface: SurfaceIdentification + /** In ticks. Defaults to living forever. */ + readonly time_to_live?: uint + /** The forces that this object is rendered to. */ + readonly forces?: ForceIdentification[] + /** The players that this object is rendered to. */ + readonly players?: PlayerIdentification[] + /** If this is rendered to anyone at all. Defaults to true. */ + readonly visible?: boolean + /** If this should be drawn below sprites and entities. */ + readonly draw_on_ground?: boolean + /** If this should only be rendered in alt mode. Defaults to false. */ + readonly only_in_alt_mode?: boolean + }): uint64 + /** + * Create a text. + * + * **Note**: Not all fonts support scaling. + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.draw_text View documentation} + * + * @returns Id of the render object + */ + draw_text(params: { + /** The text to display. */ + readonly text: LocalisedString + readonly surface: SurfaceIdentification + readonly target: Position | LuaEntity + /** Only used if `target` is a LuaEntity. */ + readonly target_offset?: Vector + readonly color: Color + readonly scale?: double + /** Name of font to use. Defaults to the same font as flying-text. */ + readonly font?: string + /** In ticks. Defaults to living forever. */ + readonly time_to_live?: uint + /** The forces that this object is rendered to. */ + readonly forces?: ForceIdentification[] + /** The players that this object is rendered to. */ + readonly players?: PlayerIdentification[] + /** If this is rendered to anyone at all. Defaults to true. */ + readonly visible?: boolean + /** If this should be drawn below sprites and entities. */ + readonly draw_on_ground?: boolean + /** The orientation of the text. Default is 0. */ + readonly orientation?: RealOrientation + /** Defaults to "left". Other options are "right" and "center". */ + readonly alignment?: "left" | "right" | "center" + /** Defaults to "top". Other options are "middle", "baseline" and "bottom". */ + readonly vertical_alignment?: "top" | "middle" | "baseline" | "bottom" + /** + * Defaults to false. If true, the text scales with player zoom, resulting in it always being the same size on + * screen, and the size compared to the game world changes. + */ + readonly scale_with_zoom?: boolean + /** If this should only be rendered in alt mode. Defaults to false. */ + readonly only_in_alt_mode?: boolean + }): uint64 + /** + * Create a circle. + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.draw_circle View documentation} + * + * @returns Id of the render object + */ + draw_circle(params: { + readonly color: Color + /** In tiles. */ + readonly radius: double + /** Width of the outline, used only if filled = false. Value is in pixels (32 per tile). */ + readonly width?: float + /** If the circle should be filled. */ + readonly filled: boolean + readonly target: Position | LuaEntity + /** Only used if `target` is a LuaEntity. */ + readonly target_offset?: Vector + readonly surface: SurfaceIdentification + /** In ticks. Defaults to living forever. */ + readonly time_to_live?: uint + /** The forces that this object is rendered to. */ + readonly forces?: ForceIdentification[] + /** The players that this object is rendered to. */ + readonly players?: PlayerIdentification[] + /** If this is rendered to anyone at all. Defaults to true. */ + readonly visible?: boolean + /** If this should be drawn below sprites and entities. */ + readonly draw_on_ground?: boolean + /** If this should only be rendered in alt mode. Defaults to false. */ + readonly only_in_alt_mode?: boolean + }): uint64 + /** + * Create a rectangle. + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.draw_rectangle View documentation} + * + * @returns Id of the render object + */ + draw_rectangle(params: { + readonly color: Color + /** Width of the outline, used only if filled = false. Value is in pixels (32 per tile). */ + readonly width?: float + /** If the rectangle should be filled. */ + readonly filled: boolean + readonly left_top: Position | LuaEntity + /** Only used if `left_top` is a LuaEntity. */ + readonly left_top_offset?: Vector + readonly right_bottom: Position | LuaEntity + /** Only used if `right_bottom` is a LuaEntity. */ + readonly right_bottom_offset?: Vector + readonly surface: SurfaceIdentification + /** In ticks. Defaults to living forever. */ + readonly time_to_live?: uint + /** The forces that this object is rendered to. */ + readonly forces?: ForceIdentification[] + /** The players that this object is rendered to. */ + readonly players?: PlayerIdentification[] + /** If this is rendered to anyone at all. Defaults to true. */ + readonly visible?: boolean + /** If this should be drawn below sprites and entities. */ + readonly draw_on_ground?: boolean + /** If this should only be rendered in alt mode. Defaults to false. */ + readonly only_in_alt_mode?: boolean + }): uint64 + /** + * Create an arc. + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.draw_arc View documentation} + * + * @returns Id of the render object + */ + draw_arc(params: { + readonly color: Color + /** The radius of the outer edge of the arc, in tiles. */ + readonly max_radius: double + /** The radius of the inner edge of the arc, in tiles. */ + readonly min_radius: double + /** Where the arc starts, in radian. */ + readonly start_angle: float + /** The angle of the arc, in radian. */ + readonly angle: float + readonly target: Position | LuaEntity + /** Only used if `target` is a LuaEntity. */ + readonly target_offset?: Vector + readonly surface: SurfaceIdentification + /** In ticks. Defaults to living forever. */ + readonly time_to_live?: uint + /** The forces that this object is rendered to. */ + readonly forces?: ForceIdentification[] + /** The players that this object is rendered to. */ + readonly players?: PlayerIdentification[] + /** If this is rendered to anyone at all. Defaults to true. */ + readonly visible?: boolean + /** If this should be drawn below sprites and entities. */ + readonly draw_on_ground?: boolean + /** If this should only be rendered in alt mode. Defaults to false. */ + readonly only_in_alt_mode?: boolean + }): uint64 + /** + * Create a triangle mesh defined by a triangle strip. + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.draw_polygon View documentation} + * + * @returns Id of the render object + */ + draw_polygon(params: { + readonly color: Color + readonly vertices: ScriptRenderVertexTarget[] + /** Acts like an offset applied to all vertices that are not set to an entity. */ + readonly target?: Position | LuaEntity + /** Only used if `target` is a LuaEntity. */ + readonly target_offset?: Vector + /** The orientation applied to all vertices. Default is 0. */ + readonly orientation?: RealOrientation + /** + * If given, the vertices (that are not set to an entity) rotate so that it faces this target. Note that + * `orientation` is still applied. + */ + readonly orientation_target?: Position | LuaEntity + /** Only used if `orientation_target` is a LuaEntity. */ + readonly orientation_target_offset?: Vector + readonly surface: SurfaceIdentification + /** In ticks. Defaults to living forever. */ + readonly time_to_live?: uint + /** The forces that this object is rendered to. */ + readonly forces?: ForceIdentification[] + /** The players that this object is rendered to. */ + readonly players?: PlayerIdentification[] + /** If this is rendered to anyone at all. Defaults to true. */ + readonly visible?: boolean + /** If this should be drawn below sprites and entities. */ + readonly draw_on_ground?: boolean + /** If this should only be rendered in alt mode. Defaults to false. */ + readonly only_in_alt_mode?: boolean + }): uint64 + /** + * Create a sprite. + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.draw_sprite View documentation} + * + * @example + * This will draw an iron plate icon at the character's feet. The sprite will move together with the character. + * + * ```lua + * rendering.draw_sprite{sprite = "item.iron-plate", target = game.player.character, surface = game.player.surface} + * ``` + * + * @example + * This will draw an iron plate icon at the character's head. The sprite will move together with the character. + * + * ```lua + * rendering.draw_sprite{sprite = "item.iron-plate", target = game.player.character, target_offset = {0, -2}, surface = game.player.surface} + * ``` + * + * @returns Id of the render object + */ + draw_sprite(params: { + readonly sprite: SpritePath + /** The orientation of the sprite. Default is 0. */ + readonly orientation?: RealOrientation + /** Horizontal scale of the sprite. Default is 1. */ + readonly x_scale?: double + /** Vertical scale of the sprite. Default is 1. */ + readonly y_scale?: double + readonly tint?: Color + readonly render_layer?: RenderLayer + /** If given, the sprite rotates so that it faces this target. Note that `orientation` is still applied to the sprite. */ + readonly orientation_target?: Position | LuaEntity + /** Only used if `orientation_target` is a LuaEntity. */ + readonly orientation_target_offset?: Vector + /** Offsets the center of the sprite if `orientation_target` is given. This offset will rotate together with the sprite. */ + readonly oriented_offset?: Vector + /** Center of the sprite. */ + readonly target: Position | LuaEntity + /** Only used if `target` is a LuaEntity. */ + readonly target_offset?: Vector + readonly surface: SurfaceIdentification + /** In ticks. Defaults to living forever. */ + readonly time_to_live?: uint + /** The forces that this object is rendered to. */ + readonly forces?: ForceIdentification[] + /** The players that this object is rendered to. */ + readonly players?: PlayerIdentification[] + /** If this is rendered to anyone at all. Defaults to true. */ + readonly visible?: boolean + /** If this should only be rendered in alt mode. Defaults to false. */ + readonly only_in_alt_mode?: boolean + }): uint64 + /** + * Create a light. + * + * **Note**: The base game uses the utility sprites `light_medium` and `light_small` for lights. + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.draw_light View documentation} + * + * @returns Id of the render object + */ + draw_light(params: { + readonly sprite: SpritePath + /** The orientation of the light. Default is 0. */ + readonly orientation?: RealOrientation + /** Default is 1. */ + readonly scale?: float + /** Default is 1. */ + readonly intensity?: float + /** The minimum darkness at which this light is rendered. Default is 0. */ + readonly minimum_darkness?: float + /** + * If this light has the same orientation as the entity target, default is false. Note that `orientation` is + * still applied to the sprite. + */ + readonly oriented?: boolean + /** Defaults to white (no tint). */ + readonly color?: Color + /** Center of the light. */ + readonly target: Position | LuaEntity + /** Only used if `target` is a LuaEntity. */ + readonly target_offset?: Vector + readonly surface: SurfaceIdentification + /** In ticks. Defaults to living forever. */ + readonly time_to_live?: uint + /** The forces that this object is rendered to. */ + readonly forces?: ForceIdentification[] + /** The players that this object is rendered to. */ + readonly players?: PlayerIdentification[] + /** If this is rendered to anyone at all. Defaults to true. */ + readonly visible?: boolean + /** If this should only be rendered in alt mode. Defaults to false. */ + readonly only_in_alt_mode?: boolean + }): uint64 + /** + * Create an animation. + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.draw_animation View documentation} + * + * @returns Id of the render object + */ + draw_animation(params: { + /** Name of an {@link https://wiki.factorio.com/Prototype/Animation animation prototype}. */ + readonly animation: string + /** The orientation of the animation. Default is 0. */ + readonly orientation?: RealOrientation + /** Horizontal scale of the animation. Default is 1. */ + readonly x_scale?: double + /** Vertical scale of the animation. Default is 1. */ + readonly y_scale?: double + readonly tint?: Color + readonly render_layer?: RenderLayer + /** How many frames the animation goes forward per tick. Default is 1. */ + readonly animation_speed?: double + /** Offset of the animation in frames. Default is 0. */ + readonly animation_offset?: double + /** + * If given, the animation rotates so that it faces this target. Note that `orientation` is still applied to the + * animation. + */ + readonly orientation_target?: Position | LuaEntity + /** Only used if `orientation_target` is a LuaEntity. */ + readonly orientation_target_offset?: Vector + /** + * Offsets the center of the animation if `orientation_target` is given. This offset will rotate together with + * the animation. + */ + readonly oriented_offset?: Vector + /** Center of the animation. */ + readonly target: Position | LuaEntity + /** Only used if `target` is a LuaEntity. */ + readonly target_offset?: Vector + readonly surface: SurfaceIdentification + /** In ticks. Defaults to living forever. */ + readonly time_to_live?: uint + /** The forces that this object is rendered to. */ + readonly forces?: ForceIdentification[] + /** The players that this object is rendered to. */ + readonly players?: PlayerIdentification[] + /** If this is rendered to anyone at all. Defaults to true. */ + readonly visible?: boolean + /** If this should only be rendered in alt mode. Defaults to false. */ + readonly only_in_alt_mode?: boolean + }): uint64 + /** + * Destroy the object with the given id. + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.destroy View documentation} + * + * @param id + */ + destroy(id: uint64): void + /** + * Does a font with this name exist? + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.is_font_valid View documentation} + * + * @param font_name + */ + is_font_valid(font_name: string): boolean + /** + * Does a valid object with this id exist? + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.is_valid View documentation} + * + * @param id + */ + is_valid(id: uint64): boolean + /** + * Gets an array of all valid object ids. + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.get_all_ids View documentation} + * + * @param mod_name - If provided, get only the render objects created by this mod. + */ + get_all_ids(mod_name?: string): uint64[] + /** + * Destroys all render objects. + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.clear View documentation} + * + * @param mod_name - If provided, only the render objects created by this mod are destroyed. + */ + clear(mod_name?: string): void + /** + * Gets the type of the given object. The types are "text", "line", "circle", "rectangle", "arc", "polygon", + * "sprite", "light" and "animation". + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.get_type View documentation} + * + * @param id + */ + get_type(id: uint64): "text" | "line" | "circle" | "rectangle" | "arc" | "polygon" | "sprite" | "light" | "animation" + /** + * Reorder this object so that it is drawn in front of the already existing objects. + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.bring_to_front View documentation} + * + * @param id + */ + bring_to_front(id: uint64): void + /** + * The surface the object with this id is rendered on. + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.get_surface View documentation} + * + * @param id + */ + get_surface(id: uint64): LuaSurface + /** + * Get the time to live of the object with this id. This will be 0 if the object does not expire. + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.get_time_to_live View documentation} + * + * @param id + */ + get_time_to_live(id: uint64): uint + /** + * Set the time to live of the object with this id. Set to 0 if the object should not expire. + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.set_time_to_live View documentation} + * + * @param id + * @param time_to_live + */ + set_time_to_live(id: uint64, time_to_live: uint): void + /** + * Get the forces that the object with this id is rendered to or `nil` if visible to all forces. + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.get_forces View documentation} + * + * @param id + */ + get_forces(id: uint64): LuaForce[] | undefined + /** + * Set the forces that the object with this id is rendered to. + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.set_forces View documentation} + * + * @param id + * @param forces - Providing an empty array will set the object to be visible to all forces. + */ + set_forces(id: uint64, forces: ForceIdentification[]): void + /** + * Get the players that the object with this id is rendered to or `nil` if visible to all players. + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.get_players View documentation} + * + * @param id + */ + get_players(id: uint64): LuaPlayer[] | undefined + /** + * Set the players that the object with this id is rendered to. + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.set_players View documentation} + * + * @param id + * @param players - Providing an empty array will set the object to be visible to all players. + */ + set_players(id: uint64, players: PlayerIdentification[]): void + /** + * Get whether this is rendered to anyone at all. + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.get_visible View documentation} + * + * @param id + */ + get_visible(id: uint64): boolean + /** + * Set whether this is rendered to anyone at all. + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.set_visible View documentation} + * + * @param id + * @param visible + */ + set_visible(id: uint64, visible: boolean): void + /** + * Get whether this is being drawn on the ground, under most entities and sprites. + * + * *Can only be used if this is Text, Line, Circle, Rectangle, Arc or Polygon* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.get_draw_on_ground View documentation} + * + * @param id + */ + get_draw_on_ground(id: uint64): boolean + /** + * Set whether this is being drawn on the ground, under most entities and sprites. + * + * *Can only be used if this is Text, Line, Circle, Rectangle, Arc or Polygon* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.set_draw_on_ground View documentation} + * + * @param id + * @param draw_on_ground + */ + set_draw_on_ground(id: uint64, draw_on_ground: boolean): void + /** + * Get whether this is only rendered in alt-mode. + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.get_only_in_alt_mode View documentation} + * + * @param id + */ + get_only_in_alt_mode(id: uint64): boolean + /** + * Set whether this is only rendered in alt-mode. + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.set_only_in_alt_mode View documentation} + * + * @param id + * @param only_in_alt_mode + */ + set_only_in_alt_mode(id: uint64, only_in_alt_mode: boolean): void + /** + * Get the color or tint of the object with this id. + * + * *Can only be used if this is Text, Line, Circle, Rectangle, Arc, Polygon, Sprite, Light or Animation* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.get_color View documentation} + * + * @param id + * @returns Or `nil` if the object does not support color. + */ + get_color(id: uint64): ColorTable | undefined + /** + * Set the color or tint of the object with this id. Does nothing if this object does not support color. + * + * *Can only be used if this is Text, Line, Circle, Rectangle, Arc, Polygon, Sprite, Light or Animation* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.set_color View documentation} + * + * @param id + * @param color + */ + set_color(id: uint64, color: Color): void + /** + * Get the width of the object with this id. Value is in pixels (32 per tile). + * + * *Can only be used if this is Line, Circle or Rectangle* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.get_width View documentation} + * + * @param id + * @returns Or `nil` if the object does not support width. + */ + get_width(id: uint64): float | undefined + /** + * Set the width of the object with this id. Does nothing if this object does not support width. Value is in pixels + * (32 per tile). + * + * *Can only be used if this is Line, Circle or Rectangle* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.set_width View documentation} + * + * @param id + * @param width + */ + set_width(id: uint64, width: float): void + /** + * Get from where the line with this id is drawn or `nil` if this object is not a line. + * + * *Can only be used if this is Line* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.get_from View documentation} + * + * @param id + */ + get_from(id: uint64): ScriptRenderTarget | undefined + /** + * Set from where the line with this id is drawn. Does nothing if the object is not a line. + * + * *Can only be used if this is Line* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.set_from View documentation} + * + * @param id + * @param from + * @param from_offset + */ + set_from(id: uint64, from: Position | LuaEntity, from_offset?: Vector): void + /** + * Get where the line with this id is drawn to or `nil` if the object is not a line. + * + * *Can only be used if this is Line* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.get_to View documentation} + * + * @param id + */ + get_to(id: uint64): ScriptRenderTarget | undefined + /** + * Set where the line with this id is drawn to. Does nothing if this object is not a line. + * + * *Can only be used if this is Line* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.set_to View documentation} + * + * @param id + * @param to + * @param to_offset + */ + set_to(id: uint64, to: Position | LuaEntity, to_offset?: Vector): void + /** + * Get the dash length of the line with this id or `nil` if the object is not a line. + * + * *Can only be used if this is Line* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.get_dash_length View documentation} + * + * @param id + */ + get_dash_length(id: uint64): double | undefined + /** + * Set the dash length of the line with this id. Does nothing if this object is not a line. + * + * *Can only be used if this is Line* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.set_dash_length View documentation} + * + * @param id + * @param dash_length + */ + set_dash_length(id: uint64, dash_length: double): void + /** + * Get the length of the gaps in the line with this id or `nil` if the object is not a line. + * + * *Can only be used if this is Line* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.get_gap_length View documentation} + * + * @param id + */ + get_gap_length(id: uint64): double | undefined + /** + * Set the length of the gaps in the line with this id. Does nothing if this object is not a line. + * + * *Can only be used if this is Line* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.set_gap_length View documentation} + * + * @param id + * @param gap_length + */ + set_gap_length(id: uint64, gap_length: double): void + /** + * Set the length of the dashes and the length of the gaps in the line with this id. Does nothing if this object is + * not a line. + * + * *Can only be used if this is Line* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.set_dashes View documentation} + * + * @param id + * @param dash_length + * @param gap_length + */ + set_dashes(id: uint64, dash_length: double, gap_length: double): void + /** + * Get where the object with this id is drawn or `nil` if the object does not support target. + * + * **Note**: Polygon vertices that are set to an entity will ignore this. + * + * *Can only be used if this is Text, Circle, Arc, Polygon, Sprite, Light or Animation* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.get_target View documentation} + * + * @param id + */ + get_target(id: uint64): ScriptRenderTarget | undefined + /** + * Set where the object with this id is drawn. Does nothing if this object does not support target. + * + * **Note**: Polygon vertices that are set to an entity will ignore this. + * + * *Can only be used if this is Text, Circle, Arc, Polygon, Sprite, Light or Animation* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.set_target View documentation} + * + * @param id + * @param target + * @param target_offset + */ + set_target(id: uint64, target: Position | LuaEntity, target_offset?: Vector): void + /** + * Get the orientation of the object with this id or `nil` if the object is not a text, polygon, sprite, light or animation. + * + * **Note**: Polygon vertices that are set to an entity will ignore this. + * + * *Can only be used if this is Text, Polygon, Sprite, Light or Animation* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.get_orientation View documentation} + * + * @param id + */ + get_orientation(id: uint64): RealOrientation | undefined + /** + * Set the orientation of the object with this id. Does nothing if this object is not a text, polygon, sprite, light + * or animation. + * + * **Note**: Polygon vertices that are set to an entity will ignore this. + * + * *Can only be used if this is Text, Polygon, Sprite, Light or Animation* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.set_orientation View documentation} + * + * @param id + * @param orientation + */ + set_orientation(id: uint64, orientation: RealOrientation): void + /** + * Get the scale of the text or light with this id or `nil` if the object is not a text or light. + * + * *Can only be used if this is Text or Light* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.get_scale View documentation} + * + * @param id + */ + get_scale(id: uint64): double | undefined + /** + * Set the scale of the text or light with this id. Does nothing if this object is not a text or light. + * + * *Can only be used if this is Text or Light* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.set_scale View documentation} + * + * @param id + * @param scale + */ + set_scale(id: uint64, scale: double): void + /** + * Get the text that is displayed by the text with this id or `nil` if the object is not a text. + * + * *Can only be used if this is Text* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.get_text View documentation} + * + * @param id + */ + get_text(id: uint64): LocalisedString | undefined + /** + * Set the text that is displayed by the text with this id. Does nothing if this object is not a text. + * + * *Can only be used if this is Text* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.set_text View documentation} + * + * @param id + * @param text + */ + set_text(id: uint64, text: LocalisedString): void + /** + * Get the font of the text with this id or `nil` if the object is not a text. + * + * *Can only be used if this is Text* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.get_font View documentation} + * + * @param id + */ + get_font(id: uint64): string | undefined + /** + * Set the font of the text with this id. Does nothing if this object is not a text. + * + * *Can only be used if this is Text* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.set_font View documentation} + * + * @param id + * @param font + */ + set_font(id: uint64, font: string): void + /** + * Get the alignment of the text with this id or `nil` if the object is not a text. + * + * *Can only be used if this is Text* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.get_alignment View documentation} + * + * @param id + */ + get_alignment(id: uint64): string | undefined + /** + * Set the alignment of the text with this id. Does nothing if this object is not a text. + * + * *Can only be used if this is Text* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.set_alignment View documentation} + * + * @param id + * @param alignment - "left", "right" or "center". + */ + set_alignment(id: uint64, alignment: "left" | "right" | "center"): void + /** + * Get the vertical alignment of the text with this id or `nil` if the object is not a text. + * + * *Can only be used if this is Text* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.get_vertical_alignment View documentation} + * + * @param id + */ + get_vertical_alignment(id: uint64): string | undefined + /** + * Set the vertical alignment of the text with this id. Does nothing if this object is not a text. + * + * *Can only be used if this is Text* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.set_vertical_alignment View documentation} + * + * @param id + * @param alignment - "top", "middle", "baseline" or "bottom" + */ + set_vertical_alignment(id: uint64, alignment: "top" | "middle" | "baseline" | "bottom"): void + /** + * Get if the text with this id scales with player zoom or `nil` if the object is not a text. + * + * *Can only be used if this is Text* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.get_scale_with_zoom View documentation} + * + * @param id + */ + get_scale_with_zoom(id: uint64): boolean | undefined + /** + * Set if the text with this id scales with player zoom, resulting in it always being the same size on screen, and + * the size compared to the game world changes. Does nothing if this object is not a text. + * + * *Can only be used if this is Text* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.set_scale_with_zoom View documentation} + * + * @param id + * @param scale_with_zoom + */ + set_scale_with_zoom(id: uint64, scale_with_zoom: boolean): void + /** + * Get if the circle or rectangle with this id is filled or `nil` if the object is not a circle or rectangle. + * + * *Can only be used if this is Circle or Rectangle* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.get_filled View documentation} + * + * @param id + */ + get_filled(id: uint64): boolean | undefined + /** + * Set if the circle or rectangle with this id is filled. Does nothing if this object is not a circle or rectangle. + * + * *Can only be used if this is Circle or Rectangle* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.set_filled View documentation} + * + * @param id + * @param filled + */ + set_filled(id: uint64, filled: boolean): void + /** + * Get the radius of the circle with this id or `nil` if the object is not a circle. + * + * *Can only be used if this is Circle* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.get_radius View documentation} + * + * @param id + */ + get_radius(id: uint64): double | undefined + /** + * Set the radius of the circle with this id. Does nothing if this object is not a circle. + * + * *Can only be used if this is Circle* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.set_radius View documentation} + * + * @param id + * @param radius + */ + set_radius(id: uint64, radius: double): void + /** + * Get where top left corner of the rectangle with this id is drawn or `nil` if the object is not a rectangle. + * + * *Can only be used if this is Rectangle* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.get_left_top View documentation} + * + * @param id + */ + get_left_top(id: uint64): ScriptRenderTarget | undefined + /** + * Set where top left corner of the rectangle with this id is drawn. Does nothing if this object is not a rectangle. + * + * *Can only be used if this is Rectangle* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.set_left_top View documentation} + * + * @param id + * @param left_top + * @param left_top_offset + */ + set_left_top(id: uint64, left_top: Position | LuaEntity, left_top_offset?: Vector): void + /** + * Get where bottom right corner of the rectangle with this id is drawn or `nil` if the object is not a rectangle. + * + * *Can only be used if this is Rectangle* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.get_right_bottom View documentation} + * + * @param id + */ + get_right_bottom(id: uint64): ScriptRenderTarget | undefined + /** + * Set where top bottom right of the rectangle with this id is drawn. Does nothing if this object is not a rectangle. + * + * *Can only be used if this is Rectangle* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.set_right_bottom View documentation} + * + * @param id + * @param right_bottom + * @param right_bottom_offset + */ + set_right_bottom(id: uint64, right_bottom: Position | LuaEntity, right_bottom_offset?: Vector): void + /** + * Set the corners of the rectangle with this id. Does nothing if this object is not a rectangle. + * + * *Can only be used if this is Rectangle* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.set_corners View documentation} + * + * @param id + * @param left_top + * @param left_top_offset + * @param right_bottom + * @param right_bottom_offset + */ + set_corners( + id: uint64, + left_top: Position | LuaEntity, + left_top_offset: Vector, + right_bottom: Position | LuaEntity, + right_bottom_offset: Vector + ): void + /** + * Get the radius of the outer edge of the arc with this id or `nil` if the object is not a arc. + * + * *Can only be used if this is Arc* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.get_max_radius View documentation} + * + * @param id + */ + get_max_radius(id: uint64): double | undefined + /** + * Set the radius of the outer edge of the arc with this id. Does nothing if this object is not a arc. + * + * *Can only be used if this is Arc* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.set_max_radius View documentation} + * + * @param id + * @param max_radius + */ + set_max_radius(id: uint64, max_radius: double): void + /** + * Get the radius of the inner edge of the arc with this id or `nil` if the object is not a arc. + * + * *Can only be used if this is Arc* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.get_min_radius View documentation} + * + * @param id + */ + get_min_radius(id: uint64): double | undefined + /** + * Set the radius of the inner edge of the arc with this id. Does nothing if this object is not a arc. + * + * *Can only be used if this is Arc* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.set_min_radius View documentation} + * + * @param id + * @param min_radius + */ + set_min_radius(id: uint64, min_radius: double): void + /** + * Get where the arc with this id starts or `nil` if the object is not a arc. + * + * *Can only be used if this is Arc* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.get_start_angle View documentation} + * + * @param id + * @returns Angle in radian + */ + get_start_angle(id: uint64): float | undefined + /** + * Set where the arc with this id starts. Does nothing if this object is not a arc. + * + * *Can only be used if this is Arc* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.set_start_angle View documentation} + * + * @param id + * @param start_angle - Angle in radian + */ + set_start_angle(id: uint64, start_angle: float): void + /** + * Get the angle of the arc with this id or `nil` if the object is not a arc. + * + * *Can only be used if this is Arc* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.get_angle View documentation} + * + * @param id + * @returns Angle in radian + */ + get_angle(id: uint64): float | undefined + /** + * Set the angle of the arc with this id. Does nothing if this object is not a arc. + * + * *Can only be used if this is Arc* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.set_angle View documentation} + * + * @param id + * @param angle - Angle in radian + */ + set_angle(id: uint64, angle: float): void + /** + * Get the vertices of the polygon with this id or `nil` if the object is not a polygon. + * + * *Can only be used if this is Polygon* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.get_vertices View documentation} + * + * @param id + */ + get_vertices(id: uint64): ScriptRenderTarget[] | undefined + /** + * Set the vertices of the polygon with this id. Does nothing if this object is not a polygon. + * + * *Can only be used if this is Polygon* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.set_vertices View documentation} + * + * @param id + * @param vertices + */ + set_vertices(id: uint64, vertices: ScriptRenderVertexTarget[]): void + /** + * Get the sprite of the sprite or light with this id or `nil` if the object is not a sprite or light. + * + * *Can only be used if this is Sprite or Light* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.get_sprite View documentation} + * + * @param id + */ + get_sprite(id: uint64): SpritePath | undefined + /** + * Set the sprite of the sprite or light with this id. Does nothing if this object is not a sprite or light. + * + * *Can only be used if this is Sprite or Light* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.set_sprite View documentation} + * + * @param id + * @param sprite + */ + set_sprite(id: uint64, sprite: SpritePath): void + /** + * Get the horizontal scale of the sprite or animation with this id or `nil` if the object is not a sprite or animation. + * + * *Can only be used if this is Sprite or Animation* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.get_x_scale View documentation} + * + * @param id + */ + get_x_scale(id: uint64): double | undefined + /** + * Set the horizontal scale of the sprite or animation with this id. Does nothing if this object is not a sprite or animation. + * + * *Can only be used if this is Sprite or Animation* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.set_x_scale View documentation} + * + * @param id + * @param x_scale + */ + set_x_scale(id: uint64, x_scale: double): void + /** + * Get the vertical scale of the sprite or animation with this id or `nil` if the object is not a sprite or animation. + * + * *Can only be used if this is Sprite or Animation* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.get_y_scale View documentation} + * + * @param id + */ + get_y_scale(id: uint64): double | undefined + /** + * Set the vertical scale of the sprite or animation with this id. Does nothing if this object is not a sprite or animation. + * + * *Can only be used if this is Sprite or Animation* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.set_y_scale View documentation} + * + * @param id + * @param y_scale + */ + set_y_scale(id: uint64, y_scale: double): void + /** + * Get the render layer of the sprite or animation with this id or `nil` if the object is not a sprite or animation. + * + * *Can only be used if this is Sprite or Animation* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.get_render_layer View documentation} + * + * @param id + */ + get_render_layer(id: uint64): RenderLayer | undefined + /** + * Set the render layer of the sprite or animation with this id. Does nothing if this object is not a sprite or animation. + * + * *Can only be used if this is Sprite or Animation* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.set_render_layer View documentation} + * + * @param id + * @param render_layer + */ + set_render_layer(id: uint64, render_layer: RenderLayer): void + /** + * The object rotates so that it faces this target. Note that `orientation` is still applied to the object. Get the + * orientation_target of the object with this id or `nil` if no target or if this object is not a polygon, sprite, + * or animation. + * + * **Note**: Polygon vertices that are set to an entity will ignore this. + * + * *Can only be used if this is Polygon, Sprite or Animation* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.get_orientation_target View documentation} + * + * @param id + */ + get_orientation_target(id: uint64): ScriptRenderTarget | undefined + /** + * The object rotates so that it faces this target. Note that `orientation` is still applied to the object. Set the + * orientation_target of the object with this id. Does nothing if this object is not a polygon, sprite, or + * animation. Set to `nil` if the object should not have an orientation_target. + * + * **Note**: Polygon vertices that are set to an entity will ignore this. + * + * *Can only be used if this is Polygon, Sprite or Animation* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.set_orientation_target View documentation} + * + * @param id + * @param orientation_target + * @param orientation_target_offset + */ + set_orientation_target(id: uint64, orientation_target: Position | LuaEntity, orientation_target_offset?: Vector): void + /** + * Offsets the center of the sprite or animation if `orientation_target` is given. This offset will rotate together + * with the sprite or animation. Get the oriented_offset of the sprite or animation with this id or `nil` if this + * object is not a sprite or animation. + * + * *Can only be used if this is Sprite or Animation* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.get_oriented_offset View documentation} + * + * @param id + */ + get_oriented_offset(id: uint64): Vector | undefined + /** + * Offsets the center of the sprite or animation if `orientation_target` is given. This offset will rotate together + * with the sprite or animation. Set the oriented_offset of the sprite or animation with this id. Does nothing if + * this object is not a sprite or animation. + * + * *Can only be used if this is Sprite or Animation* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.set_oriented_offset View documentation} + * + * @param id + * @param oriented_offset + */ + set_oriented_offset(id: uint64, oriented_offset: Vector): void + /** + * Get the intensity of the light with this id or `nil` if the object is not a light. + * + * *Can only be used if this is Light* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.get_intensity View documentation} + * + * @param id + */ + get_intensity(id: uint64): float | undefined + /** + * Set the intensity of the light with this id. Does nothing if this object is not a light. + * + * *Can only be used if this is Light* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.set_intensity View documentation} + * + * @param id + * @param intensity + */ + set_intensity(id: uint64, intensity: float): void + /** + * Get the minimum darkness at which the light with this id is rendered or `nil` if the object is not a light. + * + * *Can only be used if this is Light* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.get_minimum_darkness View documentation} + * + * @param id + */ + get_minimum_darkness(id: uint64): float | undefined + /** + * Set the minimum darkness at which the light with this id is rendered. Does nothing if this object is not a light. + * + * *Can only be used if this is Light* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.set_minimum_darkness View documentation} + * + * @param id + * @param minimum_darkness + */ + set_minimum_darkness(id: uint64, minimum_darkness: float): void + /** + * Get if the light with this id is rendered has the same orientation as the target entity or `nil` if the object is + * not a light. Note that `orientation` is still applied to the sprite. + * + * *Can only be used if this is Light* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.get_oriented View documentation} + * + * @param id + */ + get_oriented(id: uint64): boolean | undefined + /** + * Set if the light with this id is rendered has the same orientation as the target entity. Does nothing if this + * object is not a light. Note that `orientation` is still applied to the sprite. + * + * *Can only be used if this is Light* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.set_oriented View documentation} + * + * @param id + * @param oriented + */ + set_oriented(id: uint64, oriented: boolean): void + /** + * Get the animation prototype name of the animation with this id or `nil` if the object is not an animation. + * + * *Can only be used if this is Animation* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.get_animation View documentation} + * + * @param id + */ + get_animation(id: uint64): string | undefined + /** + * Set the animation prototype name of the animation with this id. Does nothing if this object is not an animation. + * + * *Can only be used if this is Animation* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.set_animation View documentation} + * + * @param id + * @param animation + */ + set_animation(id: uint64, animation: string): void + /** + * Get the animation speed of the animation with this id or `nil` if the object is not an animation. + * + * *Can only be used if this is Animation* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.get_animation_speed View documentation} + * + * @param id + * @returns Animation speed in frames per tick. + */ + get_animation_speed(id: uint64): double | undefined + /** + * Set the animation speed of the animation with this id. Does nothing if this object is not an animation. + * + * *Can only be used if this is Animation* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.set_animation_speed View documentation} + * + * @param id + * @param animation_speed - Animation speed in frames per tick. + */ + set_animation_speed(id: uint64, animation_speed: double): void + /** + * Get the animation offset of the animation with this id or `nil` if the object is not an animation. + * + * *Can only be used if this is Animation* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.get_animation_offset View documentation} + * + * @param id + * @returns Animation offset in frames. + */ + get_animation_offset(id: uint64): double | undefined + /** + * Set the animation offset of the animation with this id. Does nothing if this object is not an animation. + * + * *Can only be used if this is Animation* + * + * {@link https://lua-api.factorio.com/next/LuaRendering.html#LuaRendering.set_animation_offset View documentation} + * + * @param id + * @param animation_offset - Animation offset in frames. + */ + set_animation_offset(id: uint64, animation_offset: double): void + /** This object's name. */ + readonly object_name: "LuaRendering" +} + +/** + * Prototype of a resource category. + * + * {@link https://lua-api.factorio.com/next/LuaResourceCategoryPrototype.html View documentation} + * + * @noSelf + */ +interface LuaResourceCategoryPrototype { + /** + * Name of this prototype. + * + * {@link https://lua-api.factorio.com/next/LuaResourceCategoryPrototype.html#LuaResourceCategoryPrototype.name View documentation} + */ + readonly name: string + /** + * Order string of this prototype. + * + * {@link https://lua-api.factorio.com/next/LuaResourceCategoryPrototype.html#LuaResourceCategoryPrototype.order View documentation} + */ + readonly order: string + readonly localised_name: LocalisedString + readonly localised_description: LocalisedString + /** + * 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: "LuaResourceCategoryPrototype" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * Control behavior for roboports. + * + * {@link https://lua-api.factorio.com/next/LuaRoboportControlBehavior.html View documentation} + * + * @noSelf + */ +interface LuaRoboportControlBehavior extends LuaControlBehavior { + /** + * `true` if the roboport should report the logistics network content to the circuit network. + * + * {@link https://lua-api.factorio.com/next/LuaRoboportControlBehavior.html#LuaRoboportControlBehavior.read_logistics View documentation} + */ + read_logistics: boolean + /** + * `true` if the roboport should report the robot statistics to the circuit network. + * + * {@link https://lua-api.factorio.com/next/LuaRoboportControlBehavior.html#LuaRoboportControlBehavior.read_robot_stats View documentation} + */ + read_robot_stats: boolean + available_logistic_output_signal: SignalID + total_logistic_output_signal: SignalID + available_construction_output_signal: SignalID + total_construction_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: "LuaRoboportControlBehavior" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * Object containing mod settings of three distinct types: `startup`, `global`, and `player`. An instance of LuaSettings + * is available through the global object named `settings`. + * + * {@link https://lua-api.factorio.com/next/LuaSettings.html View documentation} + * + * @noSelf + */ +interface LuaSettings { + /** + * Gets the current per-player settings for the given player, indexed by prototype name. Returns the same structure + * as {@link LuaPlayer.mod_settings LuaPlayer::mod_settings}. + * + * **Note**: This can become invalid if during operation if the given player becomes invalid. + * + * {@link https://lua-api.factorio.com/next/LuaSettings.html#LuaSettings.get_player_settings View documentation} + * + * @param player + */ + get_player_settings(player: PlayerIdentification): LuaCustomTable + /** + * The startup mod settings, indexed by prototype name. + * + * {@link https://lua-api.factorio.com/next/LuaSettings.html#LuaSettings.startup View documentation} + */ + readonly startup: LuaCustomTable + /** + * The current global mod settings, indexed by prototype name. + * + * Even though these are marked as read-only, they can be changed by overwriting individual {@link ModSetting} tables + * in the custom table. Mods can only change their own settings. Using the in-game console, all global settings can + * be changed. + * + * {@link https://lua-api.factorio.com/next/LuaSettings.html#LuaSettings.global View documentation} + */ + readonly global: LuaCustomTable + /** + * The default player mod settings for this map, indexed by prototype name. + * + * Even though these are marked as read-only, they can be changed by overwriting individual {@link ModSetting} tables + * in the custom table. Mods can only change their own settings. Using the in-game console, all player settings can + * be changed. + * + * {@link https://lua-api.factorio.com/next/LuaSettings.html#LuaSettings.player View documentation} + */ + readonly player: LuaCustomTable + /** This object's name. */ + readonly object_name: "LuaSettings" +} + +/** + * Prototype of a shortcut. + * + * {@link https://lua-api.factorio.com/next/LuaShortcutPrototype.html View documentation} + * + * @noSelf + */ +interface LuaShortcutPrototype { + /** + * Name of this prototype. + * + * {@link https://lua-api.factorio.com/next/LuaShortcutPrototype.html#LuaShortcutPrototype.name View documentation} + */ + readonly name: string + /** + * Order string of this prototype. + * + * {@link https://lua-api.factorio.com/next/LuaShortcutPrototype.html#LuaShortcutPrototype.order View documentation} + */ + readonly order: string + readonly localised_name: LocalisedString + readonly localised_description: LocalisedString + readonly action: string + readonly item_to_spawn: LuaItemPrototype + readonly technology_to_unlock: LuaTechnologyPrototype + readonly toggleable: boolean + readonly associated_control_input: 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: "LuaShortcutPrototype" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * Control behavior for storage tanks. + * + * {@link https://lua-api.factorio.com/next/LuaStorageTankControlBehavior.html View documentation} + * + * @noSelf + */ +interface LuaStorageTankControlBehavior extends LuaControlBehavior { + /** + * 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: "LuaStorageTankControlBehavior" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * Style of a GUI element. All of the attributes listed here may be `nil` if not available for a particular GUI element. + * + * {@link https://lua-api.factorio.com/next/LuaStyle.html View documentation} + * + * @noSelf + */ +interface LuaStyle { + /** + * Gui of the {@link LuaGuiElement} of this style. + * + * {@link https://lua-api.factorio.com/next/LuaStyle.html#LuaStyle.gui View documentation} + */ + readonly gui: LuaGui + /** + * Name of this style. + * + * {@link https://lua-api.factorio.com/next/LuaStyle.html#LuaStyle.name View documentation} + */ + readonly name: string + /** + * Minimal width ensures, that the widget will never be smaller than than that size. It can't be squashed to be smaller. + * + * {@link https://lua-api.factorio.com/next/LuaStyle.html#LuaStyle.minimal_width View documentation} + */ + minimal_width: int + /** + * Maximal width ensures, that the widget will never be bigger than than that size. It can't be stretched to be bigger. + * + * {@link https://lua-api.factorio.com/next/LuaStyle.html#LuaStyle.maximal_width View documentation} + */ + maximal_width: int + /** + * Minimal height ensures, that the widget will never be smaller than than that size. It can't be squashed to be smaller. + * + * {@link https://lua-api.factorio.com/next/LuaStyle.html#LuaStyle.minimal_height View documentation} + */ + minimal_height: int + /** + * Maximal height ensures, that the widget will never be bigger than than that size. It can't be stretched to be bigger. + * + * {@link https://lua-api.factorio.com/next/LuaStyle.html#LuaStyle.maximal_height View documentation} + */ + maximal_height: int + /** + * Natural width specifies the width of the element tries to have, but it can still be squashed/stretched to have a + * smaller or bigger size. + * + * {@link https://lua-api.factorio.com/next/LuaStyle.html#LuaStyle.natural_width View documentation} + */ + natural_width: int + /** + * Natural height specifies the height of the element tries to have, but it can still be squashed/stretched to have + * a smaller or bigger size. + * + * {@link https://lua-api.factorio.com/next/LuaStyle.html#LuaStyle.natural_height View documentation} + */ + natural_height: int + top_padding: int + right_padding: int + bottom_padding: int + left_padding: int + top_margin: int + right_margin: int + bottom_margin: int + left_margin: int + /** + * Horizontal align of the inner content of the widget, possible values are "left", "center" or "right" + * + * {@link https://lua-api.factorio.com/next/LuaStyle.html#LuaStyle.horizontal_align View documentation} + */ + horizontal_align: "left" | "center" | "right" + /** + * Vertical align of the inner content of the widget, possible values are "top", "center" or "bottom" + * + * {@link https://lua-api.factorio.com/next/LuaStyle.html#LuaStyle.vertical_align View documentation} + */ + vertical_align: "top" | "center" | "bottom" + font_color: Color + font: string + /** + * Space between the table cell contents top and border. + * + * *Can only be used if this is LuaTableStyle* + * + * {@link https://lua-api.factorio.com/next/LuaStyle.html#LuaStyle.top_cell_padding View documentation} + */ + top_cell_padding: int + /** + * Space between the table cell contents right and border. + * + * *Can only be used if this is LuaTableStyle* + * + * {@link https://lua-api.factorio.com/next/LuaStyle.html#LuaStyle.right_cell_padding View documentation} + */ + right_cell_padding: int + /** + * Space between the table cell contents bottom and border. + * + * *Can only be used if this is LuaTableStyle* + * + * {@link https://lua-api.factorio.com/next/LuaStyle.html#LuaStyle.bottom_cell_padding View documentation} + */ + bottom_cell_padding: int + /** + * Space between the table cell contents left and border. + * + * *Can only be used if this is LuaTableStyle* + * + * {@link https://lua-api.factorio.com/next/LuaStyle.html#LuaStyle.left_cell_padding View documentation} + */ + left_cell_padding: int + /** + * If the GUI element stretches its size horizontally to other elements. + * + * {@link https://lua-api.factorio.com/next/LuaStyle.html#LuaStyle.horizontally_stretchable View documentation} + */ + horizontally_stretchable: boolean + /** + * If the GUI element stretches its size vertically to other elements. + * + * {@link https://lua-api.factorio.com/next/LuaStyle.html#LuaStyle.vertically_stretchable View documentation} + */ + vertically_stretchable: boolean + /** + * If the GUI element can be squashed (by maximal width of some parent element) horizontally. This is mainly meant + * to be used for scroll-pane The default value is false. + * + * {@link https://lua-api.factorio.com/next/LuaStyle.html#LuaStyle.horizontally_squashable View documentation} + */ + horizontally_squashable: boolean + /** + * If the GUI element can be squashed (by maximal height of some parent element) vertically. This is mainly meant to + * be used for scroll-pane The default (parent) value for scroll pane is true, false otherwise. + * + * {@link https://lua-api.factorio.com/next/LuaStyle.html#LuaStyle.vertically_squashable View documentation} + */ + vertically_squashable: boolean + /** + * How this GUI element handles rich text. + * + * *Can only be used if this is LuaLabelStyle, LuaTextBoxStyle or LuaTextFieldStyle* + * + * {@link https://lua-api.factorio.com/next/LuaStyle.html#LuaStyle.rich_text_setting View documentation} + */ + rich_text_setting: defines.rich_text_setting + /** + * *Can only be used if this is LuaButtonStyle* + * + * {@link https://lua-api.factorio.com/next/LuaStyle.html#LuaStyle.hovered_font_color View documentation} + */ + hovered_font_color: Color + /** + * *Can only be used if this is LuaButtonStyle* + * + * {@link https://lua-api.factorio.com/next/LuaStyle.html#LuaStyle.clicked_font_color View documentation} + */ + clicked_font_color: Color + /** + * *Can only be used if this is LuaButtonStyle or LuaTabStyle* + * + * {@link https://lua-api.factorio.com/next/LuaStyle.html#LuaStyle.disabled_font_color View documentation} + */ + disabled_font_color: Color + /** + * *Can only be used if this is LuaButtonStyle* + * + * {@link https://lua-api.factorio.com/next/LuaStyle.html#LuaStyle.pie_progress_color View documentation} + */ + pie_progress_color: Color + /** + * *Can only be used if this is LuaButtonStyle* + * + * {@link https://lua-api.factorio.com/next/LuaStyle.html#LuaStyle.clicked_vertical_offset View documentation} + */ + clicked_vertical_offset: int + /** + * *Can only be used if this is LuaButtonStyle* + * + * {@link https://lua-api.factorio.com/next/LuaStyle.html#LuaStyle.selected_font_color View documentation} + */ + selected_font_color: Color + /** + * *Can only be used if this is LuaButtonStyle* + * + * {@link https://lua-api.factorio.com/next/LuaStyle.html#LuaStyle.selected_hovered_font_color View documentation} + */ + selected_hovered_font_color: Color + /** + * *Can only be used if this is LuaButtonStyle* + * + * {@link https://lua-api.factorio.com/next/LuaStyle.html#LuaStyle.selected_clicked_font_color View documentation} + */ + selected_clicked_font_color: Color + /** + * *Can only be used if this is LuaButtonStyle* + * + * {@link https://lua-api.factorio.com/next/LuaStyle.html#LuaStyle.strikethrough_color View documentation} + */ + strikethrough_color: Color + /** + * Horizontal space between individual cells. + * + * *Can only be used if this is LuaTableStyle, LuaFlowStyle or LuaHorizontalFlow* + * + * {@link https://lua-api.factorio.com/next/LuaStyle.html#LuaStyle.horizontal_spacing View documentation} + */ + horizontal_spacing: int + /** + * Vertical space between individual cells. + * + * *Can only be used if this is LuaTableStyle, LuaFlowStyle, LuaVerticalFlowStyle or LuaTabbedPaneStyle* + * + * {@link https://lua-api.factorio.com/next/LuaStyle.html#LuaStyle.vertical_spacing View documentation} + */ + vertical_spacing: int + /** + * *Can only be used if this is LuaFrameStyle* + * + * {@link https://lua-api.factorio.com/next/LuaStyle.html#LuaStyle.use_header_filler View documentation} + */ + use_header_filler: boolean + /** + * *Can only be used if this is LuaProgressBarStyle* + * + * {@link https://lua-api.factorio.com/next/LuaStyle.html#LuaStyle.color View documentation} + */ + color: Color + /** + * Array containing the alignment for every column of this table element. Even though this property is marked as + * read-only, the alignment can be changed by indexing the LuaCustomTable, like so: + * + * {@link https://lua-api.factorio.com/next/LuaStyle.html#LuaStyle.column_alignments View documentation} + * + * @example + * ```lua + * table_element.style.column_alignments[1] = "center" + * ``` + */ + readonly column_alignments: LuaCustomTable + /** + * *Can only be used if this is LabelStyle* + * + * {@link https://lua-api.factorio.com/next/LuaStyle.html#LuaStyle.single_line View documentation} + */ + single_line: boolean + /** + * *Can only be used if this is ScrollPaneStyle* + * + * {@link https://lua-api.factorio.com/next/LuaStyle.html#LuaStyle.extra_top_padding_when_activated View documentation} + */ + extra_top_padding_when_activated: int + /** + * *Can only be used if this is ScrollPaneStyle* + * + * {@link https://lua-api.factorio.com/next/LuaStyle.html#LuaStyle.extra_bottom_padding_when_activated View documentation} + */ + extra_bottom_padding_when_activated: int + /** + * *Can only be used if this is ScrollPaneStyle* + * + * {@link https://lua-api.factorio.com/next/LuaStyle.html#LuaStyle.extra_left_padding_when_activated View documentation} + */ + extra_left_padding_when_activated: int + /** + * *Can only be used if this is ScrollPaneStyle* + * + * {@link https://lua-api.factorio.com/next/LuaStyle.html#LuaStyle.extra_right_padding_when_activated View documentation} + */ + extra_right_padding_when_activated: int + /** + * *Can only be used if this is ScrollPaneStyle* + * + * {@link https://lua-api.factorio.com/next/LuaStyle.html#LuaStyle.extra_top_margin_when_activated View documentation} + */ + extra_top_margin_when_activated: int + /** + * *Can only be used if this is ScrollPaneStyle* + * + * {@link https://lua-api.factorio.com/next/LuaStyle.html#LuaStyle.extra_bottom_margin_when_activated View documentation} + */ + extra_bottom_margin_when_activated: int + /** + * *Can only be used if this is ScrollPaneStyle* + * + * {@link https://lua-api.factorio.com/next/LuaStyle.html#LuaStyle.extra_left_margin_when_activated View documentation} + */ + extra_left_margin_when_activated: int + /** + * *Can only be used if this is ScrollPaneStyle* + * + * {@link https://lua-api.factorio.com/next/LuaStyle.html#LuaStyle.extra_right_margin_when_activated View documentation} + */ + extra_right_margin_when_activated: int + /** + * *Can only be used if this is ImageStyle* + * + * {@link https://lua-api.factorio.com/next/LuaStyle.html#LuaStyle.stretch_image_to_widget_size View documentation} + */ + stretch_image_to_widget_size: boolean + /** + * *Can only be used if this is TabStyle* + * + * {@link https://lua-api.factorio.com/next/LuaStyle.html#LuaStyle.badge_font View documentation} + */ + badge_font: string + /** + * *Can only be used if this is TabStyle* + * + * {@link https://lua-api.factorio.com/next/LuaStyle.html#LuaStyle.badge_horizontal_spacing View documentation} + */ + badge_horizontal_spacing: int + /** + * *Can only be used if this is TabStyle* + * + * {@link https://lua-api.factorio.com/next/LuaStyle.html#LuaStyle.default_badge_font_color View documentation} + */ + default_badge_font_color: Color + /** + * *Can only be used if this is TabStyle* + * + * {@link https://lua-api.factorio.com/next/LuaStyle.html#LuaStyle.selected_badge_font_color View documentation} + */ + selected_badge_font_color: Color + /** + * *Can only be used if this is TabStyle* + * + * {@link https://lua-api.factorio.com/next/LuaStyle.html#LuaStyle.disabled_badge_font_color View documentation} + */ + disabled_badge_font_color: Color + /** + * Sets both minimal and maximal width to the given value. + * + * {@link https://lua-api.factorio.com/next/LuaStyle.html#LuaStyle.width View documentation} + */ + set width(value: int) + /** + * Sets both minimal and maximal height to the given value. + * + * {@link https://lua-api.factorio.com/next/LuaStyle.html#LuaStyle.height View documentation} + */ + set height(value: int) + /** + * Sets both width and height to the given value. Also accepts an array with two values, setting width to the first + * and height to the second one. + * + * {@link https://lua-api.factorio.com/next/LuaStyle.html#LuaStyle.size View documentation} + */ + set size(value: int | int[]) + /** + * Sets top/right/bottom/left paddings to this value. An array with two values sets top/bottom padding to the first + * value and left/right padding to the second value. An array with four values sets top, right, bottom, left padding + * respectively. + * + * {@link https://lua-api.factorio.com/next/LuaStyle.html#LuaStyle.padding View documentation} + */ + set padding(value: int | int[]) + /** + * Sets top/right/bottom/left margins to this value. An array with two values sets top/bottom margin to the first + * value and left/right margin to the second value. An array with four values sets top, right, bottom, left margin + * respectively. + * + * {@link https://lua-api.factorio.com/next/LuaStyle.html#LuaStyle.margin View documentation} + */ + set margin(value: int | int[]) + /** + * Space between the table cell contents and border. Sets top/right/bottom/left cell paddings to this value. + * + * *Can only be used if this is LuaTableStyle* + * + * {@link https://lua-api.factorio.com/next/LuaStyle.html#LuaStyle.cell_padding View documentation} + */ + set cell_padding(value: int) + /** + * Sets extra_top/right/bottom/left_padding_when_actived to this value. An array with two values sets top/bottom + * padding to the first value and left/right padding to the second value. An array with four values sets top, right, + * bottom, left padding respectively. + * + * {@link https://lua-api.factorio.com/next/LuaStyle.html#LuaStyle.extra_padding_when_activated View documentation} + */ + set extra_padding_when_activated(value: int | int[]) + /** + * Sets extra_top/right/bottom/left_margin_when_activated to this value. An array with two values sets top/bottom + * margin to the first value and left/right margin to the second value. An array with four values sets top, right, + * bottom, left margin respectively. + * + * {@link https://lua-api.factorio.com/next/LuaStyle.html#LuaStyle.extra_margin_when_activated View documentation} + */ + set extra_margin_when_activated(value: int | int[]) + /** + * 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: "LuaStyle" + /** All methods and properties that this object supports. */ + help(): string +} + +interface BaseSurfaceCreateEntity { + /** The entity prototype name to create. */ + readonly name: string + /** Where to create the entity. */ + readonly position: Position + /** Desired orientation of the entity after creation. */ + readonly direction?: defines.direction + /** Force of the entity, default is enemy. */ + readonly force?: ForceIdentification + /** Entity with health for the new entity to target. */ + readonly target?: LuaEntity + /** Source entity. Used for beams and highlight-boxes. */ + readonly source?: LuaEntity + /** If true, building will attempt to simulate fast-replace building. */ + readonly fast_replace?: boolean + /** If given set the last_user to this player. If fast_replace is true simulate fast replace using this player. */ + readonly player?: PlayerIdentification + /** + * If false while fast_replace is true and player is nil any items from fast-replacing will be deleted instead of + * dropped on the ground. + */ + readonly spill?: boolean + /** If true; {@link defines.events.script_raised_built} will be fired on successful entity creation. */ + readonly raise_built?: boolean + /** If false, the building effect smoke will not be shown around the new entity. */ + readonly create_build_effect_smoke?: boolean + /** If true, entity types that have spawn_decorations property will apply triggers defined in the property. */ + readonly spawn_decorations?: boolean + /** If true, any characters that are in the way of the entity are teleported out of the way. */ + readonly move_stuck_players?: boolean + /** + * If provided, the entity will attempt to pull stored values from this item (for example; creating a spidertron + * from a previously named and mined spidertron) + */ + readonly item?: LuaItemStack +} + +interface AssemblingMachineSurfaceCreateEntity extends BaseSurfaceCreateEntity { + readonly recipe?: string +} + +interface BeamSurfaceCreateEntity extends BaseSurfaceCreateEntity { + /** + * Absolute target position that can be used instead of target entity (entity has precedence if both entity and + * position are defined). + */ + readonly target_position?: Position + /** + * Absolute source position that can be used instead of source entity (entity has precedence if both entity and + * position are defined). + */ + readonly source_position?: Position + /** If set, beam will be destroyed when distance between source and target is greater than this value. */ + readonly max_length?: uint + /** If set, beam will be destroyed after this value of ticks. */ + readonly duration?: uint + /** Source position will be offset by this value when rendering the beam. */ + readonly source_offset?: Vector +} + +interface ContainerSurfaceCreateEntity extends BaseSurfaceCreateEntity { + /** Inventory index where the red limiting bar should be set. */ + readonly bar?: uint +} + +interface CliffSurfaceCreateEntity extends BaseSurfaceCreateEntity { + /** If not specified, `direction` will be used instead. */ + readonly cliff_orientation?: CliffOrientation +} + +interface FlyingTextSurfaceCreateEntity extends BaseSurfaceCreateEntity { + /** The string to show. */ + readonly text: LocalisedString + /** Color of the displayed text. */ + readonly color?: Color + readonly render_player_index?: uint +} + +interface EntityGhostSurfaceCreateEntity extends BaseSurfaceCreateEntity { + /** The prototype name of the entity contained in the ghost. */ + readonly inner_name: string + /** If `false` the ghost entity will not expire. Default is `false`. */ + readonly expires?: boolean +} + +interface FireSurfaceCreateEntity extends BaseSurfaceCreateEntity { + /** With how many small flames should the fire on ground be created. Defaults to the initial flame count of the prototype. */ + readonly initial_ground_flame_count?: uint8 +} + +interface InserterSurfaceCreateEntity extends BaseSurfaceCreateEntity { + readonly conditions: InserterCircuitConditions + readonly filters: InventoryFilter[] +} + +interface ItemEntitySurfaceCreateEntity extends BaseSurfaceCreateEntity { + /** The stack of items to create. */ + readonly stack: SimpleItemStack +} + +interface ItemRequestProxySurfaceCreateEntity extends BaseSurfaceCreateEntity { + /** The target items are to be delivered to. */ + readonly target: LuaEntity + /** The stacks of items to be delivered to target entity from logistic network. */ + readonly modules: Record +} + +interface RollingStockSurfaceCreateEntity extends BaseSurfaceCreateEntity { + /** The orientation of this rolling stock. */ + readonly orientation?: RealOrientation + /** The color of this rolling stock, if it supports colors. */ + readonly color?: Color +} + +interface LocomotiveSurfaceCreateEntity extends BaseSurfaceCreateEntity { + /** Whether the locomotive should snap to an adjacent train stop. Defaults to true. */ + readonly snap_to_train_stop?: boolean +} + +interface LogisticContainerSurfaceCreateEntity extends BaseSurfaceCreateEntity { + readonly request_filters?: InventoryFilter[] +} + +interface ParticleSurfaceCreateEntity extends BaseSurfaceCreateEntity { + readonly movement: Vector + readonly height: float + readonly vertical_speed: float + readonly frame_speed: float +} + +interface ArtilleryFlareSurfaceCreateEntity extends BaseSurfaceCreateEntity { + readonly movement: Vector + readonly height: float + readonly vertical_speed: float + readonly frame_speed: float +} + +interface ProjectileSurfaceCreateEntity extends BaseSurfaceCreateEntity { + readonly speed: double + readonly max_range: double +} + +interface ResourceSurfaceCreateEntity extends BaseSurfaceCreateEntity { + readonly amount: uint + /** + * If colliding trees are removed normally for this resource entity based off the prototype tree removal values. + * Default is true. + */ + readonly enable_tree_removal?: boolean + /** If colliding cliffs are removed. Default is true. */ + readonly enable_cliff_removal?: boolean + /** + * If true, the resource entity will be placed to center of a tile as map generator would place it, otherwise + * standard non-resource grid alignment rules will apply. Default is true. + */ + readonly snap_to_tile_center?: boolean +} + +interface UndergroundBeltSurfaceCreateEntity extends BaseSurfaceCreateEntity { + /** `"output"` or `"input"`; default is `"input"`. */ + readonly type?: "output" | "input" +} + +interface ProgrammableSpeakerSurfaceCreateEntity extends BaseSurfaceCreateEntity { + readonly parameters?: ProgrammableSpeakerParameters + readonly alert_parameters?: ProgrammableSpeakerAlertParameters +} + +interface CharacterCorpseSurfaceCreateEntity extends BaseSurfaceCreateEntity { + readonly inventory_size?: uint + readonly player_index?: uint +} + +interface HighlightBoxSurfaceCreateEntity extends BaseSurfaceCreateEntity { + /** + * The bounding box defining the highlight box using absolute map coordinates. If specified, the `position` + * parameter is ignored, but needs to be present anyways. If not specified, the game falls back to the `source` + * parameter first, then the `target` parameter second. One of these three parameters need to be specified. + */ + readonly bounding_box?: BoundingBox + /** Specifies the graphical appearance (color) of the highlight box. Defaults to `"electricity"`. */ + readonly box_type?: CursorBoxRenderType + /** The player to render the highlight box for. If not provided, it will be rendered for all players. */ + readonly render_player_index?: uint + /** + * The blink interval for this highlight box. Makes it be shown every `blink_interval` ticks. Defaults to `0` + * (constantly shown). + */ + readonly blink_interval?: uint + /** The amount of time in ticks that the highlight box will exist for. Defaults to existing forever. */ + readonly time_to_live?: uint +} + +interface SpeechBubbleSurfaceCreateEntity extends BaseSurfaceCreateEntity { + readonly text: LocalisedString + readonly lifetime?: uint +} + +interface SimpleEntityWithOwnerSurfaceCreateEntity extends BaseSurfaceCreateEntity { + readonly render_player_index?: uint +} + +interface SimpleEntityWithForceSurfaceCreateEntity extends BaseSurfaceCreateEntity { + readonly render_player_index?: uint +} + +type SurfaceCreateEntity = + | AssemblingMachineSurfaceCreateEntity + | BeamSurfaceCreateEntity + | ContainerSurfaceCreateEntity + | CliffSurfaceCreateEntity + | FlyingTextSurfaceCreateEntity + | EntityGhostSurfaceCreateEntity + | FireSurfaceCreateEntity + | InserterSurfaceCreateEntity + | ItemEntitySurfaceCreateEntity + | ItemRequestProxySurfaceCreateEntity + | RollingStockSurfaceCreateEntity + | LocomotiveSurfaceCreateEntity + | LogisticContainerSurfaceCreateEntity + | ParticleSurfaceCreateEntity + | ArtilleryFlareSurfaceCreateEntity + | ProjectileSurfaceCreateEntity + | ResourceSurfaceCreateEntity + | UndergroundBeltSurfaceCreateEntity + | ProgrammableSpeakerSurfaceCreateEntity + | CharacterCorpseSurfaceCreateEntity + | HighlightBoxSurfaceCreateEntity + | SpeechBubbleSurfaceCreateEntity + | SimpleEntityWithOwnerSurfaceCreateEntity + | SimpleEntityWithForceSurfaceCreateEntity + +/** + * A "domain" of the world. Surfaces can only be created and deleted through the API. Surfaces are uniquely identified + * by their name. Every game contains at least the surface "nauvis". + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html View documentation} + * + * @noSelf + */ +interface LuaSurface { + /** + * Get the pollution for a given position. + * + * **Note**: Pollution is stored per chunk, so this will return the same value for all positions in one chunk. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.get_pollution View documentation} + * + * @example + * ```lua + * game.surfaces[1].get_pollution({1,2}) + * ``` + * + * @param position + */ + get_pollution(position: Position): double + /** + * Check for collisions with terrain or other entities. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.can_place_entity View documentation} + */ + can_place_entity(params: { + /** Name of the entity prototype to check. */ + readonly name: string + /** Where the entity would be placed. */ + readonly position: Position + /** Direction of the placed entity. */ + readonly direction?: defines.direction + /** The force that would place the entity. If not specified, the enemy force is assumed. */ + readonly force?: ForceIdentification + /** Which type of check should be carried out. */ + readonly build_check_type?: defines.build_check_type + /** + * If `true`, entities that can be marked for deconstruction are ignored. Only used if `build_check_type` is + * either `manual_ghost`, `script_ghost` or `blueprint_ghost`. + */ + readonly forced?: boolean + /** The prototype name of the entity contained in the ghost. Only used if `name` is `entity-ghost`. */ + readonly inner_name?: string + }): boolean + /** + * If there exists an entity at the given location that can be fast-replaced with the given entity parameters. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.can_fast_replace View documentation} + */ + can_fast_replace(params: { + /** Name of the entity to check */ + readonly name: string + /** Where the entity would be placed */ + readonly position: Position + /** Direction the entity would be placed */ + readonly direction?: defines.direction + /** The force that would place the entity. If not specified, the enemy force is assumed. */ + readonly force?: ForceIdentification + }): boolean + /** + * Find a specific entity at a specific position. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.find_entity View documentation} + * + * @example + * ```lua + * game.player.selected.surface.find_entity('filter-inserter', {0,0}) + * ``` + * + * @param entity - Entity to look for + * @param position - Coordinates to look at + * @returns Will be `nil` if no such entity is found. + */ + find_entity(entity: string, position: Position): LuaEntity | undefined + /** + * Find entities in a given area. + * + * If no area is given all entities on the surface are returned. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.find_entities View documentation} + * + * @example + * Will evaluate to a list of all entities within given area. + * + * ```lua + * game.surfaces["nauvis"].find_entities({{-10, -10}, {10, 10}}) + * ``` + * + * @param area + */ + find_entities(area?: BoundingBox): LuaEntity[] + /** + * Find entities of given type or name in a given area. + * + * If no filters (`name`, `type`, `force`, etc.) are given, returns all entities in the search area. If multiple + * filters are specified, returns only entities matching all given filters. + * + * If no area or position are given, then the entire surface is searched. If position is given, returns entities + * colliding with that position (i.e the given position is within the entity's collision box). If position and + * radius are given, returns entities in that radius of the position. If area is specified, returns entities + * colliding with that area. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.find_entities_filtered View documentation} + * + * @example + * ```lua + * game.surfaces[1].find_entities_filtered{area = {{-10, -10}, {10, 10}}, type = "resource"} -- gets all resources in the rectangle + * game.surfaces[1].find_entities_filtered{area = {{-10, -10}, {10, 10}}, name = "iron-ore"} -- gets all iron ores in the rectangle + * game.surfaces[1].find_entities_filtered{area = {{-10, -10}, {10, 10}}, name = {"iron-ore", "copper-ore"}} -- gets all iron ore and copper ore in the rectangle + * game.surfaces[1].find_entities_filtered{area = {{-10, -10}, {10, 10}}, force = "player"} -- gets player owned entities in the rectangle + * game.surfaces[1].find_entities_filtered{area = {{-10, -10}, {10, 10}}, limit = 5} -- gets the first 5 entities in the rectangle + * game.surfaces[1].find_entities_filtered{position = {0, 0}, radius = 10} -- gets all entities within 10 tiles of the position [0,0]. + * ``` + */ + find_entities_filtered(params: { + readonly area?: BoundingBox + /** Has precedence over area field. */ + readonly position?: Position + /** If given with position, will return all entities within the radius of the position. */ + readonly radius?: double + readonly name?: string | string[] + readonly type?: string | string[] + readonly ghost_name?: string | string[] + readonly ghost_type?: string | string[] + readonly direction?: defines.direction | defines.direction[] + readonly collision_mask?: CollisionMaskLayer | CollisionMaskLayer[] + readonly force?: ForceIdentification | ForceIdentification[] + readonly to_be_deconstructed?: boolean + readonly to_be_upgraded?: boolean + readonly limit?: uint + /** + * If the filters should be inverted. These filters are: name, type, ghost_name, ghost_type, direction, + * collision_mask, force. + */ + readonly invert?: boolean + }): LuaEntity[] + /** + * Find tiles of a given name in a given area. + * + * If no filters are given returns all tiles in the search area. + * + * If no area or position and radius is given, then the entire surface is searched. If position and radius are + * given, only tiles within the radius of the position are included. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.find_tiles_filtered View documentation} + */ + find_tiles_filtered(params: { + readonly area?: BoundingBox + /** Ignored if not given with radius. */ + readonly position?: Position + /** If given with position, will return all entities within the radius of the position. */ + readonly radius?: double + readonly name?: string | string[] + readonly limit?: uint + readonly has_hidden_tile?: boolean + readonly collision_mask?: CollisionMaskLayer | CollisionMaskLayer[] + }): LuaTile[] + /** + * Count entities of given type or name in a given area. Works just like + * {@link LuaSurface.find_entities_filtered LuaSurface::find_entities_filtered}, except this only returns the count. + * As it doesn't construct all the wrapper objects, this is more efficient if one is only interested in the number + * of entities. + * + * If no area or position are given, then the entire surface is searched. If position is given, returns entities + * colliding with that position (i.e the given position is within the entity's collision box). If position and + * radius are given, returns entities in that radius of the position. If area is specified, returns entities + * colliding with that area. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.count_entities_filtered View documentation} + */ + count_entities_filtered(params: { + readonly area?: BoundingBox + readonly position?: Position + /** If given with position, will count all entities within the radius of the position. */ + readonly radius?: double + readonly name?: string | string[] + readonly type?: string | string[] + readonly ghost_name?: string | string[] + readonly ghost_type?: string | string[] + readonly direction?: defines.direction | defines.direction[] + readonly collision_mask?: CollisionMaskLayer | CollisionMaskLayer[] + readonly force?: ForceIdentification | ForceIdentification[] + readonly to_be_deconstructed?: boolean + readonly to_be_upgraded?: boolean + readonly limit?: uint + /** + * If the filters should be inverted. These filters are: name, type, ghost_name, ghost_type, direction, + * collision_mask, force. + */ + readonly invert?: boolean + }): uint + /** + * Count tiles of a given name in a given area. Works just like + * {@link LuaSurface.find_tiles_filtered LuaSurface::find_tiles_filtered}, except this only returns the count. As it + * doesn't construct all the wrapper objects, this is more efficient if one is only interested in the number of tiles. + * + * If no area or position and radius is given, then the entire surface is searched. If position and radius are + * given, only tiles within the radius of the position are included. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.count_tiles_filtered View documentation} + */ + count_tiles_filtered(params: { + readonly area?: BoundingBox + /** Ignored if not given with radius. */ + readonly position?: Position + /** If given with position, will return all entities within the radius of the position. */ + readonly radius?: double + readonly name?: string | string[] + readonly limit?: uint + readonly has_hidden_tile?: boolean + readonly collision_mask?: CollisionMaskLayer | CollisionMaskLayer[] + }): uint + /** + * Find a non-colliding position within a given radius. + * + * **Note**: Special care needs to be taken when using a radius of `0`. The game will not stop searching until it + * finds a suitable position, so it is important to make sure such a position exists. One particular case where it + * would not be able to find a solution is running it before any chunks have been generated. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.find_non_colliding_position View documentation} + * + * @param name - Prototype name of the entity to find a position for. (The bounding box for the collision checking + * is taken from this prototype.) + * @param center - Center of the search area. + * @param radius - Max distance from `center` to search in. A radius of `0` means an infinitely-large search area. + * @param precision - The step length from the given position as it searches, in tiles. Minimum value is `0.01`. + * @param force_to_tile_center - Will only check tile centers. This can be useful when your intent is to place a + * building at the resulting position, as they must generally be placed at tile centers. Default false. + * @returns The non-colliding position. May be `nil` if no suitable position was found. + */ + find_non_colliding_position( + name: string, + center: Position, + radius: double, + precision: double, + force_to_tile_center?: boolean + ): PositionTable | undefined + /** + * Find a non-colliding position within a given rectangle. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.find_non_colliding_position_in_box View documentation} + * + * @param name - Prototype name of the entity to find a position for. (The bounding box for the collision checking + * is taken from this prototype.) + * @param search_space - The rectangle to search inside. + * @param precision - The step length from the given position as it searches, in tiles. Minimum value is 0.01. + * @param force_to_tile_center - Will only check tile centers. This can be useful when your intent is to place a + * building at the resulting position, as they must generally be placed at tile centers. Default false. + * @returns The non-colliding position. May be `nil` if no suitable position was found. + */ + find_non_colliding_position_in_box( + name: string, + search_space: BoundingBox, + precision: double, + force_to_tile_center?: boolean + ): PositionTable | undefined + /** + * Spill items on the ground centered at a given location. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.spill_item_stack View documentation} + * + * @param position - Center of the spillage + * @param items - Items to spill + * @param enable_looted - When true, each created item will be flagged with the + * {@link LuaEntity.to_be_looted LuaEntity::to_be_looted} flag. + * @param force - When provided (and not `nil`) the items will be marked for deconstruction by this force. + * @param allow_belts - Whether items can be spilled onto belts. Defaults to `true`. + * @returns The created item-on-ground entities. + */ + spill_item_stack( + position: Position, + items: ItemStackIdentification, + enable_looted?: boolean, + force?: LuaForce | string, + allow_belts?: boolean + ): LuaEntity[] + /** + * Find enemy units (entities with type "unit") of a given force within an area. + * + * **Note**: This is more efficient than {@link LuaSurface.find_entities LuaSurface::find_entities}. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.find_enemy_units View documentation} + * + * @example + * Find all units who would be interested to attack the player, within 100-tile area. + * + * ```lua + * local enemies = game.player.surface.find_enemy_units(game.player.position, 100) + * ``` + * + * @param center - Center of the search area + * @param radius - Radius of the circular search area + * @param force - Force to find enemies of. If not given, uses the player force. + */ + find_enemy_units(center: Position, radius: double, force?: LuaForce | string): LuaEntity[] + /** + * Find units (entities with type "unit") of a given force and force condition within a given area. + * + * **Note**: This is more efficient than {@link LuaSurface.find_entities LuaSurface::find_entities}. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.find_units View documentation} + * + * @example + * Find friendly units to "player" force + * + * ```lua + * local friendly_units = game.player.surface.find_units({area = {{-10, -10},{10, 10}}, force = "player", condition = "friend") + * ``` + * + * @example + * Find units of "player" force + * + * ```lua + * local units = game.player.surface.find_units({area = {{-10, -10},{10, 10}}, force = "player", condition = "same"}) + * ``` + */ + find_units(params: { + /** Box to find units within. */ + readonly area: BoundingBox + /** Force performing the search. */ + readonly force: LuaForce | string + /** Only forces which meet the condition will be included in the search. */ + readonly condition: ForceCondition + }): LuaEntity[] + /** + * Find the enemy entity-with-force ({@link https://wiki.factorio.com/Military_units_and_structures military entity}) + * closest to the given position. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.find_nearest_enemy View documentation} + * + * @returns The nearest enemy entity-with-force or `nil` if no enemy could be found within the given area. + */ + find_nearest_enemy(params: { + /** Center of the search area. */ + readonly position: Position + /** Radius of the circular search area. */ + readonly max_distance: double + /** The force the result will be an enemy of. Uses the player force if not specified. */ + readonly force?: ForceIdentification + }): LuaEntity | undefined + /** + * Find the enemy entity-with-owner closest to the given position. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.find_nearest_enemy_entity_with_owner View documentation} + * + * @returns The nearest enemy entity-with-owner or `nil` if no enemy could be found within the given area. + */ + find_nearest_enemy_entity_with_owner(params: { + /** Center of the search area. */ + readonly position: Position + /** Radius of the circular search area. */ + readonly max_distance: double + /** The force the result will be an enemy of. Uses the player force if not specified. */ + readonly force?: ForceIdentification + }): LuaEntity | undefined + /** + * Give a command to multiple units. This will automatically select suitable units for the task. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.set_multi_command View documentation} + * + * @returns Number of units actually sent. May be less than `count` if not enough units were available. + */ + set_multi_command(params: { + readonly command: Command + /** Number of units to give the command to. */ + readonly unit_count: uint + /** Force of the units this command is to be given to. If not specified, uses the enemy force. */ + readonly force?: ForceIdentification + /** Radius to search for units. The search area is centered on the destination of the command. */ + readonly unit_search_distance?: uint + }): uint + /** + * Create an entity on this surface. + * + * Other attributes may be specified depending on the type of entity: + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.create_entity View documentation} + * + * @example + * ```lua + * asm = game.surfaces[1].create_entity{name = "assembling-machine-1", position = {15, 3}, force = game.forces.player, recipe = "iron-stick"} + * ``` + * + * @example + * Creates a filter inserter with circuit conditions and a filter + * + * ```lua + * game.surfaces[1].create_entity{ + * name = "filter-inserter", position = {20, 15}, force = game.player.force, + * conditions = {red = {name = "wood", count = 3, operator = ">"}, + * green = {name = "iron-ore", count = 1, operator = "<"}, + * logistics = {name = "wood", count = 3, operator = "="}}, + * filters = {{index = 1, name = "iron-ore"}} + * } + * ``` + * + * @example + * Creates a requester chest already set to request 128 iron plates. + * + * ```lua + * game.surfaces[1].create_entity{ + * name = "logistic-chest-requester", position = {game.player.position.x+3, game.player.position.y}, + * force = game.player.force, request_filters = {{index = 1, name = "iron-plate", count = 128}} + * } + * ``` + * + * @example + * ```lua + * game.surfaces[1].create_entity{name = "big-biter", position = {15, 3}, force = game.forces.player} -- Friendly biter + * game.surfaces[1].create_entity{name = "medium-biter", position = {15, 3}, force = game.forces.enemy} -- Enemy biter + * ``` + * + * @example + * Creates a basic inserter at the player's location facing north + * + * ```lua + * game.surfaces[1].create_entity{name = "inserter", position = game.player.position, direction = defines.direction.north} + * ``` + * + * @returns The created entity or `nil` if the creation failed. + */ + create_entity(params: SurfaceCreateEntity): LuaEntity | undefined + create_trivial_smoke(params: { + /** The smoke prototype name to create. */ + readonly name: string + /** Where to create the smoke. */ + readonly position: Position + }): void + /** + * Creates a particle at the given location + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.create_particle View documentation} + */ + create_particle(params: { + /** The particle name. */ + readonly name: string + /** Where to create the particle. */ + readonly position: Position + readonly movement: Vector + readonly height: float + readonly vertical_speed: float + readonly frame_speed: float + }): void + /** + * Create a new unit group at a given position. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.create_unit_group View documentation} + */ + create_unit_group(params: { + /** Initial position of the new unit group. */ + readonly position: Position + /** Force of the new unit group. Defaults to `"enemy"`. */ + readonly force?: ForceIdentification + }): LuaUnitGroup + /** + * Send a group to build a new base. + * + * **Note**: The specified force must be AI-controlled; i.e. `force.ai_controllable` must be `true`. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.build_enemy_base View documentation} + * + * @param position - Location of the new base. + * @param unit_count - Number of biters to send for the base-building task. + * @param force - Force the new base will belong to. Defaults to enemy. + */ + build_enemy_base(position: Position, unit_count: uint, force?: ForceIdentification): void + /** + * Get the tile at a given position. + * + * **Note**: The input position params can also be a single tile position. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.get_tile View documentation} + * + * @param x + * @param y + */ + get_tile(x: int, y: int): LuaTile + /** + * Set tiles at specified locations. Can automatically correct the edges around modified tiles. + * + * Placing a {@link LuaTilePrototype.mineable_properties mineable} tile on top of a non-mineable one will turn the + * latter into the {@link LuaTile.hidden_tile LuaTile::hidden_tile} for that tile. Placing a mineable tile on a + * mineable one or a non-mineable tile on a non-mineable one will not modify the hidden tile. This restriction can + * however be circumvented by using {@link LuaSurface.set_hidden_tile LuaSurface::set_hidden_tile}. + * + * **Note**: It is recommended to call this method once for all the tiles you want to change rather than calling it + * individually for every tile. As the tile correction is used after every step, calling it one by one could cause + * the tile correction logic to redo some of the changes. Also, many small API calls are generally more performance + * intensive than one big one. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.set_tiles View documentation} + * + * @param tiles + * @param correct_tiles - If `false`, the correction logic is not applied to the changed tiles. Defaults to `true`. + * @param remove_colliding_entities - `true`, `false`, or `abort_on_collision`. Defaults to `true`. + * @param remove_colliding_decoratives - `true` or `false`. Defaults to `true`. + * @param raise_event - `true` or `false`. Defaults to `false`. + */ + set_tiles( + tiles: Tile[], + correct_tiles?: boolean, + remove_colliding_entities?: boolean | string, + remove_colliding_decoratives?: boolean, + raise_event?: boolean + ): void + /** + * Spawn pollution at the given position. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.pollute View documentation} + * + * @param source - Where to spawn the pollution. + * @param amount - How much pollution to add. + */ + pollute(source: Position, amount: double): void + /** + * Get an iterator going over every chunk on this surface. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.get_chunks View documentation} + */ + get_chunks(): LuaChunkIterator + /** + * Is a given chunk generated? + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.is_chunk_generated View documentation} + * + * @param position - The chunk's position. + */ + is_chunk_generated(position: ChunkPosition): boolean + /** + * Request that the game's map generator generate chunks at the given position for the given radius on this surface. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.request_to_generate_chunks View documentation} + * + * @param position - Where to generate the new chunks. + * @param radius - The chunk radius from `position` to generate new chunks in. + */ + request_to_generate_chunks(position: Position, radius: uint): void + /** + * Blocks and generates all chunks that have been requested using all available threads. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.force_generate_chunk_requests View documentation} + */ + force_generate_chunk_requests(): void + /** + * Set generated status of a chunk. Useful when copying chunks. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.set_chunk_generated_status View documentation} + * + * @param position - The chunk's position. + * @param status - The chunk's new status. + */ + set_chunk_generated_status(position: ChunkPosition, status: defines.chunk_generated_status): void + /** + * Find the logistic network that covers a given position. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.find_logistic_network_by_position View documentation} + * + * @param position + * @param force - Force the logistic network should belong to. + * @returns The found network or `nil` if no such network was found. + */ + find_logistic_network_by_position(position: Position, force: ForceIdentification): LuaLogisticNetwork | undefined + /** + * Finds all of the logistics networks whose construction area intersects with the given position. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.find_logistic_networks_by_construction_area View documentation} + * + * @param position + * @param force - Force the logistic networks should belong to. + */ + find_logistic_networks_by_construction_area(position: Position, force: ForceIdentification): LuaLogisticNetwork[] + /** + * Place a deconstruction request. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.deconstruct_area View documentation} + */ + deconstruct_area(params: { + /** The area to mark for deconstruction. */ + readonly area: BoundingBox + /** The force whose bots should perform the deconstruction. */ + readonly force: ForceIdentification + /** The player to set the last_user to if any. */ + readonly player?: PlayerIdentification + /** If chunks covered by fog-of-war are skipped. */ + readonly skip_fog_of_war?: boolean + /** The deconstruction item to use if any. */ + readonly item?: LuaItemStack + }): void + /** + * Cancel a deconstruction order. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.cancel_deconstruct_area View documentation} + */ + cancel_deconstruct_area(params: { + /** The area to cancel deconstruction orders in. */ + readonly area: BoundingBox + /** The force whose deconstruction orders to cancel. */ + readonly force: ForceIdentification + /** The player to set the last_user to if any. */ + readonly player?: PlayerIdentification + /** If chunks covered by fog-of-war are skipped. */ + readonly skip_fog_of_war?: boolean + /** The deconstruction item to use if any. */ + readonly item?: LuaItemStack + }): void + /** + * Place an upgrade request. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.upgrade_area View documentation} + */ + upgrade_area(params: { + /** The area to mark for upgrade. */ + readonly area: BoundingBox + /** The force whose bots should perform the upgrade. */ + readonly force: ForceIdentification + /** The player to set the last_user to if any. */ + readonly player?: PlayerIdentification + /** If chunks covered by fog-of-war are skipped. */ + readonly skip_fog_of_war?: boolean + /** The upgrade item to use. */ + readonly item: LuaItemStack + }): void + /** + * Cancel a upgrade order. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.cancel_upgrade_area View documentation} + */ + cancel_upgrade_area(params: { + /** The area to cancel upgrade orders in. */ + readonly area: BoundingBox + /** The force whose upgrade orders to cancel. */ + readonly force: ForceIdentification + /** The player to set the last_user to if any. */ + readonly player?: PlayerIdentification + /** If chunks covered by fog-of-war are skipped. */ + readonly skip_fog_of_war?: boolean + /** The upgrade item to use if any. */ + readonly item?: LuaItemStack + }): void + /** + * The hidden tile name or `nil` if there isn't one for the given position. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.get_hidden_tile View documentation} + * + * @param position - The tile position. + */ + get_hidden_tile(position: TilePosition): string | undefined + /** + * Set the hidden tile for the specified position. While during normal gameplay only + * {@link LuaTilePrototype.mineable_properties non-mineable} tiles can become hidden, this method allows any kind of + * tile to be set as the hidden one. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.set_hidden_tile View documentation} + * + * @param position - The tile position. + * @param tile - The new hidden tile or `nil` to clear the hidden tile. + */ + set_hidden_tile(position: TilePosition, tile: string | LuaTilePrototype | undefined): void + /** + * Gets all tiles of the given types that are connected horizontally or vertically to the given tile position + * including the given tile position. + * + * **Note**: This won't find tiles in non-generated chunks. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.get_connected_tiles View documentation} + * + * @param position - The tile position to start at. + * @param tiles - The tiles to search for. + * @returns The resulting set of tiles. + */ + get_connected_tiles(position: Position, tiles: string[]): PositionTable[] + /** + * **Note**: This won't delete the chunk immediately. Chunks are deleted at the end of the current tick. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.delete_chunk View documentation} + * + * @param position - The chunk position to delete + */ + delete_chunk(position: ChunkPosition): void + /** + * Regenerate autoplacement of some entities on this surface. This can be used to autoplace newly-added entities. + * + * **Note**: All specified entity prototypes must be autoplacable. If nothing is given all entities are generated on + * all chunks. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.regenerate_entity View documentation} + * + * @param entities - Prototype names of entity or entities to autoplace. When `nil` all entities with an autoplace are used. + * @param chunks - The chunk positions to regenerate the entities on. If not given all chunks are regenerated. Note + * chunks with status < entities are ignored. + */ + regenerate_entity(entities?: string | string[], chunks?: ChunkPosition[]): void + /** + * Regenerate autoplacement of some decoratives on this surface. This can be used to autoplace newly-added decoratives. + * + * **Note**: All specified decorative prototypes must be autoplacable. If nothing is given all decoratives are + * generated on all chunks. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.regenerate_decorative View documentation} + * + * @param decoratives - Prototype names of decorative or decoratives to autoplace. When `nil` all decoratives with + * an autoplace are used. + * @param chunks - The chunk positions to regenerate the entities on. If not given all chunks are regenerated. Note + * chunks with status < entities are ignored. + */ + regenerate_decorative(decoratives?: string | string[], chunks?: ChunkPosition[]): void + /** + * Print text to the chat console of all players on this surface. + * + * **Note**: Messages that are identical to a message sent in the last 60 ticks are not printed again. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.print View documentation} + * + * @param message + * @param color + */ + print(message: LocalisedString, color?: Color): void + /** + * Removes all decoratives from the given area. If no area and no position are given, then the entire surface is searched. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.destroy_decoratives View documentation} + */ + destroy_decoratives(params: { + readonly area?: BoundingBox + readonly position?: TilePosition + readonly name?: string | string[] | LuaDecorativePrototype | LuaDecorativePrototype[] + readonly limit?: uint + /** If the filters should be inverted. */ + readonly invert?: boolean + }): void + /** + * Adds the given decoratives to the surface. + * + * **Note**: This will merge decoratives of the same type that already exist effectively increasing the "amount" field. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.create_decoratives View documentation} + */ + create_decoratives(params: { + /** If collision should be checked against entities/tiles. */ + readonly check_collision?: boolean + readonly decoratives: Decorative[] + }): void + /** + * Find decoratives of a given name in a given area. + * + * If no filters are given, returns all decoratives in the search area. If multiple filters are specified, returns + * only decoratives matching every given filter. If no area and no position are given, the entire surface is searched. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.find_decoratives_filtered View documentation} + * + * @example + * ```lua + * game.surfaces[1].find_decoratives_filtered{area = {{-10, -10}, {10, 10}}, name = "sand-decal"} -- gets all sand-decals in the rectangle + * game.surfaces[1].find_decoratives_filtered{area = {{-10, -10}, {10, 10}}, limit = 5} -- gets the first 5 decoratives in the rectangle + * ``` + */ + find_decoratives_filtered(params: { + readonly area?: BoundingBox + readonly position?: TilePosition + readonly name?: string | string[] | LuaDecorativePrototype | LuaDecorativePrototype[] + readonly limit?: uint + /** If the filters should be inverted. */ + readonly invert?: boolean + }): DecorativeResult[] + /** + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.get_trains View documentation} + * + * @param force - If given only trains matching this force are returned. + */ + get_trains(force?: ForceIdentification): LuaTrain[] + /** + * Clears all pollution on this surface. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.clear_pollution View documentation} + */ + clear_pollution(): void + /** + * Play a sound for every player on this surface. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.play_sound View documentation} + */ + play_sound(params: { + /** The sound to play. */ + readonly path: SoundPath + /** Where the sound should be played. If not given, it's played at the current position of each player. */ + readonly position?: Position + /** The volume of the sound to play. Must be between 0 and 1 inclusive. */ + readonly volume_modifier?: double + /** The volume mixer to play the sound through. Defaults to the default mixer for the given sound type. */ + readonly override_sound_type?: SoundType + }): void + /** + * Gets the resource amount of all resources on this surface + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.get_resource_counts View documentation} + */ + get_resource_counts(): Record + /** + * Gets a random generated chunk position or 0,0 if no chunks have been generated on this surface. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.get_random_chunk View documentation} + */ + get_random_chunk(): ChunkPositionTable + /** + * Clones the given area. + * + * **Note**: {@link defines.events.on_entity_cloned} is raised for each entity, and then + * {@link defines.events.on_area_cloned} is raised. + * + * **Note**: Entities are cloned in an order such that they can always be created, eg rails before trains. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.clone_area View documentation} + */ + clone_area(params: { + readonly source_area: BoundingBox + readonly destination_area: BoundingBox + readonly destination_surface?: SurfaceIdentification + readonly destination_force?: LuaForce | string + /** If tiles should be cloned */ + readonly clone_tiles?: boolean + /** If entities should be cloned */ + readonly clone_entities?: boolean + /** If decoratives should be cloned */ + readonly clone_decoratives?: boolean + /** If the destination entities should be cleared */ + readonly clear_destination_entities?: boolean + /** If the destination decoratives should be cleared */ + readonly clear_destination_decoratives?: boolean + /** If the destination surface should be expanded when destination_area is outside current bounds. Default false. */ + readonly expand_map?: boolean + /** If true, the building effect smoke will be shown around the new entities. */ + readonly create_build_effect_smoke?: boolean + }): void + /** + * Clones the given area. + * + * **Note**: {@link defines.events.on_entity_cloned} is raised for each entity, and then + * {@link defines.events.on_area_cloned} is raised. + * + * **Note**: Entities are cloned in an order such that they can always be created, eg rails before trains. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.clone_brush View documentation} + */ + clone_brush(params: { + readonly source_offset: TilePosition + readonly destination_offset: TilePosition + readonly source_positions: TilePosition[] + readonly destination_surface?: SurfaceIdentification + readonly destination_force?: LuaForce | string + /** If tiles should be cloned */ + readonly clone_tiles?: boolean + /** If entities should be cloned */ + readonly clone_entities?: boolean + /** If decoratives should be cloned */ + readonly clone_decoratives?: boolean + /** If the destination entities should be cleared */ + readonly clear_destination_entities?: boolean + /** If the destination decoratives should be cleared */ + readonly clear_destination_decoratives?: boolean + /** If the destination surface should be expanded when destination_area is outside current bounds. Default false. */ + readonly expand_map?: boolean + /** If manual-style collision checks should be done. */ + readonly manual_collision_mode?: boolean + /** If true, the building effect smoke will be shown around the new entities. */ + readonly create_build_effect_smoke?: boolean + }): void + /** + * Clones the given entities. + * + * **Note**: {@link defines.events.on_entity_cloned} is raised for each entity. + * + * **Note**: Entities are cloned in an order such that they can always be created, eg rails before trains. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.clone_entities View documentation} + */ + clone_entities(params: { + readonly entities: LuaEntity[] + readonly destination_offset: Vector + readonly destination_surface?: SurfaceIdentification + readonly destination_force?: ForceIdentification + readonly snap_to_grid?: boolean + /** If true, the building effect smoke will be shown around the new entities. */ + readonly create_build_effect_smoke?: boolean + }): void + /** + * Clears this surface deleting all entities and chunks on it. + * + * **Note**: This won't clear the surface immediately. It will be cleared at the end of the current tick. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.clear View documentation} + * + * @param ignore_characters - Whether characters on this surface that are connected to or associated with players + * should be ignored (not destroyed). + */ + clear(ignore_characters?: boolean): void + /** + * Generates a path with the specified constraints (as an array of {@link PathfinderWaypoint PathfinderWaypoints}) + * using the unit pathfinding algorithm. This path can be used to emulate pathing behavior by script for non-unit + * entities. If you want to command actual units to move, use the + * {@link LuaEntity.set_command LuaEntity::set_command} functionality instead. + * + * The resulting path is ultimately returned asynchronously via + * {@link OnScriptPathRequestFinishedEvent on_script_path_request_finished}. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.request_path View documentation} + * + * @returns A unique handle to identify this call when + * {@link OnScriptPathRequestFinishedEvent on_script_path_request_finished} fires. + */ + request_path(params: { + /** The dimensions of the object that's supposed to travel the path. */ + readonly bounding_box: BoundingBox + /** The list of masks the `bounding_box` collides with. */ + readonly collision_mask: CollisionMask | string[] + /** The position from which to start pathfinding. */ + readonly start: Position + /** The position to find a path to. */ + readonly goal: Position + /** The force for which to generate the path, determining which gates can be opened for example. */ + readonly force: ForceIdentification + /** How close the pathfinder needs to get to its `goal` (in tiles). Defaults to `1`. */ + readonly radius?: double + /** Flags that affect pathfinder behavior. */ + readonly pathfind_flags?: PathfinderFlags + /** Whether the path request can open gates. Defaults to `false`. */ + readonly can_open_gates?: boolean + /** + * Defines how coarse the pathfinder's grid is. Smaller values mean a coarser grid (negative numbers allowed). + * Defaults to `0`. + */ + readonly path_resolution_modifier?: int + /** Makes the pathfinder ignore collisions with this entity if it is given. */ + readonly entity_to_ignore?: LuaEntity + }): uint + /** + * Gets the script areas that match the given name or if no name is given all areas are returned. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.get_script_areas View documentation} + * + * @param name + */ + get_script_areas(name?: string): ScriptArea[] + /** + * Gets the first script area by name or id. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.get_script_area View documentation} + * + * @param key - The name or id of the area to get. + */ + get_script_area(key?: string | uint): ScriptArea + /** + * Sets the given script area to the new values. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.edit_script_area View documentation} + * + * @param id - The area to edit. + * @param area + */ + edit_script_area(id: uint, area: ScriptArea): void + /** + * Adds the given script area. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.add_script_area View documentation} + * + * @param area + * @returns The id of the created area. + */ + add_script_area(area: ScriptArea): uint + /** + * Removes the given script area. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.remove_script_area View documentation} + * + * @param id + * @returns If the area was actually removed. False when it didn't exist. + */ + remove_script_area(id: uint): boolean + /** + * Gets the script positions that match the given name or if no name is given all positions are returned. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.get_script_positions View documentation} + * + * @param name + */ + get_script_positions(name?: string): ScriptPosition[] + /** + * Gets the first script position by name or id. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.get_script_position View documentation} + * + * @param key - The name or id of the position to get. + */ + get_script_position(key?: string | uint): ScriptPosition + /** + * Sets the given script position to the new values. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.edit_script_position View documentation} + * + * @param id - The position to edit. + * @param area + */ + edit_script_position(id: uint, area: ScriptPosition): void + /** + * Adds the given script position. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.add_script_position View documentation} + * + * @param area + * @returns The id of the created position. + */ + add_script_position(area: ScriptPosition): uint + /** + * Removes the given script position. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.remove_script_position View documentation} + * + * @param id + * @returns If the position was actually removed. False when it didn't exist. + */ + remove_script_position(id: uint): boolean + /** + * Gets the map exchange string for the current map generation settings of this surface. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.get_map_exchange_string View documentation} + */ + get_map_exchange_string(): string + /** + * Gets the starting area radius of this surface. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.get_starting_area_radius View documentation} + */ + get_starting_area_radius(): double + /** + * Gets the closest entity in the list to this position. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.get_closest View documentation} + * + * @param position + * @param entities - The Entities to check + */ + get_closest(position: Position, entities: LuaEntity[]): LuaEntity + /** + * Gets train stops matching the given filters. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.get_train_stops View documentation} + */ + get_train_stops(params?: { readonly name?: string | string[]; readonly force?: ForceIdentification }): LuaEntity[] + /** + * Gets the total amount of pollution on the surface by iterating over all of the chunks containing pollution. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.get_total_pollution View documentation} + */ + get_total_pollution(): double + /** + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.entity_prototype_collides View documentation} + * + * @param prototype - The entity prototype to check + * @param position - The position to check + * @param use_map_generation_bounding_box - If the map generation bounding box should be used instead of the + * collision bounding box + * @param direction + */ + entity_prototype_collides( + prototype: EntityPrototypeIdentification, + position: Position, + use_map_generation_bounding_box: boolean, + direction?: defines.direction + ): void + /** + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.decorative_prototype_collides View documentation} + * + * @param prototype - The decorative prototype to check + * @param position - The position to check + */ + decorative_prototype_collides(prototype: string, position: Position): void + /** + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.calculate_tile_properties View documentation} + * + * @param property_names - Names of properties (e.g. "elevation") to calculate + * @param positions - Positions for which to calculate property values + * @returns Table of property value lists, keyed by property name + */ + calculate_tile_properties(property_names: string[], positions: Position[]): Record + /** + * Returns all the entities with force on this chunk for the given force. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.get_entities_with_force View documentation} + * + * @param position - The chunk's position. + * @param force - Entities of this force will be returned. + */ + get_entities_with_force(position: ChunkPosition, force: LuaForce | string): LuaEntity[] + /** + * Sets the given area to the checkerboard lab tiles. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.build_checkerboard View documentation} + * + * @param area - The tile area. + */ + build_checkerboard(area: BoundingBox): void + /** + * The name of this surface. Names are unique among surfaces. + * + * **Note**: the default surface can't be renamed. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.name View documentation} + */ + name: string + /** + * Unique ID associated with this surface. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.index View documentation} + */ + readonly index: uint + /** + * The generation settings for this surface. These can be modified to after surface generation, but note that this + * will not retroactively update the surface. To manually adjust it, + * {@link LuaSurface.regenerate_entity LuaSurface::regenerate_entity}, + * {@link LuaSurface.regenerate_decorative LuaSurface::regenerate_decorative} and + * {@link LuaSurface.delete_chunk LuaSurface::delete_chunk} can be used. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.map_gen_settings View documentation} + */ + map_gen_settings: MapGenSettings + /** + * When set to true, new chunks will be generated with lab tiles, instead of using the surface's map generation settings. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.generate_with_lab_tiles View documentation} + */ + generate_with_lab_tiles: boolean + /** + * When set to true, the sun will always shine. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.always_day View documentation} + */ + always_day: boolean + /** + * Current time of day, as a number in range [0, 1). + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.daytime View documentation} + */ + daytime: float + /** + * Amount of darkness at the current time. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.darkness View documentation} + */ + readonly darkness: float + /** + * Current wind speed. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.wind_speed View documentation} + */ + wind_speed: double + /** + * Current wind direction. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.wind_orientation View documentation} + */ + wind_orientation: RealOrientation + /** + * Change in wind orientation per tick. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.wind_orientation_change View documentation} + */ + wind_orientation_change: double + /** + * Is peaceful mode enabled on this surface? + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.peaceful_mode View documentation} + */ + peaceful_mode: boolean + /** + * True if daytime is currently frozen. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.freeze_daytime View documentation} + */ + freeze_daytime: boolean + /** + * The number of ticks per day for this surface. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.ticks_per_day View documentation} + */ + ticks_per_day: uint + /** + * The daytime when dusk starts. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.dusk View documentation} + */ + dusk: double + /** + * The daytime when dawn starts. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.dawn View documentation} + */ + dawn: double + /** + * The daytime when evening starts. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.evening View documentation} + */ + evening: double + /** + * The daytime when morning starts. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.morning View documentation} + */ + morning: double + /** + * The multiplier of solar power on this surface. Cannot be less than 0. + * + * **Note**: Solar equipment is still limited to its maximum power output. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.solar_power_multiplier View documentation} + */ + solar_power_multiplier: double + /** + * The minimal brightness during the night. Default is `0.15`. The value has an effect on the game simalution only, + * it doesn't have any effect on rendering. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.min_brightness View documentation} + */ + min_brightness: double + /** + * Defines how surface daytime brightness influences each color channel of the current color lookup table (LUT). + * + * The LUT is multiplied by `((1 - weight) + brightness * weight)` and result is clamped to range [0, 1]. + * + * Default is `{0, 0, 0}`, which means no influence. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.brightness_visual_weights View documentation} + * + * @example + * Makes night on the surface pitch black, assuming {@link LuaSurface.min_brightness LuaSurface::min_brightness} being set to default value `0.15`. + * + * ```lua + * game.surfaces[1].brightness_visual_weights = { 1 / 0.85, 1 / 0.85, 1 / 0.85 } + * ``` + */ + brightness_visual_weights: ColorModifier + /** + * If clouds are shown on this surface. + * + * **Note**: If false, clouds are never shown. If true the player must also have clouds enabled in graphics settings + * for them to be shown. + * + * {@link https://lua-api.factorio.com/next/LuaSurface.html#LuaSurface.show_clouds View documentation} + */ + show_clouds: 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: "LuaSurface" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * One research item. + * + * {@link https://lua-api.factorio.com/next/LuaTechnology.html View documentation} + * + * @noSelf + */ +interface LuaTechnology { + /** + * Reload this technology from its prototype. + * + * {@link https://lua-api.factorio.com/next/LuaTechnology.html#LuaTechnology.reload View documentation} + */ + reload(): void + /** + * The force this technology belongs to. + * + * {@link https://lua-api.factorio.com/next/LuaTechnology.html#LuaTechnology.force View documentation} + */ + readonly force: LuaForce + /** + * Name of this technology. + * + * {@link https://lua-api.factorio.com/next/LuaTechnology.html#LuaTechnology.name View documentation} + */ + readonly name: string + /** + * Localised name of this technology. + * + * {@link https://lua-api.factorio.com/next/LuaTechnology.html#LuaTechnology.localised_name View documentation} + */ + readonly localised_name: LocalisedString + readonly localised_description: LocalisedString + /** + * The prototype of this technology. + * + * {@link https://lua-api.factorio.com/next/LuaTechnology.html#LuaTechnology.prototype View documentation} + */ + readonly prototype: LuaTechnologyPrototype + /** + * Can this technology be researched? + * + * {@link https://lua-api.factorio.com/next/LuaTechnology.html#LuaTechnology.enabled View documentation} + */ + enabled: boolean + /** + * If this technology will be visible in the research GUI even though it is disabled. + * + * {@link https://lua-api.factorio.com/next/LuaTechnology.html#LuaTechnology.visible_when_disabled View documentation} + */ + visible_when_disabled: boolean + /** + * Is this an upgrade-type research? + * + * {@link https://lua-api.factorio.com/next/LuaTechnology.html#LuaTechnology.upgrade View documentation} + */ + readonly upgrade: boolean + /** + * Has this technology been researched? Switching from `false` to `true` will trigger the technology advancement + * perks; switching from `true` to `false` will reverse them. + * + * {@link https://lua-api.factorio.com/next/LuaTechnology.html#LuaTechnology.researched View documentation} + */ + researched: boolean + /** + * Prerequisites of this technology. The result maps technology name to the {@link LuaTechnology} object. + * + * {@link https://lua-api.factorio.com/next/LuaTechnology.html#LuaTechnology.prerequisites View documentation} + */ + readonly prerequisites: Record + /** + * Ingredients labs will require to research this technology. + * + * {@link https://lua-api.factorio.com/next/LuaTechnology.html#LuaTechnology.research_unit_ingredients View documentation} + * + * @see {@link LuaTechnology.research_unit_count} + */ + readonly research_unit_ingredients: Ingredient[] + /** + * Effects applied when this technology is researched. + * + * {@link https://lua-api.factorio.com/next/LuaTechnology.html#LuaTechnology.effects View documentation} + */ + readonly effects: TechnologyModifier[] + /** + * Number of research units required for this technology. + * + * **Note**: This is multiplied by the current research cost multiplier, unless + * {@link LuaTechnologyPrototype.ignore_tech_cost_multiplier LuaTechnologyPrototype::ignore_tech_cost_multiplier} is `true`. + * + * {@link https://lua-api.factorio.com/next/LuaTechnology.html#LuaTechnology.research_unit_count View documentation} + * + * @see {@link LuaTechnology.research_unit_ingredients} + */ + readonly research_unit_count: uint + /** + * Amount of energy required to finish a unit of research. + * + * {@link https://lua-api.factorio.com/next/LuaTechnology.html#LuaTechnology.research_unit_energy View documentation} + */ + readonly research_unit_energy: double + /** + * Order string for this prototype. + * + * {@link https://lua-api.factorio.com/next/LuaTechnology.html#LuaTechnology.order View documentation} + */ + readonly order: string + /** + * The current level of this technology. For level-based technology writing to this is the same as researching the + * technology to the *previous* level. Writing the level will set + * {@link LuaTechnology.enabled LuaTechnology::enabled} to `true`. + * + * {@link https://lua-api.factorio.com/next/LuaTechnology.html#LuaTechnology.level View documentation} + */ + level: uint + /** + * The count formula used for this infinite research or nil if this isn't an infinite research. + * + * {@link https://lua-api.factorio.com/next/LuaTechnology.html#LuaTechnology.research_unit_count_formula View documentation} + * + * @see {@link LuaGameScript.evaluate_expression} + */ + readonly research_unit_count_formula: string | undefined + /** + * 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: "LuaTechnology" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * A Technology prototype. + * + * {@link https://lua-api.factorio.com/next/LuaTechnologyPrototype.html View documentation} + * + * @noSelf + */ +interface LuaTechnologyPrototype { + /** + * Name of this technology. + * + * {@link https://lua-api.factorio.com/next/LuaTechnologyPrototype.html#LuaTechnologyPrototype.name View documentation} + */ + readonly name: string + /** + * Localised name of this technology. + * + * {@link https://lua-api.factorio.com/next/LuaTechnologyPrototype.html#LuaTechnologyPrototype.localised_name View documentation} + */ + readonly localised_name: LocalisedString + readonly localised_description: LocalisedString + /** + * If this technology prototype is enabled by default (enabled at the beginning of a game). + * + * {@link https://lua-api.factorio.com/next/LuaTechnologyPrototype.html#LuaTechnologyPrototype.enabled View documentation} + */ + readonly enabled: boolean + /** + * If this technology prototype is hidden. + * + * {@link https://lua-api.factorio.com/next/LuaTechnologyPrototype.html#LuaTechnologyPrototype.hidden View documentation} + */ + readonly hidden: boolean + /** + * If this technology will be visible in the research GUI even though it is disabled. + * + * {@link https://lua-api.factorio.com/next/LuaTechnologyPrototype.html#LuaTechnologyPrototype.visible_when_disabled View documentation} + */ + readonly visible_when_disabled: boolean + /** + * If this technology ignores the technology cost multiplier setting. + * + * **Note**: {@link LuaTechnologyPrototype.research_unit_count LuaTechnologyPrototype::research_unit_count} will + * already take this setting into account. + * + * {@link https://lua-api.factorio.com/next/LuaTechnologyPrototype.html#LuaTechnologyPrototype.ignore_tech_cost_multiplier View documentation} + */ + readonly ignore_tech_cost_multiplier: boolean + /** + * If the is technology prototype is an upgrade to some other technology. + * + * {@link https://lua-api.factorio.com/next/LuaTechnologyPrototype.html#LuaTechnologyPrototype.upgrade View documentation} + */ + readonly upgrade: boolean + /** + * Prerequisites of this technology. The result maps technology name to the {@link LuaTechnologyPrototype} object. + * + * {@link https://lua-api.factorio.com/next/LuaTechnologyPrototype.html#LuaTechnologyPrototype.prerequisites View documentation} + */ + readonly prerequisites: Record + /** + * Ingredients labs will require to research this technology. + * + * {@link https://lua-api.factorio.com/next/LuaTechnologyPrototype.html#LuaTechnologyPrototype.research_unit_ingredients View documentation} + * + * @see {@link LuaTechnologyPrototype.research_unit_count} + */ + readonly research_unit_ingredients: Ingredient[] + /** + * Effects applied when this technology is researched. + * + * {@link https://lua-api.factorio.com/next/LuaTechnologyPrototype.html#LuaTechnologyPrototype.effects View documentation} + */ + readonly effects: TechnologyModifier[] + /** + * Number of research units required for this technology. + * + * **Note**: This is multiplied by the current research cost multiplier, unless + * {@link LuaTechnologyPrototype.ignore_tech_cost_multiplier LuaTechnologyPrototype::ignore_tech_cost_multiplier} is `true`. + * + * {@link https://lua-api.factorio.com/next/LuaTechnologyPrototype.html#LuaTechnologyPrototype.research_unit_count View documentation} + * + * @see {@link LuaTechnologyPrototype.research_unit_ingredients} + */ + readonly research_unit_count: uint + /** + * Amount of energy required to finish a unit of research. + * + * {@link https://lua-api.factorio.com/next/LuaTechnologyPrototype.html#LuaTechnologyPrototype.research_unit_energy View documentation} + */ + readonly research_unit_energy: double + /** + * Order string for this prototype. + * + * {@link https://lua-api.factorio.com/next/LuaTechnologyPrototype.html#LuaTechnologyPrototype.order View documentation} + */ + readonly order: string + /** + * The level of this research. + * + * {@link https://lua-api.factorio.com/next/LuaTechnologyPrototype.html#LuaTechnologyPrototype.level View documentation} + */ + readonly level: uint + /** + * The max level of this research. + * + * {@link https://lua-api.factorio.com/next/LuaTechnologyPrototype.html#LuaTechnologyPrototype.max_level View documentation} + */ + readonly max_level: uint + /** + * The count formula used for this infinite research or nil if this isn't an infinite research. + * + * {@link https://lua-api.factorio.com/next/LuaTechnologyPrototype.html#LuaTechnologyPrototype.research_unit_count_formula View documentation} + * + * @see {@link LuaGameScript.evaluate_expression} + */ + readonly research_unit_count_formula: string | undefined + /** + * 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: "LuaTechnologyPrototype" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * A single "square" on the map. + * + * {@link https://lua-api.factorio.com/next/LuaTile.html View documentation} + * + * @noSelf + */ +interface LuaTile { + /** + * What type of things can collide with this tile? + * + * {@link https://lua-api.factorio.com/next/LuaTile.html#LuaTile.collides_with View documentation} + * + * @example + * Check if the character would collide with a tile + * + * ```lua + * game.player.print(tostring(game.player.surface.get_tile(1, 1).collides_with("player-layer"))) + * ``` + * + * @param layer + */ + collides_with(layer: CollisionMaskLayer): boolean + /** + * Is this tile marked for deconstruction? + * + * {@link https://lua-api.factorio.com/next/LuaTile.html#LuaTile.to_be_deconstructed View documentation} + */ + to_be_deconstructed(): boolean + /** + * Orders deconstruction of this tile by the given force. + * + * {@link https://lua-api.factorio.com/next/LuaTile.html#LuaTile.order_deconstruction View documentation} + * + * @param force - The force whose robots are supposed to do the deconstruction. + * @param player - The player to set the last_user to if any. + * @returns The deconstructible tile proxy created if any or `nil`. + */ + order_deconstruction(force: ForceIdentification, player?: PlayerIdentification): LuaEntity | undefined + /** + * Cancels deconstruction if it is scheduled, does nothing otherwise. + * + * {@link https://lua-api.factorio.com/next/LuaTile.html#LuaTile.cancel_deconstruction View documentation} + * + * @param force - The force who did the deconstruction order. + * @param player - The player to set the last_user to if any. + */ + cancel_deconstruction(force: ForceIdentification, player?: PlayerIdentification): void + /** + * Prototype name of this tile. E.g. `"sand-3"` or `"grass-2"`. + * + * {@link https://lua-api.factorio.com/next/LuaTile.html#LuaTile.name View documentation} + */ + readonly name: string + readonly prototype: LuaTilePrototype + /** + * The position this tile references. + * + * {@link https://lua-api.factorio.com/next/LuaTile.html#LuaTile.position View documentation} + */ + readonly position: PositionTable + /** + * The name of the {@link LuaTilePrototype} hidden under this tile or `nil` if there is no hidden tile. During normal + * gameplay, only {@link LuaTilePrototype.mineable_properties non-mineable} tiles can become hidden. This can however + * be circumvented with {@link LuaSurface.set_hidden_tile LuaSurface::set_hidden_tile}. + * + * {@link https://lua-api.factorio.com/next/LuaTile.html#LuaTile.hidden_tile View documentation} + */ + readonly hidden_tile: string | undefined + /** + * The surface this tile is on. + * + * {@link https://lua-api.factorio.com/next/LuaTile.html#LuaTile.surface View documentation} + */ + readonly surface: LuaSurface + /** + * 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: "LuaTile" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * Prototype of a tile. + * + * {@link https://lua-api.factorio.com/next/LuaTilePrototype.html View documentation} + * + * @noSelf + */ +interface LuaTilePrototype { + /** + * Name of this prototype. + * + * {@link https://lua-api.factorio.com/next/LuaTilePrototype.html#LuaTilePrototype.name View documentation} + */ + readonly name: string + /** + * Order string of this prototype. + * + * {@link https://lua-api.factorio.com/next/LuaTilePrototype.html#LuaTilePrototype.order View documentation} + */ + readonly order: string + readonly localised_name: LocalisedString + readonly localised_description: LocalisedString + /** + * The collision mask this tile uses + * + * {@link https://lua-api.factorio.com/next/LuaTilePrototype.html#LuaTilePrototype.collision_mask View documentation} + */ + readonly collision_mask: CollisionMask + readonly collision_mask_with_flags: CollisionMaskWithFlags + readonly layer: uint + /** + * Autoplace specification for this prototype. `nil` if none. + * + * {@link https://lua-api.factorio.com/next/LuaTilePrototype.html#LuaTilePrototype.autoplace_specification View documentation} + */ + readonly autoplace_specification: AutoplaceSpecification | undefined + readonly walking_speed_modifier: float + readonly vehicle_friction_modifier: float + readonly map_color: ColorTable + /** + * The probability that decorative entities will be removed from on top of this tile when this tile is generated. + * + * {@link https://lua-api.factorio.com/next/LuaTilePrototype.html#LuaTilePrototype.decorative_removal_probability View documentation} + */ + readonly decorative_removal_probability: float + readonly automatic_neighbors: boolean + readonly allowed_neighbors: Record + /** + * If this tile needs correction logic applied when it's generated in the world.. + * + * {@link https://lua-api.factorio.com/next/LuaTilePrototype.html#LuaTilePrototype.needs_correction View documentation} + */ + readonly needs_correction: boolean + readonly mineable_properties: { + /** Is this tile mineable at all? */ + readonly minable: boolean + /** Energy required to mine a tile. */ + readonly miningtime: double + /** + * Prototype name of the particle produced when mining this tile. Will only be present if this tile produces any + * particle during mining. + */ + readonly miningparticle?: string + /** Products obtained by mining this tile. */ + readonly products: Product[] + } + /** + * The next direction of this tile or `nil` - used when a tile has multiple directions (such as hazard concrete) + * + * {@link https://lua-api.factorio.com/next/LuaTilePrototype.html#LuaTilePrototype.next_direction View documentation} + */ + readonly next_direction: LuaTilePrototype | undefined + /** + * Items that when placed will produce this tile. It is a dictionary indexed by the item prototype name. + * + * {@link https://lua-api.factorio.com/next/LuaTilePrototype.html#LuaTilePrototype.items_to_place_this View documentation} + */ + readonly items_to_place_this: SimpleItemStack[] + /** + * False if this tile is not allowed in blueprints regardless of the ability to build it. + * + * {@link https://lua-api.factorio.com/next/LuaTilePrototype.html#LuaTilePrototype.can_be_part_of_blueprint View documentation} + */ + readonly can_be_part_of_blueprint: boolean + /** + * Amount of pollution emissions per second this tile will absorb. + * + * {@link https://lua-api.factorio.com/next/LuaTilePrototype.html#LuaTilePrototype.emissions_per_second View documentation} + */ + readonly emissions_per_second: double + /** + * 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: "LuaTilePrototype" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * A train. Trains are a sequence of connected rolling stocks -- locomotives and wagons. + * + * {@link https://lua-api.factorio.com/next/LuaTrain.html View documentation} + * + * @noSelf + */ +interface LuaTrain { + /** + * Get the amount of a particular item stored in the train. + * + * {@link https://lua-api.factorio.com/next/LuaTrain.html#LuaTrain.get_item_count View documentation} + * + * @param item - Item name to count. If not given, counts all items. + */ + get_item_count(item?: string): uint + /** + * Get a mapping of the train's inventory. + * + * {@link https://lua-api.factorio.com/next/LuaTrain.html#LuaTrain.get_contents View documentation} + * + * @returns The counts, indexed by item names. + */ + get_contents(): Record + /** + * Remove some items from the train. + * + * {@link https://lua-api.factorio.com/next/LuaTrain.html#LuaTrain.remove_item View documentation} + * + * @param stack - The amount and type of items to remove + * @returns Number of items actually removed. + */ + remove_item(stack: ItemStackIdentification): uint + /** + * Insert a stack into the train. + * + * {@link https://lua-api.factorio.com/next/LuaTrain.html#LuaTrain.insert View documentation} + * + * @param stack + */ + insert(stack: ItemStackIdentification): void + /** + * Clear all items in this train. + * + * {@link https://lua-api.factorio.com/next/LuaTrain.html#LuaTrain.clear_items_inside View documentation} + */ + clear_items_inside(): void + /** + * Checks if the path is invalid and tries to re-path if it isn't. + * + * {@link https://lua-api.factorio.com/next/LuaTrain.html#LuaTrain.recalculate_path View documentation} + * + * @param force - Forces the train to re-path regardless of the current path being valid or not. + * @returns If the train has a path after the repath attempt. + */ + recalculate_path(force?: boolean): boolean + /** + * Get the amount of a particular fluid stored in the train. + * + * {@link https://lua-api.factorio.com/next/LuaTrain.html#LuaTrain.get_fluid_count View documentation} + * + * @param fluid - Fluid name to count. If not given, counts all fluids. + */ + get_fluid_count(fluid?: string): double + /** + * Gets a mapping of the train's fluid inventory. + * + * {@link https://lua-api.factorio.com/next/LuaTrain.html#LuaTrain.get_fluid_contents View documentation} + * + * @returns The counts, indexed by fluid names. + */ + get_fluid_contents(): Record + /** + * Remove some fluid from the train. + * + * {@link https://lua-api.factorio.com/next/LuaTrain.html#LuaTrain.remove_fluid View documentation} + * + * @param fluid + * @returns The amount of fluid actually removed. + */ + remove_fluid(fluid: Fluid): double + /** + * Inserts the given fluid into the first available location in this train. + * + * {@link https://lua-api.factorio.com/next/LuaTrain.html#LuaTrain.insert_fluid View documentation} + * + * @param fluid + * @returns The amount inserted. + */ + insert_fluid(fluid: Fluid): double + /** + * Clears all fluids in this train. + * + * {@link https://lua-api.factorio.com/next/LuaTrain.html#LuaTrain.clear_fluids_inside View documentation} + */ + clear_fluids_inside(): void + /** + * Go to the station specified by the index in the train's schedule. + * + * {@link https://lua-api.factorio.com/next/LuaTrain.html#LuaTrain.go_to_station View documentation} + * + * @param index + */ + go_to_station(index: uint): void + /** + * Gets all rails under the train. + * + * {@link https://lua-api.factorio.com/next/LuaTrain.html#LuaTrain.get_rails View documentation} + */ + get_rails(): LuaEntity[] + /** + * When `true`, the train is explicitly controlled by the player or script. When `false`, the train moves + * autonomously according to its schedule. + * + * {@link https://lua-api.factorio.com/next/LuaTrain.html#LuaTrain.manual_mode View documentation} + */ + manual_mode: boolean + /** + * Current speed. + * + * **Note**: Changing the speed of the train is potentially an unsafe operation because train uses the speed for its + * internal calculations of break distances, etc. + * + * {@link https://lua-api.factorio.com/next/LuaTrain.html#LuaTrain.speed View documentation} + */ + speed: double + /** + * Current max speed when moving forward, depends on locomotive prototype and fuel. + * + * {@link https://lua-api.factorio.com/next/LuaTrain.html#LuaTrain.max_forward_speed View documentation} + */ + readonly max_forward_speed: double + /** + * Current max speed when moving backwards, depends on locomotive prototype and fuel. + * + * {@link https://lua-api.factorio.com/next/LuaTrain.html#LuaTrain.max_backward_speed View documentation} + */ + readonly max_backward_speed: double + /** + * The weight of this train. + * + * {@link https://lua-api.factorio.com/next/LuaTrain.html#LuaTrain.weight View documentation} + */ + readonly weight: double + /** + * Rolling stocks the train is composed of. + * + * {@link https://lua-api.factorio.com/next/LuaTrain.html#LuaTrain.carriages View documentation} + */ + readonly carriages: LuaEntity[] + /** + * Arrays of locomotives. The result is two arrays, indexed by `"front_movers"` and `"back_movers"` containing the + * locomotives. E.g. `{front_movers={loco1, loco2}, back_movers={loco3}}`. + * + * {@link https://lua-api.factorio.com/next/LuaTrain.html#LuaTrain.locomotives View documentation} + */ + readonly locomotives: Record + /** + * The cargo carriages the train contains. + * + * {@link https://lua-api.factorio.com/next/LuaTrain.html#LuaTrain.cargo_wagons View documentation} + */ + readonly cargo_wagons: LuaEntity[] + /** + * The fluid carriages the train contains. + * + * {@link https://lua-api.factorio.com/next/LuaTrain.html#LuaTrain.fluid_wagons View documentation} + */ + readonly fluid_wagons: LuaEntity[] + /** + * The trains current schedule or `nil` if empty. Set to `nil` to clear. + * + * **Note**: The schedule can't be changed by modifying the returned table. Instead, changes must be made by + * assigning a new table to this attribute. + * + * {@link https://lua-api.factorio.com/next/LuaTrain.html#LuaTrain.schedule View documentation} + */ + schedule: TrainSchedule | undefined + /** + * This train's current state. + * + * {@link https://lua-api.factorio.com/next/LuaTrain.html#LuaTrain.state View documentation} + */ + readonly state: defines.train_state + /** + * The rail at the front end of the train, possibly `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaTrain.html#LuaTrain.front_rail View documentation} + */ + readonly front_rail: LuaEntity | undefined + /** + * The rail at the back end of the train, possibly `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaTrain.html#LuaTrain.back_rail View documentation} + */ + readonly back_rail: LuaEntity | undefined + readonly rail_direction_from_front_rail: defines.rail_direction + readonly rail_direction_from_back_rail: defines.rail_direction + /** + * The front stock of this train or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaTrain.html#LuaTrain.front_stock View documentation} + */ + readonly front_stock: LuaEntity | undefined + /** + * The back stock of this train or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaTrain.html#LuaTrain.back_stock View documentation} + */ + readonly back_stock: LuaEntity | undefined + /** + * The train stop this train is stopped at or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaTrain.html#LuaTrain.station View documentation} + */ + readonly station: LuaEntity | undefined + /** + * If this train has a path. + * + * {@link https://lua-api.factorio.com/next/LuaTrain.html#LuaTrain.has_path View documentation} + */ + readonly has_path: boolean + /** + * The destination rail this train is currently pathing to or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaTrain.html#LuaTrain.path_end_rail View documentation} + */ + readonly path_end_rail: LuaEntity | undefined + /** + * The destination train stop this train is currently pathing to or `nil`. + * + * {@link https://lua-api.factorio.com/next/LuaTrain.html#LuaTrain.path_end_stop View documentation} + */ + readonly path_end_stop: LuaEntity | undefined + /** + * The unique train ID. + * + * {@link https://lua-api.factorio.com/next/LuaTrain.html#LuaTrain.id View documentation} + */ + readonly id: uint + /** + * The player passengers on the train + * + * **Note**: This does *not* index using player index. See {@link LuaPlayer.index LuaPlayer::index} on each player + * instance for the player index. + * + * {@link https://lua-api.factorio.com/next/LuaTrain.html#LuaTrain.passengers View documentation} + */ + readonly passengers: LuaPlayer[] + /** + * The riding state of this train. + * + * {@link https://lua-api.factorio.com/next/LuaTrain.html#LuaTrain.riding_state View documentation} + */ + readonly riding_state: RidingState + /** + * The players killed by this train. + * + * The keys are the player indexes, the values are how often this train killed that player. + * + * {@link https://lua-api.factorio.com/next/LuaTrain.html#LuaTrain.killed_players View documentation} + */ + readonly killed_players: Record + /** + * The total number of kills by this train. + * + * {@link https://lua-api.factorio.com/next/LuaTrain.html#LuaTrain.kill_count View documentation} + */ + readonly kill_count: uint + /** + * The path this train is using or `nil` if none. + * + * {@link https://lua-api.factorio.com/next/LuaTrain.html#LuaTrain.path View documentation} + */ + readonly path: LuaRailPath | undefined + /** + * The signal this train is arriving or waiting at or `nil` if none. + * + * {@link https://lua-api.factorio.com/next/LuaTrain.html#LuaTrain.signal View documentation} + */ + readonly signal: LuaEntity | undefined + /** + * 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: "LuaTrain" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * Control behavior for train stops. + * + * {@link https://lua-api.factorio.com/next/LuaTrainStopControlBehavior.html View documentation} + * + * @noSelf + */ +interface LuaTrainStopControlBehavior extends LuaGenericOnOffControlBehavior { + /** + * `true` if the train stop should send the circuit network contents to the train to use. + * + * {@link https://lua-api.factorio.com/next/LuaTrainStopControlBehavior.html#LuaTrainStopControlBehavior.send_to_train View documentation} + */ + send_to_train: boolean + /** + * `true` if the train stop should send the train contents to the circuit network. + * + * {@link https://lua-api.factorio.com/next/LuaTrainStopControlBehavior.html#LuaTrainStopControlBehavior.read_from_train View documentation} + */ + read_from_train: boolean + /** + * `true` if the train stop should send the stopped train id to the circuit network. + * + * {@link https://lua-api.factorio.com/next/LuaTrainStopControlBehavior.html#LuaTrainStopControlBehavior.read_stopped_train View documentation} + */ + read_stopped_train: boolean + /** + * `true` if the trains_limit_signal is used to set a limit of trains incoming for train stop. + * + * {@link https://lua-api.factorio.com/next/LuaTrainStopControlBehavior.html#LuaTrainStopControlBehavior.set_trains_limit View documentation} + */ + set_trains_limit: boolean + /** + * `true` if the train stop should send amount of incoming trains to the circuit network. + * + * {@link https://lua-api.factorio.com/next/LuaTrainStopControlBehavior.html#LuaTrainStopControlBehavior.read_trains_count View documentation} + */ + read_trains_count: boolean + /** + * `true` if the train stop is enabled/disabled through the circuit network. + * + * {@link https://lua-api.factorio.com/next/LuaTrainStopControlBehavior.html#LuaTrainStopControlBehavior.enable_disable View documentation} + */ + enable_disable: boolean + /** + * The signal that will be sent when using the send-train-id option. + * + * {@link https://lua-api.factorio.com/next/LuaTrainStopControlBehavior.html#LuaTrainStopControlBehavior.stopped_train_signal View documentation} + */ + stopped_train_signal: SignalID + /** + * The signal that will be sent when using the read-trains-count option. + * + * {@link https://lua-api.factorio.com/next/LuaTrainStopControlBehavior.html#LuaTrainStopControlBehavior.trains_count_signal View documentation} + */ + trains_count_signal: SignalID + /** + * The signal to be used by set-trains-limit to limit amount of incoming trains + * + * {@link https://lua-api.factorio.com/next/LuaTrainStopControlBehavior.html#LuaTrainStopControlBehavior.trains_limit_signal View documentation} + */ + trains_limit_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: "LuaTrainStopControlBehavior" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * Control behavior for transport belts. + * + * {@link https://lua-api.factorio.com/next/LuaTransportBeltControlBehavior.html View documentation} + * + * @noSelf + */ +interface LuaTransportBeltControlBehavior extends LuaGenericOnOffControlBehavior { + /** + * If the belt will be enabled/disabled based off the circuit network. + * + * {@link https://lua-api.factorio.com/next/LuaTransportBeltControlBehavior.html#LuaTransportBeltControlBehavior.enable_disable View documentation} + */ + enable_disable: boolean + /** + * If the belt will read the contents and send them to the circuit network. + * + * {@link https://lua-api.factorio.com/next/LuaTransportBeltControlBehavior.html#LuaTransportBeltControlBehavior.read_contents View documentation} + */ + read_contents: boolean + /** + * The read mode for the belt. + * + * {@link https://lua-api.factorio.com/next/LuaTransportBeltControlBehavior.html#LuaTransportBeltControlBehavior.read_contents_mode View documentation} + */ + read_contents_mode: defines.control_behavior.transport_belt.content_read_mode + /** + * 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: "LuaTransportBeltControlBehavior" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * One line on a transport belt. + * + * {@link https://lua-api.factorio.com/next/LuaTransportLine.html View documentation} + * + * @noSelf + */ +interface LuaTransportLine extends ReadonlyArray { + /** + * Remove all items from this transport line. + * + * {@link https://lua-api.factorio.com/next/LuaTransportLine.html#LuaTransportLine.clear View documentation} + */ + clear(): void + /** + * Count some or all items on this line. + * + * {@link https://lua-api.factorio.com/next/LuaTransportLine.html#LuaTransportLine.get_item_count View documentation} + * + * @param item - Prototype name of the item to count. If not specified, count all items. + * @see {@link LuaInventory.get_item_count} + */ + get_item_count(item?: string): uint + /** + * Remove some items from this line. + * + * {@link https://lua-api.factorio.com/next/LuaTransportLine.html#LuaTransportLine.remove_item View documentation} + * + * @param items - Items to remove. + * @returns Number of items actually removed. + */ + remove_item(items: ItemStackIdentification): uint + /** + * Can an item be inserted at a given position? + * + * {@link https://lua-api.factorio.com/next/LuaTransportLine.html#LuaTransportLine.can_insert_at View documentation} + * + * @param position - Where to insert an item. + */ + can_insert_at(position: float): boolean + /** + * Can an item be inserted at the back of this line? + * + * {@link https://lua-api.factorio.com/next/LuaTransportLine.html#LuaTransportLine.can_insert_at_back View documentation} + */ + can_insert_at_back(): boolean + /** + * Insert items at a given position. + * + * {@link https://lua-api.factorio.com/next/LuaTransportLine.html#LuaTransportLine.insert_at View documentation} + * + * @param position - Where on the line to insert the items. + * @param items - Items to insert. + * @returns Were the items inserted successfully? + */ + insert_at(position: float, items: ItemStackIdentification): boolean + /** + * Insert items at the back of this line. + * + * {@link https://lua-api.factorio.com/next/LuaTransportLine.html#LuaTransportLine.insert_at_back View documentation} + * + * @param items + * @returns Were the items inserted successfully? + */ + insert_at_back(items: ItemStackIdentification): boolean + /** + * Get counts of all items on this line. + * + * {@link https://lua-api.factorio.com/next/LuaTransportLine.html#LuaTransportLine.get_contents View documentation} + * + * @returns The counts, indexed by item names. + * @see {@link LuaInventory.get_contents} + */ + get_contents(): Record + /** + * Returns whether the associated internal transport line of this line is the same as the others associated internal + * transport line. + * + * **Note**: This can return true even when the {@link LuaTransportLine.owner LuaTransportLine::owner}s are different + * (so `this == other` is false), because the internal transport lines can span multiple tiles. + * + * {@link https://lua-api.factorio.com/next/LuaTransportLine.html#LuaTransportLine.line_equals View documentation} + * + * @param other + */ + line_equals(other: LuaTransportLine): boolean + /** + * Get the number of items on this transport line. + * + * {@link https://lua-api.factorio.com/next/LuaTransportLine.html#LuaTransportLine.operator%20# View documentation} + */ + readonly length: uint + /** + * The entity this transport line belongs to. + * + * {@link https://lua-api.factorio.com/next/LuaTransportLine.html#LuaTransportLine.owner View documentation} + */ + readonly owner: LuaEntity + /** + * The transport lines that this transport line outputs items to or an empty table if none. + * + * {@link https://lua-api.factorio.com/next/LuaTransportLine.html#LuaTransportLine.output_lines View documentation} + */ + readonly output_lines: LuaTransportLine[] + /** + * The transport lines that this transport line is fed by or an empty table if none. + * + * {@link https://lua-api.factorio.com/next/LuaTransportLine.html#LuaTransportLine.input_lines View documentation} + */ + readonly input_lines: LuaTransportLine[] + /** + * The indexing operator. + * + * {@link https://lua-api.factorio.com/next/LuaTransportLine.html#LuaTransportLine.operator%20[] View documentation} + */ + readonly [index: number]: LuaItemStack + /** + * 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: "LuaTransportLine" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * Prototype of a trivial smoke. + * + * {@link https://lua-api.factorio.com/next/LuaTrivialSmokePrototype.html View documentation} + * + * @noSelf + */ +interface LuaTrivialSmokePrototype { + /** + * Name of this prototype. + * + * {@link https://lua-api.factorio.com/next/LuaTrivialSmokePrototype.html#LuaTrivialSmokePrototype.name View documentation} + */ + readonly name: string + /** + * Order string of this prototype. + * + * {@link https://lua-api.factorio.com/next/LuaTrivialSmokePrototype.html#LuaTrivialSmokePrototype.order View documentation} + */ + readonly order: string + readonly localised_name: LocalisedString + readonly localised_description: LocalisedString + readonly color: ColorTable + readonly start_scale: double + readonly end_scale: double + readonly movement_slow_down_factor: double + readonly duration: uint + readonly spread_duration: uint + readonly fade_away_duration: uint + readonly fade_in_duration: uint + readonly glow_fade_away_duration: uint + readonly cyclic: boolean + readonly affected_by_wind: boolean + readonly show_when_smoke_off: boolean + readonly glow_animation: boolean + readonly render_layer: RenderLayer + /** + * 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: "LuaTrivialSmokePrototype" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * A collection of units moving and attacking together. The engine creates autonomous unit groups to attack polluted + * areas. The script can create and control such groups as well. Groups can accept commands in the same manner as regular units. + * + * {@link https://lua-api.factorio.com/next/LuaUnitGroup.html View documentation} + * + * @noSelf + */ +interface LuaUnitGroup { + /** + * Make a unit a member of this group. Has the same effect as giving a `group_command` with this group to the unit. + * + * **Note**: The member must have the same force as the unit group. + * + * {@link https://lua-api.factorio.com/next/LuaUnitGroup.html#LuaUnitGroup.add_member View documentation} + * + * @param unit + */ + add_member(unit: LuaEntity): void + /** + * Give this group a command. + * + * {@link https://lua-api.factorio.com/next/LuaUnitGroup.html#LuaUnitGroup.set_command View documentation} + * + * @param command + * @see {@link LuaEntity.set_command} + */ + set_command(command: Command): void + /** + * Give this group a distraction command. + * + * {@link https://lua-api.factorio.com/next/LuaUnitGroup.html#LuaUnitGroup.set_distraction_command View documentation} + * + * @param command + * @see {@link LuaEntity.set_command} + */ + set_distraction_command(command: Command): void + /** + * Make this group autonomous. Autonomous groups will automatically attack polluted areas. Autonomous groups aren't + * considered to be script driven + * + * {@link https://lua-api.factorio.com/next/LuaUnitGroup.html#LuaUnitGroup.set_autonomous View documentation} + * + * @see {@link LuaUnitGroup.is_script_driven} + */ + set_autonomous(): void + /** + * Make the group start moving even if some of its members haven't yet arrived. + * + * {@link https://lua-api.factorio.com/next/LuaUnitGroup.html#LuaUnitGroup.start_moving View documentation} + */ + start_moving(): void + /** + * Dissolve this group. Its members won't be destroyed, they will be merely unlinked from this group. + * + * {@link https://lua-api.factorio.com/next/LuaUnitGroup.html#LuaUnitGroup.destroy View documentation} + */ + destroy(): void + /** + * Members of this group. + * + * {@link https://lua-api.factorio.com/next/LuaUnitGroup.html#LuaUnitGroup.members View documentation} + */ + readonly members: LuaEntity[] + /** + * Group position. This can have different meanings depending on the group state. When the group is gathering, the + * position is the place of gathering. When the group is moving, the position is the expected position of its + * members along the path. When the group is attacking, it is the average position of its members. + * + * {@link https://lua-api.factorio.com/next/LuaUnitGroup.html#LuaUnitGroup.position View documentation} + */ + readonly position: PositionTable + /** + * Whether this group is gathering, moving or attacking. + * + * {@link https://lua-api.factorio.com/next/LuaUnitGroup.html#LuaUnitGroup.state View documentation} + */ + readonly state: defines.group_state + /** + * The force of this unit group. + * + * {@link https://lua-api.factorio.com/next/LuaUnitGroup.html#LuaUnitGroup.force View documentation} + */ + readonly force: LuaForce + /** + * The surface of this unit group. + * + * {@link https://lua-api.factorio.com/next/LuaUnitGroup.html#LuaUnitGroup.surface View documentation} + */ + readonly surface: LuaSurface + /** + * The group number for this unit group. + * + * {@link https://lua-api.factorio.com/next/LuaUnitGroup.html#LuaUnitGroup.group_number View documentation} + */ + readonly group_number: uint + /** + * Whether this unit group is controlled by a script or by the game engine. + * + * {@link https://lua-api.factorio.com/next/LuaUnitGroup.html#LuaUnitGroup.is_script_driven View documentation} + * + * @see {@link LuaUnitGroup.set_autonomous} + */ + readonly is_script_driven: boolean + /** + * The command given to this group or `nil` is the group has no command. + * + * {@link https://lua-api.factorio.com/next/LuaUnitGroup.html#LuaUnitGroup.command View documentation} + */ + readonly command: Command | undefined + /** + * The distraction command given to this group or `nil` is the group currently isn't distracted. + * + * {@link https://lua-api.factorio.com/next/LuaUnitGroup.html#LuaUnitGroup.distraction_command View documentation} + */ + readonly distraction_command: Command | undefined + /** + * 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: "LuaUnitGroup" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * Prototype of a virtual signal. + * + * {@link https://lua-api.factorio.com/next/LuaVirtualSignalPrototype.html View documentation} + * + * @noSelf + */ +interface LuaVirtualSignalPrototype { + /** + * Name of this prototype. + * + * {@link https://lua-api.factorio.com/next/LuaVirtualSignalPrototype.html#LuaVirtualSignalPrototype.name View documentation} + */ + readonly name: string + /** + * Order string of this prototype. + * + * {@link https://lua-api.factorio.com/next/LuaVirtualSignalPrototype.html#LuaVirtualSignalPrototype.order View documentation} + */ + readonly order: string + readonly localised_name: LocalisedString + readonly localised_description: LocalisedString + /** + * If this is a special signal + * + * {@link https://lua-api.factorio.com/next/LuaVirtualSignalPrototype.html#LuaVirtualSignalPrototype.special View documentation} + */ + readonly special: boolean + readonly subgroup: LuaGroup + /** + * 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: "LuaVirtualSignalPrototype" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * Prototype of a void energy source. + * + * {@link https://lua-api.factorio.com/next/LuaVoidEnergySourcePrototype.html View documentation} + * + * @noSelf + */ +interface LuaVoidEnergySourcePrototype { + readonly emissions: double + readonly render_no_network_icon: boolean + readonly render_no_power_icon: 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: "LuaVoidEnergySourcePrototype" + /** All methods and properties that this object supports. */ + help(): string +} + +/** + * Control behavior for walls. + * + * {@link https://lua-api.factorio.com/next/LuaWallControlBehavior.html View documentation} + * + * @noSelf + */ +interface LuaWallControlBehavior extends LuaControlBehavior { + /** + * The circuit condition. + * + * {@link https://lua-api.factorio.com/next/LuaWallControlBehavior.html#LuaWallControlBehavior.circuit_condition View documentation} + */ + circuit_condition: CircuitConditionDefinition + open_gate: boolean + read_sensor: boolean + 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: "LuaWallControlBehavior" + /** All methods and properties that this object supports. */ + help(): string +} diff --git a/modules/mod2/typed-factorio/generated/concepts.d.ts b/modules/mod2/typed-factorio/generated/concepts.d.ts new file mode 100644 index 0000000..e097d47 --- /dev/null +++ b/modules/mod2/typed-factorio/generated/concepts.d.ts @@ -0,0 +1,5635 @@ +/** @noSelfInFile */ + +/** + * 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 cannot be recursed deeper than 20 levels and cannot have more than 20 parameters. + * + * As a special case, when the key is just the empty string, all the parameters will be concatenated (after processing, + * if any are localised strings). If there is only one parameter, it will be used as is. + * + * 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, or number which will be converted to its textual representation. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#LocalisedString View documentation} + * + * @example + * In the English translation, this will print `"No ammo"`; in the Czech translation, it will print `"Bez munice"`: + * + * ```lua + * 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"`: + * + * ```lua + * game.player.print({"description.durability", 5, 9}) + * ``` + * + * @example + * This will print `"hello"` in all translations: + * + * ```lua + * game.player.print({"", "hello"}) + * ``` + * + * @example + * This will print `"Iron plate: 60"` in the English translation and `"Eisenplatte: 60"` in the German translation. + * + * ```lua + * game.print({"", {"item-name.iron-plate"}, ": ", 60}) + * ``` + */ +type LocalisedString = [string, ...LocalisedString[]] | string | number + +interface DisplayResolution { + readonly width: uint + readonly height: uint +} + +interface PersonalLogisticParameters { + /** The item. `nil` clears the filter. */ + readonly name?: string + readonly min?: 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". + * + * {@link https://lua-api.factorio.com/next/Concepts.html#RealOrientation View documentation} + */ +type RealOrientation = float + +interface PositionTable { + readonly x: int + readonly y: int +} + +type PositionArray = readonly [x: int, y: int] + +/** + * Coordinates of a tile in a map. Positions may be specified either as a dictionary with `x`, `y` as keys, or simply as + * an array with two elements. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#Position View documentation} + * + * @example + * Explicit definition: + * + * ```lua + * {x = 50, y = 20} + * {y = 20, x = 50} + * ``` + * + * @example + * Shorthand: ```lua + * {10, 20} + * ``` + */ +type Position = PositionTable | PositionArray + +interface ChunkPositionTable { + readonly x: int + readonly y: int +} + +type ChunkPositionArray = readonly [x: int, y: int] + +/** + * Coordinates of a chunk in a {@link LuaSurface} where each integer `x`/`y` represents a different chunk. This uses the + * same format as {@link Position}, meaning it can be specified either with or without explicit keys. A {@link Position} + * can be translated to a ChunkPosition by dividing the `x`/`y` values by 32. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#ChunkPosition View documentation} + */ +type ChunkPosition = ChunkPositionTable | ChunkPositionArray + +interface TilePositionTable { + readonly x: int + readonly y: int +} + +type TilePositionArray = readonly [x: int, y: int] + +/** + * Coordinates of a tile in a chunk on a {@link LuaSurface} where each integer `x`/`y` represents a different tile. This + * uses the same format as {@link Position} except it rounds any `x`/`y` down to whole numbers. It can be specified + * either with or without explicit keys. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#TilePosition View documentation} + */ +type TilePosition = TilePositionTable | TilePositionArray + +interface GuiLocationTable { + readonly x: int + readonly y: int +} + +type GuiLocationArray = readonly [x: int, y: int] + +/** + * Screen coordinates of a GUI element in a {@link LuaGui}. This uses the same format as {@link Position} except it rounds + * any `x`/`y` down to whole numbers. It can be specified either with or without explicit keys. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#GuiLocation View documentation} + */ +type GuiLocation = GuiLocationTable | GuiLocationArray + +/** + * A {@link ChunkPosition} with an added bounding box for the area of the chunk. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#ChunkPositionAndArea View documentation} + */ +interface ChunkPositionAndArea { + readonly x: int + readonly y: int + readonly area: BoundingBox +} + +/** + * A table used to define a manual shape for a piece of equipment. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#EquipmentPoint View documentation} + */ +interface EquipmentPoint { + readonly x: uint + readonly y: uint +} + +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[] +} + +interface TabAndContent { + readonly tab: LuaGuiElement + readonly content: LuaGuiElement +} + +interface OldTileAndPosition { + readonly old_tile: LuaTilePrototype + readonly position: TilePosition +} + +/** + * A dictionary of string to the four basic Lua types: `string`, `boolean`, `number`, `table`. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#Tags View documentation} + * + * @example + * ```lua + * {a = 1, b = true, c = "three", d = {e = "f"}} + * ``` + */ +type Tags = Record + +/** + * **Note**: The vectors for all 5 position attributes are a table with `x` and `y` keys instead of an array. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#SmokeSource View documentation} + */ +interface SmokeSource { + readonly name: string + readonly frequency: double + readonly offset: double + readonly position?: PositionTable + readonly north_position?: PositionTable + readonly east_position?: PositionTable + readonly south_position?: PositionTable + readonly west_position?: PositionTable + readonly deviation?: Position + 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. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#Vector View documentation} + * + * @example + * ```lua + * right = {1.0, 0.0} + * ``` + */ +type Vector = PositionArray + +interface BoundingBoxTable { + readonly left_top: Position + readonly right_bottom: Position + readonly orientation?: RealOrientation +} + +type BoundingBoxArray = readonly [left_top: Position, right_bottom: Position, orientation?: RealOrientation] + +/** + * Two positions, specifying the top-left and bottom-right corner of the box respectively. Like with {@link Position}, + * the names of the members may be omitted. When read from the game, the third member `orientation` is present if it is + * non-zero, however it is ignored when provided to the game. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#BoundingBox View documentation} + * + * @example + * Explicit definition: + * + * ```lua + * {left_top = {-2, -3}, right_bottom = {5, 8}} + * ``` + * + * @example + * Shorthand: ```lua + * {{-2, -3}, {5, 8}} + * ``` + */ +type BoundingBox = BoundingBoxTable | BoundingBoxArray + +/** + * An area defined using the map editor. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#ScriptArea View documentation} + */ +interface ScriptArea { + readonly area: BoundingBox + readonly name: string + readonly color: Color + readonly id: uint +} + +/** + * A position defined using the map editor. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#ScriptPosition View documentation} + */ +interface ScriptPosition { + readonly position: Position + readonly name: string + readonly color: Color + readonly id: uint +} + +interface ColorTable { + readonly r?: float + readonly g?: float + readonly b?: float + readonly a?: float +} + +type ColorArray = readonly [r?: float, g?: float, b?: float, a?: float] + +/** + * 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 Position}, 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). + * + * {@link https://lua-api.factorio.com/next/Concepts.html#Color View documentation} + * + * @example + * ```lua + * 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 + * ``` + */ +type Color = ColorTable | ColorArray + +interface ColorModifierTable { + readonly r?: float + readonly g?: float + readonly b?: float + readonly a?: float +} + +type ColorModifierArray = readonly [r?: float, g?: float, b?: float, a?: float] + +/** + * 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]. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#ColorModifier View documentation} + */ +type ColorModifier = ColorModifierTable | ColorModifierArray + +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 +} + +interface Alert { + /** The tick this alert was created. */ + readonly tick: uint + readonly target?: LuaEntity + readonly prototype?: LuaEntityPrototype + readonly position?: Position + /** 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. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#ScriptRenderVertexTarget View documentation} + */ +interface ScriptRenderVertexTarget { + readonly target: Position | LuaEntity + /** Only used if `target` is a LuaEntity. */ + readonly target_offset?: Vector +} + +interface PathfinderWaypoint { + /** The position of the waypoint on its surface. */ + readonly position: Position + /** `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 +} + +interface CutsceneWaypoint { + /** Position to pan the camera to. */ + readonly position?: Position + /** 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 +} + +interface Decorative { + /** The name of the decorative prototype. */ + readonly name: string + readonly position: Position + readonly amount: uint8 +} + +interface DecorativeResult { + readonly position: TilePosition + readonly decorative: LuaDecorativePrototype + readonly amount: uint +} + +/** + * **Note**: Either `icon`, `text`, or both must be provided. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#ChartTagSpec View documentation} + */ +interface ChartTagSpec { + readonly position: Position + 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. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#GameViewSettings View documentation} + */ +interface GameViewSettings { + /** + * Show the controller GUI elements. This includes the toolbar, the selected tool slot, the armour slot, and the gun + * and ammunition slots. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#GameViewSettings#GameViewSettings.show_controller_gui View documentation} + */ + show_controller_gui: boolean + /** + * Show the chart in the upper right-hand corner of the screen. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#GameViewSettings#GameViewSettings.show_minimap View documentation} + */ + show_minimap: boolean + /** + * Show research progress and name in the upper right-hand corner of the screen. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#GameViewSettings#GameViewSettings.show_research_info View documentation} + */ + show_research_info: boolean + /** + * Show overlay icons on entities. Also known as "alt-mode". + * + * {@link https://lua-api.factorio.com/next/Concepts.html#GameViewSettings#GameViewSettings.show_entity_info View documentation} + */ + show_entity_info: boolean + /** + * Show the flashing alert icons next to the player's toolbar. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#GameViewSettings#GameViewSettings.show_alert_gui View 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. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#GameViewSettings#GameViewSettings.update_entity_selection View documentation} + */ + update_entity_selection: boolean + /** + * When `true` (`false` is default), the rails will always show the rail block visualisation. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#GameViewSettings#GameViewSettings.show_rail_block_visualisation View documentation} + */ + show_rail_block_visualisation: boolean + /** + * Shows or hides the buttons row. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#GameViewSettings#GameViewSettings.show_side_menu View documentation} + */ + show_side_menu: boolean + /** + * Shows or hides the view options when map is opened. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#GameViewSettings#GameViewSettings.show_map_view_options View documentation} + */ + show_map_view_options: boolean + /** + * Shows or hides quickbar of shortcuts. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#GameViewSettings#GameViewSettings.show_quickbar View documentation} + */ + show_quickbar: boolean + /** + * Shows or hides the shortcut bar. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#GameViewSettings#GameViewSettings.show_shortcut_bar View documentation} + */ + show_shortcut_bar: boolean +} + +/** + * What is shown in the map view. If a field is not given, that setting will not be changed. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#MapViewSettings View documentation} + */ +interface MapViewSettings { + readonly "show-logistic-network"?: boolean + readonly "show-electric-network"?: boolean + readonly "show-turret-range"?: boolean + readonly "show-pollution"?: boolean + readonly "show-train-station-names"?: boolean + readonly "show-player-names"?: boolean + readonly "show-networkless-logistic-members"?: boolean + readonly "show-non-standard-map-info"?: boolean +} + +/** + * These values are for the time frame of one second (60 ticks). + * + * {@link https://lua-api.factorio.com/next/Concepts.html#PollutionMapSettings View documentation} + */ +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. Defaults to `1`. */ + readonly aeging: 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) is visualized as this value instead. + * Defaults to `50`. + */ + readonly min_to_show_per_chunk: double + /** Defaults to `60`. */ + readonly min_pollution_to_damage_trees: double + /** Defaults to `150`. */ + readonly pollution_with_max_forest_damage: double + /** Defaults to `50`. */ + readonly pollution_per_tree_damage: double + /** Defaults to `10`. */ + readonly pollution_restored_per_tree_damage: double + /** Defaults to `20`. */ + readonly max_pollution_to_restore_trees: double + /** Defaults to `1`. */ + readonly enemy_attack_pollution_consumption_modifier: double +} + +/** + * These values represent a percentual increase in evolution. This means a value of `0.1` would increase evolution by 10%. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#EnemyEvolutionMapSettings View documentation} + */ +interface EnemyEvolutionMapSettings { + /** Whether enemy evolution is enabled at all. */ + readonly enabled: boolean + /** The amount evolution naturally progresses by every second. Defaults to `0.000004`. */ + readonly time_factor: double + /** The amount evolution progresses for every destroyed spawner. Defaults to `0.002`. */ + readonly destroy_factor: double + /** The amount evolution progresses for every unit of pollution. Defaults to `0.0000009`. */ + readonly pollution_factor: double +} + +/** + * Candidate chunks are given scores to determine which one of them should be expanded into. This score takes into + * account various settings noted below. The iteration is over a square region centered around the chunk for which the + * calculation is done, and includes the central chunk as well. Distances are calculated as + * {@link https://en.wikipedia.org/wiki/Taxicab_geometry Manhattan distance}. + * + * The pseudocode algorithm to determine a chunk's score is as follows: + * + * ```lua + * player = 0 + * for neighbour in all chunks within enemy_building_influence_radius from chunk: + * player += number of player buildings on neighbour + * * building_coefficient + * * neighbouring_chunk_coefficient^distance(chunk, neighbour) + * + * base = 0 + * for neighbour in all chunk within friendly_base_influence_radius from chunk: + * base += num of enemy bases on neighbour + * * other_base_coefficient + * * neighbouring_base_chunk_coefficient^distance(chunk, neighbour) + * + * score(chunk) = 1 / (1 + player + base) + * ``` + * + * {@link https://lua-api.factorio.com/next/Concepts.html#EnemyExpansionMapSettings View documentation} + */ +interface EnemyExpansionMapSettings { + /** Whether enemy expansion is enabled at all. */ + readonly enabled: boolean + /** + * Distance in chunks from the furthest base around to prevent expansions from reaching too far into the player's + * territory. Defaults to `7`. + */ + readonly max_expansion_distance: uint + /** Defaults to `2`. */ + readonly friendly_base_influence_radius: uint + /** Defaults to `2`. */ + readonly enemy_building_influence_radius: uint + /** Defaults to `0.1`. */ + readonly building_coefficient: double + /** Defaults to `2.0`. */ + readonly other_base_coefficient: double + /** Defaults to `0.5`. */ + readonly neighbouring_chunk_coefficient: double + /** Defaults to `0.4`. */ + readonly neighbouring_base_chunk_coefficient: double + /** + * A chunk has to have at most this high of a percentage of unbuildable tiles for it to be considered a candidate to + * avoid chunks full of water as candidates. Defaults to `0.9`, or 90%. + */ + readonly max_colliding_tiles_coefficient: double + /** + * The minimum size of a biter group that goes to build a new base. This is multiplied by the evolution factor. + * Defaults to `5`. + */ + readonly settler_group_min_size: uint + /** + * The maximum size of a biter group that goes to build a new base. This is multiplied by the evolution factor. + * Defaults to `20`. + */ + readonly settler_group_max_size: uint + /** + * The minimum time between expansions in ticks. The actual cooldown is adjusted to the current evolution levels. + * Defaults to `4*3,600=14,400` ticks. + */ + readonly min_expansion_cooldown: uint + /** + * The maximum time between expansions in ticks. The actual cooldown is adjusted to the current evolution levels. + * Defaults to `60*3,600=216,000` ticks. + */ + readonly max_expansion_cooldown: uint +} + +interface UnitGroupMapSettings { + /** + * The minimum amount of time in ticks a group will spend gathering before setting off. The actual time is a random + * time between the minimum and maximum times. Defaults to `3,600` ticks. + */ + readonly min_group_gathering_time: uint + /** + * The maximum amount of time in ticks a group will spend gathering before setting off. The actual time is a random + * time between the minimum and maximum times. Defaults to `10*3,600=36,000` ticks. + */ + readonly max_group_gathering_time: uint + /** + * After gathering has finished, the group is allowed to wait this long in ticks for delayed members. New members + * are not accepted anymore however. Defaults to `2*3,600=7,200` ticks. + */ + readonly max_wait_time_for_late_members: uint + /** The minimum group radius in tiles. The actual radius is adjusted based on the number of members. Defaults to `5.0`. */ + readonly min_group_radius: double + /** The maximum group radius in tiles. The actual radius is adjusted based on the number of members. Defaults to `30.0`. */ + readonly max_group_radius: double + /** + * The maximum speed a percentage of its regular speed that a group member can speed up to when catching up with the + * group. Defaults to `1.4`, or 140%. + */ + readonly max_member_speedup_when_behind: double + /** + * The minimum speed a percentage of its regular speed that a group member can slow down to when ahead of the group. + * Defaults to `0.6`, or 60%. + */ + readonly max_member_slowdown_when_ahead: double + /** + * The minimum speed as a percentage of its maximum speed that a group will slow down to so members that fell behind + * can catch up. Defaults to `0.3`, or 30%. + */ + readonly max_group_slowdown_factor: double + /** + * When a member of a group falls back more than this factor times the group radius, the group will slow down to its + * `max_group_slowdown_factor` speed to let them catch up. Defaults to `3`. + */ + readonly max_group_member_fallback_factor: double + /** + * When a member of a group falls back more than this factor times the group radius, it will be dropped from the + * group. Defaults to `10`. + */ + readonly member_disown_distance: double + readonly tick_tolerance_when_member_arrives: uint + /** The maximum number of automatically created unit groups gathering for attack at any time. Defaults to `30`. */ + readonly max_gathering_unit_groups: uint + /** + * The maximum number of members for an attack unit group. This only affects automatically created unit groups, + * manual groups created through the API are unaffected. Defaults to `200`. + */ + readonly max_unit_group_size: uint +} + +interface SteeringMapSetting { + /** Does not include the radius of the unit. */ + readonly radius: double + readonly separation_factor: double + readonly separation_force: double + /** Used to make steering look better for aesthetic purposes. */ + readonly force_unit_fuzzy_goto_behavior: boolean +} + +interface SteeringMapSettings { + readonly default: SteeringMapSetting + readonly moving: SteeringMapSetting +} + +interface PathFinderMapSettings { + /** Determines whether forwards (`>1`), backwards (`<-1`), or symmetrical (`1`) search is preferred. Defaults to `5`. */ + readonly fwd2bwd_ratio: uint + /** + * When looking at which node to check next, their heuristic value is multiplied by this ratio. The higher it is, + * the more the search is directed straight at the goal. Defaults to `2`. + */ + readonly goal_pressure_ratio: double + /** The maximum number of nodes that are expanded per tick. Defaults to `1,000`. */ + readonly max_steps_worked_per_tick: double + /** The maximum amount of work each pathfinding job is allowed to do per tick. Defaults to `8,000`. */ + readonly max_work_done_per_tick: uint + /** Whether to cache paths at all. Defaults to `true`. */ + readonly use_path_cache: boolean + /** Number of elements in the short cache. Defaults to `5`. */ + readonly short_cache_size: uint + /** Number of elements in the long cache. Defaults to `25`. */ + readonly long_cache_size: uint + /** The minimal distance to the goal in tiles required to be searched in the short path cache. Defaults to `10`. */ + readonly short_cache_min_cacheable_distance: double + /** The minimal number of nodes required to be searched in the short path cache. Defaults to `50`. */ + readonly short_cache_min_algo_steps_to_cache: uint + /** The minimal distance to the goal in tiles required to be searched in the long path cache. Defaults to `30`. */ + readonly long_cache_min_cacheable_distance: double + /** + * When looking for a connection to a cached path, search at most for this number of steps times the original + * estimate. Defaults to `100`. + */ + readonly cache_max_connect_to_cache_steps_multiplier: uint + /** + * When looking for a path from cache, make sure it doesn't start too far from the requested start in relative + * terms. Defaults to `0.2`. + */ + readonly cache_accept_path_start_distance_ratio: double + /** + * When looking for a path from cache, make sure it doesn't end too far from the requested end in relative terms. + * This is typically more lenient than the start ratio since the end target could be moving. Defaults to `0.15`. + */ + readonly cache_accept_path_end_distance_ratio: double + /** Same principle as `cache_accept_path_start_distance_ratio`, but used for negative cache queries. Defaults to `0.3`. */ + readonly negative_cache_accept_path_start_distance_ratio: double + /** Same principle as `cache_accept_path_end_distance_ratio`, but used for negative cache queries. Defaults to `0.3`. */ + readonly negative_cache_accept_path_end_distance_ratio: double + /** When assigning a rating to the best path, this multiplier times start distances is considered. Defaults to `10`. */ + readonly cache_path_start_distance_rating_multiplier: double + /** + * When assigning a rating to the best path, this multiplier times end distances is considered. This value is + * typically higher than the start multiplier as this results in better end path quality. Defaults to `20`. + */ + readonly cache_path_end_distance_rating_multiplier: double + /** + * A penalty that is applied for another unit that is on the way to the goal. This is mainly relevant for situations + * where a group of units has arrived at the target they are supposed to attack, making units further back circle + * around to reach the target. Defaults to `30`. + */ + readonly stale_enemy_with_same_destination_collision_penalty: double + /** The distance in tiles after which other moving units are not considered for pathfinding. Defaults to `5`. */ + readonly ignore_moving_enemy_collision_distance: double + /** + * A penalty that is applied for another unit that is too close and either not moving or has a different goal. + * Defaults to `30`. + */ + readonly enemy_with_different_destination_collision_penalty: double + /** The general collision penalty with other units. Defaults to `10`. */ + readonly general_entity_collision_penalty: double + /** The collision penalty for positions that require the destruction of an entity to get to. Defaults to `3`. */ + readonly general_entity_subsequent_collision_penalty: double + /** + * The collision penalty for collisions in the extended bounding box but outside the entity's actual bounding box. + * Defaults to `3`. + */ + readonly extended_collision_penalty: double + /** The amount of path finder requests accepted per tick regardless of the requested path's length. Defaults to `10`. */ + readonly max_clients_to_accept_any_new_request: uint + /** + * When the `max_clients_to_accept_any_new_request` amount is exhausted, only path finder requests with a short + * estimate will be accepted until this amount (per tick) is reached. Defaults to `100`. + */ + readonly max_clients_to_accept_short_new_request: uint + /** The maximum direct distance in tiles before a request is no longer considered short. Defaults to `100`. */ + readonly direct_distance_to_consider_short_request: uint + /** The maximum amount of nodes a short request will traverse before being rescheduled as a long request. Defaults to `1000`. */ + readonly short_request_max_steps: uint + /** + * The amount of steps that are allocated to short requests each tick, as a percentage of all available steps. + * Defaults to `0.5`, or 50%. + */ + readonly short_request_ratio: double + /** The minimum amount of steps that are guaranteed to be performed for every request. Defaults to `2000`. */ + readonly min_steps_to_check_path_find_termination: uint + /** + * If the actual amount of steps is higher than the initial estimate by this factor, pathfinding is terminated. + * Defaults to `2000.0`. + */ + readonly start_to_goal_cost_multiplier_to_terminate_path_find: double + /** + * The thresholds of waiting clients after each of which the per-tick work limit will be increased by the + * corresponding value in `overload_multipliers`. This is to avoid clients having to wait too long. Must have the + * same number of elements as `overload_multipliers`. Defaults to `{0, 100, 500}`. + */ + readonly overload_levels: uint[] + /** + * The multipliers to the amount of per-tick work applied after the corresponding thresholds in `overload_levels` + * have been reached. Must have the same number of elements as `overload_multipliers`. Defaults to `{2, 3, 4}`. + */ + readonly overload_multipliers: double[] + /** The delay in ticks between decrementing the score of all paths in the negative cache by one. Defaults to `20`. */ + readonly negative_path_cache_delay_interval: uint +} + +/** + * Various game-related settings. Updating any of the attributes will immediately take effect in the game engine. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#MapSettings View documentation} + * + * @example + * Increase the number of short paths the pathfinder can cache. + * + * ```lua + * game.map_settings.path_finder.short_cache_size = 15 + * ``` + */ +interface MapSettings { + readonly pollution: PollutionMapSettings + readonly enemy_evolution: EnemyEvolutionMapSettings + readonly enemy_expansion: EnemyExpansionMapSettings + readonly unit_group: UnitGroupMapSettings + readonly steering: SteeringMapSettings + readonly path_finder: PathFinderMapSettings + /** + * If a behavior fails this many times, the enemy (or enemy group) is destroyed. This solves biters getting stuck + * within their own base. + */ + readonly max_failed_behavior_count: uint +} + +/** + * Technology and recipe difficulty settings. Updating any of the attributes will immediately take effect in the game engine. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#DifficultySettings View documentation} + */ +interface DifficultySettings { + readonly recipe_difficulty: defines.difficulty_settings.recipe_difficulty + readonly technology_difficulty: defines.difficulty_settings.technology_difficulty + /** A value in range [0.001, 1000]. */ + readonly technology_price_multiplier: double + /** + * Either `"after-victory"`, `"always"` or `"never"`. Changing this to `"always"` or `"after-victory"` does not + * automatically unlock the research queue. See {@link LuaForce} for that. + */ + readonly research_queue_setting: "after-victory" | "always" | "never" +} + +/** + * The data that can be extracted from a map exchange string, as a plain table. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#MapExchangeStringData View documentation} + */ +interface MapExchangeStringData { + /** + * All the regular map settings plus an additional table called `difficulty_settings` that contains the + * {@link DifficultySettings}. + */ + readonly map_settings: MapSettings + readonly map_gen_settings: MapGenSettings +} + +interface BlueprintItemIcon { + /** Name of the item prototype whose icon should be used. */ + readonly name: string + /** Index of the icon in the blueprint icons slots. Has to be an integer in the range [1, 4]. */ + readonly index: uint +} + +interface BlueprintSignalIcon { + /** The icon to use. It can be any item icon as well as any virtual signal icon. */ + readonly signal: SignalID + /** Index of the icon in the blueprint icons slots. Has to be an integer in the range [1, 4]. */ + readonly index: uint +} + +/** + * Information about a single connection between two connection points. + * + * {@link https://wiki.factorio.com/Blueprint_string_format#Connection_data_object View Documentation} + */ +interface BlueprintConnectionData { + /** ID of the entity this connection is connected with. */ + entity_id: uint + /** The circuit connector id of the entity this connection is connected to, see {@link defines.circuit_connector_id} */ + circuit_id?: defines.circuit_connector_id +} + +/** + * The actual point where a wire is connected to. Contains information about where it is connected to. + * + * {@link https://wiki.factorio.com/Blueprint_string_format#Connection_point_object View Documentation} + */ +interface BlueprintConnectionPoint { + /** + * An array of {@link BlueprintConnectionData Connection data object} containing all the connections from this point + * created by red wire. + */ + red?: BlueprintConnectionData[] + /** + * An array of {@link BlueprintConnectionData Connection data object} containing all the connections from this point + * created by green wire. + */ + green?: BlueprintConnectionData[] +} + +/** + * Object containing information about the connections to other entities formed by red or green wires. + * + * {@link https://wiki.factorio.com/Blueprint_string_format#Connection_object View Documentation} + */ +interface BlueprintCircuitConnection { + /** First connection point. The default for everything that doesn't have multiple connection points. */ + "1"?: BlueprintConnectionPoint + /** Second connection point. For example, the "output" part of an arithmetic combinator. */ + "2"?: BlueprintConnectionPoint +} + +/** + * The representation of an entity inside of a blueprint. It has at least these fields, but can contain additional ones + * depending on the kind of entity. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#BlueprintEntity View documentation} + */ +interface BlueprintEntity { + /** The entity's unique identifier in the blueprint. */ + readonly entity_number: uint + /** The prototype name of the entity. */ + readonly name: string + /** The position of the entity. */ + readonly position: Position + /** + * The direction the entity is facing. Only present for entities that can face in different directions and when the + * entity is not facing north. + */ + readonly direction?: defines.direction + /** The entity tags of the entity, if there are any. Only relevant for entity ghosts. */ + readonly tags?: Tags + /** + * The items that the entity will request when revived, if there are any. It's a mapping of prototype names to + * amounts. Only relevant for entity ghosts. + */ + readonly items?: Record + /** + * The circuit network connections of the entity, if there are any. Only relevant for entities that support circuit + * connections. + */ + readonly connections?: BlueprintCircuitConnection + /** + * The control behavior of the entity, if it has one. The format of the control behavior depends on the entity's + * type. Only relevant for entities that support control behaviors. + */ + readonly control_behavior?: BlueprintControlBehavior + /** The schedule of the entity, if it has one. Only relevant for locomotives. */ + readonly schedule?: TrainScheduleRecord[] +} + +interface Tile { + /** The position of the tile. */ + readonly position: Position + /** The prototype name of the tile. */ + readonly name: string +} + +interface Fluid { + /** Fluid prototype name of the fluid. */ + readonly name: string + /** Amount of the fluid. */ + readonly amount: double + /** + * The temperature. When reading from {@link LuaFluidBox}, this field will always be present. It is not necessary to + * specify it when writing, however. When not specified, the fluid will be set to the fluid's default temperature as + * specified in the fluid's prototype. + */ + readonly temperature?: double +} + +interface BaseIngredient { + /** `"item"` or `"fluid"`. */ + readonly type: "item" | "fluid" + /** Prototype name of the required item or fluid. */ + readonly name: string + /** Amount of the item or fluid. */ + readonly amount: double + /** How much of this ingredient is a catalyst. */ + readonly catalyst_amount?: uint | double +} + +interface FluidIngredient extends BaseIngredient { + readonly type: "fluid" + /** The minimum fluid temperature required. */ + readonly minimum_temperature?: double + /** The maximum fluid temperature allowed. */ + readonly maximum_temperature?: double +} + +interface OtherIngredient extends BaseIngredient { + readonly type: "item" +} + +/** + * Other attributes may be specified depending on `type`: + * + * {@link https://lua-api.factorio.com/next/Concepts.html#Ingredient View documentation} + */ +type Ingredient = FluidIngredient | OtherIngredient + +interface BaseProduct { + /** `"item"` or `"fluid"`. */ + readonly type: "item" | "fluid" + /** Prototype name of the result. */ + readonly name: string + /** Amount of the item or fluid to give. If not specified, `amount_min`, `amount_max` and `probability` must all be specified. */ + readonly amount?: double + /** Minimal amount of the item or fluid to give. Has no effect when `amount` is specified. */ + readonly amount_min?: uint | double + /** Maximum amount of the item or fluid to give. Has no effect when `amount` is specified. */ + readonly amount_max?: uint | double + /** A value in range [0, 1]. Item or fluid is only given with this probability; otherwise no product is produced. */ + readonly probability?: double + /** How much of this product is a catalyst. */ + readonly catalyst_amount?: uint | double +} + +interface FluidProduct extends BaseProduct { + readonly type: "fluid" + /** The fluid temperature of this product. */ + readonly temperature?: double +} + +interface OtherProduct extends BaseProduct { + readonly type: "item" +} + +/** + * Other attributes may be specified depending on `type`: + * + * {@link https://lua-api.factorio.com/next/Concepts.html#Product View documentation} + * + * @example + * Products of the "steel-chest" recipe (an array of Product): + * + * ```lua + * {{type="item", name="steel-chest", amount=1}} + * ``` + * + * @example + * Products of the "advanced-oil-processing" recipe: + * + * ```lua + * {{type="fluid", name="heavy-oil", amount=1}, + * {type="fluid", name="light-oil", amount=4.5}, + * {type="fluid", name="petroleum-gas", amount=5.5}} + * ``` + * + * @example + * What a custom recipe would look like that had a probability of 0.5 to return a minimum amount of 1 and a maximum amount of 5: + * + * ```lua + * {{type=0, name="custom-item", probability=0.5, amount_min=1, amount_max=5}} + * ``` + * + * @see {@link LuaRecipe.products} + */ +type Product = FluidProduct | OtherProduct + +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 +} + +interface BaseTechnologyModifier { + /** + * Modifier type. Specifies which of the other fields will be available. Possible values are: + * `"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-additional-mining-categories"`, + * `"character-logistic-requests"`. + */ + readonly type: + | "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-additional-mining-categories" + | "character-logistic-requests" +} + +interface GunSpeedTechnologyModifier extends BaseTechnologyModifier { + readonly type: "gun-speed" + /** Prototype name of the ammunition category that is affected */ + readonly ammo_category: string + /** Modification value. This will be added to the current gun speed modifier upon researching. */ + readonly modifier: double +} + +interface AmmoDamageTechnologyModifier extends BaseTechnologyModifier { + readonly type: "ammo-damage" + /** Prototype name of the ammunition category that is affected */ + readonly ammo_category: string + /** Modification value. This will be added to the current ammo damage modifier upon researching. */ + readonly modifier: double +} + +interface GiveItemTechnologyModifier extends BaseTechnologyModifier { + readonly type: "give-item" + /** Item prototype name to give. */ + readonly item: string + /** Number of items to give. Defaults to `1`. */ + readonly count?: uint +} + +interface TurretAttackTechnologyModifier extends BaseTechnologyModifier { + readonly type: "turret-attack" + /** Turret prototype name this modifier will affect. */ + readonly turret_id: string + /** Modification value. This will be added to the current turret damage modifier upon researching. */ + readonly modifier: double +} + +interface UnlockRecipeTechnologyModifier extends BaseTechnologyModifier { + readonly type: "unlock-recipe" + /** Recipe prototype name to unlock. */ + readonly recipe: string +} + +interface NothingTechnologyModifier extends BaseTechnologyModifier { + readonly type: "nothing" + /** Description of this nothing modifier. */ + readonly effect_description: LocalisedString +} + +interface OtherTechnologyModifier extends BaseTechnologyModifier { + readonly type: + | "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" + | "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" + | "character-additional-mining-categories" + | "character-logistic-requests" + /** Modification value. This value will be added to the variable it modifies. */ + readonly modifier: double +} + +/** + * The effect that is applied when a technology is researched. It is a table that contains at least the field `type`. + * + * Other attributes may be specified depending on `type`: + * + * {@link https://lua-api.factorio.com/next/Concepts.html#TechnologyModifier View documentation} + */ +type TechnologyModifier = + | GunSpeedTechnologyModifier + | AmmoDamageTechnologyModifier + | GiveItemTechnologyModifier + | TurretAttackTechnologyModifier + | UnlockRecipeTechnologyModifier + | NothingTechnologyModifier + | OtherTechnologyModifier + +/** + * A single offer on a market entity. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#Offer View documentation} + */ +interface Offer { + /** List of prices. */ + readonly price: Ingredient[] + /** The action that will take place when a player accepts the offer. Usually a `"give-item"` modifier. */ + readonly offer: TechnologyModifier +} + +/** + * Specifies how probability and richness are calculated when placing something on the map. Can be specified either + * using `probability_expression` and `richness_expression` or by using all the other fields. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#AutoplaceSpecification View documentation} + */ +interface AutoplaceSpecification { + readonly probability_expression: NoiseExpression + readonly richness_expression: NoiseExpression + readonly coverage: double + readonly sharpness: double + readonly max_probability: double + readonly placement_density: uint + readonly richness_base: double + readonly richness_multiplier: double + readonly richness_multiplier_distance_bonus: double + readonly starting_area_size: uint + readonly order: string + readonly default_enabled: boolean + readonly peaks?: AutoplaceSpecificationPeak[] + /** Control prototype name. */ + readonly control?: string + readonly tile_restriction?: AutoplaceSpecificationRestriction[] + readonly force: string + readonly random_probability_penalty: double +} + +/** + * A fragment of a functional program used to generate coherent noise, probably for purposes related to terrain + * generation. These can only be meaningfully written/modified during the data load phase. More detailed information is + * found on the {@link https://wiki.factorio.com/Types/NoiseExpression wiki}. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#NoiseExpression View documentation} + */ +interface NoiseExpression { + /** Names the type of the expression and determines what other fields are required. */ + readonly type: string +} + +interface AutoplaceSpecificationPeak { + readonly influence: double + readonly max_influence: double + readonly min_influence: double + readonly richness_influence: double + readonly noisePersistence: double + /** Prototype name of the noise layer. */ + readonly noise_layer?: string + readonly noise_octaves_difference: double + readonly water_optimal: double + readonly water_range: double + readonly water_max_range: double + readonly water_top_property_limit: double + readonly elevation_optimal: double + readonly elevation_range: double + readonly elevation_max_range: double + readonly elevation_top_property_limit: double + readonly temperature_optimal: double + readonly temperature_range: double + readonly temperature_max_range: double + readonly temperature_top_property_limit: double + readonly starting_area_weight_optimal: double + readonly starting_area_weight_range: double + readonly starting_area_weight_max_range: double + readonly starting_area_weight_top_property_limit: double + readonly tier_from_start_optimal: double + readonly tier_from_start_range: double + readonly tier_from_start_max_range: double + readonly tier_from_start_top_property_limit: double + readonly distance_optimal: double + readonly distance_range: double + readonly distance_max_range: double + readonly distance_top_property_limit: double + readonly aux_optimal: double + readonly aux_range: double + readonly aux_max_range: double + readonly aux_top_property_limit: double +} + +interface AutoplaceSpecificationRestriction { + /** Tile prototype name */ + readonly first?: string + /** Second prototype name */ + readonly second?: string +} + +interface Resistance { + /** Absolute damage decrease */ + readonly decrease: float + /** Percentual damage decrease */ + readonly percent: float +} + +/** + * A floating point number specifying an amount. + * + * For backwards compatibility, MapGenSizes can also be specified as one of the following strings, which will be + * converted to a number (when queried, a number will always be returned): + * + * - `"none"` - equivalent to `0` + * - `"very-low"`, `"very-small"`, `"very-poor"` - equivalent to `1/2` + * - `"low"`, `"small"`, `"poor"` - equivalent to `1/sqrt(2)` + * - `"normal"`, `"medium"`, `"regular"` - equivalent to `1` + * - `"high"`, `"big"`, `"good"` - equivalent to `sqrt(2)` + * - `"very-high"`, `"very-big"`, `"very-good"` - equivalent to `2` + * + * **Note**: The map generation algorithm officially supports the range of values the in-game map generation screen + * shows (specifically `0` and values from `1/6` to `6`). Values outside this range are not guaranteed to work as expected. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#MapGenSize View documentation} + */ +type MapGenSize = + | number + | "none" + | "very-low" + | "very-small" + | "very-poor" + | "low" + | "small" + | "poor" + | "normal" + | "medium" + | "regular" + | "high" + | "big" + | "good" + | "very-high" + | "very-big" + | "very-good" + +interface AutoplaceSetting { + readonly frequency: MapGenSize + readonly size: MapGenSize + readonly richness: MapGenSize +} + +interface AutoplaceSettings { + /** Whether missing autoplace names for this type should be default enabled. */ + readonly treat_missing_as_default: boolean + readonly settings: Record +} + +interface AutoplaceControl { + /** + * For things that are placed as spots such as ores and enemy bases, frequency is generally proportional to number + * of spots placed per unit area. For continuous features such as forests, frequency is how compressed the + * probability function is over distance, i.e. the inverse of 'scale' (similar to terrain_segmentation). When the + * {@link LuaAutoplaceControlPrototype} is of the category `"terrain"`, then scale is shown in the map generator GUI + * instead of frequency. + */ + readonly frequency: MapGenSize + /** + * For things that are placed as spots, size is proportional to the area of each spot. For continuous features, size + * affects how much of the map is covered with the thing, and is called 'coverage' in the GUI. + */ + readonly size: MapGenSize + /** + * Has different effects for different things, but generally affects the 'health' or density of a thing that is + * placed without affecting where it is placed. For trees, richness affects tree health. For ores, richness + * multiplies the amount of ore at any given tile in a patch. Metadata about autoplace controls (such as whether or + * not 'richness' does anything for them) can be found in the {@link LuaAutoplaceControlPrototype} by looking up + * `game.autoplace_control_prototypes[(control prototype name)]`, e.g. + * `game.autoplace_control_prototypes["enemy-base"].richness` is false, because enemy base autoplacement doesn't use + * richness. + */ + readonly richness: MapGenSize +} + +interface CliffPlacementSettings { + /** Name of the cliff prototype. */ + readonly name: string + /** + * Elevation at which the first row of cliffs is placed. The default is `10`, and this cannot be set from the map + * generation GUI. + */ + readonly cliff_elevation_0: float + /** + * Elevation difference between successive rows of cliffs. This is inversely proportional to 'frequency' in the map + * generation GUI. Specifically, when set from the GUI the value is `40 / frequency`. + */ + readonly cliff_elevation_interval: float + /** + * Corresponds to 'continuity' in the GUI. This value is not used directly, but is used by the 'cliffiness' noise + * expression, which in combination with elevation and the two cliff elevation properties drives cliff placement + * (cliffs are placed when elevation crosses the elevation contours defined by `cliff_elevation_0` and + * `cliff_elevation_interval` when 'cliffiness' is greater than `0.5`). The default 'cliffiness' expression + * interprets this value such that larger values result in longer unbroken walls of cliffs, and smaller values + * (between `0` and `1`) result in larger gaps in cliff walls. + */ + readonly richness: MapGenSize +} + +/** + * The 'map type' dropdown in the map generation GUI is actually a selector for elevation generator. The base game sets + * `property_expression_names.elevation` to `"0_16-elevation"` to reproduce terrain from 0.16 or to `"0_17-island"` for + * the island preset. If generators are available for other properties, the 'map type' dropdown in the GUI will be + * renamed to 'elevation' and shown along with selectors for the other selectable properties. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#MapGenSettings View documentation} + * + * @example + * Assuming a NamedNoiseExpression with the name "my-alternate-grass1-probability" is defined + * + * ```lua + * local surface = game.player.surface + * local mgs = surface.map_gen_settings + * mgs.property_expression_names["tile:grass1:probability"] = "my-alternate-grass1-probability" + * surface.map_gen_settings = mgs + * ``` would override the probability of grass1 being placed at any given point on the current surface. + * + * @example + * To make there be no deep water on (newly generated chunks) a surface: + * + * ```lua + * local surface = game.player.surface + * local mgs = surface.map_gen_settings + * mgs.property_expression_names["tile:deepwater:probability"] = -1000 + * surface.map_gen_settings = mgs + * ``` This does not require a NamedNoiseExpression to be defined, since literal numbers (and strings naming literal numbers, e.g. `"123"`) are understood to stand for constant value expressions. + */ +interface MapGenSettings { + /** + * The inverse of 'water scale' in the map generator GUI. Lower `terrain_segmentation` increases the scale of + * elevation features (lakes, continents, etc). This behavior can be overridden with alternate elevation generators + * (see `property_expression_names`, below). + */ + readonly terrain_segmentation: MapGenSize + /** + * The equivalent to 'water coverage' in the map generator GUI. Specifically, when this value is non-zero, + * `water_level = 10 * log2` (the value of this field), and the elevation generator subtracts water level from + * elevation before adding starting lakes. If water is set to 'none', elevation is clamped to a small positive value + * before adding starting lakes. This behavior can be overridden with alternate elevation generators (see + * `property_expression_names`, below). + */ + readonly water: MapGenSize + /** Indexed by autoplace control prototype name. */ + readonly autoplace_controls: Record + /** Whether undefined `autoplace_controls` should fall back to the default controls or not. Defaults to `true`. */ + readonly default_enable_all_autoplace_controls: boolean + /** + * Each setting in this dictionary maps the string type to the settings for that type. Valid types are `"entity"`, + * `"tile"` and `"decorative"`. + */ + readonly autoplace_settings: Record + /** Map generation settings for entities of the type "cliff". */ + readonly cliff_settings: CliffPlacementSettings + /** The random seed used to generated this map. */ + readonly seed: uint + /** + * Width in tiles. If `0`, the map has 'infinite' width, with the actual limitation being one million tiles in each + * direction from the center. + */ + readonly width: uint + /** + * Height in tiles. If `0`, the map has 'infinite' height, with the actual limitation being one million tiles in + * each direction from the center. + */ + readonly height: uint + /** Size of the starting area. */ + readonly starting_area: MapGenSize + /** Positions of the starting areas. */ + readonly starting_points: Position[] + /** Whether peaceful mode is enabled for this map. */ + readonly peaceful_mode: boolean + /** + * Overrides for tile property value generators. Values either name a NamedNoiseExpression or can be literal + * numbers, stored as strings (e.g. `"5"`). All other controls can be overridden by a property expression names. + * Notable properties: + * + * - `moisture` - a value between 0 and 1 that determines whether a tile becomes sandy (low moisture) or grassy (high moisture). + * - `aux` - a value between 0 and 1 that determines whether low-moisture tiles become sand or red desert. + * - `temperature` - provides a value (vaguely representing degrees Celsius, varying between -20 and 50) that is used + * (together with moisture and aux) as part of tree and decorative placement. + * - `elevation` - tiles values less than zero become water. Cliffs are placed along certain contours according to + * {@link CliffPlacementSettings}. + * - `cliffiness` - determines whether (when >0.5) or not (when <0.5) a cliff will be placed at an otherwise suitable + * (according to {@link CliffPlacementSettings}) location. + * - `enemy-base-intensity` - a number that is referenced by both `enemy-base-frequency` and `enemy-base-radius`. i.e. + * if this is overridden, enemy base frequency and size will both be affected and do something reasonable. By + * default, this expression returns a value proportional to distance from any starting point, clamped at about 7. + * - `enemy-base-frequency` - a number representing average number of enemy bases per tile for a region, by default in + * terms of `enemy-base-intensity`. + * - `enemy-base-radius` - a number representing the radius of an enemy base, if one were to be placed on the given + * tile, by default proportional to a constant plus `enemy-base-intensity`. Climate controls ('Moisture' and + * 'Terrain type' at the bottom of the Terrain tab in the map generator GUI) don't have their own dedicated + * structures in MapGenSettings. Instead, their values are stored as property expression overrides with long names: + * - `control-setting:moisture:frequency:multiplier` - frequency (inverse of scale) multiplier for moisture noise. Default is 1. + * - `control-setting:moisture:bias` - global bias for moisture (which normally varies between 0 and 1). Default is 0. + * - `control-setting:aux:frequency:multiplier` - frequency (inverse of scale) multiplier for aux (called 'terrain + * type' in the GUI) noise. Default is 1. + * - `control-setting:aux:bias` - global bias for aux/terrain type (which normally varies between 0 and 1). Default is + * 0. All other MapGenSettings feed into named noise expressions, and therefore placement can be overridden by + * including the name of a property in this dictionary. The probability and richness functions for placing + * specific tiles, entities, and decoratives can be overridden by including an entry named + * `{tile|entity|decorative}:(prototype name):{probability|richness}`. + */ + readonly property_expression_names: Record +} + +interface SignalID { + /** `"item"`, `"fluid"`, or `"virtual"`. */ + readonly type: "item" | "fluid" | "virtual" + /** Name of the item, fluid or virtual signal. */ + readonly name?: string +} + +/** + * An actual signal transmitted by the network. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#Signal View documentation} + */ +interface Signal { + /** ID of the signal. */ + readonly signal: SignalID + /** Value of the signal. */ + readonly count: int +} + +interface UpgradeFilter { + /** `"item"`, or `"entity"`. */ + readonly type: "item" | "entity" + /** Name of the item, or entity. */ + readonly name?: string +} + +/** + * A single filter used by an infinity-filters instance. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#InfinityInventoryFilter View documentation} + */ +interface InfinityInventoryFilter { + /** Name of the item. */ + readonly name: string + /** The count of the filter. */ + readonly count?: uint + /** `"at-least"`, `"at-most"`, or `"exactly"`. Defaults to `"at-least"`. */ + readonly mode?: "at-least" | "at-most" | "exactly" + /** The index of this filter in the filters list. */ + readonly index: uint +} + +/** + * A single filter used by an infinity-pipe type entity. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#InfinityPipeFilter View documentation} + */ +interface InfinityPipeFilter { + /** Name of the fluid. */ + readonly name: string + /** The fill percentage the pipe (e.g. 0.5 for 50%). Can't be negative. */ + readonly percentage?: double + /** The temperature of the fluid. Defaults to the default/minimum temperature of the fluid. */ + readonly temperature?: double + /** `"at-least"`, `"at-most"`, `"exactly"`, `"add"`, or `"remove"`. Defaults to `"at-least"`. */ + readonly mode?: "at-least" | "at-most" | "exactly" | "add" | "remove" +} + +interface FluidBoxFilter { + /** Fluid prototype name of the filtered fluid. */ + readonly name: string + /** The minimum temperature allowed into the fluidbox. */ + readonly minimum_temperature: double + /** The maximum temperature allowed into the fluidbox. */ + readonly maximum_temperature: double +} + +interface FluidBoxFilterSpec { + /** Fluid prototype name of the filtered fluid. */ + readonly name: string + /** The minimum temperature allowed into the fluidbox. */ + readonly minimum_temperature?: double + /** The maximum temperature allowed into the fluidbox. */ + readonly maximum_temperature?: double + /** Force the filter to be set, regardless of current fluid content. */ + readonly force?: boolean +} + +/** + * The settings used by a heat-interface type entity. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#HeatSetting View documentation} + */ +interface HeatSetting { + /** The target temperature. Defaults to the minimum temperature of the heat buffer. */ + readonly temperature?: double + /** `"at-least"`, `"at-most"`, `"exactly"`, `"add"`, or `"remove"`. Defaults to `"at-least"`. */ + readonly mode?: "at-least" | "at-most" | "exactly" | "add" | "remove" +} + +interface HeatConnection { + readonly position: Vector + readonly direction: defines.direction +} + +/** + * A definition of a fluidbox connection point. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#FluidBoxConnection View documentation} + */ +interface FluidBoxConnection { + /** The connection type: "input", "output", or "input-output". */ + readonly type: "input" | "output" | "input-output" + /** The 4 cardinal direction connection points for this pipe. This vector is a table with `x` and `y` keys instead of an array. */ + readonly positions: PositionTable[] + /** The maximum tile distance this underground connection can connect at if this is an underground pipe. */ + readonly max_underground_distance?: uint +} + +interface ArithmeticCombinatorParameters { + /** First signal to use in an operation. If not specified, the second argument will be the value of `first_constant`. */ + readonly first_signal?: SignalID + /** Second signal to use in an operation. If not specified, the second argument will be the value of `second_constant`. */ + readonly second_signal?: SignalID + /** Constant to use as the first argument of the operation. Has no effect when `first_signal` is set. Defaults to `0`. */ + readonly first_constant?: int + /** Constant to use as the second argument of the operation. Has no effect when `second_signal` is set. Defaults to `0`. */ + readonly second_constant?: int + /** + * Must be one of `"*"`, `"/"`, `"+"`, `"-"`, `"%"`, `"^"`, `"<<"`, `">>"`, `"AND"`, `"OR"`, `"XOR"`. When not + * specified, defaults to `"*"`. + */ + readonly operation?: "*" | "/" | "+" | "-" | "%" | "^" | "<<" | ">>" | "AND" | "OR" | "XOR" + /** Specifies the signal to output. */ + readonly output_signal?: SignalID +} + +interface ConstantCombinatorParameters { + /** Signal to emit. */ + readonly signal: SignalID + /** Value of the signal to emit. */ + readonly count: int + /** Index of the constant combinator's slot to set this signal to. */ + readonly index: uint +} + +/** + * A {@link string} that specifies how the inputs should be compared. + * + * **Note**: 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. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#ComparatorString View documentation} + */ +type ComparatorString /** "equal to" */ = + | "=" /** "greater than" */ + | ">" /** "lesser than" */ + | "<" /** "greater than or equal to" */ + | "\u2265" /** "greater than or equal to" */ + | ">=" /** "lesser than or equal to" */ + | "\u2264" /** "lesser than or equal to" */ + | "<=" /** "not equal to" */ + | "\u2260" /** "not equal to" */ + | "!=" + +interface DeciderCombinatorParameters { + /** Defaults to blank. */ + readonly first_signal?: SignalID + /** + * Second signal to use in an operation, if any. If this is not specified, the second argument to a decider + * combinator's operation is assumed to be the value of `constant`. + */ + readonly second_signal?: SignalID + /** Constant to use as the second argument of operation. Defaults to `0`. */ + readonly constant?: uint + /** Specifies how the inputs should be compared. If not specified, defaults to `"<"`. */ + readonly comparator?: ComparatorString + /** Defaults to blank. */ + readonly output_signal?: SignalID + /** Defaults to `true`. When `false`, will output a value of `1` for the given `output_signal`. */ + readonly copy_count_from_input?: boolean +} + +interface InserterCircuitConditions { + readonly circuit?: CircuitCondition + readonly logistics?: CircuitCondition +} + +interface CircuitCondition { + /** Specifies how the inputs should be compared. If not specified, defaults to `"<"`. */ + readonly comparator?: ComparatorString + /** Defaults to blank */ + readonly first_signal?: SignalID + /** What to compare `first_signal` to. If not specified, `first_signal` will be compared to `constant`. */ + readonly second_signal?: SignalID + /** + * Constant to compare `first_signal` to. Has no effect when `second_signal` is set. When neither `second_signal` + * nor `constant` are specified, the effect is as though `constant` were specified with the value `0`. + */ + readonly constant?: int +} + +interface CircuitConditionDefinition { + readonly condition: CircuitCondition + /** Whether the condition is currently fulfilled */ + readonly fulfilled?: boolean +} + +interface CircuitConnectionDefinition { + /** Wire color, either {@link defines.wire_type.red} or {@link defines.wire_type.green}. */ + readonly wire: defines.wire_type + readonly target_entity: LuaEntity + readonly source_circuit_id: defines.circuit_connector_id + readonly target_circuit_id: defines.circuit_connector_id +} + +interface WireConnectionDefinition { + /** Wire color, either {@link defines.wire_type.red} or {@link defines.wire_type.green}. */ + readonly wire: defines.wire_type + /** The entity to (dis)connect the source entity with. */ + readonly target_entity: LuaEntity + /** Mandatory if the source entity has more than one circuit connection using circuit wire. */ + readonly source_circuit_id?: defines.circuit_connector_id + /** Mandatory if the target entity has more than one circuit connection using circuit wire. */ + readonly target_circuit_id?: defines.circuit_connector_id + /** Mandatory if the source entity has more than one wire connection using copper wire. */ + readonly source_wire_id?: defines.circuit_connector_id + /** Mandatory if the target entity has more than one wire connection using copper wire. */ + readonly target_wire_id?: defines.circuit_connector_id +} + +interface InventoryFilter { + /** Position of the corresponding filter slot. */ + readonly index: uint + /** Item prototype name of the item to filter. */ + readonly name: string +} + +interface PlaceAsTileResult { + /** The tile prototype. */ + readonly result: LuaTilePrototype + readonly condition_size: uint + readonly condition: CollisionMask +} + +interface BaseCommand { + /** Type of command. The remaining fields depend on the value of this field. */ + readonly type: defines.command +} + +interface AttackCommand extends BaseCommand { + readonly type: defines.command.attack + readonly target: LuaEntity + /** Defaults to `defines.distraction.by_enemy`. */ + readonly distraction?: defines.distraction +} + +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?: Position + /** 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 +} + +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[] +} + +interface GroupCommand extends BaseCommand { + readonly type: defines.command.group + /** The group whose command to follow. */ + readonly group: LuaUnitGroup + /** 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 +} + +interface AttackAreaCommand extends BaseCommand { + readonly type: defines.command.attack_area + /** Center of the attack area. */ + readonly destination: Position + /** Radius of the attack area. */ + readonly radius: double + /** Defaults to `defines.distraction.by_enemy`. */ + readonly distraction?: defines.distraction +} + +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 uint, which means wander forever. */ + readonly ticks_to_wait?: uint +} + +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 uint, which means stop forever. */ + readonly ticks_to_wait?: uint +} + +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 +} + +interface BuildBaseCommand extends BaseCommand { + readonly type: defines.command.build_base + /** Where to build the base. */ + readonly destination: Position + /** 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 https://lua-api.factorio.com/next/Concepts.html#Command View documentation} + */ +type Command = + | AttackCommand + | GoToLocationCommand + | CompoundCommand + | GroupCommand + | AttackAreaCommand + | WanderCommand + | StopCommand + | FleeCommand + | BuildBaseCommand + +interface PathfinderFlags { + /** Allows pathing through friendly entities. Defaults to `false`. */ + readonly allow_destroy_friendly_entities?: boolean + /** Allows the pathfinder to path through entities of the same force. Defaults to `false`. */ + readonly allow_paths_through_own_entities?: boolean + /** + * Enables path caching. This can be more efficient, but might fail to respond to changes in the environment. + * Defaults to `true`. + */ + readonly cache?: boolean + /** Makes the pathfinder try to path in straight lines. Defaults to `false`. */ + readonly prefer_straight_paths?: boolean + /** + * Sets lower priority on the path request, meaning it might take longer to find a path at the expense of speeding + * up others. Defaults to `false`. + */ + readonly low_priority?: boolean + /** + * Makes the pathfinder not break in the middle of processing this pathfind, no matter how much work is needed. + * Defaults to `false`. + */ + readonly no_break?: boolean +} + +interface UnitSpawnDefinition { + /** Prototype name of the unit that would be spawned. */ + readonly unit: string + /** The points at which to spawn the unit. */ + readonly spawn_points: SpawnPointDefinition[] +} + +interface SpawnPointDefinition { + /** Evolution factor for which this weight applies. */ + readonly evolution_factor: double + /** Probability of spawning this unit at this evolution factor. */ + readonly weight: double +} + +interface ItemStackDefinition { + /** Prototype name of the item the stack holds. */ + readonly name: string + /** Number of items the stack holds. If not specified, defaults to `1`. */ + readonly count?: uint + /** Health of the items in the stack. Defaults to `1.0`. */ + readonly health?: float + /** Durability of the tool items in the stack. */ + readonly durability?: double + /** Amount of ammo in the ammo items in the stack. */ + readonly ammo?: double + /** Tags of the items with tags in the stack. */ + readonly tags?: string[] +} + +/** + * - String: The name of the item, which represents a full stack of that item. + * - ItemStackDefinition: The detailed definition of an item stack. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#SimpleItemStack View documentation} + * + * @example + * Both of these lines specify an item stack of one iron plate: + * + * ```lua + * {name="iron-plate"} + * ``` + * + * ```lua + * {name="iron-plate", count=1} + * ``` + * + * @example + * This is a stack of 47 copper plates: + * + * ```lua + * {name="copper-plate", count=47} + * ``` + * + * @example + * These are both full stacks of iron plates (for iron-plate, a full stack is 100 plates): + * + * ```lua + * "iron-plate" + * ``` + * + * ```lua + * {name="iron-plate", count=100} + * ``` + */ +type SimpleItemStack = string | ItemStackDefinition + +/** + * - String: The fluid name. + * - LuaFluidPrototype: The fluid prototype. + * - Fluid: The fluid. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#FluidIdentification View documentation} + */ +type FluidIdentification = string | LuaFluidPrototype | Fluid + +/** + * - String: The force name. + * - LuaForce: A reference to {@link LuaForce} may be passed directly. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#ForceIdentification View documentation} + */ +type ForceIdentification = string | LuaForce + +/** + * - String: The technology name. + * - LuaTechnology: A reference to {@link LuaTechnology} may be passed directly. + * - LuaTechnologyPrototype: A reference to {@link LuaTechnologyPrototype} may be passed directly. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#TechnologyIdentification View documentation} + */ +type TechnologyIdentification = string | LuaTechnology | LuaTechnologyPrototype + +/** + * - Uint: It will be the index of the surface. `nauvis` has index `1`, the first surface-created surface will have index + * `2` and so on. + * - String: It will be the surface name. E.g. `"nauvis"`. + * - LuaSurface: A reference to {@link LuaSurface} may be passed directly. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#SurfaceIdentification View documentation} + */ +type SurfaceIdentification = uint | string | LuaSurface + +/** + * - Uint: The player index. + * - String: The player name. + * - LuaPlayer: A reference to {@link LuaPlayer} may be passed directly. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#PlayerIdentification View documentation} + */ +type PlayerIdentification = uint | string | LuaPlayer + +type ItemStackIdentification = SimpleItemStack | LuaItemStack + +/** + * - LuaEntity: The entity. + * - LuaEntityPrototype: The entity prototype. + * - String: The prototype name. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#EntityPrototypeIdentification View documentation} + */ +type EntityPrototypeIdentification = LuaEntity | LuaEntityPrototype | string + +/** + * - LuaItemStack: The item. + * - LuaItemPrototype: The item prototype. + * - String: The prototype name. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#ItemPrototypeIdentification View documentation} + */ +type ItemPrototypeIdentification = LuaItemStack | LuaItemPrototype | string + +interface WaitCondition { + /** + * One of `"time"`, `"inactivity"`, `"full"`, `"empty"`, `"item_count"`, `"circuit"`, `"robots_inactive"`, + * `"fluid_count"`, `"passenger_present"`, `"passenger_not_present"`. + */ + readonly type: + | "time" + | "inactivity" + | "full" + | "empty" + | "item_count" + | "circuit" + | "robots_inactive" + | "fluid_count" + | "passenger_present" + | "passenger_not_present" + /** + * Either `"and"`, or `"or"`. Tells how this condition is to be compared with the preceding conditions in the + * corresponding `wait_conditions` array. + */ + readonly compare_type: "and" | "or" + /** Number of ticks to wait or of inactivity. Only present when `type` is `"time"` or `"inactivity"`. */ + readonly ticks?: uint + /** Only present when `type` is `"item_count"`, `"circuit"` or `"fluid_count"`. */ + readonly condition?: CircuitCondition +} + +interface TrainScheduleRecord { + /** Name of the station. */ + readonly station?: string + /** Rail to path to. Ignored if `station` is present. */ + readonly rail?: LuaEntity + readonly wait_conditions?: WaitCondition[] + /** Only present when the station is temporary, the value is then always `true`. */ + readonly temporary?: boolean +} + +interface TrainSchedule { + /** Index of the currently active record */ + readonly current: uint + readonly records: TrainScheduleRecord[] +} + +interface BaseGuiArrowSpecification { + /** + * This determines which of the following fields will be required. Must be one of `"nowhere"` (will remove the arrow + * entirely), `"goal"` (will point to the current goal), `"entity_info"`, `"active_window"`, `"entity"`, + * `"position"`, `"crafting_queue"` or `"item_stack"` (will point to a given item stack in an inventory). Depending + * on this value, other fields may have to be specified. + */ + readonly type: + | "nowhere" + | "goal" + | "entity_info" + | "active_window" + | "entity" + | "position" + | "crafting_queue" + | "item_stack" +} + +interface EntityGuiArrowSpecification extends BaseGuiArrowSpecification { + readonly type: "entity" + readonly entity: LuaEntity +} + +interface PositionGuiArrowSpecification extends BaseGuiArrowSpecification { + readonly type: "position" + readonly position: Position +} + +interface CraftingQueueGuiArrowSpecification extends BaseGuiArrowSpecification { + readonly type: "crafting_queue" + /** Index in the crafting queue to point to. */ + readonly crafting_queueindex: uint +} + +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 + /** Must be either `"player"`, `"target"`, `"player-quickbar"` or `"player-equipment-bar"`. */ + readonly source: "player" | "target" | "player-quickbar" | "player-equipment-bar" +} + +interface OtherGuiArrowSpecification extends BaseGuiArrowSpecification { + readonly type: "nowhere" | "goal" | "entity_info" | "active_window" +} + +/** + * Used for specifying where a GUI arrow should point to. + * + * Other attributes may be specified depending on `type`: + * + * {@link https://lua-api.factorio.com/next/Concepts.html#GuiArrowSpecification View documentation} + */ +type GuiArrowSpecification = + | EntityGuiArrowSpecification + | PositionGuiArrowSpecification + | CraftingQueueGuiArrowSpecification + | ItemStackGuiArrowSpecification + | OtherGuiArrowSpecification + +interface AmmoType { + readonly action?: TriggerItem[] + /** + * One of `"entity"` (fires at an entity), `"position"` (fires directly at a position), or `"direction"` (fires in a + * direction). + */ + readonly target_type: "entity" | "position" | "direction" + /** + * When `true`, the gun will be able to shoot even when the target is out of range. Only applies when `target_type` + * is `position`. The gun will fire at the maximum range in the direction of the target position. Defaults to `false`. + */ + readonly clamp_position?: boolean + /** Ammo category of this ammo. */ + readonly category: string + /** Energy consumption of a single shot, if applicable. Defaults to `0`. */ + readonly energy_consumption?: double +} + +interface BeamTarget { + /** The target entity. */ + readonly entity?: LuaEntity + /** The target position. */ + readonly position?: Position +} + +interface RidingState { + readonly acceleration: defines.riding.acceleration + readonly direction: defines.riding.direction +} + +type SpriteType = + | "item" + | "entity" + | "technology" + | "recipe" + | "item-group" + | "fluid" + | "tile" + | "virtual-signal" + | "achievement" + | "equipment" + | "file" + | "utility" + +/** + * It is specified by {@link string}. It can be either the name of a + * {@link https://wiki.factorio.com/Prototype/Sprite sprite prototype} defined in the data stage or a path in form "type/name". + * + * The supported types are: + * + * - `"item"` - for example "item/iron-plate" is the icon sprite of iron plate + * - `"entity"` - for example "entity/small-biter" is the icon sprite of the small biter + * - `"technology"` + * - `"recipe"` + * - `"item-group"` + * - `"fluid"` + * - `"tile"` + * - `"virtual-signal"` + * - `"achievement"` + * - `"equipment"` + * - `"file"` - path to an image file located inside the current scenario. This file is not preloaded so it will be + * slower; for frequently used sprites, it is better to define sprite prototype and use it instead. + * - `"utility"` - sprite defined in the utility-sprites object, these are the pictures used by the game internally for the UI. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#SpritePath View documentation} + */ +type SpritePath = string | `${SpriteType}/${string}` + +/** + * A sound defined by a {@link string}. It can be either the name of a + * {@link https://wiki.factorio.com/Prototype/Sound sound prototype} defined in the data stage or a path in the form + * `"type/name"`. The latter option can be sorted into three categories. + * + * The utility and ambient types each contain general use sound prototypes defined by the game itself. + * + * - `"utility"` - Uses the {@link https://wiki.factorio.com/Prototype/UtilitySounds UtilitySounds} prototype. Example: + * `"utility/wire_connect_pole"` + * - `"ambient"` - Uses {@link https://wiki.factorio.com/Prototype/AmbientSound AmbientSound} prototypes. Example: + * `"ambient/resource-deficiency"` + * + * The following types can be combined with any tile name as long as its prototype defines the + * + * corresponding sound. + * + * - `"tile-walking"` - Uses {@link https://wiki.factorio.com/Prototype/Tile#walking_sound Tile::walking_sound}. Example: + * `"tile-walking/concrete"` + * - `"tile-mined"` - Uses {@link https://wiki.factorio.com/Prototype/Tile#mined_sound Tile::mined_sound} + * - `"tile-build-small"` - Uses {@link https://wiki.factorio.com/Prototype/Tile#build_sound Tile::build_sound}. Example: + * `"tile-build-small/concrete"` + * - `"tile-build-medium"` - Uses {@link https://wiki.factorio.com/Prototype/Tile#build_sound Tile::build_sound} + * - `"tile-build-large"` - Uses {@link https://wiki.factorio.com/Prototype/Tile#build_sound Tile::build_sound} + * + * The following types can be combined with any entity name as long as its prototype defines the + * + * corresponding sound. + * + * - `"entity-build"` - Uses {@link https://wiki.factorio.com/Prototype/Entity#build_sound Entity::build_sound}. Example: + * `"entity-build/wooden-chest"` + * - `"entity-mined"` - Uses {@link https://wiki.factorio.com/Prototype/Entity#mined_sound Entity::mined_sound} + * - `"entity-mining"` - Uses {@link https://wiki.factorio.com/Prototype/Entity#mining_sound Entity::mining_sound} + * - `"entity-vehicle_impact"` - Uses + * {@link https://wiki.factorio.com/Prototype/Entity#vehicle_impact_sound Entity::vehicle_impact_sound} + * - `"entity-rotated"` - Uses {@link https://wiki.factorio.com/Prototype/Entity#rotated_sound Entity::rotated_sound} + * - `"entity-open"` - Uses {@link https://wiki.factorio.com/Prototype/Entity#open_sound Entity::open_sound} + * - `"entity-close"` - Uses {@link https://wiki.factorio.com/Prototype/Entity#close_sound Entity::close_sound} + * + * {@link https://lua-api.factorio.com/next/Concepts.html#SoundPath View documentation} + */ +type SoundPath = string | `${SoundType}/${string}` + +interface ModuleEffectValue { + /** The percentual increase of the attribute. A value of `0.6` means a 60% increase. */ + readonly bonus: float +} + +/** + * {@link https://lua-api.factorio.com/next/Concepts.html#ModuleEffects View documentation} + * + * @example + * These are the effects of the vanilla Productivity Module 3 (up to floating point imprecisions): + * + * ```lua + * {consumption={bonus=0.6}, + * speed={bonus=-0.15}, + * productivity={bonus=0.06}, + * pollution={bonus=0.075}} + * ``` + */ +interface ModuleEffects { + readonly consumption?: ModuleEffectValue + readonly speed?: ModuleEffectValue + readonly productivity?: ModuleEffectValue + readonly pollution?: ModuleEffectValue +} + +/** + * This is a set of flags given as a dictionary[{@link string} → {@link boolean}]. When a flag is set, it is present in + * the dictionary with the value `true`. Unset flags aren't present in the dictionary at all. So, the boolean value is + * meaningless and exists just for easy table lookup if a flag is set. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#EntityPrototypeFlags View documentation} + */ +interface EntityPrototypeFlags { + readonly "not-rotatable"?: boolean + readonly "placeable-neutral"?: boolean + readonly "placeable-player"?: boolean + readonly "placeable-enemy"?: boolean + readonly "placeable-off-grid"?: boolean + readonly "player-creation"?: boolean + readonly "building-direction-8-way"?: boolean + readonly "filter-directions"?: boolean + readonly "fast-replaceable-no-build-while-moving"?: boolean + readonly "breaths-air"?: boolean + readonly "not-repairable"?: boolean + readonly "not-on-map"?: boolean + readonly "not-deconstructable"?: boolean + readonly "not-blueprintable"?: boolean + readonly hidden?: boolean + readonly "hide-alt-info"?: boolean + readonly "fast-replaceable-no-cross-type-while-moving"?: boolean + readonly "no-gap-fill-while-building"?: boolean + readonly "not-flammable"?: boolean + readonly "no-automated-item-removal"?: boolean + readonly "no-automated-item-insertion"?: boolean + readonly "no-copy-paste"?: boolean + readonly "not-selectable-in-game"?: boolean + readonly "not-upgradable"?: boolean +} + +/** + * This is a set of flags given as dictionary[{@link string} → {@link boolean}]. When a flag is set, it is present in the + * dictionary with the value `true`. Unset flags aren't present in the dictionary at all. So, the boolean value is + * meaningless and exists just for easy table lookup if a flag is set. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#ItemPrototypeFlags View documentation} + */ +interface ItemPrototypeFlags { + readonly "draw-logistic-overlay"?: boolean + readonly hidden?: boolean + readonly "always-show"?: boolean + readonly "hide-from-bonus-gui"?: boolean + readonly "hide-from-fuel-tooltip"?: boolean + readonly "not-stackable"?: boolean + readonly "can-extend-inventory"?: boolean + readonly "primary-place-result"?: boolean + readonly "mod-openable"?: boolean + readonly "only-in-cursor"?: boolean +} + +/** + * A {@link string} specifying a collision mask layer. + * + * Possible values for the string are: + * + * - `"ground-tile"` + * - `"water-tile"` + * - `"resource-layer"` + * - `"doodad-layer"` + * - `"floor-layer"` + * - `"item-layer"` + * - `"ghost-layer"` + * - `"object-layer"` + * - `"player-layer"` + * - `"train-layer"` + * - `"rail-layer"` + * - `"transport-belt-layer"` + * - `"not-setup"` + * + * Additionally the values `"layer-13"` through `"layer-55"`. These layers are currently unused by the game but may + * change. If a mod is going to use one of the unused layers it's recommended to start at the higher layers because the + * base game will take from the lower ones. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#CollisionMaskLayer View documentation} + */ +type CollisionMaskLayer = + | "ground-tile" + | "water-tile" + | "resource-layer" + | "doodad-layer" + | "floor-layer" + | "item-layer" + | "ghost-layer" + | "object-layer" + | "player-layer" + | "train-layer" + | "rail-layer" + | "transport-belt-layer" + | "not-setup" + | `layer-${number}` + +/** + * This is a set of masks given as a dictionary[{@link CollisionMaskLayer} → {@link boolean}]. Only set masks are present + * in the dictionary and they have the value `true`. Unset flags aren't present at all. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#CollisionMask View documentation} + */ +type CollisionMask = { + readonly [P in CollisionMaskLayer]?: true +} + +/** + * A {@link CollisionMask} but also includes any flags this mask has. + * + * Flags such as: + * + * - `"not-colliding-with-itself"` + * - `"consider-tile-transitions"` + * - `"colliding-with-tiles-only"` + * + * {@link https://lua-api.factorio.com/next/Concepts.html#CollisionMaskWithFlags View documentation} + */ +type CollisionMaskWithFlags = { + readonly [P in + | CollisionMaskLayer + | "not-colliding-with-itself" + | "consider-tile-transitions" + | "colliding-with-tiles-only"]?: true +} + +/** + * This is a set of trigger target masks given as a dictionary[{@link string} → {@link boolean}]. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#TriggerTargetMask View documentation} + */ +type TriggerTargetMask = { + readonly [P in string]?: true +} + +interface TriggerEffectItem { + /** + * One of`"damage"`, `"create-entity"`, `"create-explosion"`, `"create-fire"`, `"create-smoke"`, + * `"create-trivial-smoke"`, `"create-particle"`, `"create-sticker"`, `"nested-result"`, `"play-sound"`, + * `"push-back"`, `"destroy-cliffs"`, `"show-explosion-on-chart"`, `"insert-item"`, `"script"`. + */ + readonly type: + | "damage" + | "create-entity" + | "create-explosion" + | "create-fire" + | "create-smoke" + | "create-trivial-smoke" + | "create-particle" + | "create-sticker" + | "nested-result" + | "play-sound" + | "push-back" + | "destroy-cliffs" + | "show-explosion-on-chart" + | "insert-item" + | "script" + readonly repeat_count: uint + readonly affects_target: boolean + readonly show_in_tooltip: boolean +} + +interface TriggerDelivery { + /** One of `"instant"`, `"projectile"`, `"flame-thrower"`, `"beam"`, `"stream"`, `"artillery"`. */ + readonly type: "instant" | "projectile" | "flame-thrower" | "beam" | "stream" | "artillery" + readonly source_effects: TriggerEffectItem[] + readonly target_effects: TriggerEffectItem[] +} + +interface TriggerItem { + /** One of `"direct"`, `"area"`, `"line"`, `"cluster"`. */ + 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 +} + +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 + /** This vector is a table with `x` and `y` keys instead of an array. */ + readonly center: PositionTable + readonly creation_distance: double + readonly creation_distance_orientation: double + readonly use_source_position: boolean +} + +/** + * An array with the following members: + * + * - A {@link RealOrientation} + * - A {@link Vector} + * + * {@link https://lua-api.factorio.com/next/Concepts.html#CircularProjectileCreationSpecification View documentation} + */ +type CircularProjectileCreationSpecification = [RealOrientation, Vector] + +interface AttackParameterFluid { + /** Name of the {@link LuaFluidPrototype}. */ + readonly type: string + /** Multiplier applied to the damage of an attack. */ + readonly damage_modifier: double +} + +interface BaseAttackParameters { + /** The type of AttackParameter. One of `'projectile'`, `'stream'` or `'beam'`. */ + readonly type: "projectile" | "stream" | "beam" + /** Maximum range of attack. */ + readonly range: float + /** Minimum range of attack. Used with flamethrower turrets to prevent self-immolation. */ + readonly min_range: float + /** Defines how the range is determined. Either `'center-to-center'` or `'bounding-box-to-bounding-box'`. */ + readonly range_mode: "center-to-center" | "bounding-box-to-bounding-box" + /** When searching for the nearest enemy to attack, `fire_penalty` is added to the enemy's distance if they are on fire. */ + readonly fire_penalty: float + /** + * When searching for an enemy to attack, a higher `rotate_penalty` will discourage targeting enemies that would + * take longer to turn to face. + */ + readonly rotate_penalty: float + /** + * When searching for an enemy to attack, a higher `health_penalty` will discourage targeting enemies with high + * health. A negative penalty will do the opposite. + */ + readonly health_penalty: float + /** + * If less than `range`, the entity will choose a random distance between `range` and `min_attack_distance` and + * attack from that distance. Used for spitters. + */ + readonly min_attack_distance: float + /** The arc that the entity can attack in as a fraction of a circle. A value of `1` means the full 360 degrees. */ + readonly turn_range: float + /** Multiplier applied to the damage of an attack. */ + readonly damage_modifier: float + /** Multiplier applied to the ammo consumption of an attack. */ + readonly ammo_consumption_modifier: float + /** Minimum amount of ticks between shots. If this is less than `1`, multiple shots can be performed per tick. */ + readonly cooldown: float + /** Number of ticks it takes for the weapon to actually shoot after it has been ordered to do so. */ + readonly warmup: uint + readonly movement_slow_down_factor: double + readonly movement_slow_down_cooldown: float + readonly ammo_type?: AmmoType + /** List of the names of compatible {@link LuaAmmoCategoryPrototype LuaAmmoCategoryPrototypes}. */ + readonly ammo_categories?: string[] +} + +interface ProjectileAttackParameters extends BaseAttackParameters { + readonly type: "projectile" + readonly projectile_center: Vector + readonly projectile_creation_distance: float + readonly projectile_orientation_offset: float + readonly shell_particle?: CircularParticleCreationSpecification + readonly projectile_creation_parameters?: CircularProjectileCreationSpecification[] +} + +interface StreamAttackParameters extends BaseAttackParameters { + readonly type: "stream" + readonly gun_barrel_length: float + readonly gun_center_shift: Record + readonly fluid_consumption: float + readonly fluids?: AttackParameterFluid[] + readonly projectile_creation_parameters?: CircularProjectileCreationSpecification[] +} + +interface OtherAttackParameters extends BaseAttackParameters { + readonly type: "beam" +} + +/** + * Other attributes may be specified depending on `type`: + * + * {@link https://lua-api.factorio.com/next/Concepts.html#AttackParameters View documentation} + */ +type AttackParameters = ProjectileAttackParameters | StreamAttackParameters | OtherAttackParameters + +interface CapsuleAction { + /** One of `"throw"`, `"equipment-remote"`, `"use-on-self"`. */ + readonly type: "throw" | "equipment-remote" | "use-on-self" + /** Only present when `type` is `"throw"` or `"use-on-self"`. */ + readonly attack_parameters?: AttackParameters + /** Only present when `type` is `"equipment-remote"`. It is the equipment prototype name. */ + readonly equipment?: string +} + +/** + * This is a set of flags given as a dictionary[{@link string} → {@link boolean}]. Set flags are present in the dictionary + * with the value `true`; unset flags aren't present at all. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#SelectionModeFlags View documentation} + */ +interface SelectionModeFlags { + /** Entities that can be selected for blueprint. */ + readonly blueprint?: boolean + /** Entities that can be marked for deconstruction. */ + readonly deconstruct?: boolean + /** Entities that can be marked for deconstruction cancelling. */ + readonly "cancel-deconstruct"?: boolean + readonly items?: boolean + readonly trees?: boolean + /** Buildable entities. */ + readonly "buildable-type"?: boolean + /** Only select an area. */ + readonly nothing?: boolean + /** Entities that can be placed using an item. */ + readonly "items-to-place"?: boolean + readonly "any-entity"?: boolean + readonly "any-tile"?: boolean + /** Entities with the same force as the selector. */ + readonly "same-force"?: boolean + readonly "not-same-force"?: boolean + readonly friend?: boolean + readonly enemy?: boolean + readonly upgrade?: boolean + readonly "cancel-upgrade"?: boolean + readonly "entity-with-health"?: boolean + readonly "entity-with-force"?: boolean + readonly "entity-with-owner"?: boolean +} + +interface LogisticFilter { + /** The index this filter applies to. */ + readonly index: uint + /** The item name for this filter. */ + readonly name: string + /** The count for this filter. */ + readonly count: uint +} + +/** + * **Note**: Runtime settings can be changed through console commands and by the mod that owns the settings by writing a + * new table to the ModSetting. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#ModSetting View documentation} + */ +interface ModSetting { + /** The value of the mod setting. The type depends on the setting. */ + readonly value: uint | double | boolean | string +} + +/** + * Any basic type (string, number, boolean) or table. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#AnyBasic View documentation} + */ +type AnyBasic = string | number | boolean | table + +/** + * Any basic type (string, number, boolean), table, or LuaObject. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#Any View documentation} + */ +type Any = any + +interface ProgrammableSpeakerParameters { + readonly playback_volume: double + readonly playback_globally: boolean + readonly allow_polyphony: boolean +} + +interface ProgrammableSpeakerAlertParameters { + readonly show_alert: boolean + readonly show_on_map: boolean + readonly icon_signal_id: SignalID + readonly alert_message: string +} + +interface ProgrammableSpeakerCircuitParameters { + readonly signal_value_is_pitch: boolean + readonly instrument_id: uint + readonly note_id: uint +} + +interface ProgrammableSpeakerInstrument { + readonly name: string + readonly notes: string[] +} + +/** + * A {@link string} that specifies where a gui element should be. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#Alignment View documentation} + */ +type Alignment = + | "top-left" + | "middle-left" /** The same as `"middle-left"` */ + | "left" + | "bottom-left" + | "top-center" + | "middle-center" /** The same as `"middle-center"` */ + | "center" + | "bottom-center" + | "top-right" /** The same as `"middle-right"` */ + | "right" + | "bottom-right" + +/** + * Information about the event that has been raised. The table can also contain other fields depending on the type of + * event. See {@link https://lua-api.factorio.com/next/events.html the list of Factorio events} for more information on these. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#EventData View documentation} + */ +interface EventData { + /** The identifier of the event this handler was registered to. */ + readonly name: EventId + /** The tick during which the event happened. */ + readonly tick: uint + /** The name of the mod that raised the event if it was raised using {@link LuaBootstrap.raise_event LuaBootstrap::raise_event}. */ + readonly mod_name?: string +} + +interface NthTickEventData { + /** The tick during which the event happened. */ + readonly tick: uint + /** The nth tick this handler was registered to. */ + readonly nth_tick: uint +} + +interface ModChangeData { + /** Old version of the mod. May be `nil` if the mod wasn't previously present (i.e. it was just added). */ + readonly old_version: string | undefined + /** New version of the mod. May be `nil` if the mod is no longer present (i.e. it was just removed). */ + readonly new_version: string | undefined +} + +interface ConfigurationChangedData { + /** Old version of the map. Present only when loading map version other than the current version. */ + readonly old_version?: string + /** New version of the map. Present only when loading map version other than the current version. */ + readonly new_version?: string + /** Dictionary of mod changes. It is indexed by mod name. */ + readonly mod_changes: Record + /** `true` when mod startup settings have changed since the last time this save was loaded. */ + readonly mod_startup_settings_changed: boolean + /** `true` when mod prototype migrations have been applied since the last time this save was loaded. */ + readonly migration_applied: boolean +} + +interface CustomCommandData { + /** The name of the command. */ + readonly name: string + /** The tick the command was used in. */ + readonly tick: uint + /** The player who issued the command, or `nil` if it was issued from the server console. */ + readonly player_index?: uint + /** The parameter passed after the command, if there is one. */ + readonly parameter?: string +} + +interface SelectedPrototypeData { + /** E.g. `"entity"`. */ + readonly base_type: string + /** E.g. `"tree"`. */ + readonly derived_type: string + /** E.g. `"tree-05"`. */ + readonly name: string +} + +interface ScriptRenderTarget { + readonly entity?: LuaEntity + readonly entity_offset?: Vector + readonly position?: Position +} + +type MouseButtonFlag = + | "left" + | "right" + | "middle" + | "button-4" + | "button-5" + | "button-6" + | "button-7" + | "button-8" + | "button-9" + +type MouseButtonFlagsTable = { + readonly [P in MouseButtonFlag]?: true +} + +type MouseButtonFlagsArray = readonly (MouseButtonFlag | "left-and-right")[] + +/** + * This is a set of flags given as a dictionary[{@link string} → {@link boolean}]. When a flag is set, it is present in + * the dictionary with the value `true`. Unset flags aren't present in the dictionary at all. + * + * To write to this, use an array[{@link string}] of the mouse buttons that should be possible to use with on button. + * + * When setting flags, the flag `"left-and-right"` can also be set which will set `"left"` and `"right"` true. + * + * Possible flags when reading are: + * + * - `"left"` + * - `"right"` + * - `"middle"` + * - `"button-4"` + * - `"button-5"` + * - `"button-6"` + * - `"button-7"` + * - `"button-8"` + * - `"button-9"` + * + * {@link https://lua-api.factorio.com/next/Concepts.html#MouseButtonFlags View documentation} + */ +type MouseButtonFlags = MouseButtonFlagsTable | MouseButtonFlagsArray + +/** + * It is specified by {@link string}. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#CursorBoxRenderType View documentation} + */ +type CursorBoxRenderType /** Yellow box. */ = + | "entity" /** Red box. */ + | "not-allowed" /** Light blue box. */ + | "electricity" /** Light blue box. */ + | "pair" /** Green box. */ + | "copy" /** White box. */ + | "train-visualization" /** Light blue box. */ + | "logistics" /** Green box. */ + | "blueprint-snap-rectangle" + +/** + * It is specified by {@link string}. + * + * {@link https://lua-api.factorio.com/next/Concepts.html#ForceCondition View documentation} + */ +type ForceCondition /** All forces pass. */ = + | "all" /** Forces which will attack pass. */ + | "enemy" /** Forces which won't attack pass. */ + | "ally" /** Forces which are friends pass. */ + | "friend" /** Forces which are not friends pass. */ + | "not-friend" /** The same force pass. */ + | "same" /** The non-same forces pass. */ + | "not-same" + +/** + * A value between 0 and 255 inclusive represented by one of the following named {@link string} or string version of the + * value (for example `"27"` and `"decals"` are both valid). Higher values are rendered on top of lower values. + * + * - `"water-tile"`: 15 + * - `"ground-tile"`: 25 + * - `"tile-transition"`: 26 + * - `"decals"`: 27 + * - `"lower-radius-visualization"`: 29 + * - `"radius-visualization"`: 30 + * - `"transport-belt-integration"`: 65 + * - `"resource"`:66 + * - `"building-smoke"`:67 + * - `"decorative"`: 92 + * - `"ground-patch"`: 93 + * - `"ground-patch-higher"`: 94 + * - `"ground-patch-higher2"`: 95 + * - `"remnants"`: 112 + * - `"floor"`: 113 + * - `"transport-belt"`: 114 + * - `"transport-belt-endings"`: 115 + * - `"floor-mechanics-under-corpse"`: 120 + * - `"corpse"`: 121 + * - `"floor-mechanics"`: 122 + * - `"item"`: 123 + * - `"lower-object"`: 124 + * - `"transport-belt-circuit-connector"`: 126 + * - `"lower-object-above-shadow"`: 127 + * - `"object"`: 129 + * - `"higher-object-under"`: 131 + * - `"higher-object-above"`: 132 + * - `"item-in-inserter-hand"`: 134 + * - `"wires"`: 135 + * - `"wires-above"`: 136 + * - `"entity-info-icon"`: 138 + * - `"entity-info-icon-above"`: 139 + * - `"explosion"`: 142 + * - `"projectile"`: 143 + * - `"smoke"`: 144 + * - `"air-object"`: 145 + * - `"air-entity-info-icon"`: 147 + * - `"light-effect"`: 148 + * - `"selection-box"`: 187 + * - `"higher-selection-box"`: 188 + * - `"collision-selection-box"`: 189 + * - `"arrow"`: 190 + * - `"cursor"`: 210 + * + * {@link https://lua-api.factorio.com/next/Concepts.html#RenderLayer View documentation} + */ +type RenderLayer = + | number + | `${number}` + | "water-tile" + | "ground-tile" + | "tile-transition" + | "decals" + | "lower-radius-visualization" + | "radius-visualization" + | "transport-belt-integration" + | "resource" + | "building-smoke" + | "decorative" + | "ground-patch" + | "ground-patch-higher" + | "remnants" + | "floor" + | "transport-belt" + | "transport-belt-endings" + | "floor-mechanics-under-corpse" + | "corpse" + | "floor-mechanics" + | "item" + | "lower-object" + | "transport-belt-circuit-connector" + | "lower-object-above-shadow" + | "object" + | "higher-object-under" + | "higher-object-above" + | "item-in-inserter-hand" + | "wires" + | "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" + +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" + +interface ItemStackLocation { + readonly inventory: defines.inventory + readonly slot: uint +} + +interface VehicleAutomaticTargetingParameters { + readonly auto_target_without_gunner: boolean + readonly auto_target_with_gunner: boolean +} + +type SoundType = "game-effect" | "gui-effect" | "ambient" | "environment" | "walking" | "alert" | "wind" + +interface BaseItemPrototypeFilter { + /** + * The condition to filter on. One of `"tool"`, `"mergeable"`, `"item-with-inventory"`, `"selection-tool"`, + * `"item-with-label"`, `"has-rocket-launch-products"`, `"fuel"`, `"place-result"`, `"burnt-result"`, + * `"place-as-tile"`, `"placed-as-equipment-result"`, `"name"`, `"type"`, `"flag"`, `"subgroup"`, `"fuel-category"`, + * `"stack-size"`, `"default-request-amount"`, `"wire-count"`, `"fuel-value"`, `"fuel-acceleration-multiplier"`, + * `"fuel-top-speed-multiplier"`, `"fuel-emissions-multiplier"` + */ + readonly filter: + | "tool" + | "mergeable" + | "item-with-inventory" + | "selection-tool" + | "item-with-label" + | "has-rocket-launch-products" + | "fuel" + | "place-result" + | "burnt-result" + | "place-as-tile" + | "placed-as-equipment-result" + | "name" + | "type" + | "flag" + | "subgroup" + | "fuel-category" + | "stack-size" + | "default-request-amount" + | "wire-count" + | "fuel-value" + | "fuel-acceleration-multiplier" + | "fuel-top-speed-multiplier" + | "fuel-emissions-multiplier" + /** + * How to combine this with the previous filter. Must be `"or"` or `"and"`. Defaults to `"or"`. When evaluating the + * filters, `"and"` has higher precedence than `"or"`. + */ + readonly mode?: "or" | "and" + /** Inverts the condition. Default is `false`. */ + readonly invert?: boolean +} + +interface PlaceResultItemPrototypeFilter extends BaseItemPrototypeFilter { + readonly filter: "place-result" + /** Filters for the place result. */ + readonly elem_filters?: EntityPrototypeFilter[] +} + +interface BurntResultItemPrototypeFilter extends BaseItemPrototypeFilter { + readonly filter: "burnt-result" + /** Filters for the burnt result. */ + readonly elem_filters?: ItemPrototypeFilter[] +} + +interface PlaceAsTileItemPrototypeFilter extends BaseItemPrototypeFilter { + readonly filter: "place-as-tile" + /** Filters for the placed tile. */ + readonly elem_filters?: TilePrototypeFilter[] +} + +interface PlacedAsEquipmentResultItemPrototypeFilter extends BaseItemPrototypeFilter { + readonly filter: "placed-as-equipment-result" + /** Filters for the placed equipment. */ + readonly elem_filters?: EquipmentPrototypeFilter[] +} + +/** + * For use within nested filters such as the `has-product-item` filter of array[{@link RecipePrototypeFilter}]. To get a + * specific prototype by name, see {@link LuaGameScript.item_prototypes LuaGameScript::item_prototypes}. + */ +interface NameItemPrototypeFilter extends BaseItemPrototypeFilter { + readonly filter: "name" + /** The prototype name, or list of acceptable names. */ + readonly name: string | string[] +} + +/** + * Usage example: + * + * ```lua + * game.get_filtered_item_prototypes({{filter = "type", type = "armor"}}) + * ``` + */ +interface TypeItemPrototypeFilter extends BaseItemPrototypeFilter { + readonly filter: "type" + /** The prototype type */ + readonly type: string +} + +interface FlagItemPrototypeFilter extends BaseItemPrototypeFilter { + readonly filter: "flag" + /** One of the values in {@link ItemPrototypeFlags}. */ + readonly flag: string +} + +interface SubgroupItemPrototypeFilter extends BaseItemPrototypeFilter { + readonly filter: "subgroup" + /** A {@link LuaGroup} (subgroup) name */ + readonly subgroup: string +} + +interface FuelCategoryItemPrototypeFilter extends BaseItemPrototypeFilter { + readonly filter: "fuel-category" + /** A {@link LuaFuelCategoryPrototype} name */ + readonly "fuel-category": string +} + +/** + * Usage example: + * + * ```lua + * game.get_filtered_item_prototypes({{filter = "stack-size", comparison = ">", value = 20}, {filter = "stack-size", comparison = "<", value = 100, mode = "and"}}) + * ``` + */ +interface StackSizeItemPrototypeFilter extends BaseItemPrototypeFilter { + readonly filter: "stack-size" + readonly comparison: ComparatorString + /** The value to compare against. */ + readonly value: uint +} + +interface DefaultRequestAmountItemPrototypeFilter extends BaseItemPrototypeFilter { + readonly filter: "default-request-amount" + readonly comparison: ComparatorString + /** The value to compare against. */ + readonly value: uint +} + +interface WireCountItemPrototypeFilter extends BaseItemPrototypeFilter { + readonly filter: "wire-count" + readonly comparison: ComparatorString + /** The value to compare against. */ + readonly value: uint +} + +interface FuelValueItemPrototypeFilter extends BaseItemPrototypeFilter { + readonly filter: "fuel-value" + readonly comparison: ComparatorString + /** The value to compare against. */ + readonly value: double +} + +interface FuelAccelerationMultiplierItemPrototypeFilter extends BaseItemPrototypeFilter { + readonly filter: "fuel-acceleration-multiplier" + readonly comparison: ComparatorString + /** The value to compare against. */ + readonly value: double +} + +interface FuelTopSpeedMultiplierItemPrototypeFilter extends BaseItemPrototypeFilter { + readonly filter: "fuel-top-speed-multiplier" + readonly comparison: ComparatorString + /** The value to compare against. */ + readonly value: double +} + +interface FuelEmissionsMultiplierItemPrototypeFilter extends BaseItemPrototypeFilter { + readonly filter: "fuel-emissions-multiplier" + readonly comparison: ComparatorString + /** The value to compare against. */ + readonly value: double +} + +interface OtherItemPrototypeFilter extends BaseItemPrototypeFilter { + readonly filter: + | "tool" + | "mergeable" + | "item-with-inventory" + | "selection-tool" + | "item-with-label" + | "has-rocket-launch-products" + | "fuel" +} + +/** + * Other attributes may be specified depending on `filter`: + * + * {@link https://lua-api.factorio.com/next/Concepts.html#ItemPrototypeFilter View documentation} + */ +type ItemPrototypeFilter = + | PlaceResultItemPrototypeFilter + | BurntResultItemPrototypeFilter + | PlaceAsTileItemPrototypeFilter + | PlacedAsEquipmentResultItemPrototypeFilter + | NameItemPrototypeFilter + | TypeItemPrototypeFilter + | FlagItemPrototypeFilter + | SubgroupItemPrototypeFilter + | FuelCategoryItemPrototypeFilter + | StackSizeItemPrototypeFilter + | DefaultRequestAmountItemPrototypeFilter + | WireCountItemPrototypeFilter + | FuelValueItemPrototypeFilter + | FuelAccelerationMultiplierItemPrototypeFilter + | FuelTopSpeedMultiplierItemPrototypeFilter + | FuelEmissionsMultiplierItemPrototypeFilter + | OtherItemPrototypeFilter + +interface BaseModSettingPrototypeFilter { + /** The condition to filter on. One of `"type"`, `"mod"`, `"setting-type"` */ + readonly filter: "type" | "mod" | "setting-type" + /** + * How to combine this with the previous filter. Must be `"or"` or `"and"`. Defaults to `"or"`. When evaluating the + * filters, `"and"` has higher precedence than `"or"`. + */ + readonly mode?: "or" | "and" + /** Inverts the condition. Default is `false`. */ + readonly invert?: boolean +} + +interface TypeModSettingPrototypeFilter extends BaseModSettingPrototypeFilter { + readonly filter: "type" + /** The prototype type */ + readonly type: string +} + +interface ModModSettingPrototypeFilter extends BaseModSettingPrototypeFilter { + readonly filter: "mod" + /** The mod name */ + readonly mod: string +} + +interface SettingTypeModSettingPrototypeFilter extends BaseModSettingPrototypeFilter { + readonly filter: "setting-type" + /** The setting scope type (startup, runtime-global, or runtime-per-user) */ + readonly type: string +} + +/** + * Other attributes may be specified depending on `filter`: + * + * {@link https://lua-api.factorio.com/next/Concepts.html#ModSettingPrototypeFilter View documentation} + */ +type ModSettingPrototypeFilter = + | TypeModSettingPrototypeFilter + | ModModSettingPrototypeFilter + | SettingTypeModSettingPrototypeFilter + +interface BaseTechnologyPrototypeFilter { + /** + * The condition to filter on. One of `"enabled"`, `"hidden"`, `"upgrade"`, `"visible-when-disabled"`, + * `"has-effects"`, `"has-prerequisites"`, `"research-unit-ingredient"`, `"level"`, `"max-level"`, `"time"` + */ + readonly filter: + | "enabled" + | "hidden" + | "upgrade" + | "visible-when-disabled" + | "has-effects" + | "has-prerequisites" + | "research-unit-ingredient" + | "level" + | "max-level" + | "time" + /** + * How to combine this with the previous filter. Must be `"or"` or `"and"`. Defaults to `"or"`. When evaluating the + * filters, `"and"` has higher precedence than `"or"`. + */ + readonly mode?: "or" | "and" + /** Inverts the condition. Default is `false`. */ + readonly invert?: boolean +} + +interface ResearchUnitIngredientTechnologyPrototypeFilter extends BaseTechnologyPrototypeFilter { + readonly filter: "research-unit-ingredient" + /** The research ingredient to check. */ + readonly ingredient: string +} + +interface LevelTechnologyPrototypeFilter extends BaseTechnologyPrototypeFilter { + readonly filter: "level" + readonly comparison: ComparatorString + /** The value to compare against. */ + readonly value: uint +} + +interface MaxLevelTechnologyPrototypeFilter extends BaseTechnologyPrototypeFilter { + readonly filter: "max-level" + readonly comparison: ComparatorString + /** The value to compare against. */ + readonly value: uint +} + +interface TimeTechnologyPrototypeFilter extends BaseTechnologyPrototypeFilter { + readonly filter: "time" + readonly comparison: ComparatorString + /** The value to compare against. */ + readonly value: uint +} + +interface OtherTechnologyPrototypeFilter extends BaseTechnologyPrototypeFilter { + readonly filter: "enabled" | "hidden" | "upgrade" | "visible-when-disabled" | "has-effects" | "has-prerequisites" +} + +/** + * Other attributes may be specified depending on `filter`: + * + * {@link https://lua-api.factorio.com/next/Concepts.html#TechnologyPrototypeFilter View documentation} + */ +type TechnologyPrototypeFilter = + | ResearchUnitIngredientTechnologyPrototypeFilter + | LevelTechnologyPrototypeFilter + | MaxLevelTechnologyPrototypeFilter + | TimeTechnologyPrototypeFilter + | OtherTechnologyPrototypeFilter + +interface BaseDecorativePrototypeFilter { + /** The condition to filter on. One of `"decal"`, `"autoplace"`, `"collision-mask"` */ + readonly filter: "decal" | "autoplace" | "collision-mask" + /** + * How to combine this with the previous filter. Must be `"or"` or `"and"`. Defaults to `"or"`. When evaluating the + * filters, `"and"` has higher precedence than `"or"`. + */ + readonly mode?: "or" | "and" + /** Inverts the condition. Default is `false`. */ + readonly invert?: boolean +} + +interface CollisionMaskDecorativePrototypeFilter extends BaseDecorativePrototypeFilter { + readonly filter: "collision-mask" + readonly mask: CollisionMask | CollisionMaskWithFlags + /** How to filter: `"collides"` or `"layers-equals"` */ + readonly mask_mode: "collides" | "layers-equals" +} + +interface OtherDecorativePrototypeFilter extends BaseDecorativePrototypeFilter { + readonly filter: "decal" | "autoplace" +} + +/** + * Other attributes may be specified depending on `filter`: + * + * {@link https://lua-api.factorio.com/next/Concepts.html#DecorativePrototypeFilter View documentation} + */ +type DecorativePrototypeFilter = CollisionMaskDecorativePrototypeFilter | OtherDecorativePrototypeFilter + +interface BaseAchievementPrototypeFilter { + /** The condition to filter on. One of `"allowed-without-fight"`, `"type"` */ + readonly filter: "allowed-without-fight" | "type" + /** + * How to combine this with the previous filter. Must be `"or"` or `"and"`. Defaults to `"or"`. When evaluating the + * filters, `"and"` has higher precedence than `"or"`. + */ + readonly mode?: "or" | "and" + /** Inverts the condition. Default is `false`. */ + readonly invert?: boolean +} + +interface TypeAchievementPrototypeFilter extends BaseAchievementPrototypeFilter { + readonly filter: "type" + /** The prototype type */ + readonly type: string +} + +interface OtherAchievementPrototypeFilter extends BaseAchievementPrototypeFilter { + readonly filter: "allowed-without-fight" +} + +/** + * Other attributes may be specified depending on `filter`: + * + * {@link https://lua-api.factorio.com/next/Concepts.html#AchievementPrototypeFilter View documentation} + */ +type AchievementPrototypeFilter = TypeAchievementPrototypeFilter | OtherAchievementPrototypeFilter + +interface BaseFluidPrototypeFilter { + /** + * The condition to filter on. One of `"hidden"`, `"name"`, `"subgroup"`, `"default-temperature"`, + * `"max-temperature"`, `"heat-capacity"`, `"fuel-value"`, `"emissions-multiplier"`, `"gas-temperature"` + */ + readonly filter: + | "hidden" + | "name" + | "subgroup" + | "default-temperature" + | "max-temperature" + | "heat-capacity" + | "fuel-value" + | "emissions-multiplier" + | "gas-temperature" + /** + * How to combine this with the previous filter. Must be `"or"` or `"and"`. Defaults to `"or"`. When evaluating the + * filters, `"and"` has higher precedence than `"or"`. + */ + readonly mode?: "or" | "and" + /** Inverts the condition. Default is `false`. */ + readonly invert?: boolean +} + +/** + * For use within nested filters such as the `has-product-fluid` filter of array[{@link RecipePrototypeFilter}]. To get a + * specific prototype by name, see {@link LuaGameScript.fluid_prototypes LuaGameScript::fluid_prototypes}. + */ +interface NameFluidPrototypeFilter extends BaseFluidPrototypeFilter { + readonly filter: "name" + /** The prototype name, or list of acceptable names. */ + readonly name: string | string[] +} + +interface SubgroupFluidPrototypeFilter extends BaseFluidPrototypeFilter { + readonly filter: "subgroup" + /** A {@link LuaGroup} (subgroup) name */ + readonly subgroup: string +} + +interface DefaultTemperatureFluidPrototypeFilter extends BaseFluidPrototypeFilter { + readonly filter: "default-temperature" + readonly comparison: ComparatorString + /** The value to compare against. */ + readonly value: double +} + +interface MaxTemperatureFluidPrototypeFilter extends BaseFluidPrototypeFilter { + readonly filter: "max-temperature" + readonly comparison: ComparatorString + /** The value to compare against. */ + readonly value: double +} + +interface HeatCapacityFluidPrototypeFilter extends BaseFluidPrototypeFilter { + readonly filter: "heat-capacity" + readonly comparison: ComparatorString + /** The value to compare against. */ + readonly value: double +} + +interface FuelValueFluidPrototypeFilter extends BaseFluidPrototypeFilter { + readonly filter: "fuel-value" + readonly comparison: ComparatorString + /** The value to compare against. */ + readonly value: double +} + +interface EmissionsMultiplierFluidPrototypeFilter extends BaseFluidPrototypeFilter { + readonly filter: "emissions-multiplier" + readonly comparison: ComparatorString + /** The value to compare against. */ + readonly value: double +} + +interface GasTemperatureFluidPrototypeFilter extends BaseFluidPrototypeFilter { + readonly filter: "gas-temperature" + readonly comparison: ComparatorString + /** The value to compare against. */ + readonly value: double +} + +interface OtherFluidPrototypeFilter extends BaseFluidPrototypeFilter { + readonly filter: "hidden" +} + +/** + * Other attributes may be specified depending on `filter`: + * + * {@link https://lua-api.factorio.com/next/Concepts.html#FluidPrototypeFilter View documentation} + */ +type FluidPrototypeFilter = + | NameFluidPrototypeFilter + | SubgroupFluidPrototypeFilter + | DefaultTemperatureFluidPrototypeFilter + | MaxTemperatureFluidPrototypeFilter + | HeatCapacityFluidPrototypeFilter + | FuelValueFluidPrototypeFilter + | EmissionsMultiplierFluidPrototypeFilter + | GasTemperatureFluidPrototypeFilter + | OtherFluidPrototypeFilter + +interface BaseEquipmentPrototypeFilter { + /** The condition to filter on. One of `"item-to-place"`, `"type"` */ + readonly filter: "item-to-place" | "type" + /** + * How to combine this with the previous filter. Must be `"or"` or `"and"`. Defaults to `"or"`. When evaluating the + * filters, `"and"` has higher precedence than `"or"`. + */ + readonly mode?: "or" | "and" + /** Inverts the condition. Default is `false`. */ + readonly invert?: boolean +} + +interface TypeEquipmentPrototypeFilter extends BaseEquipmentPrototypeFilter { + readonly filter: "type" + /** The prototype type */ + readonly type: string +} + +interface OtherEquipmentPrototypeFilter extends BaseEquipmentPrototypeFilter { + readonly filter: "item-to-place" +} + +/** + * Other attributes may be specified depending on `filter`: + * + * {@link https://lua-api.factorio.com/next/Concepts.html#EquipmentPrototypeFilter View documentation} + */ +type EquipmentPrototypeFilter = TypeEquipmentPrototypeFilter | OtherEquipmentPrototypeFilter + +interface BaseTilePrototypeFilter { + /** + * The condition to filter on. One of `"minable"`, `"autoplace"`, `"blueprintable"`, `"item-to-place"`, + * `"collision-mask"`, `"walking-speed-modifier"`, `"vehicle-friction-modifier"`, + * `"decorative-removal-probability"`, `"emissions"` + */ + readonly filter: + | "minable" + | "autoplace" + | "blueprintable" + | "item-to-place" + | "collision-mask" + | "walking-speed-modifier" + | "vehicle-friction-modifier" + | "decorative-removal-probability" + | "emissions" + /** + * How to combine this with the previous filter. Must be `"or"` or `"and"`. Defaults to `"or"`. When evaluating the + * filters, `"and"` has higher precedence than `"or"`. + */ + readonly mode?: "or" | "and" + /** Inverts the condition. Default is `false`. */ + readonly invert?: boolean +} + +interface CollisionMaskTilePrototypeFilter extends BaseTilePrototypeFilter { + readonly filter: "collision-mask" + readonly mask: CollisionMask | CollisionMaskWithFlags + /** How to filter: `"collides"` or `"layers-equals"` */ + readonly mask_mode: "collides" | "layers-equals" +} + +interface WalkingSpeedModifierTilePrototypeFilter extends BaseTilePrototypeFilter { + readonly filter: "walking-speed-modifier" + readonly comparison: ComparatorString + /** The value to compare against. */ + readonly value: double +} + +interface VehicleFrictionModifierTilePrototypeFilter extends BaseTilePrototypeFilter { + readonly filter: "vehicle-friction-modifier" + readonly comparison: ComparatorString + /** The value to compare against. */ + readonly value: double +} + +interface DecorativeRemovalProbabilityTilePrototypeFilter extends BaseTilePrototypeFilter { + readonly filter: "decorative-removal-probability" + readonly comparison: ComparatorString + /** The value to compare against. */ + readonly value: float +} + +interface EmissionsTilePrototypeFilter extends BaseTilePrototypeFilter { + readonly filter: "emissions" + readonly comparison: ComparatorString + /** The value to compare against. */ + readonly value: double +} + +interface OtherTilePrototypeFilter extends BaseTilePrototypeFilter { + readonly filter: "minable" | "autoplace" | "blueprintable" | "item-to-place" +} + +/** + * Other attributes may be specified depending on `filter`: + * + * {@link https://lua-api.factorio.com/next/Concepts.html#TilePrototypeFilter View documentation} + */ +type TilePrototypeFilter = + | CollisionMaskTilePrototypeFilter + | WalkingSpeedModifierTilePrototypeFilter + | VehicleFrictionModifierTilePrototypeFilter + | DecorativeRemovalProbabilityTilePrototypeFilter + | EmissionsTilePrototypeFilter + | OtherTilePrototypeFilter + +interface BaseRecipePrototypeFilter { + /** + * The condition to filter on. One of `"enabled"`, `"hidden"`, `"hidden-from-flow-stats"`, + * `"hidden-from-player-crafting"`, `"allow-as-intermediate"`, `"allow-intermediates"`, `"allow-decomposition"`, + * `"always-show-made-in"`, `"always-show-products"`, `"show-amount-in-title"`, `"has-ingredients"`, + * `"has-products"`, `"has-ingredient-item"`, `"has-ingredient-fluid"`, `"has-product-item"`, `"has-product-fluid"`, + * `"subgroup"`, `"category"`, `"energy"`, `"emissions-multiplier"`, `"request-paste-multiplier"`, `"overload-multiplier"` + */ + readonly filter: + | "enabled" + | "hidden" + | "hidden-from-flow-stats" + | "hidden-from-player-crafting" + | "allow-as-intermediate" + | "allow-intermediates" + | "allow-decomposition" + | "always-show-made-in" + | "always-show-products" + | "show-amount-in-title" + | "has-ingredients" + | "has-products" + | "has-ingredient-item" + | "has-ingredient-fluid" + | "has-product-item" + | "has-product-fluid" + | "subgroup" + | "category" + | "energy" + | "emissions-multiplier" + | "request-paste-multiplier" + | "overload-multiplier" + /** + * How to combine this with the previous filter. Must be `"or"` or `"and"`. Defaults to `"or"`. When evaluating the + * filters, `"and"` has higher precedence than `"or"`. + */ + readonly mode?: "or" | "and" + /** Inverts the condition. Default is `false`. */ + readonly invert?: boolean +} + +interface HasIngredientItemRecipePrototypeFilter extends BaseRecipePrototypeFilter { + readonly filter: "has-ingredient-item" + /** Matches if at least 1 ingredient is an item that matches these filters. */ + readonly elem_filters?: ItemPrototypeFilter[] +} + +/** + * Usage example: + * + * ```lua + * -- selects recipes that consume sulfuric acid + * {{filter = "has-ingredient-fluid", elem_filters = {{filter = "name", name = "sulfuric-acid"}}}} + * ``` + */ +interface HasIngredientFluidRecipePrototypeFilter extends BaseRecipePrototypeFilter { + readonly filter: "has-ingredient-fluid" + /** Matches if at least 1 ingredient is a fluid that matches these filters. */ + readonly elem_filters?: FluidPrototypeFilter[] +} + +/** + * Usage example: + * + * ```lua + * -- selects recipes that produce an item + * {{filter = "has-product-item"}} + * -- selects recipes that produce iron plates + * {{filter = "has-product-item", elem_filters = {{filter = "name", name = "iron-plate"}}}} + * -- selects recipes that produce items that place furnaces + * {{filter = "has-product-item", elem_filters = {{filter = "place-result", elem_filters = {{filter = "type", type = "furnace"}}}}}} + * ``` + */ +interface HasProductItemRecipePrototypeFilter extends BaseRecipePrototypeFilter { + readonly filter: "has-product-item" + /** Matches if at least 1 product is an item that matches these filters. */ + readonly elem_filters?: ItemPrototypeFilter[] +} + +interface HasProductFluidRecipePrototypeFilter extends BaseRecipePrototypeFilter { + readonly filter: "has-product-fluid" + /** Matches if at least 1 product is a fluid that matches these filters. */ + readonly elem_filters?: FluidPrototypeFilter[] +} + +interface SubgroupRecipePrototypeFilter extends BaseRecipePrototypeFilter { + readonly filter: "subgroup" + /** A {@link LuaGroup} (subgroup) name */ + readonly subgroup: string +} + +interface CategoryRecipePrototypeFilter extends BaseRecipePrototypeFilter { + readonly filter: "category" + /** A {@link LuaRecipeCategoryPrototype} name */ + readonly category: string +} + +interface EnergyRecipePrototypeFilter extends BaseRecipePrototypeFilter { + readonly filter: "energy" + readonly comparison: ComparatorString + /** The value to compare against. */ + readonly value: double +} + +interface EmissionsMultiplierRecipePrototypeFilter extends BaseRecipePrototypeFilter { + readonly filter: "emissions-multiplier" + readonly comparison: ComparatorString + /** The value to compare against. */ + readonly value: double +} + +interface RequestPasteMultiplierRecipePrototypeFilter extends BaseRecipePrototypeFilter { + readonly filter: "request-paste-multiplier" + readonly comparison: ComparatorString + /** The value to compare against. */ + readonly value: uint +} + +interface OverloadMultiplierRecipePrototypeFilter extends BaseRecipePrototypeFilter { + readonly filter: "overload-multiplier" + readonly comparison: ComparatorString + /** The value to compare against. */ + readonly value: uint +} + +interface OtherRecipePrototypeFilter extends BaseRecipePrototypeFilter { + readonly filter: + | "enabled" + | "hidden" + | "hidden-from-flow-stats" + | "hidden-from-player-crafting" + | "allow-as-intermediate" + | "allow-intermediates" + | "allow-decomposition" + | "always-show-made-in" + | "always-show-products" + | "show-amount-in-title" + | "has-ingredients" + | "has-products" +} + +/** + * Other attributes may be specified depending on `filter`: + * + * {@link https://lua-api.factorio.com/next/Concepts.html#RecipePrototypeFilter View documentation} + */ +type RecipePrototypeFilter = + | HasIngredientItemRecipePrototypeFilter + | HasIngredientFluidRecipePrototypeFilter + | HasProductItemRecipePrototypeFilter + | HasProductFluidRecipePrototypeFilter + | SubgroupRecipePrototypeFilter + | CategoryRecipePrototypeFilter + | EnergyRecipePrototypeFilter + | EmissionsMultiplierRecipePrototypeFilter + | RequestPasteMultiplierRecipePrototypeFilter + | OverloadMultiplierRecipePrototypeFilter + | OtherRecipePrototypeFilter + +interface BaseEntityPrototypeFilter { + /** + * The condition to filter on. One of `"flying-robot"`, `"robot-with-logistics-interface"`, `"rail"`, `"ghost"`, + * `"explosion"`, `"vehicle"`, `"crafting-machine"`, `"rolling-stock"`, `"turret"`, `"transport-belt-connectable"`, + * `"wall-connectable"`, `"buildable"`, `"placable-in-editor"`, `"clonable"`, `"selectable"`, `"hidden"`, + * `"entity-with-health"`, `"building"`, `"fast-replaceable"`, `"uses-direction"`, `"minable"`, + * `"circuit-connectable"`, `"autoplace"`, `"blueprintable"`, `"item-to-place"`, `"name"`, `"type"`, + * `"collision-mask"`, `"flag"`, `"build-base-evolution-requirement"`, `"selection-priority"`, `"emissions"`, + * `"crafting-category"` + */ + readonly filter: + | "flying-robot" + | "robot-with-logistics-interface" + | "rail" + | "ghost" + | "explosion" + | "vehicle" + | "crafting-machine" + | "rolling-stock" + | "turret" + | "transport-belt-connectable" + | "wall-connectable" + | "buildable" + | "placable-in-editor" + | "clonable" + | "selectable" + | "hidden" + | "entity-with-health" + | "building" + | "fast-replaceable" + | "uses-direction" + | "minable" + | "circuit-connectable" + | "autoplace" + | "blueprintable" + | "item-to-place" + | "name" + | "type" + | "collision-mask" + | "flag" + | "build-base-evolution-requirement" + | "selection-priority" + | "emissions" + | "crafting-category" + /** + * How to combine this with the previous filter. Must be `"or"` or `"and"`. Defaults to `"or"`. When evaluating the + * filters, `"and"` has higher precedence than `"or"`. + */ + readonly mode?: "or" | "and" + /** Inverts the condition. Default is `false`. */ + readonly invert?: boolean +} + +/** + * For use within nested filters such as the `place-result` filter of array[{@link ItemPrototypeFilter}]. To get a + * specific prototype by name, see {@link LuaGameScript.entity_prototypes LuaGameScript::entity_prototypes}. + */ +interface NameEntityPrototypeFilter extends BaseEntityPrototypeFilter { + readonly filter: "name" + /** The prototype name, or list of acceptable names. */ + readonly name: string | string[] +} + +/** + * Usage example: + * + * ```lua + * game.get_filtered_entity_prototypes({{filter = "type", type = "unit"}}) + * ``` + */ +interface TypeEntityPrototypeFilter extends BaseEntityPrototypeFilter { + readonly filter: "type" + /** The prototype type */ + readonly type: string +} + +/** + * Usage example: + * + * ```lua + * game.get_filtered_entity_prototypes({{filter = "collision-mask", mask = "player-layer", mask_mode = "collides"}}) + * ``` + */ +interface CollisionMaskEntityPrototypeFilter extends BaseEntityPrototypeFilter { + readonly filter: "collision-mask" + readonly mask: CollisionMask | CollisionMaskWithFlags + /** How to filter: `"collides"` or `"layers-equals"` */ + readonly mask_mode: "collides" | "layers-equals" +} + +/** + * Usage example: + * + * ```lua + * game.get_filtered_entity_prototypes({{filter = "flag", flag = "placeable-player"}, {filter = "flag", flag = "placeable-enemy", mode = "and"}}) + * ``` + */ +interface FlagEntityPrototypeFilter extends BaseEntityPrototypeFilter { + readonly filter: "flag" + /** One of the values in {@link EntityPrototypeFlags}. */ + readonly flag: string +} + +interface BuildBaseEvolutionRequirementEntityPrototypeFilter extends BaseEntityPrototypeFilter { + readonly filter: "build-base-evolution-requirement" + readonly comparison: ComparatorString + /** The value to compare against. */ + readonly value: double +} + +interface SelectionPriorityEntityPrototypeFilter extends BaseEntityPrototypeFilter { + readonly filter: "selection-priority" + readonly comparison: ComparatorString + /** The value to compare against. */ + readonly value: uint8 +} + +interface EmissionsEntityPrototypeFilter extends BaseEntityPrototypeFilter { + readonly filter: "emissions" + readonly comparison: ComparatorString + /** The value to compare against. */ + readonly value: double +} + +interface CraftingCategoryEntityPrototypeFilter extends BaseEntityPrototypeFilter { + readonly filter: "crafting-category" + /** Matches if the prototype is for a crafting machine with this crafting category. */ + readonly crafting_category: string +} + +interface OtherEntityPrototypeFilter extends BaseEntityPrototypeFilter { + readonly filter: + | "flying-robot" + | "robot-with-logistics-interface" + | "rail" + | "ghost" + | "explosion" + | "vehicle" + | "crafting-machine" + | "rolling-stock" + | "turret" + | "transport-belt-connectable" + | "wall-connectable" + | "buildable" + | "placable-in-editor" + | "clonable" + | "selectable" + | "hidden" + | "entity-with-health" + | "building" + | "fast-replaceable" + | "uses-direction" + | "minable" + | "circuit-connectable" + | "autoplace" + | "blueprintable" + | "item-to-place" +} + +/** + * Other attributes may be specified depending on `filter`: + * + * {@link https://lua-api.factorio.com/next/Concepts.html#EntityPrototypeFilter View documentation} + */ +type EntityPrototypeFilter = + | NameEntityPrototypeFilter + | TypeEntityPrototypeFilter + | CollisionMaskEntityPrototypeFilter + | FlagEntityPrototypeFilter + | BuildBaseEvolutionRequirementEntityPrototypeFilter + | SelectionPriorityEntityPrototypeFilter + | EmissionsEntityPrototypeFilter + | CraftingCategoryEntityPrototypeFilter + | OtherEntityPrototypeFilter + +interface BaseScriptRaisedReviveEventFilter { + /** + * The condition to filter on. One of `"ghost"`, `"rail"`, `"rail-signal"`, `"rolling-stock"`, + * `"robot-with-logistics-interface"`, `"vehicle"`, `"turret"`, `"crafting-machine"`, `"wall-connectable"`, + * `"transport-belt-connectable"`, `"circuit-network-connectable"`, `"type"`, `"name"`, `"ghost_type"`, `"ghost_name"` + */ + readonly filter: + | "ghost" + | "rail" + | "rail-signal" + | "rolling-stock" + | "robot-with-logistics-interface" + | "vehicle" + | "turret" + | "crafting-machine" + | "wall-connectable" + | "transport-belt-connectable" + | "circuit-network-connectable" + | "type" + | "name" + | "ghost_type" + | "ghost_name" + /** + * How to combine this with the previous filter. Must be `"or"` or `"and"`. Defaults to `"or"`. When evaluating the + * filters, `"and"` has higher precedence than `"or"`. + */ + readonly mode?: "or" | "and" + /** Inverts the condition. Default is `false`. */ + readonly invert?: boolean +} + +interface TypeScriptRaisedReviveEventFilter extends BaseScriptRaisedReviveEventFilter { + readonly filter: "type" + /** The prototype type */ + readonly type: string +} + +interface NameScriptRaisedReviveEventFilter extends BaseScriptRaisedReviveEventFilter { + readonly filter: "name" + /** The prototype name */ + readonly name: string +} + +interface GhostTypeScriptRaisedReviveEventFilter extends BaseScriptRaisedReviveEventFilter { + readonly filter: "ghost_type" + /** The ghost prototype type */ + readonly type: string +} + +interface GhostNameScriptRaisedReviveEventFilter extends BaseScriptRaisedReviveEventFilter { + readonly filter: "ghost_name" + /** The ghost prototype name */ + readonly name: string +} + +interface OtherScriptRaisedReviveEventFilter extends BaseScriptRaisedReviveEventFilter { + readonly filter: + | "ghost" + | "rail" + | "rail-signal" + | "rolling-stock" + | "robot-with-logistics-interface" + | "vehicle" + | "turret" + | "crafting-machine" + | "wall-connectable" + | "transport-belt-connectable" + | "circuit-network-connectable" +} + +/** + * Other attributes may be specified depending on `filter`: + * + * {@link https://lua-api.factorio.com/next/Concepts.html#LuaScriptRaisedReviveEventFilter View documentation} + */ +type LuaScriptRaisedReviveEventFilter = + | TypeScriptRaisedReviveEventFilter + | NameScriptRaisedReviveEventFilter + | GhostTypeScriptRaisedReviveEventFilter + | GhostNameScriptRaisedReviveEventFilter + | OtherScriptRaisedReviveEventFilter + +interface BaseEntityDiedEventFilter { + /** + * The condition to filter on. One of `"ghost"`, `"rail"`, `"rail-signal"`, `"rolling-stock"`, + * `"robot-with-logistics-interface"`, `"vehicle"`, `"turret"`, `"crafting-machine"`, `"wall-connectable"`, + * `"transport-belt-connectable"`, `"circuit-network-connectable"`, `"type"`, `"name"`, `"ghost_type"`, `"ghost_name"` + */ + readonly filter: + | "ghost" + | "rail" + | "rail-signal" + | "rolling-stock" + | "robot-with-logistics-interface" + | "vehicle" + | "turret" + | "crafting-machine" + | "wall-connectable" + | "transport-belt-connectable" + | "circuit-network-connectable" + | "type" + | "name" + | "ghost_type" + | "ghost_name" + /** + * How to combine this with the previous filter. Must be `"or"` or `"and"`. Defaults to `"or"`. When evaluating the + * filters, `"and"` has higher precedence than `"or"`. + */ + readonly mode?: "or" | "and" + /** Inverts the condition. Default is `false`. */ + readonly invert?: boolean +} + +interface TypeEntityDiedEventFilter extends BaseEntityDiedEventFilter { + readonly filter: "type" + /** The prototype type */ + readonly type: string +} + +interface NameEntityDiedEventFilter extends BaseEntityDiedEventFilter { + readonly filter: "name" + /** The prototype name */ + readonly name: string +} + +interface GhostTypeEntityDiedEventFilter extends BaseEntityDiedEventFilter { + readonly filter: "ghost_type" + /** The ghost prototype type */ + readonly type: string +} + +interface GhostNameEntityDiedEventFilter extends BaseEntityDiedEventFilter { + readonly filter: "ghost_name" + /** The ghost prototype name */ + readonly name: string +} + +interface OtherEntityDiedEventFilter extends BaseEntityDiedEventFilter { + readonly filter: + | "ghost" + | "rail" + | "rail-signal" + | "rolling-stock" + | "robot-with-logistics-interface" + | "vehicle" + | "turret" + | "crafting-machine" + | "wall-connectable" + | "transport-belt-connectable" + | "circuit-network-connectable" +} + +/** + * Other attributes may be specified depending on `filter`: + * + * {@link https://lua-api.factorio.com/next/Concepts.html#LuaEntityDiedEventFilter View documentation} + */ +type LuaEntityDiedEventFilter = + | TypeEntityDiedEventFilter + | NameEntityDiedEventFilter + | GhostTypeEntityDiedEventFilter + | GhostNameEntityDiedEventFilter + | OtherEntityDiedEventFilter + +interface BaseEntityMarkedForDeconstructionEventFilter { + /** + * The condition to filter on. One of `"ghost"`, `"rail"`, `"rail-signal"`, `"rolling-stock"`, + * `"robot-with-logistics-interface"`, `"vehicle"`, `"turret"`, `"crafting-machine"`, `"wall-connectable"`, + * `"transport-belt-connectable"`, `"circuit-network-connectable"`, `"type"`, `"name"`, `"ghost_type"`, `"ghost_name"` + */ + readonly filter: + | "ghost" + | "rail" + | "rail-signal" + | "rolling-stock" + | "robot-with-logistics-interface" + | "vehicle" + | "turret" + | "crafting-machine" + | "wall-connectable" + | "transport-belt-connectable" + | "circuit-network-connectable" + | "type" + | "name" + | "ghost_type" + | "ghost_name" + /** + * How to combine this with the previous filter. Must be `"or"` or `"and"`. Defaults to `"or"`. When evaluating the + * filters, `"and"` has higher precedence than `"or"`. + */ + readonly mode?: "or" | "and" + /** Inverts the condition. Default is `false`. */ + readonly invert?: boolean +} + +interface TypeEntityMarkedForDeconstructionEventFilter extends BaseEntityMarkedForDeconstructionEventFilter { + readonly filter: "type" + /** The prototype type */ + readonly type: string +} + +interface NameEntityMarkedForDeconstructionEventFilter extends BaseEntityMarkedForDeconstructionEventFilter { + readonly filter: "name" + /** The prototype name */ + readonly name: string +} + +interface GhostTypeEntityMarkedForDeconstructionEventFilter extends BaseEntityMarkedForDeconstructionEventFilter { + readonly filter: "ghost_type" + /** The ghost prototype type */ + readonly type: string +} + +interface GhostNameEntityMarkedForDeconstructionEventFilter extends BaseEntityMarkedForDeconstructionEventFilter { + readonly filter: "ghost_name" + /** The ghost prototype name */ + readonly name: string +} + +interface OtherEntityMarkedForDeconstructionEventFilter extends BaseEntityMarkedForDeconstructionEventFilter { + readonly filter: + | "ghost" + | "rail" + | "rail-signal" + | "rolling-stock" + | "robot-with-logistics-interface" + | "vehicle" + | "turret" + | "crafting-machine" + | "wall-connectable" + | "transport-belt-connectable" + | "circuit-network-connectable" +} + +/** + * Other attributes may be specified depending on `filter`: + * + * {@link https://lua-api.factorio.com/next/Concepts.html#LuaEntityMarkedForDeconstructionEventFilter View documentation} + */ +type LuaEntityMarkedForDeconstructionEventFilter = + | TypeEntityMarkedForDeconstructionEventFilter + | NameEntityMarkedForDeconstructionEventFilter + | GhostTypeEntityMarkedForDeconstructionEventFilter + | GhostNameEntityMarkedForDeconstructionEventFilter + | OtherEntityMarkedForDeconstructionEventFilter + +interface BasePreGhostDeconstructedEventFilter { + /** + * The condition to filter on. One of `"ghost"`, `"rail"`, `"rail-signal"`, `"rolling-stock"`, + * `"robot-with-logistics-interface"`, `"vehicle"`, `"turret"`, `"crafting-machine"`, `"wall-connectable"`, + * `"transport-belt-connectable"`, `"circuit-network-connectable"`, `"type"`, `"name"`, `"ghost_type"`, `"ghost_name"` + */ + readonly filter: + | "ghost" + | "rail" + | "rail-signal" + | "rolling-stock" + | "robot-with-logistics-interface" + | "vehicle" + | "turret" + | "crafting-machine" + | "wall-connectable" + | "transport-belt-connectable" + | "circuit-network-connectable" + | "type" + | "name" + | "ghost_type" + | "ghost_name" + /** + * How to combine this with the previous filter. Must be `"or"` or `"and"`. Defaults to `"or"`. When evaluating the + * filters, `"and"` has higher precedence than `"or"`. + */ + readonly mode?: "or" | "and" + /** Inverts the condition. Default is `false`. */ + readonly invert?: boolean +} + +interface TypePreGhostDeconstructedEventFilter extends BasePreGhostDeconstructedEventFilter { + readonly filter: "type" + /** The prototype type */ + readonly type: string +} + +interface NamePreGhostDeconstructedEventFilter extends BasePreGhostDeconstructedEventFilter { + readonly filter: "name" + /** The prototype name */ + readonly name: string +} + +interface GhostTypePreGhostDeconstructedEventFilter extends BasePreGhostDeconstructedEventFilter { + readonly filter: "ghost_type" + /** The ghost prototype type */ + readonly type: string +} + +interface GhostNamePreGhostDeconstructedEventFilter extends BasePreGhostDeconstructedEventFilter { + readonly filter: "ghost_name" + /** The ghost prototype name */ + readonly name: string +} + +interface OtherPreGhostDeconstructedEventFilter extends BasePreGhostDeconstructedEventFilter { + readonly filter: + | "ghost" + | "rail" + | "rail-signal" + | "rolling-stock" + | "robot-with-logistics-interface" + | "vehicle" + | "turret" + | "crafting-machine" + | "wall-connectable" + | "transport-belt-connectable" + | "circuit-network-connectable" +} + +/** + * Other attributes may be specified depending on `filter`: + * + * {@link https://lua-api.factorio.com/next/Concepts.html#LuaPreGhostDeconstructedEventFilter View documentation} + */ +type LuaPreGhostDeconstructedEventFilter = + | TypePreGhostDeconstructedEventFilter + | NamePreGhostDeconstructedEventFilter + | GhostTypePreGhostDeconstructedEventFilter + | GhostNamePreGhostDeconstructedEventFilter + | OtherPreGhostDeconstructedEventFilter + +interface BaseScriptRaisedDestroyEventFilter { + /** + * The condition to filter on. One of `"ghost"`, `"rail"`, `"rail-signal"`, `"rolling-stock"`, + * `"robot-with-logistics-interface"`, `"vehicle"`, `"turret"`, `"crafting-machine"`, `"wall-connectable"`, + * `"transport-belt-connectable"`, `"circuit-network-connectable"`, `"type"`, `"name"`, `"ghost_type"`, `"ghost_name"` + */ + readonly filter: + | "ghost" + | "rail" + | "rail-signal" + | "rolling-stock" + | "robot-with-logistics-interface" + | "vehicle" + | "turret" + | "crafting-machine" + | "wall-connectable" + | "transport-belt-connectable" + | "circuit-network-connectable" + | "type" + | "name" + | "ghost_type" + | "ghost_name" + /** + * How to combine this with the previous filter. Must be `"or"` or `"and"`. Defaults to `"or"`. When evaluating the + * filters, `"and"` has higher precedence than `"or"`. + */ + readonly mode?: "or" | "and" + /** Inverts the condition. Default is `false`. */ + readonly invert?: boolean +} + +interface TypeScriptRaisedDestroyEventFilter extends BaseScriptRaisedDestroyEventFilter { + readonly filter: "type" + /** The prototype type */ + readonly type: string +} + +interface NameScriptRaisedDestroyEventFilter extends BaseScriptRaisedDestroyEventFilter { + readonly filter: "name" + /** The prototype name */ + readonly name: string +} + +interface GhostTypeScriptRaisedDestroyEventFilter extends BaseScriptRaisedDestroyEventFilter { + readonly filter: "ghost_type" + /** The ghost prototype type */ + readonly type: string +} + +interface GhostNameScriptRaisedDestroyEventFilter extends BaseScriptRaisedDestroyEventFilter { + readonly filter: "ghost_name" + /** The ghost prototype name */ + readonly name: string +} + +interface OtherScriptRaisedDestroyEventFilter extends BaseScriptRaisedDestroyEventFilter { + readonly filter: + | "ghost" + | "rail" + | "rail-signal" + | "rolling-stock" + | "robot-with-logistics-interface" + | "vehicle" + | "turret" + | "crafting-machine" + | "wall-connectable" + | "transport-belt-connectable" + | "circuit-network-connectable" +} + +/** + * Other attributes may be specified depending on `filter`: + * + * {@link https://lua-api.factorio.com/next/Concepts.html#LuaScriptRaisedDestroyEventFilter View documentation} + */ +type LuaScriptRaisedDestroyEventFilter = + | TypeScriptRaisedDestroyEventFilter + | NameScriptRaisedDestroyEventFilter + | GhostTypeScriptRaisedDestroyEventFilter + | GhostNameScriptRaisedDestroyEventFilter + | OtherScriptRaisedDestroyEventFilter + +interface BaseUpgradeCancelledEventFilter { + /** + * The condition to filter on. One of `"ghost"`, `"rail"`, `"rail-signal"`, `"rolling-stock"`, + * `"robot-with-logistics-interface"`, `"vehicle"`, `"turret"`, `"crafting-machine"`, `"wall-connectable"`, + * `"transport-belt-connectable"`, `"circuit-network-connectable"`, `"type"`, `"name"`, `"ghost_type"`, `"ghost_name"` + */ + readonly filter: + | "ghost" + | "rail" + | "rail-signal" + | "rolling-stock" + | "robot-with-logistics-interface" + | "vehicle" + | "turret" + | "crafting-machine" + | "wall-connectable" + | "transport-belt-connectable" + | "circuit-network-connectable" + | "type" + | "name" + | "ghost_type" + | "ghost_name" + /** + * How to combine this with the previous filter. Must be `"or"` or `"and"`. Defaults to `"or"`. When evaluating the + * filters, `"and"` has higher precedence than `"or"`. + */ + readonly mode?: "or" | "and" + /** Inverts the condition. Default is `false`. */ + readonly invert?: boolean +} + +interface TypeUpgradeCancelledEventFilter extends BaseUpgradeCancelledEventFilter { + readonly filter: "type" + /** The prototype type */ + readonly type: string +} + +interface NameUpgradeCancelledEventFilter extends BaseUpgradeCancelledEventFilter { + readonly filter: "name" + /** The prototype name */ + readonly name: string +} + +interface GhostTypeUpgradeCancelledEventFilter extends BaseUpgradeCancelledEventFilter { + readonly filter: "ghost_type" + /** The ghost prototype type */ + readonly type: string +} + +interface GhostNameUpgradeCancelledEventFilter extends BaseUpgradeCancelledEventFilter { + readonly filter: "ghost_name" + /** The ghost prototype name */ + readonly name: string +} + +interface OtherUpgradeCancelledEventFilter extends BaseUpgradeCancelledEventFilter { + readonly filter: + | "ghost" + | "rail" + | "rail-signal" + | "rolling-stock" + | "robot-with-logistics-interface" + | "vehicle" + | "turret" + | "crafting-machine" + | "wall-connectable" + | "transport-belt-connectable" + | "circuit-network-connectable" +} + +/** + * Other attributes may be specified depending on `filter`: + * + * {@link https://lua-api.factorio.com/next/Concepts.html#LuaUpgradeCancelledEventFilter View documentation} + */ +type LuaUpgradeCancelledEventFilter = + | TypeUpgradeCancelledEventFilter + | NameUpgradeCancelledEventFilter + | GhostTypeUpgradeCancelledEventFilter + | GhostNameUpgradeCancelledEventFilter + | OtherUpgradeCancelledEventFilter + +interface BasePlayerRepairedEntityEventFilter { + /** + * The condition to filter on. One of `"ghost"`, `"rail"`, `"rail-signal"`, `"rolling-stock"`, + * `"robot-with-logistics-interface"`, `"vehicle"`, `"turret"`, `"crafting-machine"`, `"wall-connectable"`, + * `"transport-belt-connectable"`, `"circuit-network-connectable"`, `"type"`, `"name"`, `"ghost_type"`, `"ghost_name"` + */ + readonly filter: + | "ghost" + | "rail" + | "rail-signal" + | "rolling-stock" + | "robot-with-logistics-interface" + | "vehicle" + | "turret" + | "crafting-machine" + | "wall-connectable" + | "transport-belt-connectable" + | "circuit-network-connectable" + | "type" + | "name" + | "ghost_type" + | "ghost_name" + /** + * How to combine this with the previous filter. Must be `"or"` or `"and"`. Defaults to `"or"`. When evaluating the + * filters, `"and"` has higher precedence than `"or"`. + */ + readonly mode?: "or" | "and" + /** Inverts the condition. Default is `false`. */ + readonly invert?: boolean +} + +interface TypePlayerRepairedEntityEventFilter extends BasePlayerRepairedEntityEventFilter { + readonly filter: "type" + /** The prototype type */ + readonly type: string +} + +interface NamePlayerRepairedEntityEventFilter extends BasePlayerRepairedEntityEventFilter { + readonly filter: "name" + /** The prototype name */ + readonly name: string +} + +interface GhostTypePlayerRepairedEntityEventFilter extends BasePlayerRepairedEntityEventFilter { + readonly filter: "ghost_type" + /** The ghost prototype type */ + readonly type: string +} + +interface GhostNamePlayerRepairedEntityEventFilter extends BasePlayerRepairedEntityEventFilter { + readonly filter: "ghost_name" + /** The ghost prototype name */ + readonly name: string +} + +interface OtherPlayerRepairedEntityEventFilter extends BasePlayerRepairedEntityEventFilter { + readonly filter: + | "ghost" + | "rail" + | "rail-signal" + | "rolling-stock" + | "robot-with-logistics-interface" + | "vehicle" + | "turret" + | "crafting-machine" + | "wall-connectable" + | "transport-belt-connectable" + | "circuit-network-connectable" +} + +/** + * Other attributes may be specified depending on `filter`: + * + * {@link https://lua-api.factorio.com/next/Concepts.html#LuaPlayerRepairedEntityEventFilter View documentation} + */ +type LuaPlayerRepairedEntityEventFilter = + | TypePlayerRepairedEntityEventFilter + | NamePlayerRepairedEntityEventFilter + | GhostTypePlayerRepairedEntityEventFilter + | GhostNamePlayerRepairedEntityEventFilter + | OtherPlayerRepairedEntityEventFilter + +interface BaseEntityMarkedForUpgradeEventFilter { + /** + * The condition to filter on. One of `"ghost"`, `"rail"`, `"rail-signal"`, `"rolling-stock"`, + * `"robot-with-logistics-interface"`, `"vehicle"`, `"turret"`, `"crafting-machine"`, `"wall-connectable"`, + * `"transport-belt-connectable"`, `"circuit-network-connectable"`, `"type"`, `"name"`, `"ghost_type"`, `"ghost_name"` + */ + readonly filter: + | "ghost" + | "rail" + | "rail-signal" + | "rolling-stock" + | "robot-with-logistics-interface" + | "vehicle" + | "turret" + | "crafting-machine" + | "wall-connectable" + | "transport-belt-connectable" + | "circuit-network-connectable" + | "type" + | "name" + | "ghost_type" + | "ghost_name" + /** + * How to combine this with the previous filter. Must be `"or"` or `"and"`. Defaults to `"or"`. When evaluating the + * filters, `"and"` has higher precedence than `"or"`. + */ + readonly mode?: "or" | "and" + /** Inverts the condition. Default is `false`. */ + readonly invert?: boolean +} + +interface TypeEntityMarkedForUpgradeEventFilter extends BaseEntityMarkedForUpgradeEventFilter { + readonly filter: "type" + /** The prototype type */ + readonly type: string +} + +interface NameEntityMarkedForUpgradeEventFilter extends BaseEntityMarkedForUpgradeEventFilter { + readonly filter: "name" + /** The prototype name */ + readonly name: string +} + +interface GhostTypeEntityMarkedForUpgradeEventFilter extends BaseEntityMarkedForUpgradeEventFilter { + readonly filter: "ghost_type" + /** The ghost prototype type */ + readonly type: string +} + +interface GhostNameEntityMarkedForUpgradeEventFilter extends BaseEntityMarkedForUpgradeEventFilter { + readonly filter: "ghost_name" + /** The ghost prototype name */ + readonly name: string +} + +interface OtherEntityMarkedForUpgradeEventFilter extends BaseEntityMarkedForUpgradeEventFilter { + readonly filter: + | "ghost" + | "rail" + | "rail-signal" + | "rolling-stock" + | "robot-with-logistics-interface" + | "vehicle" + | "turret" + | "crafting-machine" + | "wall-connectable" + | "transport-belt-connectable" + | "circuit-network-connectable" +} + +/** + * Other attributes may be specified depending on `filter`: + * + * {@link https://lua-api.factorio.com/next/Concepts.html#LuaEntityMarkedForUpgradeEventFilter View documentation} + */ +type LuaEntityMarkedForUpgradeEventFilter = + | TypeEntityMarkedForUpgradeEventFilter + | NameEntityMarkedForUpgradeEventFilter + | GhostTypeEntityMarkedForUpgradeEventFilter + | GhostNameEntityMarkedForUpgradeEventFilter + | OtherEntityMarkedForUpgradeEventFilter + +interface BasePostEntityDiedEventFilter { + /** The condition to filter on. One of `"type"` */ + readonly filter: "type" + /** + * How to combine this with the previous filter. Must be `"or"` or `"and"`. Defaults to `"or"`. When evaluating the + * filters, `"and"` has higher precedence than `"or"`. + */ + readonly mode?: "or" | "and" + /** Inverts the condition. Default is `false`. */ + readonly invert?: boolean +} + +interface TypePostEntityDiedEventFilter extends BasePostEntityDiedEventFilter { + readonly filter: "type" + /** The prototype type */ + readonly type: string +} + +/** + * Other attributes may be specified depending on `filter`: + * + * {@link https://lua-api.factorio.com/next/Concepts.html#LuaPostEntityDiedEventFilter View documentation} + */ +type LuaPostEntityDiedEventFilter = TypePostEntityDiedEventFilter + +interface BasePreRobotMinedEntityEventFilter { + /** + * The condition to filter on. One of `"ghost"`, `"rail"`, `"rail-signal"`, `"rolling-stock"`, + * `"robot-with-logistics-interface"`, `"vehicle"`, `"turret"`, `"crafting-machine"`, `"wall-connectable"`, + * `"transport-belt-connectable"`, `"circuit-network-connectable"`, `"type"`, `"name"`, `"ghost_type"`, `"ghost_name"` + */ + readonly filter: + | "ghost" + | "rail" + | "rail-signal" + | "rolling-stock" + | "robot-with-logistics-interface" + | "vehicle" + | "turret" + | "crafting-machine" + | "wall-connectable" + | "transport-belt-connectable" + | "circuit-network-connectable" + | "type" + | "name" + | "ghost_type" + | "ghost_name" + /** + * How to combine this with the previous filter. Must be `"or"` or `"and"`. Defaults to `"or"`. When evaluating the + * filters, `"and"` has higher precedence than `"or"`. + */ + readonly mode?: "or" | "and" + /** Inverts the condition. Default is `false`. */ + readonly invert?: boolean +} + +interface TypePreRobotMinedEntityEventFilter extends BasePreRobotMinedEntityEventFilter { + readonly filter: "type" + /** The prototype type */ + readonly type: string +} + +interface NamePreRobotMinedEntityEventFilter extends BasePreRobotMinedEntityEventFilter { + readonly filter: "name" + /** The prototype name */ + readonly name: string +} + +interface GhostTypePreRobotMinedEntityEventFilter extends BasePreRobotMinedEntityEventFilter { + readonly filter: "ghost_type" + /** The ghost prototype type */ + readonly type: string +} + +interface GhostNamePreRobotMinedEntityEventFilter extends BasePreRobotMinedEntityEventFilter { + readonly filter: "ghost_name" + /** The ghost prototype name */ + readonly name: string +} + +interface OtherPreRobotMinedEntityEventFilter extends BasePreRobotMinedEntityEventFilter { + readonly filter: + | "ghost" + | "rail" + | "rail-signal" + | "rolling-stock" + | "robot-with-logistics-interface" + | "vehicle" + | "turret" + | "crafting-machine" + | "wall-connectable" + | "transport-belt-connectable" + | "circuit-network-connectable" +} + +/** + * Other attributes may be specified depending on `filter`: + * + * {@link https://lua-api.factorio.com/next/Concepts.html#LuaPreRobotMinedEntityEventFilter View documentation} + */ +type LuaPreRobotMinedEntityEventFilter = + | TypePreRobotMinedEntityEventFilter + | NamePreRobotMinedEntityEventFilter + | GhostTypePreRobotMinedEntityEventFilter + | GhostNamePreRobotMinedEntityEventFilter + | OtherPreRobotMinedEntityEventFilter + +interface BaseEntityClonedEventFilter { + /** + * The condition to filter on. One of `"ghost"`, `"rail"`, `"rail-signal"`, `"rolling-stock"`, + * `"robot-with-logistics-interface"`, `"vehicle"`, `"turret"`, `"crafting-machine"`, `"wall-connectable"`, + * `"transport-belt-connectable"`, `"circuit-network-connectable"`, `"type"`, `"name"`, `"ghost_type"`, `"ghost_name"` + */ + readonly filter: + | "ghost" + | "rail" + | "rail-signal" + | "rolling-stock" + | "robot-with-logistics-interface" + | "vehicle" + | "turret" + | "crafting-machine" + | "wall-connectable" + | "transport-belt-connectable" + | "circuit-network-connectable" + | "type" + | "name" + | "ghost_type" + | "ghost_name" + /** + * How to combine this with the previous filter. Must be `"or"` or `"and"`. Defaults to `"or"`. When evaluating the + * filters, `"and"` has higher precedence than `"or"`. + */ + readonly mode?: "or" | "and" + /** Inverts the condition. Default is `false`. */ + readonly invert?: boolean +} + +interface TypeEntityClonedEventFilter extends BaseEntityClonedEventFilter { + readonly filter: "type" + /** The prototype type */ + readonly type: string +} + +interface NameEntityClonedEventFilter extends BaseEntityClonedEventFilter { + readonly filter: "name" + /** The prototype name */ + readonly name: string +} + +interface GhostTypeEntityClonedEventFilter extends BaseEntityClonedEventFilter { + readonly filter: "ghost_type" + /** The ghost prototype type */ + readonly type: string +} + +interface GhostNameEntityClonedEventFilter extends BaseEntityClonedEventFilter { + readonly filter: "ghost_name" + /** The ghost prototype name */ + readonly name: string +} + +interface OtherEntityClonedEventFilter extends BaseEntityClonedEventFilter { + readonly filter: + | "ghost" + | "rail" + | "rail-signal" + | "rolling-stock" + | "robot-with-logistics-interface" + | "vehicle" + | "turret" + | "crafting-machine" + | "wall-connectable" + | "transport-belt-connectable" + | "circuit-network-connectable" +} + +/** + * Other attributes may be specified depending on `filter`: + * + * {@link https://lua-api.factorio.com/next/Concepts.html#LuaEntityClonedEventFilter View documentation} + */ +type LuaEntityClonedEventFilter = + | TypeEntityClonedEventFilter + | NameEntityClonedEventFilter + | GhostTypeEntityClonedEventFilter + | GhostNameEntityClonedEventFilter + | OtherEntityClonedEventFilter + +interface BaseScriptRaisedBuiltEventFilter { + /** + * The condition to filter on. One of `"ghost"`, `"rail"`, `"rail-signal"`, `"rolling-stock"`, + * `"robot-with-logistics-interface"`, `"vehicle"`, `"turret"`, `"crafting-machine"`, `"wall-connectable"`, + * `"transport-belt-connectable"`, `"circuit-network-connectable"`, `"type"`, `"name"`, `"ghost_type"`, `"ghost_name"` + */ + readonly filter: + | "ghost" + | "rail" + | "rail-signal" + | "rolling-stock" + | "robot-with-logistics-interface" + | "vehicle" + | "turret" + | "crafting-machine" + | "wall-connectable" + | "transport-belt-connectable" + | "circuit-network-connectable" + | "type" + | "name" + | "ghost_type" + | "ghost_name" + /** + * How to combine this with the previous filter. Must be `"or"` or `"and"`. Defaults to `"or"`. When evaluating the + * filters, `"and"` has higher precedence than `"or"`. + */ + readonly mode?: "or" | "and" + /** Inverts the condition. Default is `false`. */ + readonly invert?: boolean +} + +interface TypeScriptRaisedBuiltEventFilter extends BaseScriptRaisedBuiltEventFilter { + readonly filter: "type" + /** The prototype type */ + readonly type: string +} + +interface NameScriptRaisedBuiltEventFilter extends BaseScriptRaisedBuiltEventFilter { + readonly filter: "name" + /** The prototype name */ + readonly name: string +} + +interface GhostTypeScriptRaisedBuiltEventFilter extends BaseScriptRaisedBuiltEventFilter { + readonly filter: "ghost_type" + /** The ghost prototype type */ + readonly type: string +} + +interface GhostNameScriptRaisedBuiltEventFilter extends BaseScriptRaisedBuiltEventFilter { + readonly filter: "ghost_name" + /** The ghost prototype name */ + readonly name: string +} + +interface OtherScriptRaisedBuiltEventFilter extends BaseScriptRaisedBuiltEventFilter { + readonly filter: + | "ghost" + | "rail" + | "rail-signal" + | "rolling-stock" + | "robot-with-logistics-interface" + | "vehicle" + | "turret" + | "crafting-machine" + | "wall-connectable" + | "transport-belt-connectable" + | "circuit-network-connectable" +} + +/** + * Other attributes may be specified depending on `filter`: + * + * {@link https://lua-api.factorio.com/next/Concepts.html#LuaScriptRaisedBuiltEventFilter View documentation} + */ +type LuaScriptRaisedBuiltEventFilter = + | TypeScriptRaisedBuiltEventFilter + | NameScriptRaisedBuiltEventFilter + | GhostTypeScriptRaisedBuiltEventFilter + | GhostNameScriptRaisedBuiltEventFilter + | OtherScriptRaisedBuiltEventFilter + +interface BaseRobotMinedEntityEventFilter { + /** + * The condition to filter on. One of `"ghost"`, `"rail"`, `"rail-signal"`, `"rolling-stock"`, + * `"robot-with-logistics-interface"`, `"vehicle"`, `"turret"`, `"crafting-machine"`, `"wall-connectable"`, + * `"transport-belt-connectable"`, `"circuit-network-connectable"`, `"type"`, `"name"`, `"ghost_type"`, `"ghost_name"` + */ + readonly filter: + | "ghost" + | "rail" + | "rail-signal" + | "rolling-stock" + | "robot-with-logistics-interface" + | "vehicle" + | "turret" + | "crafting-machine" + | "wall-connectable" + | "transport-belt-connectable" + | "circuit-network-connectable" + | "type" + | "name" + | "ghost_type" + | "ghost_name" + /** + * How to combine this with the previous filter. Must be `"or"` or `"and"`. Defaults to `"or"`. When evaluating the + * filters, `"and"` has higher precedence than `"or"`. + */ + readonly mode?: "or" | "and" + /** Inverts the condition. Default is `false`. */ + readonly invert?: boolean +} + +interface TypeRobotMinedEntityEventFilter extends BaseRobotMinedEntityEventFilter { + readonly filter: "type" + /** The prototype type */ + readonly type: string +} + +interface NameRobotMinedEntityEventFilter extends BaseRobotMinedEntityEventFilter { + readonly filter: "name" + /** The prototype name */ + readonly name: string +} + +interface GhostTypeRobotMinedEntityEventFilter extends BaseRobotMinedEntityEventFilter { + readonly filter: "ghost_type" + /** The ghost prototype type */ + readonly type: string +} + +interface GhostNameRobotMinedEntityEventFilter extends BaseRobotMinedEntityEventFilter { + readonly filter: "ghost_name" + /** The ghost prototype name */ + readonly name: string +} + +interface OtherRobotMinedEntityEventFilter extends BaseRobotMinedEntityEventFilter { + readonly filter: + | "ghost" + | "rail" + | "rail-signal" + | "rolling-stock" + | "robot-with-logistics-interface" + | "vehicle" + | "turret" + | "crafting-machine" + | "wall-connectable" + | "transport-belt-connectable" + | "circuit-network-connectable" +} + +/** + * Other attributes may be specified depending on `filter`: + * + * {@link https://lua-api.factorio.com/next/Concepts.html#LuaRobotMinedEntityEventFilter View documentation} + */ +type LuaRobotMinedEntityEventFilter = + | TypeRobotMinedEntityEventFilter + | NameRobotMinedEntityEventFilter + | GhostTypeRobotMinedEntityEventFilter + | GhostNameRobotMinedEntityEventFilter + | OtherRobotMinedEntityEventFilter + +interface BasePrePlayerMinedEntityEventFilter { + /** + * The condition to filter on. One of `"ghost"`, `"rail"`, `"rail-signal"`, `"rolling-stock"`, + * `"robot-with-logistics-interface"`, `"vehicle"`, `"turret"`, `"crafting-machine"`, `"wall-connectable"`, + * `"transport-belt-connectable"`, `"circuit-network-connectable"`, `"type"`, `"name"`, `"ghost_type"`, `"ghost_name"` + */ + readonly filter: + | "ghost" + | "rail" + | "rail-signal" + | "rolling-stock" + | "robot-with-logistics-interface" + | "vehicle" + | "turret" + | "crafting-machine" + | "wall-connectable" + | "transport-belt-connectable" + | "circuit-network-connectable" + | "type" + | "name" + | "ghost_type" + | "ghost_name" + /** + * How to combine this with the previous filter. Must be `"or"` or `"and"`. Defaults to `"or"`. When evaluating the + * filters, `"and"` has higher precedence than `"or"`. + */ + readonly mode?: "or" | "and" + /** Inverts the condition. Default is `false`. */ + readonly invert?: boolean +} + +interface TypePrePlayerMinedEntityEventFilter extends BasePrePlayerMinedEntityEventFilter { + readonly filter: "type" + /** The prototype type */ + readonly type: string +} + +interface NamePrePlayerMinedEntityEventFilter extends BasePrePlayerMinedEntityEventFilter { + readonly filter: "name" + /** The prototype name */ + readonly name: string +} + +interface GhostTypePrePlayerMinedEntityEventFilter extends BasePrePlayerMinedEntityEventFilter { + readonly filter: "ghost_type" + /** The ghost prototype type */ + readonly type: string +} + +interface GhostNamePrePlayerMinedEntityEventFilter extends BasePrePlayerMinedEntityEventFilter { + readonly filter: "ghost_name" + /** The ghost prototype name */ + readonly name: string +} + +interface OtherPrePlayerMinedEntityEventFilter extends BasePrePlayerMinedEntityEventFilter { + readonly filter: + | "ghost" + | "rail" + | "rail-signal" + | "rolling-stock" + | "robot-with-logistics-interface" + | "vehicle" + | "turret" + | "crafting-machine" + | "wall-connectable" + | "transport-belt-connectable" + | "circuit-network-connectable" +} + +/** + * Other attributes may be specified depending on `filter`: + * + * {@link https://lua-api.factorio.com/next/Concepts.html#LuaPrePlayerMinedEntityEventFilter View documentation} + */ +type LuaPrePlayerMinedEntityEventFilter = + | TypePrePlayerMinedEntityEventFilter + | NamePrePlayerMinedEntityEventFilter + | GhostTypePrePlayerMinedEntityEventFilter + | GhostNamePrePlayerMinedEntityEventFilter + | OtherPrePlayerMinedEntityEventFilter + +interface BaseRobotBuiltEntityEventFilter { + /** + * The condition to filter on. One of `"ghost"`, `"rail"`, `"rail-signal"`, `"rolling-stock"`, + * `"robot-with-logistics-interface"`, `"vehicle"`, `"turret"`, `"crafting-machine"`, `"wall-connectable"`, + * `"transport-belt-connectable"`, `"circuit-network-connectable"`, `"type"`, `"name"`, `"ghost_type"`, + * `"ghost_name"`, `"force"` + */ + readonly filter: + | "ghost" + | "rail" + | "rail-signal" + | "rolling-stock" + | "robot-with-logistics-interface" + | "vehicle" + | "turret" + | "crafting-machine" + | "wall-connectable" + | "transport-belt-connectable" + | "circuit-network-connectable" + | "type" + | "name" + | "ghost_type" + | "ghost_name" + | "force" + /** + * How to combine this with the previous filter. Must be `"or"` or `"and"`. Defaults to `"or"`. When evaluating the + * filters, `"and"` has higher precedence than `"or"`. + */ + readonly mode?: "or" | "and" + /** Inverts the condition. Default is `false`. */ + readonly invert?: boolean +} + +interface TypeRobotBuiltEntityEventFilter extends BaseRobotBuiltEntityEventFilter { + readonly filter: "type" + /** The prototype type */ + readonly type: string +} + +interface NameRobotBuiltEntityEventFilter extends BaseRobotBuiltEntityEventFilter { + readonly filter: "name" + /** The prototype name */ + readonly name: string +} + +interface GhostTypeRobotBuiltEntityEventFilter extends BaseRobotBuiltEntityEventFilter { + readonly filter: "ghost_type" + /** The ghost prototype type */ + readonly type: string +} + +interface GhostNameRobotBuiltEntityEventFilter extends BaseRobotBuiltEntityEventFilter { + readonly filter: "ghost_name" + /** The ghost prototype name */ + readonly name: string +} + +interface ForceRobotBuiltEntityEventFilter extends BaseRobotBuiltEntityEventFilter { + readonly filter: "force" + /** The entity force */ + readonly force: string +} + +interface OtherRobotBuiltEntityEventFilter extends BaseRobotBuiltEntityEventFilter { + readonly filter: + | "ghost" + | "rail" + | "rail-signal" + | "rolling-stock" + | "robot-with-logistics-interface" + | "vehicle" + | "turret" + | "crafting-machine" + | "wall-connectable" + | "transport-belt-connectable" + | "circuit-network-connectable" +} + +/** + * Other attributes may be specified depending on `filter`: + * + * {@link https://lua-api.factorio.com/next/Concepts.html#LuaRobotBuiltEntityEventFilter View documentation} + */ +type LuaRobotBuiltEntityEventFilter = + | TypeRobotBuiltEntityEventFilter + | NameRobotBuiltEntityEventFilter + | GhostTypeRobotBuiltEntityEventFilter + | GhostNameRobotBuiltEntityEventFilter + | ForceRobotBuiltEntityEventFilter + | OtherRobotBuiltEntityEventFilter + +interface BaseEntityDeconstructionCancelledEventFilter { + /** + * The condition to filter on. One of `"ghost"`, `"rail"`, `"rail-signal"`, `"rolling-stock"`, + * `"robot-with-logistics-interface"`, `"vehicle"`, `"turret"`, `"crafting-machine"`, `"wall-connectable"`, + * `"transport-belt-connectable"`, `"circuit-network-connectable"`, `"type"`, `"name"`, `"ghost_type"`, `"ghost_name"` + */ + readonly filter: + | "ghost" + | "rail" + | "rail-signal" + | "rolling-stock" + | "robot-with-logistics-interface" + | "vehicle" + | "turret" + | "crafting-machine" + | "wall-connectable" + | "transport-belt-connectable" + | "circuit-network-connectable" + | "type" + | "name" + | "ghost_type" + | "ghost_name" + /** + * How to combine this with the previous filter. Must be `"or"` or `"and"`. Defaults to `"or"`. When evaluating the + * filters, `"and"` has higher precedence than `"or"`. + */ + readonly mode?: "or" | "and" + /** Inverts the condition. Default is `false`. */ + readonly invert?: boolean +} + +interface TypeEntityDeconstructionCancelledEventFilter extends BaseEntityDeconstructionCancelledEventFilter { + readonly filter: "type" + /** The prototype type */ + readonly type: string +} + +interface NameEntityDeconstructionCancelledEventFilter extends BaseEntityDeconstructionCancelledEventFilter { + readonly filter: "name" + /** The prototype name */ + readonly name: string +} + +interface GhostTypeEntityDeconstructionCancelledEventFilter extends BaseEntityDeconstructionCancelledEventFilter { + readonly filter: "ghost_type" + /** The ghost prototype type */ + readonly type: string +} + +interface GhostNameEntityDeconstructionCancelledEventFilter extends BaseEntityDeconstructionCancelledEventFilter { + readonly filter: "ghost_name" + /** The ghost prototype name */ + readonly name: string +} + +interface OtherEntityDeconstructionCancelledEventFilter extends BaseEntityDeconstructionCancelledEventFilter { + readonly filter: + | "ghost" + | "rail" + | "rail-signal" + | "rolling-stock" + | "robot-with-logistics-interface" + | "vehicle" + | "turret" + | "crafting-machine" + | "wall-connectable" + | "transport-belt-connectable" + | "circuit-network-connectable" +} + +/** + * Other attributes may be specified depending on `filter`: + * + * {@link https://lua-api.factorio.com/next/Concepts.html#LuaEntityDeconstructionCancelledEventFilter View documentation} + */ +type LuaEntityDeconstructionCancelledEventFilter = + | TypeEntityDeconstructionCancelledEventFilter + | NameEntityDeconstructionCancelledEventFilter + | GhostTypeEntityDeconstructionCancelledEventFilter + | GhostNameEntityDeconstructionCancelledEventFilter + | OtherEntityDeconstructionCancelledEventFilter + +interface BasePlayerBuiltEntityEventFilter { + /** + * The condition to filter on. One of `"ghost"`, `"rail"`, `"rail-signal"`, `"rolling-stock"`, + * `"robot-with-logistics-interface"`, `"vehicle"`, `"turret"`, `"crafting-machine"`, `"wall-connectable"`, + * `"transport-belt-connectable"`, `"circuit-network-connectable"`, `"type"`, `"name"`, `"ghost_type"`, + * `"ghost_name"`, `"force"` + */ + readonly filter: + | "ghost" + | "rail" + | "rail-signal" + | "rolling-stock" + | "robot-with-logistics-interface" + | "vehicle" + | "turret" + | "crafting-machine" + | "wall-connectable" + | "transport-belt-connectable" + | "circuit-network-connectable" + | "type" + | "name" + | "ghost_type" + | "ghost_name" + | "force" + /** + * How to combine this with the previous filter. Must be `"or"` or `"and"`. Defaults to `"or"`. When evaluating the + * filters, `"and"` has higher precedence than `"or"`. + */ + readonly mode?: "or" | "and" + /** Inverts the condition. Default is `false`. */ + readonly invert?: boolean +} + +interface TypePlayerBuiltEntityEventFilter extends BasePlayerBuiltEntityEventFilter { + readonly filter: "type" + /** The prototype type */ + readonly type: string +} + +interface NamePlayerBuiltEntityEventFilter extends BasePlayerBuiltEntityEventFilter { + readonly filter: "name" + /** The prototype name */ + readonly name: string +} + +interface GhostTypePlayerBuiltEntityEventFilter extends BasePlayerBuiltEntityEventFilter { + readonly filter: "ghost_type" + /** The ghost prototype type */ + readonly type: string +} + +interface GhostNamePlayerBuiltEntityEventFilter extends BasePlayerBuiltEntityEventFilter { + readonly filter: "ghost_name" + /** The ghost prototype name */ + readonly name: string +} + +interface ForcePlayerBuiltEntityEventFilter extends BasePlayerBuiltEntityEventFilter { + readonly filter: "force" + /** The entity force */ + readonly force: string +} + +interface OtherPlayerBuiltEntityEventFilter extends BasePlayerBuiltEntityEventFilter { + readonly filter: + | "ghost" + | "rail" + | "rail-signal" + | "rolling-stock" + | "robot-with-logistics-interface" + | "vehicle" + | "turret" + | "crafting-machine" + | "wall-connectable" + | "transport-belt-connectable" + | "circuit-network-connectable" +} + +/** + * Other attributes may be specified depending on `filter`: + * + * {@link https://lua-api.factorio.com/next/Concepts.html#LuaPlayerBuiltEntityEventFilter View documentation} + */ +type LuaPlayerBuiltEntityEventFilter = + | TypePlayerBuiltEntityEventFilter + | NamePlayerBuiltEntityEventFilter + | GhostTypePlayerBuiltEntityEventFilter + | GhostNamePlayerBuiltEntityEventFilter + | ForcePlayerBuiltEntityEventFilter + | OtherPlayerBuiltEntityEventFilter + +interface BasePlayerMinedEntityEventFilter { + /** + * The condition to filter on. One of `"ghost"`, `"rail"`, `"rail-signal"`, `"rolling-stock"`, + * `"robot-with-logistics-interface"`, `"vehicle"`, `"turret"`, `"crafting-machine"`, `"wall-connectable"`, + * `"transport-belt-connectable"`, `"circuit-network-connectable"`, `"type"`, `"name"`, `"ghost_type"`, `"ghost_name"` + */ + readonly filter: + | "ghost" + | "rail" + | "rail-signal" + | "rolling-stock" + | "robot-with-logistics-interface" + | "vehicle" + | "turret" + | "crafting-machine" + | "wall-connectable" + | "transport-belt-connectable" + | "circuit-network-connectable" + | "type" + | "name" + | "ghost_type" + | "ghost_name" + /** + * How to combine this with the previous filter. Must be `"or"` or `"and"`. Defaults to `"or"`. When evaluating the + * filters, `"and"` has higher precedence than `"or"`. + */ + readonly mode?: "or" | "and" + /** Inverts the condition. Default is `false`. */ + readonly invert?: boolean +} + +interface TypePlayerMinedEntityEventFilter extends BasePlayerMinedEntityEventFilter { + readonly filter: "type" + /** The prototype type */ + readonly type: string +} + +interface NamePlayerMinedEntityEventFilter extends BasePlayerMinedEntityEventFilter { + readonly filter: "name" + /** The prototype name */ + readonly name: string +} + +interface GhostTypePlayerMinedEntityEventFilter extends BasePlayerMinedEntityEventFilter { + readonly filter: "ghost_type" + /** The ghost prototype type */ + readonly type: string +} + +interface GhostNamePlayerMinedEntityEventFilter extends BasePlayerMinedEntityEventFilter { + readonly filter: "ghost_name" + /** The ghost prototype name */ + readonly name: string +} + +interface OtherPlayerMinedEntityEventFilter extends BasePlayerMinedEntityEventFilter { + readonly filter: + | "ghost" + | "rail" + | "rail-signal" + | "rolling-stock" + | "robot-with-logistics-interface" + | "vehicle" + | "turret" + | "crafting-machine" + | "wall-connectable" + | "transport-belt-connectable" + | "circuit-network-connectable" +} + +/** + * Other attributes may be specified depending on `filter`: + * + * {@link https://lua-api.factorio.com/next/Concepts.html#LuaPlayerMinedEntityEventFilter View documentation} + */ +type LuaPlayerMinedEntityEventFilter = + | TypePlayerMinedEntityEventFilter + | NamePlayerMinedEntityEventFilter + | GhostTypePlayerMinedEntityEventFilter + | GhostNamePlayerMinedEntityEventFilter + | OtherPlayerMinedEntityEventFilter + +interface BaseEntityDamagedEventFilter { + /** + * The condition to filter on. One of `"ghost"`, `"rail"`, `"rail-signal"`, `"rolling-stock"`, + * `"robot-with-logistics-interface"`, `"vehicle"`, `"turret"`, `"crafting-machine"`, `"wall-connectable"`, + * `"transport-belt-connectable"`, `"circuit-network-connectable"`, `"type"`, `"name"`, `"ghost_type"`, + * `"ghost_name"`, `"original-damage-amount"`, `"final-damage-amount"`, `"damage-type"`, `"final-health"` + */ + readonly filter: + | "ghost" + | "rail" + | "rail-signal" + | "rolling-stock" + | "robot-with-logistics-interface" + | "vehicle" + | "turret" + | "crafting-machine" + | "wall-connectable" + | "transport-belt-connectable" + | "circuit-network-connectable" + | "type" + | "name" + | "ghost_type" + | "ghost_name" + | "original-damage-amount" + | "final-damage-amount" + | "damage-type" + | "final-health" + /** + * How to combine this with the previous filter. Must be `"or"` or `"and"`. Defaults to `"or"`. When evaluating the + * filters, `"and"` has higher precedence than `"or"`. + */ + readonly mode?: "or" | "and" + /** Inverts the condition. Default is `false`. */ + readonly invert?: boolean +} + +interface TypeEntityDamagedEventFilter extends BaseEntityDamagedEventFilter { + readonly filter: "type" + /** The prototype type */ + readonly type: string +} + +interface NameEntityDamagedEventFilter extends BaseEntityDamagedEventFilter { + readonly filter: "name" + /** The prototype name */ + readonly name: string +} + +interface GhostTypeEntityDamagedEventFilter extends BaseEntityDamagedEventFilter { + readonly filter: "ghost_type" + /** The ghost prototype type */ + readonly type: string +} + +interface GhostNameEntityDamagedEventFilter extends BaseEntityDamagedEventFilter { + readonly filter: "ghost_name" + /** The ghost prototype name */ + readonly name: string +} + +interface OriginalDamageAmountEntityDamagedEventFilter extends BaseEntityDamagedEventFilter { + readonly filter: "original-damage-amount" + readonly comparison: ComparatorString + /** The value to compare against. */ + readonly value: float +} + +interface FinalDamageAmountEntityDamagedEventFilter extends BaseEntityDamagedEventFilter { + readonly filter: "final-damage-amount" + readonly comparison: ComparatorString + /** The value to compare against. */ + readonly value: float +} + +interface DamageTypeEntityDamagedEventFilter extends BaseEntityDamagedEventFilter { + readonly filter: "damage-type" + /** A {@link LuaDamagePrototype} name */ + readonly type: string +} + +interface FinalHealthEntityDamagedEventFilter extends BaseEntityDamagedEventFilter { + readonly filter: "final-health" + readonly comparison: ComparatorString + /** The value to compare against. */ + readonly value: float +} + +interface OtherEntityDamagedEventFilter extends BaseEntityDamagedEventFilter { + readonly filter: + | "ghost" + | "rail" + | "rail-signal" + | "rolling-stock" + | "robot-with-logistics-interface" + | "vehicle" + | "turret" + | "crafting-machine" + | "wall-connectable" + | "transport-belt-connectable" + | "circuit-network-connectable" +} + +/** + * Other attributes may be specified depending on `filter`: + * + * {@link https://lua-api.factorio.com/next/Concepts.html#LuaEntityDamagedEventFilter View documentation} + */ +type LuaEntityDamagedEventFilter = + | TypeEntityDamagedEventFilter + | NameEntityDamagedEventFilter + | GhostTypeEntityDamagedEventFilter + | GhostNameEntityDamagedEventFilter + | OriginalDamageAmountEntityDamagedEventFilter + | FinalDamageAmountEntityDamagedEventFilter + | DamageTypeEntityDamagedEventFilter + | FinalHealthEntityDamagedEventFilter + | OtherEntityDamagedEventFilter + +interface BaseSectorScannedEventFilter { + /** + * The condition to filter on. One of `"ghost"`, `"rail"`, `"rail-signal"`, `"rolling-stock"`, + * `"robot-with-logistics-interface"`, `"vehicle"`, `"turret"`, `"crafting-machine"`, `"wall-connectable"`, + * `"transport-belt-connectable"`, `"circuit-network-connectable"`, `"type"`, `"name"`, `"ghost_type"`, `"ghost_name"` + */ + readonly filter: + | "ghost" + | "rail" + | "rail-signal" + | "rolling-stock" + | "robot-with-logistics-interface" + | "vehicle" + | "turret" + | "crafting-machine" + | "wall-connectable" + | "transport-belt-connectable" + | "circuit-network-connectable" + | "type" + | "name" + | "ghost_type" + | "ghost_name" + /** + * How to combine this with the previous filter. Must be `"or"` or `"and"`. Defaults to `"or"`. When evaluating the + * filters, `"and"` has higher precedence than `"or"`. + */ + readonly mode?: "or" | "and" + /** Inverts the condition. Default is `false`. */ + readonly invert?: boolean +} + +interface TypeSectorScannedEventFilter extends BaseSectorScannedEventFilter { + readonly filter: "type" + /** The prototype type */ + readonly type: string +} + +interface NameSectorScannedEventFilter extends BaseSectorScannedEventFilter { + readonly filter: "name" + /** The prototype name */ + readonly name: string +} + +interface GhostTypeSectorScannedEventFilter extends BaseSectorScannedEventFilter { + readonly filter: "ghost_type" + /** The ghost prototype type */ + readonly type: string +} + +interface GhostNameSectorScannedEventFilter extends BaseSectorScannedEventFilter { + readonly filter: "ghost_name" + /** The ghost prototype name */ + readonly name: string +} + +interface OtherSectorScannedEventFilter extends BaseSectorScannedEventFilter { + readonly filter: + | "ghost" + | "rail" + | "rail-signal" + | "rolling-stock" + | "robot-with-logistics-interface" + | "vehicle" + | "turret" + | "crafting-machine" + | "wall-connectable" + | "transport-belt-connectable" + | "circuit-network-connectable" +} + +/** + * Other attributes may be specified depending on `filter`: + * + * {@link https://lua-api.factorio.com/next/Concepts.html#LuaSectorScannedEventFilter View documentation} + */ +type LuaSectorScannedEventFilter = + | TypeSectorScannedEventFilter + | NameSectorScannedEventFilter + | GhostTypeSectorScannedEventFilter + | GhostNameSectorScannedEventFilter + | OtherSectorScannedEventFilter + +/** + * A map gen preset. Used in {@link https://wiki.factorio.com/Prototype/MapGenPresets Prototype/MapGenPresets}. + * + * {@link https://wiki.factorio.com/Types/MapGenPreset View Documentation} + */ +interface MapGenPreset { + /** Specifies the ordering the map generator gui. */ + order: string + /** + * Whether this is the default preset. If set to boolean, this preset may not have any other properties besides this + * and order. + */ + default?: boolean + /** + * This is a table with the below key/value pairs. All key/value pairs are optional. If not set they will just use + * the default values. + */ + basic_settings: Partial + /** + * This is a table with the below key/value pairs. All key/value pairs are optional, if not set they will just use + * the existing values. + */ + readonly advanced_settings: { + readonly pollution?: { + enabled?: boolean + /** Must be <= 0.25. */ + diffusion_ratio?: double + /** Also known as dissipation rate. Must be >= 0.5. */ + ageing?: double + enemy_attack_pollution_consumption_modifier?: double + min_pollution_to_damage_trees?: double + pollution_restored_per_tree_damage?: double + } + readonly enemy_evolution?: { + enabled?: boolean + time_factor?: double + destroy_factor?: double + pollution_factor?: double + } + readonly enemy_expansion?: { + enabled?: boolean + max_expansion_distance?: double + settler_group_min_size?: double + settler_group_max_size?: double + /** In ticks. */ + min_expansion_cooldown?: double + /** In ticks. */ + max_expansion_cooldown?: double + } + readonly difficulty_settings?: { + recipe_difficulty?: defines.difficulty_settings.recipe_difficulty + technology_difficulty?: defines.difficulty_settings.technology_difficulty + technology_price_multiplier?: double + research_queue_setting?: "after-victory" | "always" | "never" + } + } +} + +interface BlueprintControlBehavior { + readonly condition?: CircuitCondition + readonly circuit_condition?: CircuitCondition + readonly filters?: Signal[] + readonly is_on?: boolean + readonly arithmetic_conditions?: ArithmeticCombinatorParameters + readonly decider_conditions?: DeciderCombinatorParameters + readonly circuit_enable_disable?: boolean + readonly circuit_read_resources?: boolean + readonly circuit_resource_read_mode?: defines.control_behavior.mining_drill.resource_read_mode + readonly read_stopped_train?: boolean + readonly train_stopped_signal?: SignalID + readonly read_from_train?: boolean + readonly send_to_train?: boolean + readonly circuit_mode_of_operation?: number + readonly circuit_read_hand_contents?: boolean + readonly circuit_hand_read_mode?: defines.control_behavior.inserter.hand_read_mode + readonly circuit_set_stack_size?: boolean + readonly stack_control_input_signal?: SignalID + readonly use_colors?: boolean + readonly read_robot_stats?: boolean + readonly read_logistics?: boolean + readonly available_logistic_output_signal?: boolean + readonly total_logistic_output_signal?: boolean + readonly available_construction_output_signal?: boolean + readonly total_construction_output_signal?: boolean + readonly circuit_contents_read_mode?: defines.control_behavior.transport_belt.content_read_mode + readonly output_signal?: SignalID + readonly circuit_close_signal?: boolean + readonly circuit_read_signal?: boolean + readonly red_output_signal?: SignalID + readonly orange_output_signal?: SignalID + readonly green_output_signal?: SignalID + readonly blue_output_signal?: SignalID + readonly circuit_open_gate?: boolean + readonly circuit_read_sensor?: boolean + readonly circuit_parameters?: ProgrammableSpeakerCircuitParameters +} diff --git a/modules/mod2/typed-factorio/generated/defines.d.ts b/modules/mod2/typed-factorio/generated/defines.d.ts new file mode 100644 index 0000000..db30ab0 --- /dev/null +++ b/modules/mod2/typed-factorio/generated/defines.d.ts @@ -0,0 +1,1642 @@ +/** @noSelfInFile */ + +declare namespace defines { + enum alert_type { + entity_destroyed, + entity_under_attack, + not_enough_construction_robots, + no_material_for_construction, + not_enough_repair_packs, + turret_fire, + custom, + no_storage, + train_out_of_fuel, + } + /** + * AI command exit status. See {@link LuaEntity.set_command LuaEntity::set_command} + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.behavior_result View documentation} + */ + enum behavior_result { + in_progress, + fail, + success, + deleted, + } + enum build_check_type { + script, + manual, + manual_ghost, + script_ghost, + blueprint_ghost, + ghost_revive, + } + /** + * State of a chain signal. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.chain_signal_state View documentation} + */ + enum chain_signal_state { + none, + all_open, + partially_open, + none_open, + } + enum chunk_generated_status { + nothing, + custom_tiles, + basic_tiles, + corrected_tiles, + tiles, + entities, + } + enum circuit_condition_index { + inserter_circuit, + inserter_logistic, + lamp, + arithmetic_combinator, + decider_combinator, + constant_combinator, + offshore_pump, + pump, + } + enum circuit_connector_id { + accumulator, + constant_combinator, + container, + programmable_speaker, + rail_signal, + rail_chain_signal, + roboport, + storage_tank, + wall, + electric_pole, + inserter, + lamp, + combinator_input, + combinator_output, + offshore_pump, + pump, + } + /** + * Command given to units describing what they should do. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.command View documentation} + */ + enum command { + /** + * Attack another entity. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.command.attack View documentation} + */ + attack = 0, + /** + * Go to a specific position. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.command.go_to_location View documentation} + */ + go_to_location = 1, + /** + * Chain commands together, see {@link defines.compound_command}. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.command.compound View documentation} + */ + compound = 2, + /** + * Do what your group wants you to do. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.command.group View documentation} + */ + group = 3, + /** + * Go to a place and attack what you see. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.command.attack_area View documentation} + */ + attack_area = 4, + /** + * Chill. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.command.wander View documentation} + */ + wander = 5, + /** + * Flee from another entity. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.command.flee View documentation} + */ + flee = 6, + /** + * Stop moving and stay where you are. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.command.stop View documentation} + */ + stop = 7, + /** + * Go to a position and build a base there. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.command.build_base View documentation} + */ + build_base = 8, + } + /** + * How commands are joined together in a compound command (see {@link defines.command.compound}). + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.compound_command View documentation} + */ + enum compound_command { + /** + * Fail on first failure. Only succeeds if all commands (executed one after another) succeed. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.compound_command.logical_and View documentation} + */ + logical_and, + /** + * Succeed on first success. Only fails if all commands (executed one after another) fail. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.compound_command.logical_or View documentation} + */ + logical_or, + /** + * Execute all commands in sequence and fail or succeed depending on the return status of the last command. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.compound_command.return_last View documentation} + */ + return_last, + } + namespace control_behavior { + namespace inserter { + enum circuit_mode_of_operation { + none, + enable_disable, + set_filters, + read_hand_contents, + set_stack_size, + } + enum hand_read_mode { + hold, + pulse, + } + } + namespace logistic_container { + enum circuit_mode_of_operation { + send_contents, + set_requests, + } + } + namespace lamp { + enum circuit_mode_of_operation { + use_colors, + } + } + namespace mining_drill { + enum resource_read_mode { + this_miner, + entire_patch, + } + } + namespace transport_belt { + enum content_read_mode { + pulse, + hold, + } + } + enum type { + /** + * {@link LuaContainerControlBehavior} + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.control_behavior.type.container View documentation} + */ + container, + /** + * {@link LuaGenericOnOffControlBehavior} + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.control_behavior.type.generic_on_off View documentation} + */ + generic_on_off, + /** + * {@link LuaInserterControlBehavior} + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.control_behavior.type.inserter View documentation} + */ + inserter, + /** + * {@link LuaLampControlBehavior} + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.control_behavior.type.lamp View documentation} + */ + lamp, + /** + * {@link LuaLogisticContainerControlBehavior} + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.control_behavior.type.logistic_container View documentation} + */ + logistic_container, + /** + * {@link LuaRoboportControlBehavior} + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.control_behavior.type.roboport View documentation} + */ + roboport, + /** + * {@link LuaStorageTankControlBehavior} + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.control_behavior.type.storage_tank View documentation} + */ + storage_tank, + /** + * {@link LuaTrainStopControlBehavior} + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.control_behavior.type.train_stop View documentation} + */ + train_stop, + /** + * {@link LuaDeciderCombinatorControlBehavior} + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.control_behavior.type.decider_combinator View documentation} + */ + decider_combinator, + /** + * {@link LuaArithmeticCombinatorControlBehavior} + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.control_behavior.type.arithmetic_combinator View documentation} + */ + arithmetic_combinator, + /** + * {@link LuaConstantCombinatorControlBehavior} + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.control_behavior.type.constant_combinator View documentation} + */ + constant_combinator, + /** + * {@link LuaTransportBeltControlBehavior} + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.control_behavior.type.transport_belt View documentation} + */ + transport_belt, + /** + * {@link LuaAccumulatorControlBehavior} + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.control_behavior.type.accumulator View documentation} + */ + accumulator, + /** + * {@link LuaRailSignalControlBehavior} + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.control_behavior.type.rail_signal View documentation} + */ + rail_signal, + /** + * {@link LuaRailChainSignalControlBehavior} + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.control_behavior.type.rail_chain_signal View documentation} + */ + rail_chain_signal, + /** + * {@link LuaWallControlBehavior} + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.control_behavior.type.wall View documentation} + */ + wall, + /** + * {@link LuaMiningDrillControlBehavior} + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.control_behavior.type.mining_drill View documentation} + */ + mining_drill, + /** + * {@link LuaProgrammableSpeakerControlBehavior} + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.control_behavior.type.programmable_speaker View documentation} + */ + programmable_speaker, + } + } + enum controllers { + /** + * Can't interact with the world, can only observe. Used in the multiplayer waiting-to-respawn screen. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.controllers.ghost View documentation} + */ + ghost, + /** + * The controller controls a character. This is the default controller in freeplay. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.controllers.character View documentation} + */ + character, + /** + * The controller isn't tied to a character. This is the default controller in sandbox. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.controllers.god View documentation} + */ + god, + /** + * The Editor Controller near ultimate power to do almost anything in the game. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.controllers.editor View documentation} + */ + editor, + /** + * The player can't interact with the world, and the camera pans around in a predefined manner. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.controllers.cutscene View documentation} + */ + cutscene, + /** + * Can't change anything in the world but can view anything. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.controllers.spectator View documentation} + */ + spectator, + } + namespace deconstruction_item { + enum entity_filter_mode { + whitelist, + blacklist, + } + enum tile_filter_mode { + whitelist, + blacklist, + } + enum tile_selection_mode { + normal, + always, + never, + only, + } + } + enum difficulty { + easy, + normal, + hard, + } + namespace difficulty_settings { + enum recipe_difficulty { + normal, + expensive, + } + enum technology_difficulty { + normal, + expensive, + } + } + enum direction { + north = 0, + northeast = 1, + east = 2, + southeast = 3, + south = 4, + southwest = 5, + west = 6, + northwest = 7, + } + enum disconnect_reason { + quit, + dropped, + reconnect, + wrong_input, + desync_limit_reached, + cannot_keep_up, + afk, + kicked, + kicked_and_deleted, + banned, + switching_servers, + } + enum distraction { + /** + * Perform command even if someone attacks the unit. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.distraction.none View documentation} + */ + none, + /** + * Attack closer enemy entities with force. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.distraction.by_enemy View documentation} + */ + by_enemy, + /** + * Attack closer enemy entities, including entities "built" by player (belts, inserters, chests). + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.distraction.by_anything View documentation} + */ + by_anything, + /** + * Attack when attacked. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.distraction.by_damage View documentation} + */ + by_damage, + } + enum entity_status { + working, + normal, + no_power, + low_power, + no_fuel, + disabled_by_control_behavior, + opened_by_circuit_network, + closed_by_circuit_network, + disabled_by_script, + marked_for_deconstruction, + /** + * Used by generators and solar panels. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.entity_status.not_plugged_in_electric_network View documentation} + */ + not_plugged_in_electric_network, + /** + * Used by power switches. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.entity_status.networks_connected View documentation} + */ + networks_connected, + /** + * Used by power switches. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.entity_status.networks_disconnected View documentation} + */ + networks_disconnected, + /** + * Used by accumulators. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.entity_status.charging View documentation} + */ + charging, + /** + * Used by accumulators. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.entity_status.discharging View documentation} + */ + discharging, + /** + * Used by accumulators. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.entity_status.fully_charged View documentation} + */ + fully_charged, + /** + * Used by logistic containers. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.entity_status.out_of_logistic_network View documentation} + */ + out_of_logistic_network, + /** + * Used by assembling machines. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.entity_status.no_recipe View documentation} + */ + no_recipe, + /** + * Used by furnaces. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.entity_status.no_ingredients View documentation} + */ + no_ingredients, + /** + * Used by boilers, fluid turrets and fluid energy sources: Boiler has no fluid to work with. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.entity_status.no_input_fluid View documentation} + */ + no_input_fluid, + /** + * Used by labs. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.entity_status.no_research_in_progress View documentation} + */ + no_research_in_progress, + /** + * Used by mining drills. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.entity_status.no_minable_resources View documentation} + */ + no_minable_resources, + /** + * Used by boilers and fluid turrets: Boiler still has some fluid but is about to run out. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.entity_status.low_input_fluid View documentation} + */ + low_input_fluid, + /** + * Used by crafting machines. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.entity_status.fluid_ingredient_shortage View documentation} + */ + fluid_ingredient_shortage, + /** + * Used by crafting machines, boilers, burner energy sources and reactors: Reactor/burner has full burnt result + * inventory, boiler has full output fluidbox. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.entity_status.full_output View documentation} + */ + full_output, + /** + * Used by crafting machines. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.entity_status.item_ingredient_shortage View documentation} + */ + item_ingredient_shortage, + /** + * Used by mining drills when the mining fluid is missing. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.entity_status.missing_required_fluid View documentation} + */ + missing_required_fluid, + /** + * Used by labs. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.entity_status.missing_science_packs View documentation} + */ + missing_science_packs, + /** + * Used by inserters. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.entity_status.waiting_for_source_items View documentation} + */ + waiting_for_source_items, + /** + * Used by inserters and mining drills. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.entity_status.waiting_for_space_in_destination View documentation} + */ + waiting_for_space_in_destination, + /** + * Used by the rocket silo. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.entity_status.preparing_rocket_for_launch View documentation} + */ + preparing_rocket_for_launch, + /** + * Used by the rocket silo. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.entity_status.waiting_to_launch_rocket View documentation} + */ + waiting_to_launch_rocket, + /** + * Used by the rocket silo. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.entity_status.launching_rocket View documentation} + */ + launching_rocket, + /** + * Used by beacons. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.entity_status.no_modules_to_transmit View documentation} + */ + no_modules_to_transmit, + /** + * Used by roboports. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.entity_status.recharging_after_power_outage View documentation} + */ + recharging_after_power_outage, + /** + * Used by inserters targeting entity ghosts. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.entity_status.waiting_for_target_to_be_built View documentation} + */ + waiting_for_target_to_be_built, + /** + * Used by inserters targeting rails. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.entity_status.waiting_for_train View documentation} + */ + waiting_for_train, + /** + * Used by ammo turrets. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.entity_status.no_ammo View documentation} + */ + no_ammo, + /** + * Used by heat energy sources. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.entity_status.low_temperature View documentation} + */ + low_temperature, + /** + * Used by constant combinators: Combinator is turned off via switch in GUI. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.entity_status.disabled View documentation} + */ + disabled, + /** + * Used by lamps. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.entity_status.turned_off_during_daytime View documentation} + */ + turned_off_during_daytime, + /** + * Used by rail signals. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.entity_status.not_connected_to_rail View documentation} + */ + not_connected_to_rail, + /** + * Used by rail signals. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.entity_status.cant_divide_segments View documentation} + */ + cant_divide_segments, + } + /** + * See the {@link https://lua-api.factorio.com/next/events.html events page} for more info on what events contain and + * when they get raised. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.events View documentation} + */ + namespace events { + /** Event type: {@link OnTickEvent} */ + const on_tick: EventId + /** Event type: {@link OnGuiClickEvent} */ + const on_gui_click: EventId + /** Event type: {@link OnGuiConfirmedEvent} */ + const on_gui_confirmed: EventId + /** Event type: {@link OnGuiTextChangedEvent} */ + const on_gui_text_changed: EventId + /** Event type: {@link OnGuiCheckedStateChangedEvent} */ + const on_gui_checked_state_changed: EventId + /** + * Event type: {@link OnEntityDiedEvent} + * + * Event filter: {@link LuaEntityDiedEventFilter} + */ + const on_entity_died: EventId + /** + * Event type: {@link OnPostEntityDiedEvent} + * + * Event filter: {@link LuaPostEntityDiedEventFilter} + */ + const on_post_entity_died: EventId + /** + * Event type: {@link OnEntityDamagedEvent} + * + * Event filter: {@link LuaEntityDamagedEventFilter} + */ + const on_entity_damaged: EventId + /** Event type: {@link OnPickedUpItemEvent} */ + const on_picked_up_item: EventId + /** + * Event type: {@link OnBuiltEntityEvent} + * + * Event filter: {@link LuaPlayerBuiltEntityEventFilter} + */ + const on_built_entity: EventId + /** + * Event type: {@link OnSectorScannedEvent} + * + * Event filter: {@link LuaSectorScannedEventFilter} + */ + const on_sector_scanned: EventId + /** Event type: {@link OnPlayerMinedItemEvent} */ + const on_player_mined_item: EventId + /** Event type: {@link OnPreBuildEvent} */ + const on_pre_build: EventId + /** Event type: {@link OnRocketLaunchedEvent} */ + const on_rocket_launched: EventId + /** + * Event type: {@link OnPrePlayerMinedItemEvent} + * + * Event filter: {@link LuaPrePlayerMinedEntityEventFilter} + */ + const on_pre_player_mined_item: EventId + /** Event type: {@link OnChunkGeneratedEvent} */ + const on_chunk_generated: EventId + /** Event type: {@link OnPlayerCraftedItemEvent} */ + const on_player_crafted_item: EventId + /** + * Event type: {@link OnRobotBuiltEntityEvent} + * + * Event filter: {@link LuaRobotBuiltEntityEventFilter} + */ + const on_robot_built_entity: EventId + /** + * Event type: {@link OnRobotPreMinedEvent} + * + * Event filter: {@link LuaPreRobotMinedEntityEventFilter} + */ + const on_robot_pre_mined: EventId + /** Event type: {@link OnRobotMinedEvent} */ + const on_robot_mined: EventId + /** Event type: {@link OnResearchStartedEvent} */ + const on_research_started: EventId + /** Event type: {@link OnResearchFinishedEvent} */ + const on_research_finished: EventId + /** Event type: {@link OnResearchReversedEvent} */ + const on_research_reversed: EventId + /** Event type: {@link OnPlayerRotatedEntityEvent} */ + const on_player_rotated_entity: EventId + /** + * Event type: {@link OnMarkedForDeconstructionEvent} + * + * Event filter: {@link LuaEntityMarkedForDeconstructionEventFilter} + */ + const on_marked_for_deconstruction: EventId< + OnMarkedForDeconstructionEvent, + LuaEntityMarkedForDeconstructionEventFilter + > + /** + * Event type: {@link OnCancelledDeconstructionEvent} + * + * Event filter: {@link LuaEntityDeconstructionCancelledEventFilter} + */ + const on_cancelled_deconstruction: EventId< + OnCancelledDeconstructionEvent, + LuaEntityDeconstructionCancelledEventFilter + > + /** Event type: {@link OnTriggerCreatedEntityEvent} */ + const on_trigger_created_entity: EventId + /** Event type: {@link OnTriggerFiredArtilleryEvent} */ + const on_trigger_fired_artillery: EventId + /** Event type: {@link OnTrainChangedStateEvent} */ + const on_train_changed_state: EventId + /** Event type: {@link OnPlayerCreatedEvent} */ + const on_player_created: EventId + /** Event type: {@link OnResourceDepletedEvent} */ + const on_resource_depleted: EventId + /** Event type: {@link OnPlayerDrivingChangedStateEvent} */ + const on_player_driving_changed_state: EventId + /** Event type: {@link OnForceCreatedEvent} */ + const on_force_created: EventId + /** Event type: {@link OnForcesMergingEvent} */ + const on_forces_merging: EventId + /** Event type: {@link OnPlayerCursorStackChangedEvent} */ + const on_player_cursor_stack_changed: EventId + /** Event type: {@link OnPreEntitySettingsPastedEvent} */ + const on_pre_entity_settings_pasted: EventId + /** Event type: {@link OnEntitySettingsPastedEvent} */ + const on_entity_settings_pasted: EventId + /** Event type: {@link OnPlayerMainInventoryChangedEvent} */ + const on_player_main_inventory_changed: EventId + /** Event type: {@link OnPlayerArmorInventoryChangedEvent} */ + const on_player_armor_inventory_changed: EventId + /** Event type: {@link OnPlayerAmmoInventoryChangedEvent} */ + const on_player_ammo_inventory_changed: EventId + /** Event type: {@link OnPlayerGunInventoryChangedEvent} */ + const on_player_gun_inventory_changed: EventId + /** Event type: {@link OnPlayerPlacedEquipmentEvent} */ + const on_player_placed_equipment: EventId + /** Event type: {@link OnPlayerRemovedEquipmentEvent} */ + const on_player_removed_equipment: EventId + /** Event type: {@link OnPrePlayerDiedEvent} */ + const on_pre_player_died: EventId + /** Event type: {@link OnPlayerDiedEvent} */ + const on_player_died: EventId + /** Event type: {@link OnPlayerRespawnedEvent} */ + const on_player_respawned: EventId + /** Event type: {@link OnPlayerJoinedGameEvent} */ + const on_player_joined_game: EventId + /** Event type: {@link OnPlayerLeftGameEvent} */ + const on_player_left_game: EventId + /** Event type: {@link OnPlayerBuiltTileEvent} */ + const on_player_built_tile: EventId + /** Event type: {@link OnPlayerMinedTileEvent} */ + const on_player_mined_tile: EventId + /** Event type: {@link OnRobotBuiltTileEvent} */ + const on_robot_built_tile: EventId + /** Event type: {@link OnRobotMinedTileEvent} */ + const on_robot_mined_tile: EventId + /** Event type: {@link OnPlayerSelectedAreaEvent} */ + const on_player_selected_area: EventId + /** Event type: {@link OnPlayerAltSelectedAreaEvent} */ + const on_player_alt_selected_area: EventId + /** Event type: {@link OnPlayerChangedSurfaceEvent} */ + const on_player_changed_surface: EventId + /** Event type: {@link OnSelectedEntityChangedEvent} */ + const on_selected_entity_changed: EventId + /** Event type: {@link OnMarketItemPurchasedEvent} */ + const on_market_item_purchased: EventId + /** Event type: {@link OnPlayerDroppedItemEvent} */ + const on_player_dropped_item: EventId + /** Event type: {@link OnBiterBaseBuiltEvent} */ + const on_biter_base_built: EventId + /** Event type: {@link OnPlayerChangedForceEvent} */ + const on_player_changed_force: EventId + /** Event type: {@link OnEntityRenamedEvent} */ + const on_entity_renamed: EventId + /** Event type: {@link OnGuiSelectionStateChangedEvent} */ + const on_gui_selection_state_changed: EventId + /** Event type: {@link OnRuntimeModSettingChangedEvent} */ + const on_runtime_mod_setting_changed: EventId + /** Event type: {@link OnDifficultySettingsChangedEvent} */ + const on_difficulty_settings_changed: EventId + /** Event type: {@link OnSurfaceCreatedEvent} */ + const on_surface_created: EventId + /** Event type: {@link OnSurfaceDeletedEvent} */ + const on_surface_deleted: EventId + /** Event type: {@link OnPreSurfaceDeletedEvent} */ + const on_pre_surface_deleted: EventId + /** + * Event type: {@link OnPlayerMinedEntityEvent} + * + * Event filter: {@link LuaPlayerMinedEntityEventFilter} + */ + const on_player_mined_entity: EventId + /** + * Event type: {@link OnRobotMinedEntityEvent} + * + * Event filter: {@link LuaRobotMinedEntityEventFilter} + */ + const on_robot_mined_entity: EventId + /** Event type: {@link OnTrainCreatedEvent} */ + const on_train_created: EventId + /** Event type: {@link OnGuiElemChangedEvent} */ + const on_gui_elem_changed: EventId + /** Event type: {@link OnPlayerSetupBlueprintEvent} */ + const on_player_setup_blueprint: EventId + /** Event type: {@link OnPlayerDeconstructedAreaEvent} */ + const on_player_deconstructed_area: EventId + /** Event type: {@link OnPlayerConfiguredBlueprintEvent} */ + const on_player_configured_blueprint: EventId + /** Event type: {@link OnConsoleChatEvent} */ + const on_console_chat: EventId + /** Event type: {@link OnConsoleCommandEvent} */ + const on_console_command: EventId + /** Event type: {@link OnPlayerRemovedEvent} */ + const on_player_removed: EventId + /** Event type: {@link OnPrePlayerRemovedEvent} */ + const on_pre_player_removed: EventId + /** Event type: {@link OnPlayerUsedCapsuleEvent} */ + const on_player_used_capsule: EventId + /** + * Event type: {@link ScriptRaisedBuiltEvent} + * + * Event filter: {@link LuaScriptRaisedBuiltEventFilter} + */ + const script_raised_built: EventId + /** + * Event type: {@link ScriptRaisedDestroyEvent} + * + * Event filter: {@link LuaScriptRaisedDestroyEventFilter} + */ + const script_raised_destroy: EventId + /** + * Event type: {@link ScriptRaisedReviveEvent} + * + * Event filter: {@link LuaScriptRaisedReviveEventFilter} + */ + const script_raised_revive: EventId + /** Event type: {@link ScriptRaisedSetTilesEvent} */ + const script_raised_set_tiles: EventId + /** Event type: {@link OnPlayerPromotedEvent} */ + const on_player_promoted: EventId + /** Event type: {@link OnPlayerDemotedEvent} */ + const on_player_demoted: EventId + /** Event type: {@link OnCombatRobotExpiredEvent} */ + const on_combat_robot_expired: EventId + /** Event type: {@link OnWorkerRobotExpiredEvent} */ + const on_worker_robot_expired: EventId + /** Event type: {@link OnPlayerChangedPositionEvent} */ + const on_player_changed_position: EventId + /** Event type: {@link OnModItemOpenedEvent} */ + const on_mod_item_opened: EventId + /** Event type: {@link OnGuiOpenedEvent} */ + const on_gui_opened: EventId + /** Event type: {@link OnGuiClosedEvent} */ + const on_gui_closed: EventId + /** Event type: {@link OnGuiValueChangedEvent} */ + const on_gui_value_changed: EventId + /** Event type: {@link OnPlayerMutedEvent} */ + const on_player_muted: EventId + /** Event type: {@link OnPlayerUnmutedEvent} */ + const on_player_unmuted: EventId + /** Event type: {@link OnPlayerCheatModeEnabledEvent} */ + const on_player_cheat_mode_enabled: EventId + /** Event type: {@link OnPlayerCheatModeDisabledEvent} */ + const on_player_cheat_mode_disabled: EventId + /** Event type: {@link OnCharacterCorpseExpiredEvent} */ + const on_character_corpse_expired: EventId + /** + * Event type: {@link OnPreGhostDeconstructedEvent} + * + * Event filter: {@link LuaPreGhostDeconstructedEventFilter} + */ + const on_pre_ghost_deconstructed: EventId + /** Event type: {@link OnPlayerPipetteEvent} */ + const on_player_pipette: EventId + /** Event type: {@link OnPlayerDisplayResolutionChangedEvent} */ + const on_player_display_resolution_changed: EventId + /** Event type: {@link OnPlayerDisplayScaleChangedEvent} */ + const on_player_display_scale_changed: EventId + /** Event type: {@link OnPrePlayerCraftedItemEvent} */ + const on_pre_player_crafted_item: EventId + /** Event type: {@link OnPlayerCancelledCraftingEvent} */ + const on_player_cancelled_crafting: EventId + /** Event type: {@link OnChunkChartedEvent} */ + const on_chunk_charted: EventId + /** Event type: {@link OnTechnologyEffectsResetEvent} */ + const on_technology_effects_reset: EventId + /** Event type: {@link OnForceResetEvent} */ + const on_force_reset: EventId + /** Event type: {@link OnLandMineArmedEvent} */ + const on_land_mine_armed: EventId + /** Event type: {@link OnForcesMergedEvent} */ + const on_forces_merged: EventId + /** Event type: {@link OnPlayerTrashInventoryChangedEvent} */ + const on_player_trash_inventory_changed: EventId + /** Event type: {@link OnPrePlayerLeftGameEvent} */ + const on_pre_player_left_game: EventId + /** Event type: {@link OnPreSurfaceClearedEvent} */ + const on_pre_surface_cleared: EventId + /** Event type: {@link OnSurfaceClearedEvent} */ + const on_surface_cleared: EventId + /** Event type: {@link OnChunkDeletedEvent} */ + const on_chunk_deleted: EventId + /** Event type: {@link OnPreChunkDeletedEvent} */ + const on_pre_chunk_deleted: EventId + /** Event type: {@link OnTrainScheduleChangedEvent} */ + const on_train_schedule_changed: EventId + /** Event type: {@link OnPlayerBannedEvent} */ + const on_player_banned: EventId + /** Event type: {@link OnPlayerKickedEvent} */ + const on_player_kicked: EventId + /** Event type: {@link OnPlayerUnbannedEvent} */ + const on_player_unbanned: EventId + /** Event type: {@link OnRocketLaunchOrderedEvent} */ + const on_rocket_launch_ordered: EventId + /** Event type: {@link OnScriptPathRequestFinishedEvent} */ + const on_script_path_request_finished: EventId + /** Event type: {@link OnAiCommandCompletedEvent} */ + const on_ai_command_completed: EventId + /** + * Event type: {@link OnMarkedForUpgradeEvent} + * + * Event filter: {@link LuaEntityMarkedForUpgradeEventFilter} + */ + const on_marked_for_upgrade: EventId + /** + * Event type: {@link OnCancelledUpgradeEvent} + * + * Event filter: {@link LuaUpgradeCancelledEventFilter} + */ + const on_cancelled_upgrade: EventId + /** Event type: {@link OnPlayerToggledMapEditorEvent} */ + const on_player_toggled_map_editor: EventId + /** + * Event type: {@link OnEntityClonedEvent} + * + * Event filter: {@link LuaEntityClonedEventFilter} + */ + const on_entity_cloned: EventId + /** Event type: {@link OnAreaClonedEvent} */ + const on_area_cloned: EventId + /** Event type: {@link OnBrushClonedEvent} */ + const on_brush_cloned: EventId + /** Event type: {@link OnGameCreatedFromScenarioEvent} */ + const on_game_created_from_scenario: EventId + /** Event type: {@link OnSurfaceImportedEvent} */ + const on_surface_imported: EventId + /** Event type: {@link OnSurfaceRenamedEvent} */ + const on_surface_renamed: EventId + /** Event type: {@link OnPlayerToggledAltModeEvent} */ + const on_player_toggled_alt_mode: EventId + /** + * Event type: {@link OnPlayerRepairedEntityEvent} + * + * Event filter: {@link LuaPlayerRepairedEntityEventFilter} + */ + const on_player_repaired_entity: EventId + /** Event type: {@link OnPlayerFastTransferredEvent} */ + const on_player_fast_transferred: EventId + /** Event type: {@link OnPreRobotExplodedCliffEvent} */ + const on_pre_robot_exploded_cliff: EventId + /** Event type: {@link OnRobotExplodedCliffEvent} */ + const on_robot_exploded_cliff: EventId + /** Event type: {@link OnEntitySpawnedEvent} */ + const on_entity_spawned: EventId + /** Event type: {@link OnCutsceneWaypointReachedEvent} */ + const on_cutscene_waypoint_reached: EventId + /** Event type: {@link OnUnitGroupCreatedEvent} */ + const on_unit_group_created: EventId + /** Event type: {@link OnUnitAddedToGroupEvent} */ + const on_unit_added_to_group: EventId + /** Event type: {@link OnUnitRemovedFromGroupEvent} */ + const on_unit_removed_from_group: EventId + /** Event type: {@link OnUnitGroupFinishedGatheringEvent} */ + const on_unit_group_finished_gathering: EventId + /** Event type: {@link OnBuildBaseArrivedEvent} */ + const on_build_base_arrived: EventId + /** Event type: {@link OnChartTagAddedEvent} */ + const on_chart_tag_added: EventId + /** Event type: {@link OnChartTagModifiedEvent} */ + const on_chart_tag_modified: EventId + /** Event type: {@link OnChartTagRemovedEvent} */ + const on_chart_tag_removed: EventId + /** Event type: {@link OnLuaShortcutEvent} */ + const on_lua_shortcut: EventId + /** Event type: {@link OnGuiLocationChangedEvent} */ + const on_gui_location_changed: EventId + /** Event type: {@link OnGuiSelectedTabChangedEvent} */ + const on_gui_selected_tab_changed: EventId + /** Event type: {@link OnGuiSwitchStateChangedEvent} */ + const on_gui_switch_state_changed: EventId + /** Event type: {@link OnForceCeaseFireChangedEvent} */ + const on_force_cease_fire_changed: EventId + /** Event type: {@link OnForceFriendsChangedEvent} */ + const on_force_friends_changed: EventId + /** Event type: {@link OnStringTranslatedEvent} */ + const on_string_translated: EventId + /** Event type: {@link OnScriptTriggerEffectEvent} */ + const on_script_trigger_effect: EventId + /** Event type: {@link OnPlayerSetQuickBarSlotEvent} */ + const on_player_set_quick_bar_slot: EventId + /** Event type: {@link OnPrePlayerToggledMapEditorEvent} */ + const on_pre_player_toggled_map_editor: EventId + /** Event type: {@link OnPreScriptInventoryResizedEvent} */ + const on_pre_script_inventory_resized: EventId + /** Event type: {@link OnScriptInventoryResizedEvent} */ + const on_script_inventory_resized: EventId + /** Event type: {@link OnEntityDestroyedEvent} */ + const on_entity_destroyed: EventId + /** Event type: {@link OnPlayerClickedGpsTagEvent} */ + const on_player_clicked_gps_tag: EventId + /** Event type: {@link OnPlayerFlushedFluidEvent} */ + const on_player_flushed_fluid: EventId + /** Event type: {@link OnPermissionGroupEditedEvent} */ + const on_permission_group_edited: EventId + /** Event type: {@link OnPrePermissionStringImportedEvent} */ + const on_pre_permission_string_imported: EventId + /** Event type: {@link OnPermissionStringImportedEvent} */ + const on_permission_string_imported: EventId + /** Event type: {@link OnPrePermissionGroupDeletedEvent} */ + const on_pre_permission_group_deleted: EventId + /** Event type: {@link OnPermissionGroupDeletedEvent} */ + const on_permission_group_deleted: EventId + /** Event type: {@link OnPermissionGroupAddedEvent} */ + const on_permission_group_added: EventId + /** Event type: {@link OnCutsceneCancelledEvent} */ + const on_cutscene_cancelled: EventId + /** Event type: {@link OnPlayerConfiguredSpiderRemoteEvent} */ + const on_player_configured_spider_remote: EventId + /** Event type: {@link OnPlayerUsedSpiderRemoteEvent} */ + const on_player_used_spider_remote: EventId + /** Event type: {@link OnSpiderCommandCompletedEvent} */ + const on_spider_command_completed: EventId + /** Event type: {@link OnEntityLogisticSlotChangedEvent} */ + const on_entity_logistic_slot_changed: EventId + /** Event type: {@link OnEquipmentInsertedEvent} */ + const on_equipment_inserted: EventId + /** Event type: {@link OnEquipmentRemovedEvent} */ + const on_equipment_removed: EventId + } + /** + * See the {@link https://lua-api.factorio.com/next/events.html events page} for more info on what events contain and + * when they get raised. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.events View documentation} + */ + type events = typeof events[keyof typeof events] + enum flow_precision_index { + five_seconds, + one_minute, + ten_minutes, + one_hour, + ten_hours, + fifty_hours, + two_hundred_fifty_hours, + one_thousand_hours, + } + enum group_state { + gathering, + moving, + attacking_distraction, + attacking_target, + finished, + pathfinding, + wander_in_group, + } + enum gui_type { + none, + entity, + research, + controller, + production, + item, + bonus, + trains, + achievement, + blueprint_library, + equipment, + logistic, + other_player, + permissions, + tutorials, + custom, + server_management, + player_management, + tile, + } + enum input_action { + activate_copy, + activate_cut, + activate_paste, + add_permission_group, + add_train_station, + admin_action, + alt_select_area, + alt_select_blueprint_entities, + alternative_copy, + begin_mining, + begin_mining_terrain, + build, + build_rail, + build_terrain, + cancel_craft, + cancel_deconstruct, + cancel_new_blueprint, + cancel_research, + cancel_upgrade, + change_active_character_tab, + change_active_item_group_for_crafting, + change_active_item_group_for_filters, + change_active_quick_bar, + change_arithmetic_combinator_parameters, + change_decider_combinator_parameters, + change_entity_label, + change_item_description, + change_item_label, + change_multiplayer_config, + change_picking_state, + change_programmable_speaker_alert_parameters, + change_programmable_speaker_circuit_parameters, + change_programmable_speaker_parameters, + change_riding_state, + change_shooting_state, + change_train_stop_station, + change_train_wait_condition, + change_train_wait_condition_data, + clear_cursor, + connect_rolling_stock, + copy, + copy_entity_settings, + copy_opened_blueprint, + copy_opened_item, + craft, + cursor_split, + cursor_transfer, + custom_input, + cycle_blueprint_book_backwards, + cycle_blueprint_book_forwards, + deconstruct, + delete_blueprint_library, + delete_blueprint_record, + delete_custom_tag, + delete_permission_group, + destroy_item, + destroy_opened_item, + disconnect_rolling_stock, + drag_train_schedule, + drag_train_wait_condition, + drop_blueprint_record, + drop_item, + edit_blueprint_tool_preview, + edit_custom_tag, + edit_permission_group, + export_blueprint, + fast_entity_split, + fast_entity_transfer, + flush_opened_entity_fluid, + flush_opened_entity_specific_fluid, + go_to_train_station, + grab_blueprint_record, + gui_checked_state_changed, + gui_click, + gui_confirmed, + gui_elem_changed, + gui_location_changed, + gui_selected_tab_changed, + gui_selection_state_changed, + gui_switch_state_changed, + gui_text_changed, + gui_value_changed, + import_blueprint, + import_blueprint_string, + import_blueprints_filtered, + import_permissions_string, + inventory_split, + inventory_transfer, + launch_rocket, + lua_shortcut, + map_editor_action, + market_offer, + mod_settings_changed, + open_achievements_gui, + open_blueprint_library_gui, + open_blueprint_record, + open_bonus_gui, + open_character_gui, + open_current_vehicle_gui, + open_equipment, + open_gui, + open_item, + open_logistic_gui, + open_mod_item, + open_parent_of_opened_item, + open_production_gui, + open_technology_gui, + open_tips_and_tricks_gui, + open_train_gui, + open_train_station_gui, + open_trains_gui, + paste_entity_settings, + place_equipment, + quick_bar_pick_slot, + quick_bar_set_selected_page, + quick_bar_set_slot, + reassign_blueprint, + remove_cables, + remove_train_station, + reset_assembling_machine, + reset_item, + rotate_entity, + select_area, + select_blueprint_entities, + select_entity_slot, + select_item, + select_mapper_slot, + select_next_valid_gun, + select_tile_slot, + send_spidertron, + set_auto_launch_rocket, + set_autosort_inventory, + set_behavior_mode, + set_car_weapons_control, + set_circuit_condition, + set_circuit_mode_of_operation, + set_controller_logistic_trash_filter_item, + set_deconstruction_item_tile_selection_mode, + set_deconstruction_item_trees_and_rocks_only, + set_entity_color, + set_entity_energy_property, + set_entity_logistic_trash_filter_item, + set_filter, + set_flat_controller_gui, + set_heat_interface_mode, + set_heat_interface_temperature, + set_infinity_container_filter_item, + set_infinity_container_remove_unfiltered_items, + set_infinity_pipe_filter, + set_inserter_max_stack_size, + set_inventory_bar, + set_linked_container_link_i_d, + set_logistic_filter_item, + set_logistic_filter_signal, + set_player_color, + set_recipe_notifications, + set_request_from_buffers, + set_research_finished_stops_game, + set_signal, + set_splitter_priority, + set_train_stopped, + set_trains_limit, + set_vehicle_automatic_targeting_parameters, + setup_assembling_machine, + setup_blueprint, + setup_single_blueprint_record, + smart_pipette, + spawn_item, + stack_split, + stack_transfer, + start_repair, + start_research, + start_walking, + stop_building_by_moving, + switch_connect_to_logistic_network, + switch_constant_combinator_state, + switch_inserter_filter_mode_state, + switch_power_switch_state, + switch_to_rename_stop_gui, + take_equipment, + toggle_deconstruction_item_entity_filter_mode, + toggle_deconstruction_item_tile_filter_mode, + toggle_driving, + toggle_enable_vehicle_logistics_while_moving, + toggle_entity_logistic_requests, + toggle_equipment_movement_bonus, + toggle_map_editor, + toggle_personal_logistic_requests, + toggle_personal_roboport, + toggle_show_entity_info, + translate_string, + undo, + upgrade, + upgrade_opened_blueprint_by_item, + upgrade_opened_blueprint_by_record, + use_artillery_remote, + use_item, + wire_dragging, + write_to_console, + } + enum inventory { + fuel, + burnt_result, + chest, + furnace_source, + furnace_result, + furnace_modules, + character_main, + character_guns, + character_ammo, + character_armor, + character_vehicle, + character_trash, + god_main, + editor_main, + editor_guns, + editor_ammo, + editor_armor, + roboport_robot, + roboport_material, + robot_cargo, + robot_repair, + assembling_machine_input, + assembling_machine_output, + assembling_machine_modules, + lab_input, + lab_modules, + mining_drill_modules, + item_main, + rocket_silo_rocket, + rocket_silo_result, + rocket, + car_trunk, + car_ammo, + cargo_wagon, + turret_ammo, + beacon_modules, + character_corpse, + artillery_turret_ammo, + artillery_wagon_ammo, + spider_trunk, + spider_ammo, + spider_trash, + } + enum logistic_member_index { + logistic_container, + vehicle_storage, + character_requester, + character_storage, + character_provider, + generic_on_off_behavior, + } + enum logistic_mode { + none, + active_provider, + storage, + requester, + passive_provider, + buffer, + } + enum mouse_button_type { + none, + left, + right, + middle, + } + /** + * A dictionary mapping all top-level prototypes by name to a list of their associated subtypes. This list is + * organized as a lookup table, meaning it maps the sub-prototype names to `0`. As an example, + * `defines.prototypes['entity']` looks like this: `{furnace=0, inserter=0, container=0, ...}`. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.prototypes View documentation} + */ + const prototypes: { + readonly [Type in string]?: { + readonly [Name in string]?: 0 & { + _notFalsyBrand: any + } + } + } + enum rail_connection_direction { + left, + straight, + right, + none, + } + enum rail_direction { + front, + back, + } + enum relative_gui_position { + top, + bottom, + left, + right, + } + enum relative_gui_type { + accumulator_gui, + achievement_gui, + additional_entity_info_gui, + admin_gui, + arithmetic_combinator_gui, + armor_gui, + assembling_machine_gui, + assembling_machine_select_recipe_gui, + beacon_gui, + blueprint_book_gui, + blueprint_library_gui, + blueprint_setup_gui, + bonus_gui, + burner_equipment_gui, + car_gui, + constant_combinator_gui, + container_gui, + controller_gui, + decider_combinator_gui, + deconstruction_item_gui, + electric_energy_interface_gui, + electric_network_gui, + entity_variations_gui, + entity_with_energy_source_gui, + equipment_grid_gui, + furnace_gui, + generic_on_off_entity_gui, + heat_interface_gui, + infinity_pipe_gui, + inserter_gui, + item_with_inventory_gui, + lab_gui, + lamp_gui, + linked_container_gui, + loader_gui, + logistic_gui, + market_gui, + mining_drill_gui, + other_player_gui, + permissions_gui, + pipe_gui, + power_switch_gui, + production_gui, + programmable_speaker_gui, + rail_chain_signal_gui, + rail_signal_gui, + reactor_gui, + rename_stop_gui, + resource_entity_gui, + roboport_gui, + rocket_silo_gui, + server_config_gui, + spider_vehicle_gui, + splitter_gui, + standalone_character_gui, + storage_tank_gui, + tile_variations_gui, + train_gui, + train_stop_gui, + trains_gui, + transport_belt_gui, + upgrade_item_gui, + wall_gui, + } + enum render_mode { + game, + chart, + chart_zoomed_in, + } + enum rich_text_setting { + enabled, + disabled, + highlight, + } + namespace riding { + enum acceleration { + nothing, + accelerating, + braking, + reversing, + } + enum direction { + left, + straight, + right, + } + } + enum shooting { + not_shooting, + shooting_enemies, + shooting_selected, + } + /** + * State of an ordinary rail signal. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.signal_state View documentation} + */ + enum signal_state { + /** + * Green. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.signal_state.open View documentation} + */ + open, + /** + * Red. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.signal_state.closed View documentation} + */ + closed, + /** + * Orange. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.signal_state.reserved View documentation} + */ + reserved, + /** + * Red - From circuit network. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.signal_state.reserved_by_circuit_network View documentation} + */ + reserved_by_circuit_network, + } + enum train_state { + /** + * Normal state -- following the path. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.train_state.on_the_path View documentation} + */ + on_the_path, + /** + * Had path and lost it -- must stop. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.train_state.path_lost View documentation} + */ + path_lost, + /** + * Doesn't have anywhere to go. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.train_state.no_schedule View documentation} + */ + no_schedule, + /** + * Has no path and is stopped. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.train_state.no_path View documentation} + */ + no_path, + /** + * Braking before a rail signal. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.train_state.arrive_signal View documentation} + */ + arrive_signal, + /** + * Waiting at a signal. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.train_state.wait_signal View documentation} + */ + wait_signal, + /** + * Braking before a station. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.train_state.arrive_station View documentation} + */ + arrive_station, + /** + * Waiting at a station. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.train_state.wait_station View documentation} + */ + wait_station, + /** + * Switched to manual control and has to stop. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.train_state.manual_control_stop View documentation} + */ + manual_control_stop, + /** + * Can move if user explicitly sits in and rides the train. + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.train_state.manual_control View documentation} + */ + manual_control, + /** + * Same as no_path but all candidate train stops are full + * + * {@link https://lua-api.factorio.com/next/defines.html#defines.train_state.destination_full View documentation} + */ + destination_full, + } + enum transport_line { + left_line, + right_line, + left_underground_line, + right_underground_line, + secondary_left_line, + secondary_right_line, + left_split_line, + right_split_line, + secondary_left_split_line, + secondary_right_split_line, + } + enum wire_connection_id { + electric_pole, + power_switch_left, + power_switch_right, + } + enum wire_type { + red, + green, + copper, + } +} diff --git a/modules/mod2/typed-factorio/generated/events.d.ts b/modules/mod2/typed-factorio/generated/events.d.ts new file mode 100644 index 0000000..b65e09a --- /dev/null +++ b/modules/mod2/typed-factorio/generated/events.d.ts @@ -0,0 +1,2976 @@ +/** @noSelfInFile */ + +/** + * Called when a {@link https://wiki.factorio.com/Prototype/CustomInput CustomInput} is activated. + * + * {@link https://lua-api.factorio.com/next/Events.html#CustomInputEvent View documentation} + */ +interface CustomInputEvent { + /** The player that activated the custom input. */ + readonly player_index: uint + /** The prototype name of the custom input that was activated. */ + readonly input_name: string + /** The mouse cursor position when the custom input was activated. */ + readonly cursor_position: Position + /** Information about the prototype that is selected when the custom input is used. `nil` if none is selected. */ + readonly selected_prototype?: SelectedPrototypeData + /** Identifier of the event */ + readonly name: string + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a unit/group completes a command. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_ai_command_completed View documentation} + */ +interface OnAiCommandCompletedEvent { + /** Unit_number/group_number of the unit/group which just completed a command. */ + readonly unit_number: uint + readonly result: defines.behavior_result + /** Was this command generated by a distraction. */ + readonly was_distracted: boolean + /** Identifier of the event */ + readonly name: typeof defines.events.on_ai_command_completed + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when an area of the map is cloned. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_area_cloned View documentation} + */ +interface OnAreaClonedEvent { + readonly source_surface: LuaSurface + readonly source_area: BoundingBox + readonly destination_surface: LuaSurface + readonly destination_area: BoundingBox + readonly destination_force?: LuaForce + readonly clone_tiles: boolean + readonly clone_entities: boolean + readonly clone_decoratives: boolean + readonly clear_destination_entities: boolean + readonly clear_destination_decoratives: boolean + /** Identifier of the event */ + readonly name: typeof defines.events.on_area_cloned + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a biter migration builds a base. + * + * **Note**: This will be called multiple times for each migration, once for every biter that is sacrificed to build + * part of the new base. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_biter_base_built View documentation} + */ +interface OnBiterBaseBuiltEvent { + /** The entity that was built. */ + readonly entity: LuaEntity + /** Identifier of the event */ + readonly name: typeof defines.events.on_biter_base_built + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a set of positions on the map is cloned. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_brush_cloned View documentation} + */ +interface OnBrushClonedEvent { + readonly source_offset: TilePosition + readonly destination_offset: TilePosition + readonly source_surface: LuaSurface + readonly source_positions: TilePosition[] + readonly destination_surface: LuaSurface + readonly destination_force?: LuaForce + readonly clone_tiles: boolean + readonly clone_entities: boolean + readonly clone_decoratives: boolean + readonly clear_destination_entities: boolean + readonly clear_destination_decoratives: boolean + /** Identifier of the event */ + readonly name: typeof defines.events.on_brush_cloned + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a {@link defines.command.build_base} command reaches its destination, and before building starts. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_build_base_arrived View documentation} + */ +interface OnBuildBaseArrivedEvent { + /** The unit the command was assigned to. */ + readonly unit?: LuaEntity + /** The unit group the command was assigned to. */ + readonly group?: LuaUnitGroup + /** Identifier of the event */ + readonly name: typeof defines.events.on_build_base_arrived + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when player builds something. Can be filtered using {@link LuaPlayerBuiltEntityEventFilter}. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_built_entity View documentation} + */ +interface OnBuiltEntityEvent { + readonly created_entity: LuaEntity + readonly player_index: uint + readonly stack: LuaItemStack + /** The item prototype used to build the entity. Note this won't exist in some situations (built from blueprint, undo, etc). */ + readonly item?: LuaItemPrototype + /** The tags associated with this entity if any. */ + readonly tags?: Tags + /** Identifier of the event */ + readonly name: typeof defines.events.on_built_entity + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when the deconstruction of an entity is canceled. Can be filtered using + * {@link LuaEntityDeconstructionCancelledEventFilter}. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_cancelled_deconstruction View documentation} + */ +interface OnCancelledDeconstructionEvent { + readonly entity: LuaEntity + readonly player_index?: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_cancelled_deconstruction + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when the upgrade of an entity is canceled. Can be filtered using {@link LuaUpgradeCancelledEventFilter}. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_cancelled_upgrade View documentation} + */ +interface OnCancelledUpgradeEvent { + readonly entity: LuaEntity + readonly player_index?: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_cancelled_upgrade + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a character corpse expires due to timeout or all of the items being removed from it. + * + * **Note**: this is not called if the corpse is mined. See {@link defines.events.on_pre_player_mined_item} to detect that. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_character_corpse_expired View documentation} + */ +interface OnCharacterCorpseExpiredEvent { + /** The corpse. */ + readonly corpse: LuaEntity + /** Identifier of the event */ + readonly name: typeof defines.events.on_character_corpse_expired + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a chart tag is created. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_chart_tag_added View documentation} + */ +interface OnChartTagAddedEvent { + readonly tag: LuaCustomChartTag + readonly force: LuaForce + readonly player_index?: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_chart_tag_added + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a chart tag is modified by a player. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_chart_tag_modified View documentation} + */ +interface OnChartTagModifiedEvent { + readonly tag: LuaCustomChartTag + readonly player_index?: uint + readonly force: LuaForce + readonly old_text: string + readonly old_icon?: SignalID + readonly old_player?: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_chart_tag_modified + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called just before a chart tag is deleted. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_chart_tag_removed View documentation} + */ +interface OnChartTagRemovedEvent { + readonly tag: LuaCustomChartTag + readonly force: LuaForce + readonly player_index?: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_chart_tag_removed + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a chunk is charted or re-charted. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_chunk_charted View documentation} + */ +interface OnChunkChartedEvent { + readonly surface_index: uint + readonly position: ChunkPosition + /** Area of the chunk. */ + readonly area: BoundingBox + readonly force: LuaForce + /** Identifier of the event */ + readonly name: typeof defines.events.on_chunk_charted + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when one or more chunks are deleted using {@link LuaSurface.delete_chunk LuaSurface::delete_chunk}. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_chunk_deleted View documentation} + */ +interface OnChunkDeletedEvent { + readonly surface_index: uint + /** The chunks deleted. */ + readonly positions: ChunkPosition[] + /** Identifier of the event */ + readonly name: typeof defines.events.on_chunk_deleted + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a chunk is generated. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_chunk_generated View documentation} + */ +interface OnChunkGeneratedEvent { + /** Area of the chunk. */ + readonly area: BoundingBox + /** Position of the chunk. */ + readonly position: ChunkPosition + /** The surface the chunk is on. */ + readonly surface: LuaSurface + /** Identifier of the event */ + readonly name: typeof defines.events.on_chunk_generated + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a combat robot expires through a lack of energy, or timeout. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_combat_robot_expired View documentation} + */ +interface OnCombatRobotExpiredEvent { + readonly robot: LuaEntity + /** The entity that owns the robot if any. */ + readonly owner?: LuaEntity + /** Identifier of the event */ + readonly name: typeof defines.events.on_combat_robot_expired + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a message is sent to the in-game console, either by a player or through the server interface. + * + * **Note**: This event only fires for plain messages, not for any commands (including `/shout` or `/whisper`). + * + * {@link https://lua-api.factorio.com/next/Events.html#on_console_chat View documentation} + */ +interface OnConsoleChatEvent { + /** The player doing the chatting, if any. */ + readonly player_index?: uint + /** The chat message that was sent. */ + readonly message: string + /** Identifier of the event */ + readonly name: typeof defines.events.on_console_chat + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when someone enters a command-like message regardless of it being a valid command. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_console_command View documentation} + */ +interface OnConsoleCommandEvent { + /** The player if any. */ + readonly player_index?: uint + /** The command as typed without the preceding forward slash ('/'). */ + readonly command: string + /** The parameters provided if any. */ + readonly parameters: string + /** Identifier of the event */ + readonly name: typeof defines.events.on_console_command + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a cutscene is cancelled by the player or by script. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_cutscene_cancelled View documentation} + */ +interface OnCutsceneCancelledEvent { + /** The player the cutscene was shown to. */ + readonly player_index: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_cutscene_cancelled + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a cutscene is playing, each time it reaches a waypoint in that cutscene. + * + * This refers to an index in the table previously passed to set_controller which started the cutscene. + * + * **Note**: Due to implementation omission, waypoint_index is 0-based. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_cutscene_waypoint_reached View documentation} + */ +interface OnCutsceneWaypointReachedEvent { + /** The player index of the player viewing the cutscene. */ + readonly player_index: uint + /** The index of the waypoint we just completed. */ + readonly waypoint_index: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_cutscene_waypoint_reached + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when the map difficulty settings are changed. + * + * **Note**: It's not guaranteed that both settings are changed - just that at least one has been changed. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_difficulty_settings_changed View documentation} + */ +interface OnDifficultySettingsChangedEvent { + readonly old_recipe_difficulty: uint + readonly old_technology_difficulty: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_difficulty_settings_changed + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when an entity is cloned. Can be filtered for the source entity using {@link LuaEntityClonedEventFilter}. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_entity_cloned View documentation} + */ +interface OnEntityClonedEvent { + readonly source: LuaEntity + readonly destination: LuaEntity + /** Identifier of the event */ + readonly name: typeof defines.events.on_entity_cloned + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when an entity is damaged. Can be filtered using {@link LuaEntityDamagedEventFilter}. + * + * **Note**: This is not called when an entities health is set directly by another mod. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_entity_damaged View documentation} + */ +interface OnEntityDamagedEvent { + readonly entity: LuaEntity + readonly damage_type: LuaDamagePrototype + /** The damage amount before resistances. */ + readonly original_damage_amount: float + /** The damage amount after resistances. */ + readonly final_damage_amount: float + /** The health of the entity after the damage was applied. */ + readonly final_health: float + /** The entity that did the attacking if available. */ + readonly cause?: LuaEntity + /** The force that did the attacking if any. */ + readonly force?: LuaForce + /** Identifier of the event */ + readonly name: typeof defines.events.on_entity_damaged + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called after an entity is destroyed that has been registered with + * {@link LuaBootstrap.register_on_entity_destroyed LuaBootstrap::register_on_entity_destroyed} + * + * **Note**: Depending on when a given entity is destroyed this will be fired at the end of the current tick or end of + * the next tick. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_entity_destroyed View documentation} + */ +interface OnEntityDestroyedEvent { + readonly registration_number: uint64 + readonly unit_number?: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_entity_destroyed + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when an entity dies. Can be filtered using {@link LuaEntityDiedEventFilter}. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_entity_died View documentation} + */ +interface OnEntityDiedEvent { + /** The entity that died. */ + readonly entity: LuaEntity + /** The entity that did the killing if available. */ + readonly cause?: LuaEntity + /** The loot generated by this entity if any. */ + readonly loot: LuaInventory + /** The force that did the killing if any. */ + readonly force?: LuaForce + /** The damage type if any. */ + readonly damage_type?: LuaDamagePrototype + /** Identifier of the event */ + readonly name: typeof defines.events.on_entity_died + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when one of an entity's personal logistic slots changes. + * + * **Note**: "Personal logistic slot" refers to a character or vehicle's personal request / auto-trash slots, not the + * request slots on logistic chests. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_entity_logistic_slot_changed View documentation} + */ +interface OnEntityLogisticSlotChangedEvent { + /** The player who changed the slot, or `nil` if changed by script. */ + readonly player_index?: uint + /** The entity for whom a logistic slot was changed. */ + readonly entity: LuaEntity + /** The slot index that was changed. */ + readonly slot_index: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_entity_logistic_slot_changed + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called after an entity has been renamed either by the player or through script. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_entity_renamed View documentation} + */ +interface OnEntityRenamedEvent { + /** If by_script is true this will not be included. */ + readonly player_index?: uint + readonly by_script: boolean + readonly entity: LuaEntity + readonly old_name: string + /** Identifier of the event */ + readonly name: typeof defines.events.on_entity_renamed + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called after entity copy-paste is done. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_entity_settings_pasted View documentation} + */ +interface OnEntitySettingsPastedEvent { + readonly player_index: uint + /** The source entity settings were copied from. */ + readonly source: LuaEntity + /** The destination entity settings were copied to. */ + readonly destination: LuaEntity + /** Identifier of the event */ + readonly name: typeof defines.events.on_entity_settings_pasted + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when an entity is spawned by a EnemySpawner + * + * {@link https://lua-api.factorio.com/next/Events.html#on_entity_spawned View documentation} + */ +interface OnEntitySpawnedEvent { + readonly spawner: LuaEntity + readonly entity: LuaEntity + /** Identifier of the event */ + readonly name: typeof defines.events.on_entity_spawned + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called after equipment is inserted into an equipment grid. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_equipment_inserted View documentation} + */ +interface OnEquipmentInsertedEvent { + /** The equipment grid inserted into. */ + readonly grid: LuaEquipmentGrid + /** The equipment inserted. */ + readonly equipment: LuaEquipment + /** Identifier of the event */ + readonly name: typeof defines.events.on_equipment_inserted + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called after equipment is removed from an equipment grid. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_equipment_removed View documentation} + */ +interface OnEquipmentRemovedEvent { + /** The equipment grid removed from. */ + readonly grid: LuaEquipmentGrid + /** The equipment removed. */ + readonly equipment: string + /** The count of equipment removed. */ + readonly count: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_equipment_removed + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when the a forces cease fire values change. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_force_cease_fire_changed View documentation} + */ +interface OnForceCeaseFireChangedEvent { + /** The force who's cease fire changed. */ + readonly force: LuaForce + /** Which force was added or removed. */ + readonly other_force: LuaForce + /** If the other force was added or removed. */ + readonly added: boolean + /** Identifier of the event */ + readonly name: typeof defines.events.on_force_cease_fire_changed + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a new force is created using `game.create_force()` + * + * **Note**: This is not called when the default forces (`'player'`, `'enemy'`, `'neutral'`) are created as they will + * always exist. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_force_created View documentation} + */ +interface OnForceCreatedEvent { + /** The newly created force. */ + readonly force: LuaForce + /** Identifier of the event */ + readonly name: typeof defines.events.on_force_created + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when the a forces friends change. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_force_friends_changed View documentation} + */ +interface OnForceFriendsChangedEvent { + /** The force who's friends changed. */ + readonly force: LuaForce + /** Which force was added or removed. */ + readonly other_force: LuaForce + /** If the other force was added or removed. */ + readonly added: boolean + /** Identifier of the event */ + readonly name: typeof defines.events.on_force_friends_changed + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when {@link LuaForce.reset LuaForce::reset} is finished. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_force_reset View documentation} + */ +interface OnForceResetEvent { + readonly force: LuaForce + /** Identifier of the event */ + readonly name: typeof defines.events.on_force_reset + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called after two forces have been merged using `game.merge_forces()`. + * + * **Note**: The source force is invalidated before this event is called and the name can be re-used in this event if desired. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_forces_merged View documentation} + */ +interface OnForcesMergedEvent { + /** The force destroyed. */ + readonly source_name: string + /** The index of the destroyed force. */ + readonly source_index: uint + /** The force entities where reassigned to. */ + readonly destination: LuaForce + /** Identifier of the event */ + readonly name: typeof defines.events.on_forces_merged + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when two forces are about to be merged using `game.merge_forces()`. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_forces_merging View documentation} + */ +interface OnForcesMergingEvent { + /** The force to be destroyed */ + readonly source: LuaForce + /** The force to reassign entities to. */ + readonly destination: LuaForce + /** Identifier of the event */ + readonly name: typeof defines.events.on_forces_merging + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a game is created from a scenario. This is fired for every mod, even when the scenario's save data + * already includes it. In those cases however, {@link LuaBootstrap.on_init LuaBootstrap::on_init} is not fired. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_game_created_from_scenario View documentation} + */ +interface OnGameCreatedFromScenarioEvent { + /** Identifier of the event */ + readonly name: typeof defines.events.on_game_created_from_scenario + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when {@link LuaGuiElement} checked state is changed (related to checkboxes and radio buttons). + * + * {@link https://lua-api.factorio.com/next/Events.html#on_gui_checked_state_changed View documentation} + */ +interface OnGuiCheckedStateChangedEvent { + /** The element whose checked state changed. */ + readonly element: LuaGuiElement + /** The player who did the change. */ + readonly player_index: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_gui_checked_state_changed + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when {@link LuaGuiElement} is clicked. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_gui_click View documentation} + */ +interface OnGuiClickEvent { + /** The clicked element. */ + readonly element: LuaGuiElement + /** The player who did the clicking. */ + readonly player_index: uint + /** The mouse button used if any. */ + readonly button: defines.mouse_button_type + /** If alt was pressed. */ + readonly alt: boolean + /** If control was pressed. */ + readonly control: boolean + /** If shift was pressed. */ + readonly shift: boolean + /** Identifier of the event */ + readonly name: typeof defines.events.on_gui_click + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when the player closes the GUI they have open. + * + * **Note**: This is only called if the player explicitly closed the GUI. + * + * **Note**: It's not advised to open any other GUI during this event because if this is run as a request to open a + * different GUI the game will force close the new opened GUI without notice to ensure the original requested GUI is opened. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_gui_closed View documentation} + */ +interface OnGuiClosedEvent { + /** The player. */ + readonly player_index: uint + /** The GUI type that was open. */ + readonly gui_type: defines.gui_type + /** The entity that was open */ + readonly entity?: LuaEntity + /** The item that was open */ + readonly item?: LuaItemStack + /** The equipment that was open */ + readonly equipment?: LuaEquipment + /** The other player that was open */ + readonly other_player?: LuaPlayer + /** The custom GUI element that was open */ + readonly element?: LuaGuiElement + /** The technology that was automatically selected when opening the research GUI */ + readonly technology?: LuaTechnology + /** The tile position that was open */ + readonly tile_position?: TilePosition + /** Identifier of the event */ + readonly name: typeof defines.events.on_gui_closed + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a {@link LuaGuiElement} is confirmed, for example by pressing Enter in a textfield. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_gui_confirmed View documentation} + */ +interface OnGuiConfirmedEvent { + /** The confirmed element. */ + readonly element: LuaGuiElement + /** The player who did the confirming. */ + readonly player_index: uint + /** If alt was pressed. */ + readonly alt: boolean + /** If control was pressed. */ + readonly control: boolean + /** If shift was pressed. */ + readonly shift: boolean + /** Identifier of the event */ + readonly name: typeof defines.events.on_gui_confirmed + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when {@link LuaGuiElement} element value is changed (related to choose element buttons). + * + * {@link https://lua-api.factorio.com/next/Events.html#on_gui_elem_changed View documentation} + */ +interface OnGuiElemChangedEvent { + /** The element whose element value changed. */ + readonly element: LuaGuiElement + /** The player who did the change. */ + readonly player_index: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_gui_elem_changed + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when {@link LuaGuiElement} element location is changed (related to frames in `player.gui.screen`). + * + * {@link https://lua-api.factorio.com/next/Events.html#on_gui_location_changed View documentation} + */ +interface OnGuiLocationChangedEvent { + /** The element whose location changed. */ + readonly element: LuaGuiElement + /** The player who did the change. */ + readonly player_index: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_gui_location_changed + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when the player opens a GUI. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_gui_opened View documentation} + */ +interface OnGuiOpenedEvent { + /** The player. */ + readonly player_index: uint + /** The GUI type that was opened. */ + readonly gui_type: defines.gui_type + /** The entity that was opened */ + readonly entity?: LuaEntity + /** The item that was opened */ + readonly item?: LuaItemStack + /** The equipment that was opened */ + readonly equipment?: LuaEquipment + /** The other player that was opened */ + readonly other_player?: LuaPlayer + /** The custom GUI element that was opened */ + readonly element?: LuaGuiElement + /** Identifier of the event */ + readonly name: typeof defines.events.on_gui_opened + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when {@link LuaGuiElement} selected tab is changed (related to tabbed-panes). + * + * {@link https://lua-api.factorio.com/next/Events.html#on_gui_selected_tab_changed View documentation} + */ +interface OnGuiSelectedTabChangedEvent { + /** The tabbed pane whose selected tab changed. */ + readonly element: LuaGuiElement + /** The player who did the change. */ + readonly player_index: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_gui_selected_tab_changed + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when {@link LuaGuiElement} selection state is changed (related to drop-downs and listboxes). + * + * {@link https://lua-api.factorio.com/next/Events.html#on_gui_selection_state_changed View documentation} + */ +interface OnGuiSelectionStateChangedEvent { + /** The element whose selection state changed. */ + readonly element: LuaGuiElement + /** The player who did the change. */ + readonly player_index: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_gui_selection_state_changed + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when {@link LuaGuiElement} switch state is changed (related to switches). + * + * {@link https://lua-api.factorio.com/next/Events.html#on_gui_switch_state_changed View documentation} + */ +interface OnGuiSwitchStateChangedEvent { + /** The switch whose switch state changed. */ + readonly element: LuaGuiElement + /** The player who did the change. */ + readonly player_index: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_gui_switch_state_changed + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when {@link LuaGuiElement} text is changed by the player. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_gui_text_changed View documentation} + */ +interface OnGuiTextChangedEvent { + /** The edited element. */ + readonly element: LuaGuiElement + /** The player who did the edit. */ + readonly player_index: uint + /** The new text in the element. */ + readonly text: string + /** Identifier of the event */ + readonly name: typeof defines.events.on_gui_text_changed + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when {@link LuaGuiElement} slider value is changed (related to the slider element). + * + * {@link https://lua-api.factorio.com/next/Events.html#on_gui_value_changed View documentation} + */ +interface OnGuiValueChangedEvent { + /** The element whose value changed. */ + readonly element: LuaGuiElement + /** The player who did the change. */ + readonly player_index: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_gui_value_changed + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a land mine is armed. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_land_mine_armed View documentation} + */ +interface OnLandMineArmedEvent { + readonly mine: LuaEntity + /** Identifier of the event */ + readonly name: typeof defines.events.on_land_mine_armed + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a custom Lua shortcut is pressed. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_lua_shortcut View documentation} + */ +interface OnLuaShortcutEvent { + readonly player_index: uint + /** Shortcut prototype name of the shortcut that was clicked. */ + readonly prototype_name: string + /** Identifier of the event */ + readonly name: typeof defines.events.on_lua_shortcut + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when an entity is marked for deconstruction with the Deconstruction planner or via script. Can be filtered + * using {@link LuaEntityMarkedForDeconstructionEventFilter}. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_marked_for_deconstruction View documentation} + */ +interface OnMarkedForDeconstructionEvent { + readonly entity: LuaEntity + readonly player_index?: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_marked_for_deconstruction + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when an entity is marked for upgrade with the Upgrade planner or via script. Can be filtered using + * {@link LuaEntityMarkedForUpgradeEventFilter}. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_marked_for_upgrade View documentation} + */ +interface OnMarkedForUpgradeEvent { + readonly entity: LuaEntity + readonly target: LuaEntityPrototype + readonly player_index?: uint + /** The new direction (if any) */ + readonly direction?: defines.direction + /** Identifier of the event */ + readonly name: typeof defines.events.on_marked_for_upgrade + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called after a player purchases some offer from a `market` entity. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_market_item_purchased View documentation} + */ +interface OnMarketItemPurchasedEvent { + /** The player who did the purchasing. */ + readonly player_index: uint + /** The market entity. */ + readonly market: LuaEntity + /** The index of the offer purchased. */ + readonly offer_index: uint + /** The amount of offers purchased. */ + readonly count: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_market_item_purchased + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when the player uses the 'Open item GUI' control on an item defined with the 'mod-openable' flag + * + * {@link https://lua-api.factorio.com/next/Events.html#on_mod_item_opened View documentation} + */ +interface OnModItemOpenedEvent { + /** The player. */ + readonly player_index: uint + /** The item clicked on. */ + readonly item: LuaItemPrototype + /** Identifier of the event */ + readonly name: typeof defines.events.on_mod_item_opened + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called directly after a permission group is added. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_permission_group_added View documentation} + */ +interface OnPermissionGroupAddedEvent { + /** The player that added the group. */ + readonly player_index: uint + /** The group added. */ + readonly group: LuaPermissionGroup + /** Identifier of the event */ + readonly name: typeof defines.events.on_permission_group_added + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called directly after a permission group is deleted. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_permission_group_deleted View documentation} + */ +interface OnPermissionGroupDeletedEvent { + /** The player doing the deletion. */ + readonly player_index: uint + /** The group that was deleted. */ + readonly group_name: string + /** The group id that was deleted. */ + readonly id: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_permission_group_deleted + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called directly after a permission group is edited in some way. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_permission_group_edited View documentation} + */ +interface OnPermissionGroupEditedEvent { + /** The player that did the editing. */ + readonly player_index: uint + /** The group being edited. */ + readonly group: LuaPermissionGroup + /** The edit type: "add-permission", "remove-permission", "enable-all", "disable-all", "add-player", "remove-player", "rename". */ + readonly type: + | "add-permission" + | "remove-permission" + | "enable-all" + | "disable-all" + | "add-player" + | "remove-player" + | "rename" + /** The action when the `type` is "add-permission" or "remove-permission". */ + readonly action: defines.input_action + /** The other player when the `type` is "add-player" or "remove-player". */ + readonly other_player_index: uint + /** The old group name when the `type` is "rename". */ + readonly old_name: string + /** The new group name when the `type` is "rename". */ + readonly new_name: string + /** Identifier of the event */ + readonly name: typeof defines.events.on_permission_group_edited + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called directly after a permission string is imported. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_permission_string_imported View documentation} + */ +interface OnPermissionStringImportedEvent { + /** The player that imported the string. */ + readonly player_index: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_permission_string_imported + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a player picks up an item. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_picked_up_item View documentation} + */ +interface OnPickedUpItemEvent { + readonly item_stack: SimpleItemStack + readonly player_index: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_picked_up_item + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called after a player alt-selects an area with a selection-tool item. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_player_alt_selected_area View documentation} + */ +interface OnPlayerAltSelectedAreaEvent { + /** The player doing the selection. */ + readonly player_index: uint + /** The surface selected. */ + readonly surface: LuaSurface + /** The area selected. */ + readonly area: BoundingBox + /** The item used to select the area. */ + readonly item: string + /** The entities selected. */ + readonly entities: LuaEntity[] + /** The tiles selected. */ + readonly tiles: LuaTile[] + /** Identifier of the event */ + readonly name: typeof defines.events.on_player_alt_selected_area + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called after a players ammo inventory changed in some way. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_player_ammo_inventory_changed View documentation} + */ +interface OnPlayerAmmoInventoryChangedEvent { + readonly player_index: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_player_ammo_inventory_changed + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called after a players armor inventory changed in some way. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_player_armor_inventory_changed View documentation} + */ +interface OnPlayerArmorInventoryChangedEvent { + readonly player_index: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_player_armor_inventory_changed + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a player is banned. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_player_banned View documentation} + */ +interface OnPlayerBannedEvent { + /** The player banned. */ + readonly player_index?: uint + /** The banned player name. */ + readonly player_name: string + /** The player that did the banning if any. */ + readonly by_player?: uint + /** The reason given if any. */ + readonly reason?: string + /** Identifier of the event */ + readonly name: typeof defines.events.on_player_banned + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called after a player builds tiles. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_player_built_tile View documentation} + */ +interface OnPlayerBuiltTileEvent { + readonly player_index: uint + /** The surface the tile(s) were built on. */ + readonly surface_index: uint + /** The position data. */ + readonly tiles: OldTileAndPosition[] + /** The tile prototype that was placed. */ + readonly tile: LuaTilePrototype + /** The item type used to build the tiles */ + readonly item?: LuaItemPrototype + /** The stack used to build the tiles (may be empty if all of the items where used to build the tiles). */ + readonly stack?: LuaItemStack + /** Identifier of the event */ + readonly name: typeof defines.events.on_player_built_tile + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a player cancels crafting. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_player_cancelled_crafting View documentation} + */ +interface OnPlayerCancelledCraftingEvent { + /** The player that did the crafting. */ + readonly player_index: uint + /** The crafting items returned to the player's inventory. */ + readonly items: LuaInventory + /** The recipe that has been cancelled. */ + readonly recipe: LuaRecipe + /** The number of crafts that have been cancelled. */ + readonly cancel_count: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_player_cancelled_crafting + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called after a player changes forces. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_player_changed_force View documentation} + */ +interface OnPlayerChangedForceEvent { + /** The player who changed forces. */ + readonly player_index: uint + /** The old force. */ + readonly force: LuaForce + /** Identifier of the event */ + readonly name: typeof defines.events.on_player_changed_force + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when the tile position a player is located at changes. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_player_changed_position View documentation} + */ +interface OnPlayerChangedPositionEvent { + /** The player. */ + readonly player_index: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_player_changed_position + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called after a player changes surfaces. + * + * **Note**: In the instance a player is moved off a surface due to it being deleted this is not called. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_player_changed_surface View documentation} + */ +interface OnPlayerChangedSurfaceEvent { + /** The player who changed surfaces. */ + readonly player_index: uint + /** The surface index the player was on. */ + readonly surface_index: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_player_changed_surface + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when cheat mode is disabled on a player. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_player_cheat_mode_disabled View documentation} + */ +interface OnPlayerCheatModeDisabledEvent { + /** The player. */ + readonly player_index: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_player_cheat_mode_disabled + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when cheat mode is enabled on a player. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_player_cheat_mode_enabled View documentation} + */ +interface OnPlayerCheatModeEnabledEvent { + /** The player. */ + readonly player_index: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_player_cheat_mode_enabled + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a player clicks a gps tag + * + * {@link https://lua-api.factorio.com/next/Events.html#on_player_clicked_gps_tag View documentation} + */ +interface OnPlayerClickedGpsTagEvent { + /** Index of the player */ + readonly player_index: uint + /** Map position contained in gps tag */ + readonly position: Position + /** Surface name contained in gps tag, even when such surface does not exists */ + readonly surface: string + /** Identifier of the event */ + readonly name: typeof defines.events.on_player_clicked_gps_tag + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a player clicks the "confirm" button in the configure Blueprint GUI. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_player_configured_blueprint View documentation} + */ +interface OnPlayerConfiguredBlueprintEvent { + /** The player. */ + readonly player_index: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_player_configured_blueprint + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a player configures spidertron remote to be connected with a given spidertron + * + * {@link https://lua-api.factorio.com/next/Events.html#on_player_configured_spider_remote View documentation} + */ +interface OnPlayerConfiguredSpiderRemoteEvent { + /** The player that configured the remote. */ + readonly player_index: uint + /** Spider vehicle to which remote was connected to. */ + readonly vehicle: LuaEntity + /** Identifier of the event */ + readonly name: typeof defines.events.on_player_configured_spider_remote + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when the player finishes crafting an item. This event fires just before the results are inserted into the + * player's inventory, not when the crafting is queued (see {@link OnPrePlayerCraftedItemEvent on_pre_player_crafted_item}). + * + * {@link https://lua-api.factorio.com/next/Events.html#on_player_crafted_item View documentation} + */ +interface OnPlayerCraftedItemEvent { + /** The item that has been crafted. */ + readonly item_stack: LuaItemStack + /** The player doing the crafting. */ + readonly player_index: uint + /** The recipe used to craft this item. */ + readonly recipe: LuaRecipe + /** Identifier of the event */ + readonly name: typeof defines.events.on_player_crafted_item + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called after the player was created. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_player_created View documentation} + */ +interface OnPlayerCreatedEvent { + readonly player_index: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_player_created + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called after a players cursorstack changed in some way. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_player_cursor_stack_changed View documentation} + */ +interface OnPlayerCursorStackChangedEvent { + readonly player_index: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_player_cursor_stack_changed + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a player selects an area with a deconstruction planner. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_player_deconstructed_area View documentation} + */ +interface OnPlayerDeconstructedAreaEvent { + /** The player doing the selection. */ + readonly player_index: uint + /** The surface selected. */ + readonly surface: LuaSurface + /** The area selected. */ + readonly area: BoundingBox + /** The item used to select the area. */ + readonly item: string + /** If normal selection or alt selection was used. */ + readonly alt: boolean + /** Identifier of the event */ + readonly name: typeof defines.events.on_player_deconstructed_area + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a player is demoted. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_player_demoted View documentation} + */ +interface OnPlayerDemotedEvent { + /** The player. */ + readonly player_index: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_player_demoted + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called after a player dies. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_player_died View documentation} + */ +interface OnPlayerDiedEvent { + readonly player_index: uint + readonly cause?: LuaEntity + /** Identifier of the event */ + readonly name: typeof defines.events.on_player_died + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when the display resolution changes for a given player. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_player_display_resolution_changed View documentation} + */ +interface OnPlayerDisplayResolutionChangedEvent { + /** The player */ + readonly player_index: uint + /** The old display resolution */ + readonly old_resolution: DisplayResolution + /** Identifier of the event */ + readonly name: typeof defines.events.on_player_display_resolution_changed + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when the display scale changes for a given player. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_player_display_scale_changed View documentation} + */ +interface OnPlayerDisplayScaleChangedEvent { + /** The player */ + readonly player_index: uint + /** The old display scale */ + readonly old_scale: double + /** Identifier of the event */ + readonly name: typeof defines.events.on_player_display_scale_changed + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when the player's driving state has changed, this means a player has either entered or left a vehicle. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_player_driving_changed_state View documentation} + */ +interface OnPlayerDrivingChangedStateEvent { + readonly player_index: uint + /** The vehicle if any. */ + readonly entity?: LuaEntity + /** Identifier of the event */ + readonly name: typeof defines.events.on_player_driving_changed_state + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a player drops an item on the ground. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_player_dropped_item View documentation} + */ +interface OnPlayerDroppedItemEvent { + readonly player_index: uint + /** The item-on-ground entity. */ + readonly entity: LuaEntity + /** Identifier of the event */ + readonly name: typeof defines.events.on_player_dropped_item + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a player fast-transfers something to or from an entity. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_player_fast_transferred View documentation} + */ +interface OnPlayerFastTransferredEvent { + /** The player transferred from or to. */ + readonly player_index: uint + /** 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 + /** Identifier of the event */ + readonly name: typeof defines.events.on_player_fast_transferred + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called after player flushed fluid + * + * {@link https://lua-api.factorio.com/next/Events.html#on_player_flushed_fluid View documentation} + */ +interface OnPlayerFlushedFluidEvent { + /** Index of the player */ + readonly player_index: uint + /** Name of a fluid that was flushed */ + readonly fluid: string + /** Amount of fluid that was removed */ + readonly amount: double + /** Entity from which flush was performed */ + readonly entity: LuaEntity + /** True if flush was requested only on this entity */ + readonly only_this_entity: boolean + /** Identifier of the event */ + readonly name: typeof defines.events.on_player_flushed_fluid + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called after a players gun inventory changed in some way. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_player_gun_inventory_changed View documentation} + */ +interface OnPlayerGunInventoryChangedEvent { + readonly player_index: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_player_gun_inventory_changed + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called after a player joins the game. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_player_joined_game View documentation} + */ +interface OnPlayerJoinedGameEvent { + readonly player_index: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_player_joined_game + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a player is kicked. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_player_kicked View documentation} + */ +interface OnPlayerKickedEvent { + /** The player kicked. */ + readonly player_index: uint + /** The player that did the kicking if any. */ + readonly by_player?: uint + /** The reason given if any. */ + readonly reason?: string + /** Identifier of the event */ + readonly name: typeof defines.events.on_player_kicked + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called after a player leaves the game. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_player_left_game View documentation} + */ +interface OnPlayerLeftGameEvent { + readonly player_index: uint + readonly reason: defines.disconnect_reason + /** Identifier of the event */ + readonly name: typeof defines.events.on_player_left_game + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called after a players main inventory changed in some way. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_player_main_inventory_changed View documentation} + */ +interface OnPlayerMainInventoryChangedEvent { + readonly player_index: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_player_main_inventory_changed + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called after the results of an entity being mined are collected just before the entity is destroyed. After this event + * any items in the buffer will be transferred into the player as if they came from mining the entity. Can be filtered + * using {@link LuaPlayerMinedEntityEventFilter}. + * + * **Note**: The buffer inventory is special in that it's only valid during this event and has a dynamic size expanding + * as more items are transferred into it. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_player_mined_entity View documentation} + */ +interface OnPlayerMinedEntityEvent { + /** The index of the player doing the mining. */ + readonly player_index: uint + /** The entity that has been mined. */ + readonly entity: LuaEntity + /** The temporary inventory that holds the result of mining the entity. */ + readonly buffer: LuaInventory + /** Identifier of the event */ + readonly name: typeof defines.events.on_player_mined_entity + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when the player mines something. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_player_mined_item View documentation} + */ +interface OnPlayerMinedItemEvent { + /** The item given to the player */ + readonly item_stack: SimpleItemStack + readonly player_index: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_player_mined_item + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called after a player mines tiles. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_player_mined_tile View documentation} + */ +interface OnPlayerMinedTileEvent { + readonly player_index: uint + /** The surface the tile(s) were mined from. */ + readonly surface_index: uint + /** The position data. */ + readonly tiles: OldTileAndPosition[] + /** Identifier of the event */ + readonly name: typeof defines.events.on_player_mined_tile + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a player is muted. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_player_muted View documentation} + */ +interface OnPlayerMutedEvent { + /** The player. */ + readonly player_index: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_player_muted + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a player invokes the "smart pipette" over an entity. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_player_pipette View documentation} + */ +interface OnPlayerPipetteEvent { + /** The player */ + readonly player_index: uint + /** The item put in the cursor */ + readonly item: LuaItemPrototype + /** If cheat mode was used to give a free stack of the item. */ + readonly used_cheat_mode: boolean + /** Identifier of the event */ + readonly name: typeof defines.events.on_player_pipette + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called after the player puts equipment in an equipment grid + * + * {@link https://lua-api.factorio.com/next/Events.html#on_player_placed_equipment View documentation} + */ +interface OnPlayerPlacedEquipmentEvent { + readonly player_index: uint + /** The equipment put in the equipment grid. */ + readonly equipment: LuaEquipment + /** The equipment grid the equipment was put in. */ + readonly grid: LuaEquipmentGrid + /** Identifier of the event */ + readonly name: typeof defines.events.on_player_placed_equipment + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a player is promoted. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_player_promoted View documentation} + */ +interface OnPlayerPromotedEvent { + /** The player. */ + readonly player_index: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_player_promoted + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a player is removed (deleted) from the game. Not to be confused with the player logging of this is + * different in that the player is deleted as if he never existed in the save file. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_player_removed View documentation} + */ +interface OnPlayerRemovedEvent { + /** The player index that was removed */ + readonly player_index: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_player_removed + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called after the player removes equipment from an equipment grid + * + * {@link https://lua-api.factorio.com/next/Events.html#on_player_removed_equipment View documentation} + */ +interface OnPlayerRemovedEquipmentEvent { + readonly player_index: uint + /** The equipment grid removed from. */ + readonly grid: LuaEquipmentGrid + /** The equipment removed. */ + readonly equipment: string + /** The count of equipment removed. */ + readonly count: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_player_removed_equipment + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a player repairs an entity. Can be filtered using {@link LuaPlayerRepairedEntityEventFilter}. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_player_repaired_entity View documentation} + */ +interface OnPlayerRepairedEntityEvent { + readonly player_index: uint + readonly entity: LuaEntity + /** Identifier of the event */ + readonly name: typeof defines.events.on_player_repaired_entity + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called after a player respawns. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_player_respawned View documentation} + */ +interface OnPlayerRespawnedEvent { + readonly player_index: uint + /** The player port used to respawn if one was used. */ + readonly player_port?: LuaEntity + /** Identifier of the event */ + readonly name: typeof defines.events.on_player_respawned + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when the player rotates an entity. This event is only fired when the entity actually changes its orientation + * -- pressing the rotate key on an entity that can't be rotated won't fire this event. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_player_rotated_entity View documentation} + */ +interface OnPlayerRotatedEntityEvent { + /** The rotated entity. */ + readonly entity: LuaEntity + /** The previous direction */ + readonly previous_direction: defines.direction + readonly player_index: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_player_rotated_entity + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called after a player selects an area with a selection-tool item. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_player_selected_area View documentation} + */ +interface OnPlayerSelectedAreaEvent { + /** The player doing the selection. */ + readonly player_index: uint + /** The surface selected. */ + readonly surface: LuaSurface + /** The area selected. */ + readonly area: BoundingBox + /** The item used to select the area. */ + readonly item: string + /** The entities selected. */ + readonly entities: LuaEntity[] + /** The tiles selected. */ + readonly tiles: LuaTile[] + /** Identifier of the event */ + readonly name: typeof defines.events.on_player_selected_area + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a player sets a quickbar slot to anything (new value, or set to empty). + * + * {@link https://lua-api.factorio.com/next/Events.html#on_player_set_quick_bar_slot View documentation} + */ +interface OnPlayerSetQuickBarSlotEvent { + readonly player_index: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_player_set_quick_bar_slot + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a player selects an area with a blueprint. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_player_setup_blueprint View documentation} + */ +interface OnPlayerSetupBlueprintEvent { + /** The player doing the selection. */ + readonly player_index: uint + /** The surface selected. */ + readonly surface: LuaSurface + /** The area selected. */ + readonly area: BoundingBox + /** The item used to select the area. */ + readonly item: string + /** If normal selection or alt selection was used. */ + readonly alt: boolean + /** The blueprint entity index to source entity mapping. Note: if any mod changes the blueprint this will be incorrect. */ + readonly mapping: LuaLazyLoadedValue> + /** Identifier of the event */ + readonly name: typeof defines.events.on_player_setup_blueprint + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a player toggles alt mode, also known as "show entity info". + * + * {@link https://lua-api.factorio.com/next/Events.html#on_player_toggled_alt_mode View documentation} + */ +interface OnPlayerToggledAltModeEvent { + readonly player_index: uint + /** + * The new alt mode value. This value is a shortcut for accessing + * {@link GameViewSettings.show_entity_info GameViewSettings::show_entity_info} on the player. + */ + readonly alt_mode: boolean + /** Identifier of the event */ + readonly name: typeof defines.events.on_player_toggled_alt_mode + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a player toggles the map editor on or off. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_player_toggled_map_editor View documentation} + */ +interface OnPlayerToggledMapEditorEvent { + readonly player_index: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_player_toggled_map_editor + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called after a players trash inventory changed in some way. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_player_trash_inventory_changed View documentation} + */ +interface OnPlayerTrashInventoryChangedEvent { + readonly player_index: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_player_trash_inventory_changed + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a player is un-banned. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_player_unbanned View documentation} + */ +interface OnPlayerUnbannedEvent { + /** The player un-banned. */ + readonly player_index?: uint + /** The player name un-banned. */ + readonly player_name: string + /** The player that did the un-banning if any. */ + readonly by_player?: uint + /** The reason the player was banned if any. */ + readonly reason?: string + /** Identifier of the event */ + readonly name: typeof defines.events.on_player_unbanned + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a player is unmuted. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_player_unmuted View documentation} + */ +interface OnPlayerUnmutedEvent { + /** The player. */ + readonly player_index: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_player_unmuted + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a player uses a capsule that results in some game action. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_player_used_capsule View documentation} + */ +interface OnPlayerUsedCapsuleEvent { + /** The player. */ + readonly player_index: uint + /** The capsule item used. */ + readonly item: LuaItemPrototype + /** The position the capsule was used. */ + readonly position: Position + /** Identifier of the event */ + readonly name: typeof defines.events.on_player_used_capsule + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a player uses spidertron remote to send a spidertron to a given position + * + * {@link https://lua-api.factorio.com/next/Events.html#on_player_used_spider_remote View documentation} + */ +interface OnPlayerUsedSpiderRemoteEvent { + /** The player that used the remote. */ + readonly player_index: uint + /** Spider vehicle which was requested to move. */ + readonly vehicle: LuaEntity + /** Goal position to which spidertron was sent to. */ + readonly position: Position + /** If the use was successful. It may fail when spidertron has different driver or when player is on different surface. */ + readonly success: boolean + /** Identifier of the event */ + readonly name: typeof defines.events.on_player_used_spider_remote + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called after an entity dies. Can be filtered using {@link LuaPostEntityDiedEventFilter}. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_post_entity_died View documentation} + */ +interface OnPostEntityDiedEvent { + /** The ghost created by the entity dying if any. */ + readonly ghost?: LuaEntity + /** The force that did the killing if any. */ + readonly force?: LuaForce + /** Position where the entity died. */ + readonly position: Position + /** The entity prototype of the entity that died. */ + readonly prototype: LuaEntityPrototype + /** The damage type if any. */ + readonly damage_type?: LuaDamagePrototype + /** The corpses created by the entity dying if any. */ + readonly corpses: LuaEntity[] + /** The surface the entity was on. */ + readonly surface_index: uint + /** The unit number the entity had if any. */ + readonly unit_number?: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_post_entity_died + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when players uses an item to build something. Called before {@link OnBuiltEntityEvent on_built_entity}. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_pre_build View documentation} + */ +interface OnPreBuildEvent { + /** The player who did the placing. */ + readonly player_index: uint + /** Where the item was placed. */ + readonly position: Position + /** Item was placed using shift building. */ + readonly shift_build: boolean + /** The direction the item was facing when placed. */ + readonly direction: defines.direction + /** If building this blueprint was flipped horizontally. */ + readonly flip_horizontal: boolean + /** If building this blueprint was flipped vertically. */ + readonly flip_vertical: boolean + /** Item was placed while moving. */ + readonly created_by_moving: boolean + /** Identifier of the event */ + readonly name: typeof defines.events.on_pre_build + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called before one or more chunks are deleted using {@link LuaSurface.delete_chunk LuaSurface::delete_chunk}. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_pre_chunk_deleted View documentation} + */ +interface OnPreChunkDeletedEvent { + readonly surface_index: uint + /** The chunks to be deleted. */ + readonly positions: ChunkPosition[] + /** Identifier of the event */ + readonly name: typeof defines.events.on_pre_chunk_deleted + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called before entity copy-paste is done. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_pre_entity_settings_pasted View documentation} + */ +interface OnPreEntitySettingsPastedEvent { + readonly player_index: uint + /** The source entity settings will be copied from. */ + readonly source: LuaEntity + /** The destination entity settings will be copied to. */ + readonly destination: LuaEntity + /** Identifier of the event */ + readonly name: typeof defines.events.on_pre_entity_settings_pasted + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called before a ghost entity is destroyed as a result of being marked for deconstruction. Can be filtered using + * {@link LuaPreGhostDeconstructedEventFilter}. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_pre_ghost_deconstructed View documentation} + */ +interface OnPreGhostDeconstructedEvent { + /** The player that did the deconstruction if any. */ + readonly player_index?: uint + readonly ghost: LuaEntity + /** Identifier of the event */ + readonly name: typeof defines.events.on_pre_ghost_deconstructed + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called directly before a permission group is deleted. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_pre_permission_group_deleted View documentation} + */ +interface OnPrePermissionGroupDeletedEvent { + /** The player doing the deletion. */ + readonly player_index: uint + /** The group to be deleted. */ + readonly group: LuaPermissionGroup + /** Identifier of the event */ + readonly name: typeof defines.events.on_pre_permission_group_deleted + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called directly before a permission string is imported. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_pre_permission_string_imported View documentation} + */ +interface OnPrePermissionStringImportedEvent { + /** The player importing the string. */ + readonly player_index: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_pre_permission_string_imported + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a player queues something to be crafted. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_pre_player_crafted_item View documentation} + */ +interface OnPrePlayerCraftedItemEvent { + /** The player doing the crafting. */ + readonly player_index: uint + /** The recipe being queued. */ + readonly recipe: LuaRecipe + /** The items removed from the players inventory to do the crafting. */ + readonly items: LuaInventory + /** The number of times the recipe is being queued. */ + readonly queued_count: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_pre_player_crafted_item + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called before a players dies. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_pre_player_died View documentation} + */ +interface OnPrePlayerDiedEvent { + readonly player_index: uint + readonly cause?: LuaEntity + /** Identifier of the event */ + readonly name: typeof defines.events.on_pre_player_died + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called before a player leaves the game. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_pre_player_left_game View documentation} + */ +interface OnPrePlayerLeftGameEvent { + readonly player_index: uint + readonly reason: defines.disconnect_reason + /** Identifier of the event */ + readonly name: typeof defines.events.on_pre_player_left_game + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when the player finishes mining an entity, before the entity is removed from map. Can be filtered using + * {@link LuaPrePlayerMinedEntityEventFilter}. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_pre_player_mined_item View documentation} + */ +interface OnPrePlayerMinedItemEvent { + /** The entity being mined */ + readonly entity: LuaEntity + readonly player_index: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_pre_player_mined_item + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called before a player is removed (deleted) from the game. Not to be confused with the player logging of this is + * different in that the player is deleted as if he never existed in the save file. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_pre_player_removed View documentation} + */ +interface OnPrePlayerRemovedEvent { + /** The player index that will be removed */ + readonly player_index: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_pre_player_removed + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called before a player toggles the map editor on or off. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_pre_player_toggled_map_editor View documentation} + */ +interface OnPrePlayerToggledMapEditorEvent { + readonly player_index: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_pre_player_toggled_map_editor + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called directly before a robot explodes cliffs. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_pre_robot_exploded_cliff View documentation} + */ +interface OnPreRobotExplodedCliffEvent { + readonly robot: LuaEntity + readonly cliff: LuaEntity + /** The cliff explosive used. */ + readonly item: LuaItemPrototype + /** Identifier of the event */ + readonly name: typeof defines.events.on_pre_robot_exploded_cliff + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called just before a script inventory is resized. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_pre_script_inventory_resized View documentation} + */ +interface OnPreScriptInventoryResizedEvent { + /** If done by console command; the player who ran the command. */ + readonly player_index?: uint + /** The mod that did the resizing. This will be `"core"` if done by console command or scenario script. */ + readonly mod: string + readonly inventory: LuaInventory + /** The old inventory size. */ + readonly old_size: uint + /** The new inventory size. */ + readonly new_size: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_pre_script_inventory_resized + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called just before a surface is cleared (all entities removed and all chunks deleted). + * + * {@link https://lua-api.factorio.com/next/Events.html#on_pre_surface_cleared View documentation} + */ +interface OnPreSurfaceClearedEvent { + readonly surface_index: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_pre_surface_cleared + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called just before a surface is deleted. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_pre_surface_deleted View documentation} + */ +interface OnPreSurfaceDeletedEvent { + readonly surface_index: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_pre_surface_deleted + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a research finishes. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_research_finished View documentation} + */ +interface OnResearchFinishedEvent { + /** The researched technology */ + readonly research: LuaTechnology + /** If the technology was researched by script. */ + readonly by_script: boolean + /** Identifier of the event */ + readonly name: typeof defines.events.on_research_finished + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a research is reversed (unresearched). + * + * {@link https://lua-api.factorio.com/next/Events.html#on_research_reversed View documentation} + */ +interface OnResearchReversedEvent { + /** The technology un-researched */ + readonly research: LuaTechnology + /** If the technology was un-researched by script. */ + readonly by_script: boolean + /** Identifier of the event */ + readonly name: typeof defines.events.on_research_reversed + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a technology research starts. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_research_started View documentation} + */ +interface OnResearchStartedEvent { + /** The technology being researched */ + readonly research: LuaTechnology + readonly last_research?: LuaTechnology + /** Identifier of the event */ + readonly name: typeof defines.events.on_research_started + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a resource entity reaches 0 or its minimum yield for infinite resources. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_resource_depleted View documentation} + */ +interface OnResourceDepletedEvent { + readonly entity: LuaEntity + /** Identifier of the event */ + readonly name: typeof defines.events.on_resource_depleted + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a construction robot builds an entity. Can be filtered using {@link LuaRobotBuiltEntityEventFilter}. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_robot_built_entity View documentation} + */ +interface OnRobotBuiltEntityEvent { + /** The robot that did the building. */ + readonly robot: LuaEntity + /** The entity built. */ + readonly created_entity: LuaEntity + /** The item used to do the building. */ + readonly stack: LuaItemStack + /** The tags associated with this entity if any. */ + readonly tags?: Tags + /** Identifier of the event */ + readonly name: typeof defines.events.on_robot_built_entity + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called after a robot builds tiles. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_robot_built_tile View documentation} + */ +interface OnRobotBuiltTileEvent { + /** The robot. */ + readonly robot: LuaEntity + /** The position data. */ + readonly tiles: OldTileAndPosition[] + /** The tile prototype that was placed. */ + readonly tile: LuaTilePrototype + /** The item type used to build the tiles. */ + readonly item: LuaItemPrototype + /** The stack used to build the tiles (may be empty if all of the items where used to build the tiles). */ + readonly stack: LuaItemStack + /** The surface the tile(s) are build on. */ + readonly surface_index: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_robot_built_tile + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called directly after a robot explodes cliffs. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_robot_exploded_cliff View documentation} + */ +interface OnRobotExplodedCliffEvent { + readonly robot: LuaEntity + /** The cliff explosive used. */ + readonly item: LuaItemPrototype + /** Identifier of the event */ + readonly name: typeof defines.events.on_robot_exploded_cliff + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a robot mines an entity. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_robot_mined View documentation} + */ +interface OnRobotMinedEvent { + /** The robot that did the mining. */ + readonly robot: LuaEntity + /** The entity the robot just picked up. */ + readonly item_stack: SimpleItemStack + /** Identifier of the event */ + readonly name: typeof defines.events.on_robot_mined + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called after the results of an entity being mined are collected just before the entity is destroyed. After this event + * any items in the buffer will be transferred into the robot as if they came from mining the entity. Can be filtered + * using {@link LuaRobotMinedEntityEventFilter}. + * + * **Note**: The buffer inventory is special in that it's only valid during this event and has a dynamic size expanding + * as more items are transferred into it. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_robot_mined_entity View documentation} + */ +interface OnRobotMinedEntityEvent { + /** The robot doing the mining. */ + readonly robot: LuaEntity + /** The entity that has been mined. */ + readonly entity: LuaEntity + /** The temporary inventory that holds the result of mining the entity. */ + readonly buffer: LuaInventory + /** Identifier of the event */ + readonly name: typeof defines.events.on_robot_mined_entity + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called after a robot mines tiles. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_robot_mined_tile View documentation} + */ +interface OnRobotMinedTileEvent { + /** The robot. */ + readonly robot: LuaEntity + /** The position data. */ + readonly tiles: OldTileAndPosition[] + /** The surface the tile(s) were mined on. */ + readonly surface_index: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_robot_mined_tile + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called before a robot mines an entity. Can be filtered using {@link LuaPreRobotMinedEntityEventFilter}. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_robot_pre_mined View documentation} + */ +interface OnRobotPreMinedEvent { + /** The robot that's about to do the mining. */ + readonly robot: LuaEntity + /** The entity which is about to be mined. */ + readonly entity: LuaEntity + /** Identifier of the event */ + readonly name: typeof defines.events.on_robot_pre_mined + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a rocket silo is ordered to be launched. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_rocket_launch_ordered View documentation} + */ +interface OnRocketLaunchOrderedEvent { + readonly rocket: LuaEntity + readonly rocket_silo: LuaEntity + /** The player that is riding the rocket, if any. */ + readonly player_index?: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_rocket_launch_ordered + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when the rocket is launched. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_rocket_launched View documentation} + */ +interface OnRocketLaunchedEvent { + readonly rocket: LuaEntity + readonly rocket_silo?: LuaEntity + /** The player that is riding the rocket, if any. */ + readonly player_index?: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_rocket_launched + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a runtime mod setting is changed by a player. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_runtime_mod_setting_changed View documentation} + */ +interface OnRuntimeModSettingChangedEvent { + /** + * If the `setting_type` is `"global"` and it was changed through the mod settings GUI, this is the index of the + * player that changed the global setting. If the `setting_type` is `"runtime-per-user"` and it changed a current + * setting of the player, this is the index of the player whose setting was changed. In all other cases, this is `nil`. + */ + readonly player_index?: uint + /** The prototype name of the setting that was changed. */ + readonly setting: string + /** Either "runtime-per-user" or "runtime-global". */ + readonly setting_type: "runtime-per-user" | "runtime-global" + /** Identifier of the event */ + readonly name: typeof defines.events.on_runtime_mod_setting_changed + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called just after a script inventory is resized. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_script_inventory_resized View documentation} + */ +interface OnScriptInventoryResizedEvent { + /** If done by console command; the player who ran the command. */ + readonly player_index?: uint + /** The mod that did the resizing. This will be `"core"` if done by console command or scenario script. */ + readonly mod: string + readonly inventory: LuaInventory + /** The old inventory size. */ + readonly old_size: uint + /** The new inventory size. */ + readonly new_size: uint + /** Any items which didn't fit into the new inventory size. */ + readonly overflow_inventory: LuaInventory + /** Identifier of the event */ + readonly name: typeof defines.events.on_script_inventory_resized + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a {@link LuaSurface.request_path LuaSurface::request_path} call completes. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_script_path_request_finished View documentation} + */ +interface OnScriptPathRequestFinishedEvent { + /** The actual path that the pathfinder has determined. `nil` if pathfinding failed. */ + readonly path?: PathfinderWaypoint[] + /** Handle to associate the callback with a particular call to {@link LuaSurface.request_path LuaSurface::request_path}. */ + readonly id: uint + /** Indicates that the pathfinder failed because it is too busy, and that you can retry later. */ + readonly try_again_later: boolean + /** Identifier of the event */ + readonly name: typeof defines.events.on_script_path_request_finished + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a script trigger effect is triggered. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_script_trigger_effect View documentation} + */ +interface OnScriptTriggerEffectEvent { + /** The effect_id specified in the trigger effect. */ + readonly effect_id: string + /** The surface the effect happened on. */ + readonly surface_index: uint + readonly source_position?: Position + readonly source_entity?: LuaEntity + readonly target_position?: Position + readonly target_entity?: LuaEntity + /** Identifier of the event */ + readonly name: typeof defines.events.on_script_trigger_effect + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when an entity of type `radar` finishes scanning a sector. Can be filtered for the radar using + * {@link LuaSectorScannedEventFilter}. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_sector_scanned View documentation} + */ +interface OnSectorScannedEvent { + /** The radar that did the scanning. */ + readonly radar: LuaEntity + /** The chunk scanned. */ + readonly chunk_position: ChunkPosition + /** Area of the scanned chunk. */ + readonly area: BoundingBox + /** Identifier of the event */ + readonly name: typeof defines.events.on_sector_scanned + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called after the selected entity changes for a given player. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_selected_entity_changed View documentation} + */ +interface OnSelectedEntityChangedEvent { + /** The player whose selected entity changed. */ + readonly player_index: uint + /** The last selected entity if it still exists and there was one. */ + readonly last_entity?: LuaEntity + /** Identifier of the event */ + readonly name: typeof defines.events.on_selected_entity_changed + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a spider finishes moving to its autopilot position. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_spider_command_completed View documentation} + */ +interface OnSpiderCommandCompletedEvent { + /** Spider vehicle which was requested to move. */ + readonly vehicle: LuaEntity + /** Identifier of the event */ + readonly name: typeof defines.events.on_spider_command_completed + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a translation request generated through + * {@link LuaPlayer.request_translation LuaPlayer::request_translation} is translated. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_string_translated View documentation} + */ +interface OnStringTranslatedEvent { + /** The player whose locale was used for the translation. */ + readonly player_index: uint + /** The localised string being translated. */ + readonly localised_string: LocalisedString + /** The translated `localised_string`. */ + readonly result: string + /** Whether the requested localised string was valid and could be translated. */ + readonly translated: boolean + /** Identifier of the event */ + readonly name: typeof defines.events.on_string_translated + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called just after a surface is cleared (all entities removed and all chunks deleted). + * + * {@link https://lua-api.factorio.com/next/Events.html#on_surface_cleared View documentation} + */ +interface OnSurfaceClearedEvent { + readonly surface_index: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_surface_cleared + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a surface is created. + * + * **Note**: This is not called when the default surface is created as it will always exist. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_surface_created View documentation} + */ +interface OnSurfaceCreatedEvent { + readonly surface_index: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_surface_created + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called after a surface is deleted. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_surface_deleted View documentation} + */ +interface OnSurfaceDeletedEvent { + readonly surface_index: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_surface_deleted + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called after a surface is imported. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_surface_imported View documentation} + */ +interface OnSurfaceImportedEvent { + readonly surface_index: uint + /** The original surface name. */ + readonly original_name: string + /** Identifier of the event */ + readonly name: typeof defines.events.on_surface_imported + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a surface is renamed. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_surface_renamed View documentation} + */ +interface OnSurfaceRenamedEvent { + readonly surface_index: uint + readonly old_name: string + readonly new_name: string + /** Identifier of the event */ + readonly name: typeof defines.events.on_surface_renamed + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when {@link LuaForce.reset_technology_effects LuaForce::reset_technology_effects} is finished. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_technology_effects_reset View documentation} + */ +interface OnTechnologyEffectsResetEvent { + readonly force: LuaForce + /** Identifier of the event */ + readonly name: typeof defines.events.on_technology_effects_reset + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * It is fired once every tick. Since this event is fired every tick, its handler shouldn't include performance heavy code. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_tick View documentation} + */ +interface OnTickEvent { + /** Identifier of the event */ + readonly name: typeof defines.events.on_tick + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a train changes state (started to stopped and vice versa) + * + * {@link https://lua-api.factorio.com/next/Events.html#on_train_changed_state View documentation} + */ +interface OnTrainChangedStateEvent { + readonly train: LuaTrain + readonly old_state: defines.train_state + /** Identifier of the event */ + readonly name: typeof defines.events.on_train_changed_state + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a new train is created either through disconnecting/connecting an existing one or building a new one. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_train_created View documentation} + */ +interface OnTrainCreatedEvent { + readonly train: LuaTrain + /** The first old train id when splitting/merging trains. */ + readonly old_train_id_1?: uint + /** The second old train id when splitting/merging trains. */ + readonly old_train_id_2?: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_train_created + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a trains schedule is changed either by the player or through script. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_train_schedule_changed View documentation} + */ +interface OnTrainScheduleChangedEvent { + readonly train: LuaTrain + /** The player who made the change if any. */ + readonly player_index?: uint + /** Identifier of the event */ + readonly name: typeof defines.events.on_train_schedule_changed + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when an entity with a trigger prototype (such as capsules) create an entity AND that trigger prototype defined + * `trigger_created_entity="true"`. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_trigger_created_entity View documentation} + */ +interface OnTriggerCreatedEntityEvent { + readonly entity: LuaEntity + readonly source?: LuaEntity + /** Identifier of the event */ + readonly name: typeof defines.events.on_trigger_created_entity + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when an entity with a trigger prototype (such as capsules) fire an artillery projectile AND that trigger + * prototype defined `trigger_fired_artillery="true"`. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_trigger_fired_artillery View documentation} + */ +interface OnTriggerFiredArtilleryEvent { + readonly entity: LuaEntity + readonly source?: LuaEntity + /** Identifier of the event */ + readonly name: typeof defines.events.on_trigger_fired_artillery + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a unit is added to a unit group. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_unit_added_to_group View documentation} + */ +interface OnUnitAddedToGroupEvent { + readonly unit: LuaEntity + readonly group: LuaUnitGroup + /** Identifier of the event */ + readonly name: typeof defines.events.on_unit_added_to_group + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a new unit group is created, before any members are added to it. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_unit_group_created View documentation} + */ +interface OnUnitGroupCreatedEvent { + readonly group: LuaUnitGroup + /** Identifier of the event */ + readonly name: typeof defines.events.on_unit_group_created + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a unit group finishes gathering and starts executing its command. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_unit_group_finished_gathering View documentation} + */ +interface OnUnitGroupFinishedGatheringEvent { + readonly group: LuaUnitGroup + /** Identifier of the event */ + readonly name: typeof defines.events.on_unit_group_finished_gathering + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a unit is removed from a unit group. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_unit_removed_from_group View documentation} + */ +interface OnUnitRemovedFromGroupEvent { + readonly unit: LuaEntity + readonly group: LuaUnitGroup + /** Identifier of the event */ + readonly name: typeof defines.events.on_unit_removed_from_group + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * Called when a worker (construction or logistic) robot expires through a lack of energy. + * + * {@link https://lua-api.factorio.com/next/Events.html#on_worker_robot_expired View documentation} + */ +interface OnWorkerRobotExpiredEvent { + readonly robot: LuaEntity + /** Identifier of the event */ + readonly name: typeof defines.events.on_worker_robot_expired + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * A static event mods can use to tell other mods they built something by script. This event is only raised if a mod + * does so with {@link LuaBootstrap.raise_event LuaBootstrap::raise_event} or + * {@link LuaBootstrap.raise_script_built LuaBootstrap::raise_script_built}, or when `raise_built` is passed to + * {@link LuaSurface.create_entity LuaSurface::create_entity}. Can be filtered using {@link LuaScriptRaisedBuiltEventFilter}. + * + * {@link https://lua-api.factorio.com/next/Events.html#script_raised_built View documentation} + */ +interface ScriptRaisedBuiltEvent { + /** The entity that has been built. */ + readonly entity: LuaEntity + /** Identifier of the event */ + readonly name: typeof defines.events.script_raised_built + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * A static event mods can use to tell other mods they destroyed something by script. This event is only raised if a mod + * does so with {@link LuaBootstrap.raise_event LuaBootstrap::raise_event} or + * {@link LuaBootstrap.raise_script_destroy LuaBootstrap::raise_script_destroy}, or when `raise_destroy` is passed to + * {@link LuaEntity.destroy LuaEntity::destroy}. Can be filtered using {@link LuaScriptRaisedDestroyEventFilter}. + * + * {@link https://lua-api.factorio.com/next/Events.html#script_raised_destroy View documentation} + */ +interface ScriptRaisedDestroyEvent { + /** The entity that was destroyed. */ + readonly entity: LuaEntity + /** Identifier of the event */ + readonly name: typeof defines.events.script_raised_destroy + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * A static event mods can use to tell other mods they revived something by script. This event is only raised if a mod + * does so with {@link LuaBootstrap.raise_event LuaBootstrap::raise_event} or + * {@link LuaBootstrap.raise_script_revive LuaBootstrap::raise_script_revive}, or when `raise_revive` is passed to + * {@link LuaEntity.revive LuaEntity::revive}. Can be filtered using {@link LuaScriptRaisedReviveEventFilter}. + * + * {@link https://lua-api.factorio.com/next/Events.html#script_raised_revive View documentation} + */ +interface ScriptRaisedReviveEvent { + /** The entity that was revived. */ + readonly entity: LuaEntity + /** The tags associated with this entity, if any. */ + readonly tags?: Tags + /** Identifier of the event */ + readonly name: typeof defines.events.script_raised_revive + /** Tick the event was generated. */ + readonly tick: uint +} + +/** + * A static event mods can use to tell other mods they changed tiles on a surface by script. This event is only raised + * if a mod does so with {@link LuaBootstrap.raise_event LuaBootstrap::raise_event} or + * {@link LuaBootstrap.raise_script_set_tiles LuaBootstrap::raise_script_set_tiles}, or when `raise_event` is passed to + * {@link LuaSurface.set_tiles LuaSurface::set_tiles}. + * + * {@link https://lua-api.factorio.com/next/Events.html#script_raised_set_tiles View documentation} + */ +interface ScriptRaisedSetTilesEvent { + /** The surface whose tiles were changed. */ + readonly surface_index: uint + /** The tiles that were changed. */ + readonly tiles: Tile[] + /** Identifier of the event */ + readonly name: typeof defines.events.script_raised_set_tiles + /** Tick the event was generated. */ + readonly tick: uint +} + +/** An event id. */ +type EventId = uint & { + readonly _eventData: T + readonly _filter: F +} + +/** + * An event id generated by {@link LuaBootstrap.generate_event_name LuaBootstrap::generate_event_name} and raisable via + * {@link LuaBootstrap.raise_event LuaBootstrap::raise_event}. + */ +type CustomEventId = EventId & { + _customEventIdBrand: any +} diff --git a/modules/mod2/typed-factorio/generated/global-objects.d.ts b/modules/mod2/typed-factorio/generated/global-objects.d.ts new file mode 100644 index 0000000..f4c5a0f --- /dev/null +++ b/modules/mod2/typed-factorio/generated/global-objects.d.ts @@ -0,0 +1,51 @@ +/** @noSelfInFile */ + +/** + * This is the main object, through which most of the API is accessed. It is, however, not available inside handlers + * registered with {@link LuaBootstrap.on_load LuaBootstrap::on_load}. + * + * {@link https://lua-api.factorio.com/next/ View documentation} + */ +declare const game: LuaGameScript + +/** + * Provides an interface for registering event handlers. + * + * {@link https://lua-api.factorio.com/next/ View documentation} + */ +declare const script: LuaBootstrap + +/** + * Allows inter-mod communication by way of providing a repository of interfaces that is shared by all mods. + * + * {@link https://lua-api.factorio.com/next/ View documentation} + */ +declare const remote: LuaRemote + +/** + * Allows registering custom commands for the in-game console accessible via the grave key. + * + * {@link https://lua-api.factorio.com/next/ View documentation} + */ +declare const commands: LuaCommandProcessor + +/** + * Allows reading the current mod settings. + * + * {@link https://lua-api.factorio.com/next/ View documentation} + */ +declare const settings: LuaSettings + +/** + * Allows printing messages to the calling RCON instance if any. + * + * {@link https://lua-api.factorio.com/next/ View documentation} + */ +declare const rcon: LuaRCON + +/** + * Allows rendering of geometric shapes, text and sprites in the game world. + * + * {@link https://lua-api.factorio.com/next/ View documentation} + */ +declare const rendering: LuaRendering diff --git a/modules/mod2/typed-factorio/generated/index.d.ts b/modules/mod2/typed-factorio/generated/index.d.ts new file mode 100644 index 0000000..4a7b7d8 --- /dev/null +++ b/modules/mod2/typed-factorio/generated/index.d.ts @@ -0,0 +1,7 @@ +/// +/// +/// +/// +/// +/// +/// diff --git a/modules/mod2/typed-factorio/package.json b/modules/mod2/typed-factorio/package.json new file mode 100644 index 0000000..6a0eb5a --- /dev/null +++ b/modules/mod2/typed-factorio/package.json @@ -0,0 +1,39 @@ +{ + "name": "typed-factorio", + "version": "0.7.1", + "description": "Featureful typescript definitions for the the Factorio modding lua api.", + "keywords": [ + "factorio", + "types", + "typescript-to-lua", + "tstl" + ], + "repository": "https://github.com/GlassBricks/typed-factorio", + "license": "MIT", + "files": [ + "**/*.d.ts" + ], + "homepage": "https://github.com/GlassBricks/typed-factorio#readme", + "scripts": { + "generate": "cd ../generator && yarn run check && yarn run gen --in ../definitions/generatorSrc --out ../definitions/generated --warn-as-error", + "generate:dev": "cd ../generator && yarn run gen --in ../definitions/generatorSrc --out ../definitions/generated --no-format", + "clean": "rimraf ./generated", + "pretest": "yarn run generate", + "test": "jest", + "prepublishOnly": "yarn run test", + "download-latest-runtime-api": "ts-node ./scripts/downloadLatest.ts" + }, + "dependencies": { + "lua-types": "^2.10.1", + "typescript": "~4.3.5", + "typescript-to-lua": "^1.0.0" + }, + "devDependencies": { + "@types/jest": "^26.0.24", + "@types/node": "^16.4.13", + "jest": "^27.0.6", + "prettier": "^2.3.2", + "ts-jest": "^27.0.4", + "ts-node": "^10.1.0" + } +} diff --git a/modules/mod2/typed-factorio/runtime/index.d.ts b/modules/mod2/typed-factorio/runtime/index.d.ts new file mode 100644 index 0000000..43bdc07 --- /dev/null +++ b/modules/mod2/typed-factorio/runtime/index.d.ts @@ -0,0 +1,10 @@ +/// + +/// + +/// +/// + +// lualib +/// +/// diff --git a/modules/mod2/typed-factorio/runtime/librariesAndFunctions.d.ts b/modules/mod2/typed-factorio/runtime/librariesAndFunctions.d.ts new file mode 100644 index 0000000..82a0f31 --- /dev/null +++ b/modules/mod2/typed-factorio/runtime/librariesAndFunctions.d.ts @@ -0,0 +1,123 @@ +// from https://lua-api.factorio.com/latest/Libraries.html +// last updated for 1.1.35, 1.1.36, 1.1.37 + +/** @noSelfInFile */ + +/** @noSelf */ +interface SerpentOptions { + /** Indentation; triggers long multi-line output. */ + indent: string + /** Provide stringified value in a comment (up to maxlevel of depth). */ + comment: boolean | number + /** Sort keys. */ + sortkeys: boolean | ((this: void, keys: any[], table: any) => void) + /** Force sparse encoding (no nil filling based on #t). */ + sparse: boolean + /** Remove spaces. */ + compact: boolean + /** Raise fatal error on non-serializable values. */ + fatal: boolean + /** Disable bytecode serialization for easy comparison. */ + nocode: boolean + /** Disable checking numbers against undefined and huge values. */ + nohuge: boolean + /** Specify max level up to which to expand nested tables. */ + maxlevel: number + /** Specify max number of elements in a table. */ + maxnum: number + /** Specify max length for all table elements. */ + maxlength: number + /** + * Use __tostring metamethod when serializing tables (v0.29); set to false to disable and serialize the table as is, + * even when __tostring is present. + */ + metatostring: boolean + /** + * Specify format for numeric values as shortest possible round-trippable double (v0.30). Use "%.16g" for better + * readability and "%.17g" (the default value) to preserve floating point precision. + */ + numformat: string + /** Allows to specify a list of values to ignore (as keys). */ + valignore: string[] + /** Allows to specify the list of keys to be serialized. Any keys not in this list are not included in final output (as keys). */ + keyallow: string[] + /** Allows to specity the list of keys to ignore in serialization. */ + keyignore: string[] + /** Allows to specify a list of value types to ignore (as keys). */ + valtypeignore: string[] + /** Provide custom output for tables. */ + custom(opts: { + /** The name of the current element with '=' or an empty string in case of array index, */ + tag: string + /** An opening table bracket { and associated indentation and newline (if any), */ + head: string + /** Table elements concatenated into a string using commas and indentation/newlines (if any), */ + body: string + /** A closing table bracket } and associated indentation and newline (if any), and */ + tail: string + /** The current level. */ + level: number + }): string + /** Name; triggers full serialization with self-ref section. */ + name: string + + refcomment: boolean | number + tablecomment: boolean | number +} + +/** + * Factorio provides the {@link https://github.com/pkulchenko/serpent serpent library} as a global variable `serpent` for + * all mods to use. It allows for easy debugging of tables, because serpent makes it trivial to print them, for example + * by using `serpent.block()`. However, serpent cannot pretty-print LuaObjects such as LuaEntity. The serpent library + * was modified to improve determinism, e.g. comments are turned off by default to avoid returning table addresses. + * Furthermore, two options were added: `refcomment` (true/false/maxlevel) and `tablecomment` (true/false/maxlevel), + * which allow to separately control the self-reference and table value output of the `comment` option. + */ +declare namespace serpent { + /** Full serialization; sets name, compact and sparse options; */ + function dump(tbl: unknown, options?: Partial): string + + /** Single line pretty printing, no self-ref section; sets sortkeys and comment options; */ + function line(tbl: unknown, options?: Partial): string + + /** Multi-line indented pretty printing, no self-ref section; sets indent, sortkeys, and comment options. */ + function block(tbl: unknown, options?: Partial): string + + /** + * For loading serialized fragments, serpent also provides `load` function that adds safety checks and reports an + * error if there is any executable code in the fragment. + */ + function load(str: string, options?: { safe?: boolean }): LuaMultiReturn<[true, T] | [false, string]> +} + +/** + * This function allows to log {@link LocalisedString} to the Factorio + * {@link https://wiki.factorio.com/Log_file log file}. This, in combination with serpent, makes debugging in the data + * stage easier, because it allows to simply inspect entire prototype tables. For example, this allows to see all + * properties of the sulfur item prototype: `log(serpent.block(data.raw["item"]["sulfur"]))` + */ +declare function log(ls: LocalisedString): void + +/** + * This function allows printing {@link LocalisedString}s to stdout without polluting the logfile. This is primarily + * useful for communicating with external tools that launch Factorio as a child process. + */ +declare function localised_print(ls: LocalisedString): void + +/** + * Factorio provides the function `table_size()` as a simple way to find the size of tables with non-continuous keys, + * because the standard `#` does not work correctly for these. The function is a C++-side implementation of the + * following Lua code, thus it is faster than using this code in Lua: + * + * local function size(t) + * local count = 0 + * for k,v in pairs(t) do + * count = count + 1 + * end + * return count + * end + * + * Note that `table_size()` does not work correctly for {@link LuaCustomTable}s, their size has to be determined with + * {@link LuaCustomTable.length LuaCustomTable::operator #} instead. + */ +declare function table_size(tbl: table): number diff --git a/modules/mod2/typed-factorio/runtime/mod-gui.d.ts b/modules/mod2/typed-factorio/runtime/mod-gui.d.ts new file mode 100644 index 0000000..761a98f --- /dev/null +++ b/modules/mod2/typed-factorio/runtime/mod-gui.d.ts @@ -0,0 +1,11 @@ +/** @noSelfInFile */ + +/** @noResolution */ +declare module "mod-gui" { + const button_style: string + const frame_style: string + + function get_button_flow(player: LuaPlayer): FrameGuiElement + + function get_frame_flow(player: LuaPlayer): FlowGuiElement +} diff --git a/modules/mod2/typed-factorio/runtime/pairs.d.ts b/modules/mod2/typed-factorio/runtime/pairs.d.ts new file mode 100644 index 0000000..2ec352f --- /dev/null +++ b/modules/mod2/typed-factorio/runtime/pairs.d.ts @@ -0,0 +1,13 @@ +/** @noSelfInFile */ + +/** Iterating with `pairs` will only iterate the array part of a {@link LuaCustomTable}. */ +declare function pairs(table: LuaCustomTable): LuaIterable> + +declare function pairs(table: LuaCustomTable): LuaIterable> + +/** + * {@link LuaCustomTable} cannot be iterated with `ipairs`. Use `pairs` instead. + * + * @deprecated + */ +declare function ipairs(table: LuaCustomTable): never diff --git a/modules/mod2/typed-factorio/runtime/util.d.ts b/modules/mod2/typed-factorio/runtime/util.d.ts new file mode 100644 index 0000000..08ed5e0 --- /dev/null +++ b/modules/mod2/typed-factorio/runtime/util.d.ts @@ -0,0 +1,120 @@ +// "util" is declared only as a module, even though it also modifies global variables +// This is both because of limitations in `declare module`, and that modules are much friendlier to tooling. + +/** @noSelfInFile */ + +/** @noResolution */ +declare module "util" { + namespace table { + function deepcopy(table: T): T + + function compare(tb1: T, tb2: T): boolean + } + + function copy(table: T): T + + function distance(position1: Position, position2: Position): number + + function positiontostr(position: Position): string + + function formattime(ticks: number): string + + /** Supports 'rrggbb', 'rgb', 'rrggbbaa', 'rgba', 'ww', 'w' */ + function color(hex: string): ColorTable + + function premul_color(color: Color): ColorTable + + function mix_color(c1: Color, c2: Color): ColorArray + + function multiply_color(c1: Color, n: number): ColorArray + + function moveposition( + position: Position, + direction: defines.direction.north | defines.direction.east | defines.direction.south | defines.direction.west, + distance: number + ): Position + function moveposition( + position: Position, + direction: defines.direction, //todo: cardinal only + distance: number + ): Position | undefined + + function oppositedirection(direction: defines.direction): defines.direction + + /** Creates a new array where each element in `stripes` is duplicated `count` times */ + function multiplystripes(count: number, stripes: T[]): T[] + + /** Gets tile position by pixel */ + function by_pixel(x: number, y: number): Position + + /** Gets tile position by pixel, hr */ + function by_pixel_hr(x: number, y: number): Position + + // omitted: foreach_sprite_definition + + function add_shift(a: PositionArray | undefined, b: PositionArray): PositionArray + function add_shift(a: PositionArray, b: PositionArray | undefined): PositionArray + function add_shift(a: PositionArray | undefined, b: PositionArray | undefined): PositionArray | undefined + + // omitted: add_shift_offset + + function mul_shift(shift: PositionArray, scale: number | undefined): PositionArray + function mul_shift(shift: PositionArray | undefined, scale: number | undefined): PositionArray | undefined + + function format_number(amount: number, append_suffix?: boolean): string + + function increment(t: number[], index: number, v?: number): void + + // omitted: conditional_return + + /** + * Recursively merges and/or deep-copies tables. Entries in later tables override entries in earlier ones, unless both + * entries are themselves tables, in which case they are recursively merged. Non-merged tables are deep-copied, so + * that the result is brand new. + */ + function merge(tables: T[]): T + + function insert_safe(entity: LuaEntity | undefined, item_dict: Record | undefined): void + + function remove_safe(entity: LuaEntity | undefined, item_dict: Record | undefined): void + + function split_whitespace(string: string): string[] + + // omitted: split, string_starts_with. already TS functions for that + + // omitted: online_players. use game.connected_players + + function clamp(x: number, lower: number, upper: number): number + + // omitted: get_walkable_tile + + // omitted: combine_icons + // omitted: technology_icons. Create an issue if you really want to see these + + function parse_energy(energy: string): number + + function product_amount( + product: { + probability: number + } & ( + | { + amount: number + } + | { + amount_min: number + amount_max: number + } + ) + ): number + + function empty_sprite(): object + + // omitted: draw_as_glow + // omitted: remove_tile_references + + function remove_from_list(list: T[], value: T): boolean + + function list_to_map(list: T[]): Record + function list_to_map(list: T[]): LuaTable + function list_to_map(list: T): LuaTable +} diff --git a/modules/mod2/typed-factorio/settings/types.d.ts b/modules/mod2/typed-factorio/settings/types.d.ts new file mode 100644 index 0000000..d11dae2 --- /dev/null +++ b/modules/mod2/typed-factorio/settings/types.d.ts @@ -0,0 +1,120 @@ +// Based off of https://wiki.factorio.com/Tutorial:Mod_settings + +export type SettingType = "bool-setting" | "int-setting" | "double-setting" | "string-setting" + +export interface BaseSettingDefinition { + type: SettingType + /** + * The name of the settings prototype should be unique to avoid mod conflicts since the mod settings are global across + * all mods. Because of that it is recommended to prefix mod settings with your mod name, + */ + name: string + localized_name?: LocalisedString + localized_description?: LocalisedString + + /** + * The order property can be used to change how the mod settings are ordered in the settings gui. Mod settings are sorted + * + * - First by mod + * - Then by the setting "order" string + * - Then finally by the setting name. + */ + order?: string + /** + * The hidden property can be used to hide mod settings from GUIs, so that they cannot be seen or changed by players. + * However, other mods can still access hidden settings. {@link https://forums.factorio.com/83316} + */ + hidden?: boolean + /** + * There are the overall kinds of settings: + * + * - **startup**: This kind of setting is available in the prototype stage, and can not be changed runtime. They have to + * be set to the same values for all players on a server. + * - **runtime-global**: This kind of setting is global to an entire save game and can be changed runtime. On servers, + * only admins can change these settings. + * - **runtime-per-user**: This kind of setting is only available runtime in the control.lua stage and each player has + * their own instance of this setting. When a player joins a server their local setting of "keep mod settings per + * save" determines if the local settings they have set are synced to the loaded save or if the save's settings are used. + * + * This "setting_type" also determines in which tab the setting is showed in the mod settings menu. + */ + + setting_type: "startup" | "runtime-global" | "runtime-per-user" +} +/** A true/false checkbox */ +export interface BoolSettingDefinition extends BaseSettingDefinition { + type: "bool-setting" + /** Defines the default value of the setting, in this case whether the checkbox is checked or not. */ + default_value: boolean + /** + * Only loaded if `hidden = true`. This forces the setting to be of this value. This can be useful for mod + * compatibility. {@link https://forums.factorio.com/viewtopic.php?p=531322#p531322} + */ + forced_value?: boolean +} +/** A signed 64 bit integer textfield (or selection dropdown) */ +export interface IntSettingDefinition extends BaseSettingDefinition { + type: "int-setting" + /** Defines the default value of the setting. */ + default_value: number + /** Defines the lowest possible number. */ + minimum_value?: number + /** Defines the highest possible number. */ + maximum_value?: number + /** + * Makes it possible to force the player to choose between the defined numbers, creates a dropdown instead of a + * textfield. If only one allowed value is given, the settings is forced to be of that value. + */ + allowed_values?: number[] +} +/** A double precision floating point textfield (or selection dropdown) */ +export interface DoubleSettingDefinition extends BaseSettingDefinition { + type: "double-setting" + /** Defines the default value of the setting. */ + default_value: number + /** Defines the lowest possible number. */ + minimum_value?: number + /** Defines the highest possible number. */ + maximum_value?: number + /** + * Makes it possible to force the player to choose between the defined numbers, creates a dropdown instead of a + * textfield. If only one allowed value is given, the settings is forced to be of that value. + */ + allowed_values?: number[] +} +/** A string textfield (or selection dropdown) */ +export interface StringSettingDefinition extends BaseSettingDefinition { + type: "string-setting" + /** Defines the default value of the setting. */ + default_value: string + /** Defines whether it's possible for the user to set the textfield to empty and apply the setting. */ + allow_blank?: boolean + /** Whether values that are input by the user should have whitespace removed from both ends of the string. */ + auto_trim?: boolean + /** + * Makes it possible to force the player to choose between the defined strings, creates a dropdown instead of a + * textfield. The strings in the dropdown can be localized (translated) and can have a tooltip, see below. If only one + * allowed value is given, the settings is forced to be of that value. + */ + allowed_values?: string[] +} +/** Setting definitions. See {@link https://wiki.factorio.com/Tutorial:Mod_settings} for more info. */ +export type SettingDefinition = + | BoolSettingDefinition + | IntSettingDefinition + | DoubleSettingDefinition + | StringSettingDefinition + +export interface Data { + readonly raw: { + [T in SettingDefinition["type"]]: Record> + } + /** + * The `data` table expects a specific format for each item in the table. Missing properties will either fall back to + * default values or give an error indicating what's missing. Extra properties that the game isn't looking for are + * simply ignored. + */ + extend(prototypes: SettingDefinition[]): void +} +/** A mapping of mod names to mod version for all enabled mods. */ +export type Mods = Record diff --git a/settings.gradle.kts b/settings.gradle.kts index bc26244..d94594e 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,8 +1,8 @@ rootProject.name = "factorio-web-map" include( -// ":modules:mod", - ":modules:mod2", + ":modules:mod", +// ":modules:mod2", ":modules:server", ) diff --git a/src/jsMain/kotlin/factorio.kt b/src/jsMain/kotlin/factorio.kt deleted file mode 100644 index b28b04f..0000000 --- a/src/jsMain/kotlin/factorio.kt +++ /dev/null @@ -1,3 +0,0 @@ - - -