typed-factorio 0.17.1 → 0.18.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1382,7 +1382,8 @@ interface LuaControl {
1382
1382
  *
1383
1383
  * {@link https://lua-api.factorio.com/latest/LuaControl.html#LuaControl.force View documentation}
1384
1384
  */
1385
- force: ForceIdentification
1385
+ get force(): LuaForce
1386
+ set force(value: ForceIdentification)
1386
1387
  /**
1387
1388
  * The currently selected entity; `nil` if none. Assigning an entity will select it if selectable otherwise clears selection.
1388
1389
  *
@@ -1532,7 +1533,8 @@ interface LuaControl {
1532
1533
  *
1533
1534
  * {@link https://lua-api.factorio.com/latest/LuaControl.html#LuaControl.cursor_ghost View documentation}
1534
1535
  */
1535
- cursor_ghost: ItemPrototypeIdentification
1536
+ get cursor_ghost(): LuaItemPrototype
1537
+ set cursor_ghost(value: ItemPrototypeIdentification)
1536
1538
  /**
1537
1539
  * `true` if the player is in a vehicle. Writing to this attribute puts the player in or out of a vehicle.
1538
1540
  *
@@ -2316,7 +2318,7 @@ interface LuaEntity extends LuaControl {
2316
2318
  * @param flag - The flag to test. See {@link EntityPrototypeFlags} for a list of flags.
2317
2319
  * @returns `true` if this entity has the given flag set.
2318
2320
  */
2319
- has_flag(flag: string): boolean
2321
+ has_flag(flag: keyof EntityPrototypeFlags): boolean
2320
2322
  /**
2321
2323
  * Same as {@link LuaEntity.has_flag LuaEntity::has_flag}, but targets the inner entity on a entity ghost.
2322
2324
  *
@@ -2327,7 +2329,7 @@ interface LuaEntity extends LuaControl {
2327
2329
  * @param flag - The flag to test. See {@link EntityPrototypeFlags} for a list of flags.
2328
2330
  * @returns `true` if the entity has the given flag set.
2329
2331
  */
2330
- ghost_has_flag(flag: string): boolean
2332
+ ghost_has_flag(flag: keyof EntityPrototypeFlags): boolean
2331
2333
  /**
2332
2334
  * Offer a thing on the market.
2333
2335
  *
@@ -4410,7 +4412,8 @@ interface LuaEntity extends LuaControl {
4410
4412
  *
4411
4413
  * {@link https://lua-api.factorio.com/latest/LuaEntity.html#LuaEntity.render_to_forces View documentation}
4412
4414
  */
4413
- render_to_forces: ForceIdentification[] | undefined
4415
+ get render_to_forces(): LuaForce[] | undefined
4416
+ set render_to_forces(value: ForceIdentification[] | undefined)
4414
4417
  /**
4415
4418
  * The rail target of this pump or `nil`.
4416
4419
  *
@@ -4740,7 +4743,7 @@ interface BaseEntity extends LuaControl {
4740
4743
  * @param flag - The flag to test. See {@link EntityPrototypeFlags} for a list of flags.
4741
4744
  * @returns `true` if this entity has the given flag set.
4742
4745
  */
4743
- has_flag(flag: string): boolean
4746
+ has_flag(flag: keyof EntityPrototypeFlags): boolean
4744
4747
  /**
4745
4748
  * Connect two devices with a circuit wire or copper cable. Depending on which type of connection should be made,
4746
4749
  * there are different procedures:
@@ -5800,7 +5803,8 @@ interface BaseEntity extends LuaControl {
5800
5803
  *
5801
5804
  * {@link https://lua-api.factorio.com/latest/LuaEntity.html#LuaEntity.render_to_forces View documentation}
5802
5805
  */
5803
- render_to_forces: ForceIdentification[] | undefined
5806
+ get render_to_forces(): LuaForce[] | undefined
5807
+ set render_to_forces(value: ForceIdentification[] | undefined)
5804
5808
  /**
5805
5809
  * Returns the id of the electric network that this entity is connected to or `nil`.
5806
5810
  *
@@ -6016,7 +6020,7 @@ interface EntityGhostEntity extends BaseEntity {
6016
6020
  * @param flag - The flag to test. See {@link EntityPrototypeFlags} for a list of flags.
6017
6021
  * @returns `true` if the entity has the given flag set.
6018
6022
  */
6019
- ghost_has_flag(flag: string): boolean
6023
+ ghost_has_flag(flag: keyof EntityPrototypeFlags): boolean
6020
6024
  /**
6021
6025
  * The unit number of the entity contained in this ghost or nil if the entity doesn't have one.
6022
6026
  *
@@ -7317,7 +7321,7 @@ interface LuaEntityPrototype {
7317
7321
  * @param flag - The flag to test. See {@link EntityPrototypeFlags} for a list of flags.
7318
7322
  * @returns `true` if this prototype has the given flag set.
7319
7323
  */
7320
- has_flag(flag: string): boolean
7324
+ has_flag(flag: keyof EntityPrototypeFlags): boolean
7321
7325
  /**
7322
7326
  * Gets the base size of the given inventory on this entity or `nil` if the given inventory doesn't exist.
7323
7327
  *
@@ -8657,7 +8661,7 @@ interface BaseEntityPrototype {
8657
8661
  * @param flag - The flag to test. See {@link EntityPrototypeFlags} for a list of flags.
8658
8662
  * @returns `true` if this prototype has the given flag set.
8659
8663
  */
8660
- has_flag(flag: string): boolean
8664
+ has_flag(flag: keyof EntityPrototypeFlags): boolean
8661
8665
  /**
8662
8666
  * Gets the base size of the given inventory on this entity or `nil` if the given inventory doesn't exist.
8663
8667
  *
@@ -15568,7 +15572,7 @@ interface LuaItemPrototype {
15568
15572
  * @param flag - The flag to test. See {@link ItemPrototypeFlags} for a list of flags.
15569
15573
  * @returns `true` if this prototype has the given flag set.
15570
15574
  */
15571
- has_flag(flag: string): boolean
15575
+ has_flag(flag: keyof ItemPrototypeFlags): boolean
15572
15576
  /**
15573
15577
  * Type of this ammo prototype or `nil` if this is not an ammo prototype.
15574
15578
  *
@@ -16107,7 +16111,7 @@ interface BaseItemPrototype {
16107
16111
  * @param flag - The flag to test. See {@link ItemPrototypeFlags} for a list of flags.
16108
16112
  * @returns `true` if this prototype has the given flag set.
16109
16113
  */
16110
- has_flag(flag: string): boolean
16114
+ has_flag(flag: keyof ItemPrototypeFlags): boolean
16111
16115
  /**
16112
16116
  * Type of this ammo prototype or `nil` if this is not an ammo prototype.
16113
16117
  *
@@ -3227,7 +3227,7 @@ interface TypeItemPrototypeFilter extends BaseItemPrototypeFilter {
3227
3227
  interface FlagItemPrototypeFilter extends BaseItemPrototypeFilter {
3228
3228
  readonly filter: "flag"
3229
3229
  /** One of the values in {@link ItemPrototypeFlags}. */
3230
- readonly flag: string
3230
+ readonly flag: keyof ItemPrototypeFlags
3231
3231
  }
3232
3232
 
3233
3233
  interface SubgroupItemPrototypeFilter extends BaseItemPrototypeFilter {
@@ -4079,7 +4079,7 @@ interface CollisionMaskEntityPrototypeFilter extends BaseEntityPrototypeFilter {
4079
4079
  interface FlagEntityPrototypeFilter extends BaseEntityPrototypeFilter {
4080
4080
  readonly filter: "flag"
4081
4081
  /** One of the values in {@link EntityPrototypeFlags}. */
4082
- readonly flag: string
4082
+ readonly flag: keyof EntityPrototypeFlags
4083
4083
  }
4084
4084
 
4085
4085
  interface BuildBaseEvolutionRequirementEntityPrototypeFilter extends BaseEntityPrototypeFilter {
@@ -1,9 +1,9 @@
1
- declare module "typescript" {
2
- interface JSDocContainer {
3
- jsDoc?: JSDoc[]
4
- }
5
- interface Node {
6
- emitNode?: unknown
7
- }
8
- }
9
- export {}
1
+ declare module "typescript" {
2
+ interface JSDocContainer {
3
+ jsDoc?: JSDoc[]
4
+ }
5
+ interface Node {
6
+ emitNode?: unknown
7
+ }
8
+ }
9
+ export {}
package/package.json CHANGED
@@ -1,58 +1,58 @@
1
- {
2
- "name": "typed-factorio",
3
- "version": "0.17.1",
4
- "description": "Featureful typescript definitions for the the Factorio modding lua api.",
5
- "keywords": [
6
- "factorio",
7
- "types",
8
- "typescript-to-lua",
9
- "tstl"
10
- ],
11
- "repository": "https://github.com/GlassBricks/typed-factorio",
12
- "license": "MIT",
13
- "files": [
14
- "**/*.d.ts"
15
- ],
16
- "homepage": "https://github.com/GlassBricks/typed-factorio#readme",
17
- "scripts": {
18
- "gen": "ts-node -P generator/tsconfig.json generator/main.ts",
19
- "generate": "yarn run gen --in ./generatorSrc --out ./generated --warn-as-error",
20
- "generate:dev": "yarn run gen --in ./generatorSrc --out ./generated --no-format",
21
- "clean": "rimraf generated",
22
- "pretest": "yarn run generate",
23
- "test": "jest",
24
- "lint": "eslint .",
25
- "check": "yarn run lint && yarn run test",
26
- "prepublishOnly": "yarn run check",
27
- "download-latest-runtime-api": "ts-node ./scripts/downloadLatest.ts"
28
- },
29
- "peerDependencies": {
30
- "lua-types": "^2.11.0",
31
- "typescript-to-lua": "^1.3.1"
32
- },
33
- "devDependencies": {
34
- "@types/jest": "^27.0.3",
35
- "@types/node": "^16.11.12",
36
- "@types/prettier": "^2.4.2",
37
- "@typescript-eslint/eslint-plugin": "^5.6.0",
38
- "@typescript-eslint/parser": "^5.6.0",
39
- "chalk": "^3.0.0",
40
- "commander": "^8.3.0",
41
- "eslint": "^8.4.1",
42
- "eslint-config-prettier": "^8.3.0",
43
- "eslint-config-standard": "^16.0.3",
44
- "eslint-import-resolver-typescript": "^2.5.0",
45
- "eslint-plugin-import": "^2.25.3",
46
- "eslint-plugin-node": "^11.1.0",
47
- "eslint-plugin-prettier": "^4.0.0",
48
- "eslint-plugin-promise": "^5.2.0",
49
- "jest": "^27.4.3",
50
- "lua-types": "^2.11.0",
51
- "prettier": "^2.5.1",
52
- "prettier-plugin-jsdoc": "^0.3.30",
53
- "ts-jest": "^27.1.0",
54
- "ts-node": "^10.4.0",
55
- "typescript": "4.5.2",
56
- "typescript-to-lua": "^1.3.1"
57
- }
58
- }
1
+ {
2
+ "name": "typed-factorio",
3
+ "version": "0.18.0",
4
+ "description": "Featureful typescript definitions for the the Factorio modding lua api.",
5
+ "keywords": [
6
+ "factorio",
7
+ "types",
8
+ "typescript-to-lua",
9
+ "tstl"
10
+ ],
11
+ "repository": "https://github.com/GlassBricks/typed-factorio",
12
+ "license": "MIT",
13
+ "files": [
14
+ "**/*.d.ts"
15
+ ],
16
+ "homepage": "https://github.com/GlassBricks/typed-factorio#readme",
17
+ "scripts": {
18
+ "gen": "ts-node -P generator/tsconfig.json generator/main.ts",
19
+ "generate": "yarn run gen --in ./generatorSrc --out ./generated --warn-as-error",
20
+ "generate:dev": "yarn run gen --in ./generatorSrc --out ./generated --no-format",
21
+ "clean": "rimraf generated",
22
+ "pretest": "yarn run generate",
23
+ "test": "jest",
24
+ "lint": "eslint .",
25
+ "check": "yarn run lint && yarn run test",
26
+ "prepublishOnly": "yarn run check",
27
+ "download-latest-runtime-api": "ts-node ./scripts/downloadLatest.ts"
28
+ },
29
+ "peerDependencies": {
30
+ "lua-types": "^2.11.0",
31
+ "typescript-to-lua": "^1.3.1"
32
+ },
33
+ "devDependencies": {
34
+ "@types/jest": "^27.0.3",
35
+ "@types/node": "^16.11.12",
36
+ "@types/prettier": "^2.4.2",
37
+ "@typescript-eslint/eslint-plugin": "^5.6.0",
38
+ "@typescript-eslint/parser": "^5.6.0",
39
+ "chalk": "^3.0.0",
40
+ "commander": "^8.3.0",
41
+ "eslint": "^8.4.1",
42
+ "eslint-config-prettier": "^8.3.0",
43
+ "eslint-config-standard": "^16.0.3",
44
+ "eslint-import-resolver-typescript": "^2.5.0",
45
+ "eslint-plugin-import": "^2.25.3",
46
+ "eslint-plugin-node": "^11.1.0",
47
+ "eslint-plugin-prettier": "^4.0.0",
48
+ "eslint-plugin-promise": "^5.2.0",
49
+ "jest": "^27.4.3",
50
+ "lua-types": "^2.11.0",
51
+ "prettier": "^2.5.1",
52
+ "prettier-plugin-jsdoc": "^0.3.30",
53
+ "ts-jest": "^27.1.0",
54
+ "ts-node": "^10.4.0",
55
+ "typescript": "4.5.2",
56
+ "typescript-to-lua": "^1.3.1"
57
+ }
58
+ }
@@ -1,10 +1,10 @@
1
- /// <reference types="lua-types/5.2" />
2
-
3
- /// <reference path="../generated/index.d.ts" />
4
-
5
- /// <reference path="librariesAndFunctions.d.ts" />
6
- /// <reference path="pairs.d.ts" />
7
-
8
- // lualib
9
- /// <reference path="util.d.ts" />
10
- /// <reference path="mod-gui.d.ts" />
1
+ /// <reference types="lua-types/5.2" />
2
+
3
+ /// <reference path="../generated/index.d.ts" />
4
+
5
+ /// <reference path="librariesAndFunctions.d.ts" />
6
+ /// <reference path="pairs.d.ts" />
7
+
8
+ // lualib
9
+ /// <reference path="util.d.ts" />
10
+ /// <reference path="mod-gui.d.ts" />
@@ -1,123 +1,123 @@
1
- // from https://lua-api.factorio.com/latest/Libraries.html
2
- // last updated for 1.1.35, 1.1.36, 1.1.37
3
-
4
- /** @noSelfInFile */
5
-
6
- /** @noSelf */
7
- interface SerpentOptions {
8
- /** Indentation; triggers long multi-line output. */
9
- indent: string
10
- /** Provide stringified value in a comment (up to maxlevel of depth). */
11
- comment: boolean | number
12
- /** Sort keys. */
13
- sortkeys: boolean | ((this: void, keys: any[], table: any) => void)
14
- /** Force sparse encoding (no nil filling based on #t). */
15
- sparse: boolean
16
- /** Remove spaces. */
17
- compact: boolean
18
- /** Raise fatal error on non-serializable values. */
19
- fatal: boolean
20
- /** Disable bytecode serialization for easy comparison. */
21
- nocode: boolean
22
- /** Disable checking numbers against undefined and huge values. */
23
- nohuge: boolean
24
- /** Specify max level up to which to expand nested tables. */
25
- maxlevel: number
26
- /** Specify max number of elements in a table. */
27
- maxnum: number
28
- /** Specify max length for all table elements. */
29
- maxlength: number
30
- /**
31
- * Use __tostring metamethod when serializing tables (v0.29); set to false to disable and serialize the table as is,
32
- * even when __tostring is present.
33
- */
34
- metatostring: boolean
35
- /**
36
- * Specify format for numeric values as shortest possible round-trippable double (v0.30). Use "%.16g" for better
37
- * readability and "%.17g" (the default value) to preserve floating point precision.
38
- */
39
- numformat: string
40
- /** Allows to specify a list of values to ignore (as keys). */
41
- valignore: string[]
42
- /** Allows to specify the list of keys to be serialized. Any keys not in this list are not included in final output (as keys). */
43
- keyallow: string[]
44
- /** Allows to specity the list of keys to ignore in serialization. */
45
- keyignore: string[]
46
- /** Allows to specify a list of value types to ignore (as keys). */
47
- valtypeignore: string[]
48
- /** Provide custom output for tables. */
49
- custom(opts: {
50
- /** The name of the current element with '=' or an empty string in case of array index, */
51
- tag: string
52
- /** An opening table bracket { and associated indentation and newline (if any), */
53
- head: string
54
- /** Table elements concatenated into a string using commas and indentation/newlines (if any), */
55
- body: string
56
- /** A closing table bracket } and associated indentation and newline (if any), and */
57
- tail: string
58
- /** The current level. */
59
- level: number
60
- }): string
61
- /** Name; triggers full serialization with self-ref section. */
62
- name: string
63
-
64
- refcomment: boolean | number
65
- tablecomment: boolean | number
66
- }
67
-
68
- /**
69
- * Factorio provides the {@link https://github.com/pkulchenko/serpent serpent library} as a global variable `serpent` for
70
- * all mods to use. It allows for easy debugging of tables, because serpent makes it trivial to print them, for example
71
- * by using `serpent.block()`. However, serpent cannot pretty-print LuaObjects such as LuaEntity. The serpent library
72
- * was modified to improve determinism, e.g. comments are turned off by default to avoid returning table addresses.
73
- * Furthermore, two options were added: `refcomment` (true/false/maxlevel) and `tablecomment` (true/false/maxlevel),
74
- * which allow to separately control the self-reference and table value output of the `comment` option.
75
- */
76
- declare namespace serpent {
77
- /** Full serialization; sets name, compact and sparse options; */
78
- function dump(tbl: unknown, options?: Partial<SerpentOptions>): string
79
-
80
- /** Single line pretty printing, no self-ref section; sets sortkeys and comment options; */
81
- function line(tbl: unknown, options?: Partial<SerpentOptions>): string
82
-
83
- /** Multi-line indented pretty printing, no self-ref section; sets indent, sortkeys, and comment options. */
84
- function block(tbl: unknown, options?: Partial<SerpentOptions>): string
85
-
86
- /**
87
- * For loading serialized fragments, serpent also provides `load` function that adds safety checks and reports an
88
- * error if there is any executable code in the fragment.
89
- */
90
- function load<T>(str: string, options?: { safe?: boolean }): LuaMultiReturn<[true, T] | [false, string]>
91
- }
92
-
93
- /**
94
- * This function allows to log {@link LocalisedString} to the Factorio
95
- * {@link https://wiki.factorio.com/Log_file log file}. This, in combination with serpent, makes debugging in the data
96
- * stage easier, because it allows to simply inspect entire prototype tables. For example, this allows to see all
97
- * properties of the sulfur item prototype: `log(serpent.block(data.raw["item"]["sulfur"]))`
98
- */
99
- declare function log(ls: LocalisedString): void
100
-
101
- /**
102
- * This function allows printing {@link LocalisedString}s to stdout without polluting the logfile. This is primarily
103
- * useful for communicating with external tools that launch Factorio as a child process.
104
- */
105
- declare function localised_print(ls: LocalisedString): void
106
-
107
- /**
108
- * Factorio provides the function `table_size()` as a simple way to find the size of tables with non-continuous keys,
109
- * because the standard `#` does not work correctly for these. The function is a C++-side implementation of the
110
- * following Lua code, thus it is faster than using this code in Lua:
111
- *
112
- * local function size(t)
113
- * local count = 0
114
- * for k,v in pairs(t) do
115
- * count = count + 1
116
- * end
117
- * return count
118
- * end
119
- *
120
- * Note that `table_size()` does not work correctly for {@link LuaCustomTable}s, their size has to be determined with
121
- * {@link LuaCustomTable.length LuaCustomTable::operator #} instead.
122
- */
123
- declare function table_size(tbl: table): number
1
+ // from https://lua-api.factorio.com/latest/Libraries.html
2
+ // last updated for 1.1.35, 1.1.36, 1.1.37
3
+
4
+ /** @noSelfInFile */
5
+
6
+ /** @noSelf */
7
+ interface SerpentOptions {
8
+ /** Indentation; triggers long multi-line output. */
9
+ indent: string
10
+ /** Provide stringified value in a comment (up to maxlevel of depth). */
11
+ comment: boolean | number
12
+ /** Sort keys. */
13
+ sortkeys: boolean | ((this: void, keys: any[], table: any) => void)
14
+ /** Force sparse encoding (no nil filling based on #t). */
15
+ sparse: boolean
16
+ /** Remove spaces. */
17
+ compact: boolean
18
+ /** Raise fatal error on non-serializable values. */
19
+ fatal: boolean
20
+ /** Disable bytecode serialization for easy comparison. */
21
+ nocode: boolean
22
+ /** Disable checking numbers against undefined and huge values. */
23
+ nohuge: boolean
24
+ /** Specify max level up to which to expand nested tables. */
25
+ maxlevel: number
26
+ /** Specify max number of elements in a table. */
27
+ maxnum: number
28
+ /** Specify max length for all table elements. */
29
+ maxlength: number
30
+ /**
31
+ * Use __tostring metamethod when serializing tables (v0.29); set to false to disable and serialize the table as is,
32
+ * even when __tostring is present.
33
+ */
34
+ metatostring: boolean
35
+ /**
36
+ * Specify format for numeric values as shortest possible round-trippable double (v0.30). Use "%.16g" for better
37
+ * readability and "%.17g" (the default value) to preserve floating point precision.
38
+ */
39
+ numformat: string
40
+ /** Allows to specify a list of values to ignore (as keys). */
41
+ valignore: string[]
42
+ /** Allows to specify the list of keys to be serialized. Any keys not in this list are not included in final output (as keys). */
43
+ keyallow: string[]
44
+ /** Allows to specity the list of keys to ignore in serialization. */
45
+ keyignore: string[]
46
+ /** Allows to specify a list of value types to ignore (as keys). */
47
+ valtypeignore: string[]
48
+ /** Provide custom output for tables. */
49
+ custom(opts: {
50
+ /** The name of the current element with '=' or an empty string in case of array index, */
51
+ tag: string
52
+ /** An opening table bracket { and associated indentation and newline (if any), */
53
+ head: string
54
+ /** Table elements concatenated into a string using commas and indentation/newlines (if any), */
55
+ body: string
56
+ /** A closing table bracket } and associated indentation and newline (if any), and */
57
+ tail: string
58
+ /** The current level. */
59
+ level: number
60
+ }): string
61
+ /** Name; triggers full serialization with self-ref section. */
62
+ name: string
63
+
64
+ refcomment: boolean | number
65
+ tablecomment: boolean | number
66
+ }
67
+
68
+ /**
69
+ * Factorio provides the {@link https://github.com/pkulchenko/serpent serpent library} as a global variable `serpent` for
70
+ * all mods to use. It allows for easy debugging of tables, because serpent makes it trivial to print them, for example
71
+ * by using `serpent.block()`. However, serpent cannot pretty-print LuaObjects such as LuaEntity. The serpent library
72
+ * was modified to improve determinism, e.g. comments are turned off by default to avoid returning table addresses.
73
+ * Furthermore, two options were added: `refcomment` (true/false/maxlevel) and `tablecomment` (true/false/maxlevel),
74
+ * which allow to separately control the self-reference and table value output of the `comment` option.
75
+ */
76
+ declare namespace serpent {
77
+ /** Full serialization; sets name, compact and sparse options; */
78
+ function dump(tbl: unknown, options?: Partial<SerpentOptions>): string
79
+
80
+ /** Single line pretty printing, no self-ref section; sets sortkeys and comment options; */
81
+ function line(tbl: unknown, options?: Partial<SerpentOptions>): string
82
+
83
+ /** Multi-line indented pretty printing, no self-ref section; sets indent, sortkeys, and comment options. */
84
+ function block(tbl: unknown, options?: Partial<SerpentOptions>): string
85
+
86
+ /**
87
+ * For loading serialized fragments, serpent also provides `load` function that adds safety checks and reports an
88
+ * error if there is any executable code in the fragment.
89
+ */
90
+ function load<T>(str: string, options?: { safe?: boolean }): LuaMultiReturn<[true, T] | [false, string]>
91
+ }
92
+
93
+ /**
94
+ * This function allows to log {@link LocalisedString} to the Factorio
95
+ * {@link https://wiki.factorio.com/Log_file log file}. This, in combination with serpent, makes debugging in the data
96
+ * stage easier, because it allows to simply inspect entire prototype tables. For example, this allows to see all
97
+ * properties of the sulfur item prototype: `log(serpent.block(data.raw["item"]["sulfur"]))`
98
+ */
99
+ declare function log(ls: LocalisedString): void
100
+
101
+ /**
102
+ * This function allows printing {@link LocalisedString}s to stdout without polluting the logfile. This is primarily
103
+ * useful for communicating with external tools that launch Factorio as a child process.
104
+ */
105
+ declare function localised_print(ls: LocalisedString): void
106
+
107
+ /**
108
+ * Factorio provides the function `table_size()` as a simple way to find the size of tables with non-continuous keys,
109
+ * because the standard `#` does not work correctly for these. The function is a C++-side implementation of the
110
+ * following Lua code, thus it is faster than using this code in Lua:
111
+ *
112
+ * local function size(t)
113
+ * local count = 0
114
+ * for k,v in pairs(t) do
115
+ * count = count + 1
116
+ * end
117
+ * return count
118
+ * end
119
+ *
120
+ * Note that `table_size()` does not work correctly for {@link LuaCustomTable}s, their size has to be determined with
121
+ * {@link LuaCustomTable.length LuaCustomTable::operator #} instead.
122
+ */
123
+ declare function table_size(tbl: table): number
@@ -1,11 +1,11 @@
1
- /** @noSelfInFile */
2
-
3
- /** @noResolution */
4
- declare module "mod-gui" {
5
- const button_style: string
6
- const frame_style: string
7
-
8
- function get_button_flow(player: LuaPlayer): FrameGuiElement
9
-
10
- function get_frame_flow(player: LuaPlayer): FlowGuiElement
11
- }
1
+ /** @noSelfInFile */
2
+
3
+ /** @noResolution */
4
+ declare module "mod-gui" {
5
+ const button_style: string
6
+ const frame_style: string
7
+
8
+ function get_button_flow(player: LuaPlayer): FrameGuiElement
9
+
10
+ function get_frame_flow(player: LuaPlayer): FlowGuiElement
11
+ }
@@ -1,14 +1,14 @@
1
- /** @noSelfInFile */
2
-
3
- /**
4
- * Iterating with `pairs` will only iterate the array part of a {@link LuaCustomTable}.
5
- *
6
- * **Note**: you can also iterate on a LuaCustomTable directly without using `pairs`, e.g. `for(const [k, v] of table)`.
7
- */
8
- declare function pairs<V>(table: LuaCustomTable<number | string, V>): LuaIterable<LuaMultiReturn<[number, V]>>
9
-
10
- /** **Note**: you can also iterate on a LuaCustomTable directly without using `pairs`, e.g. `for(const [k, v] of table)`. */
11
- declare function pairs<K extends number | string, V>(table: LuaCustomTable<K, V>): LuaIterable<LuaMultiReturn<[K, V]>>
12
-
13
- /** @deprecated {@link LuaCustomTable} cannot be iterated with `ipairs`; Use {@link pairs} instead. */
14
- declare function ipairs(table: LuaCustomTable<any, any>): never
1
+ /** @noSelfInFile */
2
+
3
+ /**
4
+ * Iterating with `pairs` will only iterate the array part of a {@link LuaCustomTable}.
5
+ *
6
+ * **Note**: you can also iterate on a LuaCustomTable directly without using `pairs`, e.g. `for(const [k, v] of table)`.
7
+ */
8
+ declare function pairs<V>(table: LuaCustomTable<number | string, V>): LuaIterable<LuaMultiReturn<[number, V]>>
9
+
10
+ /** **Note**: you can also iterate on a LuaCustomTable directly without using `pairs`, e.g. `for(const [k, v] of table)`. */
11
+ declare function pairs<K extends number | string, V>(table: LuaCustomTable<K, V>): LuaIterable<LuaMultiReturn<[K, V]>>
12
+
13
+ /** @deprecated {@link LuaCustomTable} cannot be iterated with `ipairs`; Use {@link pairs} instead. */
14
+ declare function ipairs(table: LuaCustomTable<any, any>): never