typed-factorio 0.13.0 → 0.14.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,51 +1,53 @@
1
+ // This is an auto-generated file. Do not edit directly!
2
+
1
3
  /** @noSelfInFile */
2
4
 
3
5
  /**
4
6
  * This is the main object, through which most of the API is accessed. It is, however, not available inside handlers
5
7
  * registered with {@link LuaBootstrap.on_load LuaBootstrap::on_load}.
6
8
  *
7
- * {@link https://lua-api.factorio.com/next/ View documentation}
9
+ * {@link https://lua-api.factorio.com/latest/ View documentation}
8
10
  */
9
11
  declare const game: LuaGameScript
10
12
 
11
13
  /**
12
14
  * Provides an interface for registering event handlers.
13
15
  *
14
- * {@link https://lua-api.factorio.com/next/ View documentation}
16
+ * {@link https://lua-api.factorio.com/latest/ View documentation}
15
17
  */
16
18
  declare const script: LuaBootstrap
17
19
 
18
20
  /**
19
21
  * Allows inter-mod communication by way of providing a repository of interfaces that is shared by all mods.
20
22
  *
21
- * {@link https://lua-api.factorio.com/next/ View documentation}
23
+ * {@link https://lua-api.factorio.com/latest/ View documentation}
22
24
  */
23
25
  declare const remote: LuaRemote
24
26
 
25
27
  /**
26
28
  * Allows registering custom commands for the in-game console accessible via the grave key.
27
29
  *
28
- * {@link https://lua-api.factorio.com/next/ View documentation}
30
+ * {@link https://lua-api.factorio.com/latest/ View documentation}
29
31
  */
30
32
  declare const commands: LuaCommandProcessor
31
33
 
32
34
  /**
33
35
  * Allows reading the current mod settings.
34
36
  *
35
- * {@link https://lua-api.factorio.com/next/ View documentation}
37
+ * {@link https://lua-api.factorio.com/latest/ View documentation}
36
38
  */
37
39
  declare const settings: LuaSettings
38
40
 
39
41
  /**
40
42
  * Allows printing messages to the calling RCON instance if any.
41
43
  *
42
- * {@link https://lua-api.factorio.com/next/ View documentation}
44
+ * {@link https://lua-api.factorio.com/latest/ View documentation}
43
45
  */
44
46
  declare const rcon: LuaRCON
45
47
 
46
48
  /**
47
49
  * Allows rendering of geometric shapes, text and sprites in the game world.
48
50
  *
49
- * {@link https://lua-api.factorio.com/next/ View documentation}
51
+ * {@link https://lua-api.factorio.com/latest/ View documentation}
50
52
  */
51
53
  declare const rendering: LuaRendering
@@ -1,3 +1,5 @@
1
+ // This is an auto-generated file. Do not edit directly!
2
+
1
3
  ///<reference types="lua-types/5.2" />
2
4
  ///<reference path="builtin-types.d.ts" />
3
5
  ///<reference path="defines.d.ts" />
package/package.json CHANGED
@@ -1,58 +1,58 @@
1
- {
2
- "name": "typed-factorio",
3
- "version": "0.13.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/index.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.0.0"
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.2.0"
57
- }
58
- }
1
+ {
2
+ "name": "typed-factorio",
3
+ "version": "0.14.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.0.0"
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.2.0"
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,13 +1,13 @@
1
- /** @noSelfInFile */
2
-
3
- /** Iterating with `pairs` will only iterate the array part of a {@link LuaCustomTable}. */
4
- declare function pairs<V>(table: LuaCustomTable<number | string, V>): LuaIterable<LuaMultiReturn<[number, V]>>
5
-
6
- declare function pairs<K extends keyof any, V>(table: LuaCustomTable<K, V>): LuaIterable<LuaMultiReturn<[K, V]>>
7
-
8
- /**
9
- * {@link LuaCustomTable} cannot be iterated with `ipairs`. Use `pairs` instead.
10
- *
11
- * @deprecated
12
- */
13
- declare function ipairs(table: LuaCustomTable<any, any>): never
1
+ /** @noSelfInFile */
2
+
3
+ /** Iterating with `pairs` will only iterate the array part of a {@link LuaCustomTable}. */
4
+ declare function pairs<V>(table: LuaCustomTable<number | string, V>): LuaIterable<LuaMultiReturn<[number, V]>>
5
+
6
+ declare function pairs<K extends keyof any, V>(table: LuaCustomTable<K, V>): LuaIterable<LuaMultiReturn<[K, V]>>
7
+
8
+ /**
9
+ * {@link LuaCustomTable} cannot be iterated with `ipairs`. Use `pairs` instead.
10
+ *
11
+ * @deprecated
12
+ */
13
+ declare function ipairs(table: LuaCustomTable<any, any>): never