factorio-types 1.2.54 → 1.2.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -3
- package/dist/index.d.ts +13 -0
- package/index.d.ts +2 -11
- package/package.json +2 -2
- package/src/core.d.ts +9 -4
- package/src/index.d.ts +9 -0
- package/src/lualib/autoplace_utils.d.ts +32 -0
- package/src/lualib/collision-mask-defaults.d.ts +181 -0
- package/src/lualib/collision-mask-util.d.ts +23 -0
- package/src/lualib/crash-site.d.ts +35 -0
- package/src/lualib/data-duplicate-checker.d.ts +6 -0
- package/src/lualib/event_handler.d.ts +16 -0
- package/src/lualib/index.d.ts +22 -0
- package/src/lualib/kill-score.d.ts +8 -0
- package/src/lualib/math2d.d.ts +41 -0
- package/src/lualib/math3d.d.ts +64 -0
- package/src/lualib/meld.d.ts +33 -0
- package/src/lualib/mod-gui.d.ts +25 -0
- package/src/lualib/production-score.d.ts +13 -0
- package/src/lualib/resource-autoplace.d.ts +35 -0
- package/src/lualib/silo-script.d.ts +19 -0
- package/src/lualib/space-finish-script.d.ts +10 -0
- package/src/lualib/surface-render-parameter-effects.d.ts +6 -0
- package/src/lualib/util.d.ts +167 -0
- package/src/serpent.d.ts +4 -3
- package/tsconfig.base.json +19 -0
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ This library includes [tsconfig.base.json](https://github.com/sguest/factorio-ty
|
|
|
23
23
|
|
|
24
24
|
## Stages
|
|
25
25
|
|
|
26
|
-
Factorio mods and the api go through [three distinct stages](https://lua-api.factorio.com/latest/). Types are organized into namespaces `runtime`, `prototype`, and `settings` representing the types to be used in each stage. These types, and therefore their corresponding namespaces, are a compile-time-only feature as lua does not have types,
|
|
26
|
+
Factorio mods and the api go through [three distinct stages](https://lua-api.factorio.com/latest/). Types are organized into namespaces `runtime`, `prototype`, and `settings` representing the types to be used in each stage. These types, and therefore their corresponding namespaces, are a compile-time-only feature as lua does not have types, so accessing a _type_ during the wrong phase is safe. Sometimes this is OK, such as when referencing utility functions that operate on values without interacting with game API like math functions. However, many game APIs will only work with types from the correct phase, so using an API that takes types from the wrong phase should be a red flag that you might encounter a runtime error.
|
|
27
27
|
|
|
28
28
|
Note there is some overlap between the types for the Settings and Prototype phases since both regularly provide prototype data to `data.extend()`, and in fact the settings-phase prototypes extend `prototype.PrototypeBase`. However, you should only be providing types from the `settings` namespace during the settings phase, and from the `prototype` namespace during the prototype phase.
|
|
29
29
|
|
|
@@ -70,6 +70,20 @@ end
|
|
|
70
70
|
|
|
71
71
|
Factorio makes various lua functions available to mods via [LuaLib](https://github.com/wube/factorio-data/tree/master/core/lualib)
|
|
72
72
|
|
|
73
|
-
Unlike the main parts of the factorio API, these do not exist as ambient globals but instead must be imported
|
|
73
|
+
Unlike the main parts of the factorio API, these do not exist as ambient globals but instead must be imported. If you inherit the recommended [tsconfig.base.json](https://github.com/sguest/factorio-types/blob/master/tsconfig.base.json), these import paths will all be set to `noResolvePaths`, meaning TSTL will not attempt to resolve them and will simply emit `require` statements that will allow Factorio to load the lualib files at runtime.
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
```typescript
|
|
76
|
+
import { split } from 'util';
|
|
77
|
+
|
|
78
|
+
let splitStr = split('a|b', '|');
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
import * as util from 'util';
|
|
83
|
+
|
|
84
|
+
let result = util.split_whitespace('a b');
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
The LuaLib definitions are not part of the machine-readable API spec that feeds the generation of the rest of the types in this repo. The devs [have said](https://forums.factorio.com/viewtopic.php?p=599930#p599930) better docs for lualib are in their longterm plans, but for now the only documentation is the files themselves in the `factorio-data` repo and any associated comments. Therefore, the lualib docs are hand-written by reading through the files and are more likely to contain errors. If you encounter any errors, please raise an issue and/or pull request.
|
|
88
|
+
|
|
89
|
+
The `noise` lualib definitions were previously present in this library. However, as of version 2.0.7, `noise.lua` was [removed from lualib in the factorio-data repo](https://github.com/wube/factorio-data/commit/7522d3763e76e09ce1a46cba676dfc2b6d12b127). This was accompanied by many of the required supporting types being removed from the prototype definitions, and therefore the noise definitions have been removed from this library, at least temporarily.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Type definitions for Factorio modding API
|
|
2
|
+
// Factorio API reference https://lua-api.factorio.com/latest/index.html
|
|
3
|
+
// Generated from JSON source https://lua-api.factorio.com/latest/runtime-api.json and https://lua-api.factorio.com/latest/prototype-api.json
|
|
4
|
+
// Definition source https://github.com/sguest/factorio-types
|
|
5
|
+
|
|
6
|
+
/// <reference path="./global.d.ts" />
|
|
7
|
+
/// <reference path="./classes.d.ts" />
|
|
8
|
+
/// <reference path="./concepts.d.ts" />
|
|
9
|
+
/// <reference path="./defines.d.ts" />
|
|
10
|
+
/// <reference path="./events.d.ts" />
|
|
11
|
+
/// <reference path="./prototypes.d.ts" />
|
|
12
|
+
/// <reference path="./types.d.ts" />
|
|
13
|
+
/// <reference path="./datacollection.d.ts" />
|
package/index.d.ts
CHANGED
|
@@ -3,15 +3,6 @@
|
|
|
3
3
|
// Generated from JSON source https://lua-api.factorio.com/latest/runtime-api.json and https://lua-api.factorio.com/latest/prototype-api.json
|
|
4
4
|
// Definition source https://github.com/sguest/factorio-types
|
|
5
5
|
|
|
6
|
-
/// <reference path="./src/
|
|
7
|
-
/// <reference path="./
|
|
8
|
-
/// <reference path="./src/serpent.d.ts" />
|
|
9
|
-
/// <reference path="./dist/global.d.ts" />
|
|
10
|
-
/// <reference path="./dist/classes.d.ts" />
|
|
11
|
-
/// <reference path="./dist/concepts.d.ts" />
|
|
12
|
-
/// <reference path="./dist/defines.d.ts" />
|
|
13
|
-
/// <reference path="./dist/events.d.ts" />
|
|
14
|
-
/// <reference path="./dist/prototypes.d.ts" />
|
|
15
|
-
/// <reference path="./dist/types.d.ts" />
|
|
16
|
-
/// <reference path="./dist/datacollection.d.ts" />
|
|
6
|
+
/// <reference path="./src/index.d.ts" />
|
|
7
|
+
/// <reference path="./dist/index.d.ts" />
|
|
17
8
|
/// <reference types="lua-types/jit" />
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "factorio-types",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.55",
|
|
4
4
|
"description": "Typescript declarations for the Factorio mod API",
|
|
5
5
|
"main": "index.d.ts",
|
|
6
6
|
"repository": "https://github.com/sguest/factorio-types.git",
|
|
@@ -30,4 +30,4 @@
|
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"typescript-to-lua": "^1.26.0"
|
|
32
32
|
}
|
|
33
|
-
}
|
|
33
|
+
}
|
package/src/core.d.ts
CHANGED
|
@@ -8,17 +8,22 @@ declare namespace table {
|
|
|
8
8
|
function compare(this: void, table1: object | [], table2: object | []): boolean;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
raw: prototype.dataCollection
|
|
11
|
+
interface DataType {
|
|
12
|
+
raw: prototype.dataCollection;
|
|
13
13
|
extend(values: prototype.dataExtendType[]): void,
|
|
14
|
-
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
declare const data: DataType;
|
|
15
17
|
|
|
16
18
|
/**
|
|
17
19
|
* Mapping of currently loaded mods to their version. Only exists at the data stage.
|
|
18
20
|
*/
|
|
19
21
|
declare const mods: { [key: string] : string}
|
|
20
22
|
|
|
21
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Mod-specific storage lookup that is persisted to save files https://lua-api.factorio.com/latest/auxiliary/storage.html
|
|
25
|
+
*/
|
|
26
|
+
declare const storage: { [key: string]: any };
|
|
22
27
|
|
|
23
28
|
declare function log(str: runtime.LocalisedString): void;
|
|
24
29
|
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Type definitions for Factorio modding API
|
|
2
|
+
// Factorio API reference https://lua-api.factorio.com/latest/index.html
|
|
3
|
+
// src mappings manually written to cover aspects not in the machine-readable API spec
|
|
4
|
+
// Definition source https://github.com/sguest/factorio-types
|
|
5
|
+
|
|
6
|
+
/// <reference path="./core.d.ts" />
|
|
7
|
+
/// <reference path="./settings.d.ts" />
|
|
8
|
+
/// <reference path="./serpent.d.ts" />
|
|
9
|
+
/// <reference path="./lualib/index.d.ts" />
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// https://github.com/wube/factorio-data/blob/master/core/lualib/autoplace_utils.lua
|
|
2
|
+
declare module "autoplace_utils" {
|
|
3
|
+
export interface AutoplacePeakValue {
|
|
4
|
+
influence: number;
|
|
5
|
+
richness_influence: number;
|
|
6
|
+
min_influence: number;
|
|
7
|
+
temperature_optimal: number;
|
|
8
|
+
temperature_range: number;
|
|
9
|
+
temperature_max_range: number;
|
|
10
|
+
water_optimal: number;
|
|
11
|
+
water_range: number;
|
|
12
|
+
water_max_range: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type RectangleSpecification = [[number, number], [number, number], number?];
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Add a list of autoplace peaks based on rectangles to the table ret.
|
|
19
|
+
* Rectangles is a table of rectangle specifications:
|
|
20
|
+
* {{max_temp, max_water}, {min_temp, min_water}, influence}
|
|
21
|
+
* temperatures range from 35 to -25 (°C), water from 0 to 1.
|
|
22
|
+
* the peak resulting from each rectangle has a preset influence
|
|
23
|
+
* within the rectangle and goes to zero after 5°C or 0.1 water level outside
|
|
24
|
+
* of the rectangle.
|
|
25
|
+
* Influence is optional and has default value of default_influence or 1.
|
|
26
|
+
*/
|
|
27
|
+
export function peaks(
|
|
28
|
+
this: void,
|
|
29
|
+
rectangles: RectangleSpecification[],
|
|
30
|
+
ret: AutoplacePeakValue[],
|
|
31
|
+
default_influence?: number): AutoplacePeakValue[];
|
|
32
|
+
}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
// https://github.com/wube/factorio-data/blob/master/core/lualib/collision-mask-defaults.lua
|
|
2
|
+
declare module "collision-mask-defaults" {
|
|
3
|
+
interface MaskType {
|
|
4
|
+
["agricultural-tower"]: prototype.CollisionMaskConnector,
|
|
5
|
+
["ammo-turret"]: prototype.CollisionMaskConnector,
|
|
6
|
+
["arithmetic-combinator"]: prototype.CollisionMaskConnector,
|
|
7
|
+
["artillery-turret"]: prototype.CollisionMaskConnector,
|
|
8
|
+
["assembling-machine"]: prototype.CollisionMaskConnector,
|
|
9
|
+
["asteroid-chunk"]: prototype.CollisionMaskConnector,
|
|
10
|
+
["asteroid-collector"]: prototype.CollisionMaskConnector,
|
|
11
|
+
["asteroid"]: prototype.CollisionMaskConnector,
|
|
12
|
+
["beacon"]: prototype.CollisionMaskConnector,
|
|
13
|
+
["boiler"]: prototype.CollisionMaskConnector,
|
|
14
|
+
["burner-generator"]: prototype.CollisionMaskConnector,
|
|
15
|
+
["decider-combinator"]: prototype.CollisionMaskConnector,
|
|
16
|
+
["electric-energy-interface"]: prototype.CollisionMaskConnector,
|
|
17
|
+
["electric-turret"]: prototype.CollisionMaskConnector,
|
|
18
|
+
["fluid-turret"]: prototype.CollisionMaskConnector,
|
|
19
|
+
["furnace"]: prototype.CollisionMaskConnector,
|
|
20
|
+
["generator"]: prototype.CollisionMaskConnector,
|
|
21
|
+
["heat-interface"]: prototype.CollisionMaskConnector,
|
|
22
|
+
["infinity-pipe"]: prototype.CollisionMaskConnector,
|
|
23
|
+
["inserter"]: prototype.CollisionMaskConnector,
|
|
24
|
+
["lab"]: prototype.CollisionMaskConnector,
|
|
25
|
+
["market"]: prototype.CollisionMaskConnector,
|
|
26
|
+
["mining-drill"]: prototype.CollisionMaskConnector,
|
|
27
|
+
["offshore-pump"]: prototype.CollisionMaskConnector,
|
|
28
|
+
["pipe-to-ground"]: prototype.CollisionMaskConnector,
|
|
29
|
+
["pipe"]: prototype.CollisionMaskConnector,
|
|
30
|
+
["plant"]: prototype.CollisionMaskConnector,
|
|
31
|
+
["fusion-generator"]: prototype.CollisionMaskConnector,
|
|
32
|
+
["fusion-reactor"]: prototype.CollisionMaskConnector,
|
|
33
|
+
["power-switch"]: prototype.CollisionMaskConnector,
|
|
34
|
+
["programmable-speaker"]: prototype.CollisionMaskConnector,
|
|
35
|
+
["pump"]: prototype.CollisionMaskConnector,
|
|
36
|
+
["radar"]: prototype.CollisionMaskConnector,
|
|
37
|
+
["reactor"]: prototype.CollisionMaskConnector,
|
|
38
|
+
["rocket-silo-rocket-shadow"]: prototype.CollisionMaskConnector,
|
|
39
|
+
["rocket-silo-rocket"]: prototype.CollisionMaskConnector,
|
|
40
|
+
["selector-combinator"]: prototype.CollisionMaskConnector,
|
|
41
|
+
["simple-entity-with-force"]: prototype.CollisionMaskConnector,
|
|
42
|
+
["simple-entity-with-owner"]: prototype.CollisionMaskConnector,
|
|
43
|
+
["simple-entity"]: prototype.CollisionMaskConnector,
|
|
44
|
+
["storage-tank"]: prototype.CollisionMaskConnector,
|
|
45
|
+
["thruster"]: prototype.CollisionMaskConnector,
|
|
46
|
+
["tree"]: prototype.CollisionMaskConnector,
|
|
47
|
+
["turret"]: prototype.CollisionMaskConnector,
|
|
48
|
+
["unit-spawner"]: prototype.CollisionMaskConnector,
|
|
49
|
+
["valve"]: prototype.CollisionMaskConnector,
|
|
50
|
+
["wall"]: prototype.CollisionMaskConnector,
|
|
51
|
+
["display-panel"]: prototype.CollisionMaskConnector,
|
|
52
|
+
|
|
53
|
+
["accumulator"]: prototype.CollisionMaskConnector,
|
|
54
|
+
["cargo-pod"]: prototype.CollisionMaskConnector,
|
|
55
|
+
["constant-combinator"]: prototype.CollisionMaskConnector,
|
|
56
|
+
["electric-pole"]: prototype.CollisionMaskConnector,
|
|
57
|
+
["lamp"]: prototype.CollisionMaskConnector,
|
|
58
|
+
["solar-panel"]: prototype.CollisionMaskConnector,
|
|
59
|
+
["train-stop"]: prototype.CollisionMaskConnector,
|
|
60
|
+
|
|
61
|
+
["cargo-bay"]: prototype.CollisionMaskConnector,
|
|
62
|
+
["cargo-landing-pad"]: prototype.CollisionMaskConnector,
|
|
63
|
+
["lightning-attractor"]: prototype.CollisionMaskConnector,
|
|
64
|
+
["roboport"]: prototype.CollisionMaskConnector,
|
|
65
|
+
["rocket-silo"]: prototype.CollisionMaskConnector,
|
|
66
|
+
["space-platform-hub"]: prototype.CollisionMaskConnector,
|
|
67
|
+
|
|
68
|
+
["container"]: prototype.CollisionMaskConnector,
|
|
69
|
+
["infinity-container"]: prototype.CollisionMaskConnector,
|
|
70
|
+
["linked-container"]: prototype.CollisionMaskConnector,
|
|
71
|
+
["proxy-container"]: prototype.CollisionMaskConnector,
|
|
72
|
+
["logistic-container"]: prototype.CollisionMaskConnector,
|
|
73
|
+
["temporary-container"]: prototype.CollisionMaskConnector,
|
|
74
|
+
|
|
75
|
+
["linked-belt"]: prototype.CollisionMaskConnector,
|
|
76
|
+
["loader-1x1"]: prototype.CollisionMaskConnector,
|
|
77
|
+
["loader"]: prototype.CollisionMaskConnector,
|
|
78
|
+
["splitter"]: prototype.CollisionMaskConnector,
|
|
79
|
+
["lane-splitter"]: prototype.CollisionMaskConnector,
|
|
80
|
+
["transport-belt"]: prototype.CollisionMaskConnector,
|
|
81
|
+
["underground-belt"]: prototype.CollisionMaskConnector,
|
|
82
|
+
|
|
83
|
+
["curved-rail-a"]: prototype.CollisionMaskConnector,
|
|
84
|
+
["curved-rail-b"]: prototype.CollisionMaskConnector,
|
|
85
|
+
["half-diagonal-rail"]: prototype.CollisionMaskConnector,
|
|
86
|
+
["legacy-curved-rail"]: prototype.CollisionMaskConnector,
|
|
87
|
+
["legacy-straight-rail"]: prototype.CollisionMaskConnector,
|
|
88
|
+
["straight-rail"]: prototype.CollisionMaskConnector,
|
|
89
|
+
|
|
90
|
+
["rail-ramp"]: prototype.CollisionMaskConnector,
|
|
91
|
+
["rail-ramp/allow_on_deep_oil_ocean"]: prototype.CollisionMaskConnector,
|
|
92
|
+
|
|
93
|
+
["rail-support"]: prototype.CollisionMaskConnector,
|
|
94
|
+
["rail-support/allow_on_deep_oil_ocean"]: prototype.CollisionMaskConnector,
|
|
95
|
+
|
|
96
|
+
["elevated-curved-rail-a"]: prototype.CollisionMaskConnector,
|
|
97
|
+
["elevated-curved-rail-b"]: prototype.CollisionMaskConnector,
|
|
98
|
+
["elevated-half-diagonal-rail"]: prototype.CollisionMaskConnector,
|
|
99
|
+
["elevated-straight-rail"]: prototype.CollisionMaskConnector,
|
|
100
|
+
|
|
101
|
+
["rail-chain-signal"]: prototype.CollisionMaskConnector,
|
|
102
|
+
["rail-signal"]: prototype.CollisionMaskConnector,
|
|
103
|
+
|
|
104
|
+
["rail-chain-signal/elevated"]: prototype.CollisionMaskConnector,
|
|
105
|
+
["rail-signal/elevated"]: prototype.CollisionMaskConnector,
|
|
106
|
+
|
|
107
|
+
["artillery-wagon"]: prototype.CollisionMaskConnector,
|
|
108
|
+
["infinity-cargo-wagon"]: prototype.CollisionMaskConnector,
|
|
109
|
+
["cargo-wagon"]: prototype.CollisionMaskConnector,
|
|
110
|
+
["fluid-wagon"]: prototype.CollisionMaskConnector,
|
|
111
|
+
["locomotive"]: prototype.CollisionMaskConnector,
|
|
112
|
+
|
|
113
|
+
["artillery-wagon/transition"]: prototype.CollisionMaskConnector,
|
|
114
|
+
["infinity-cargo-wagon/transition"]: prototype.CollisionMaskConnector,
|
|
115
|
+
["cargo-wagon/transition"]: prototype.CollisionMaskConnector,
|
|
116
|
+
["fluid-wagon/transition"]: prototype.CollisionMaskConnector,
|
|
117
|
+
["locomotive/transition"]: prototype.CollisionMaskConnector,
|
|
118
|
+
|
|
119
|
+
["artillery-wagon/elevated"]: prototype.CollisionMaskConnector,
|
|
120
|
+
["infinity-cargo-wagon/elevated"]: prototype.CollisionMaskConnector,
|
|
121
|
+
["cargo-wagon/elevated"]: prototype.CollisionMaskConnector,
|
|
122
|
+
["fluid-wagon/elevated"]: prototype.CollisionMaskConnector,
|
|
123
|
+
["locomotive/elevated"]: prototype.CollisionMaskConnector,
|
|
124
|
+
|
|
125
|
+
["gate"]: prototype.CollisionMaskConnector,
|
|
126
|
+
["gate/opened"]: prototype.CollisionMaskConnector,
|
|
127
|
+
|
|
128
|
+
["arrow"]: prototype.CollisionMaskConnector,
|
|
129
|
+
["artillery-flare"]: prototype.CollisionMaskConnector,
|
|
130
|
+
["artillery-projectile"]: prototype.CollisionMaskConnector,
|
|
131
|
+
["beam"]: prototype.CollisionMaskConnector,
|
|
132
|
+
["capture-robot"]: prototype.CollisionMaskConnector,
|
|
133
|
+
["character-corpse"]: prototype.CollisionMaskConnector,
|
|
134
|
+
["combat-robot"]: prototype.CollisionMaskConnector,
|
|
135
|
+
["construction-robot"]: prototype.CollisionMaskConnector,
|
|
136
|
+
["explosion"]: prototype.CollisionMaskConnector,
|
|
137
|
+
["fire"]: prototype.CollisionMaskConnector,
|
|
138
|
+
["highlight-box"]: prototype.CollisionMaskConnector,
|
|
139
|
+
["item-request-proxy"]: prototype.CollisionMaskConnector,
|
|
140
|
+
["leaf-particle"]: prototype.CollisionMaskConnector,
|
|
141
|
+
["lightning"]: prototype.CollisionMaskConnector,
|
|
142
|
+
["logistic-robot"]: prototype.CollisionMaskConnector,
|
|
143
|
+
["particle-source"]: prototype.CollisionMaskConnector,
|
|
144
|
+
["particle"]: prototype.CollisionMaskConnector,
|
|
145
|
+
["projectile"]: prototype.CollisionMaskConnector,
|
|
146
|
+
["projectile/hit"]: prototype.CollisionMaskConnector,
|
|
147
|
+
["smoke-with-trigger"]: prototype.CollisionMaskConnector,
|
|
148
|
+
["smoke"]: prototype.CollisionMaskConnector,
|
|
149
|
+
["speech-bubble"]: prototype.CollisionMaskConnector,
|
|
150
|
+
["sticker"]: prototype.CollisionMaskConnector,
|
|
151
|
+
["stream"]: prototype.CollisionMaskConnector,
|
|
152
|
+
["tile"]: prototype.CollisionMaskConnector,
|
|
153
|
+
|
|
154
|
+
["car"]: prototype.CollisionMaskConnector,
|
|
155
|
+
["character"]: prototype.CollisionMaskConnector,
|
|
156
|
+
["character/flying"]: prototype.CollisionMaskConnector,
|
|
157
|
+
["cliff"]: prototype.CollisionMaskConnector,
|
|
158
|
+
["corpse"]: prototype.CollisionMaskConnector,
|
|
159
|
+
["deconstructible-tile-proxy"]: prototype.CollisionMaskConnector,
|
|
160
|
+
["entity-ghost"]: prototype.CollisionMaskConnector,
|
|
161
|
+
["fish"]: prototype.CollisionMaskConnector,
|
|
162
|
+
["heat-pipe"]: prototype.CollisionMaskConnector,
|
|
163
|
+
["item-entity"]: prototype.CollisionMaskConnector,
|
|
164
|
+
["land-mine"]: prototype.CollisionMaskConnector,
|
|
165
|
+
["player-port"]: prototype.CollisionMaskConnector,
|
|
166
|
+
["rail-remnants"]: prototype.CollisionMaskConnector,
|
|
167
|
+
["resource"]: prototype.CollisionMaskConnector,
|
|
168
|
+
["spider-leg"]: prototype.CollisionMaskConnector,
|
|
169
|
+
["spider-unit"]: prototype.CollisionMaskConnector,
|
|
170
|
+
["spider-vehicle"]: prototype.CollisionMaskConnector,
|
|
171
|
+
["tile-ghost"]: prototype.CollisionMaskConnector,
|
|
172
|
+
["unit"]: prototype.CollisionMaskConnector,
|
|
173
|
+
["segment"]: prototype.CollisionMaskConnector,
|
|
174
|
+
["segmented-unit"]: prototype.CollisionMaskConnector,
|
|
175
|
+
["decorative"]: prototype.CollisionMaskConnector,
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const masks: MaskType;
|
|
179
|
+
|
|
180
|
+
export default masks;
|
|
181
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
declare module "collision-mask-util" {
|
|
2
|
+
export function get_default_mask(this: void, type: string): prototype.CollisionMaskConnector;
|
|
3
|
+
|
|
4
|
+
export function get_mask(
|
|
5
|
+
this: void,
|
|
6
|
+
entity_prototpe: { collision_mask: prototype.CollisionMaskConnector, type: string }): prototype.CollisionMaskConnector;
|
|
7
|
+
|
|
8
|
+
export function masks_collide(this: void, mask1: prototype.CollisionMaskConnector, mask2: prototype.CollisionMaskConnector): boolean;
|
|
9
|
+
|
|
10
|
+
export function masks_are_same(this: void, mask1: prototype.CollisionMaskConnector, mask2: prototype.CollisionMaskConnector): boolean;
|
|
11
|
+
|
|
12
|
+
export function collect_prototypes_with_mask(this: void, mask: prototype.CollisionMaskConnector): prototype.AnyPrototype[];
|
|
13
|
+
|
|
14
|
+
export function collect_prototypes_with_layer(this: void, layer: prototype.CollisionLayerID): prototype.AnyPrototype[];
|
|
15
|
+
|
|
16
|
+
export function collect_prototypes_colliding_with_mask(this: void, mask: prototype.CollisionMaskConnector): prototype.AnyPrototype[];
|
|
17
|
+
|
|
18
|
+
export function replace_layer_in_all_prototypes(this: void, old_name: prototype.CollisionLayerID, new_name: prototype.CollisionLayerID): void;
|
|
19
|
+
|
|
20
|
+
export function new_mask(this: void): prototype.CollisionMaskConnector;
|
|
21
|
+
|
|
22
|
+
export function migrate_from_before_1_2_0(this: void, old_mask: Record<prototype.CollisionLayerID, true>): prototype.CollisionMaskConnector;
|
|
23
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// https://github.com/wube/factorio-data/blob/master/core/lualib/crash-site.lua
|
|
2
|
+
declare module "crash-site" {
|
|
3
|
+
export interface ShipPart {
|
|
4
|
+
name: string;
|
|
5
|
+
angle_deviation: number;
|
|
6
|
+
variations?: number;
|
|
7
|
+
max_distance?: number;
|
|
8
|
+
min_separation?: number;
|
|
9
|
+
fire_count?: number;
|
|
10
|
+
explosion_count?: number;
|
|
11
|
+
repeat_count?: number;
|
|
12
|
+
scale_lifetime?: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function create_crash_site(
|
|
16
|
+
this: void,
|
|
17
|
+
surface: runtime.LuaSurface,
|
|
18
|
+
position: runtime.MapPosition,
|
|
19
|
+
ship_items: runtime.ItemStackIdentification[],
|
|
20
|
+
part_items: runtime.ItemStackIdentification[],
|
|
21
|
+
ship_parts: ShipPart[]): void;
|
|
22
|
+
|
|
23
|
+
export function create_cutscene(
|
|
24
|
+
this: void,
|
|
25
|
+
player: runtime.LuaPlayer,
|
|
26
|
+
goal_position: runtime.MapPosition): void
|
|
27
|
+
|
|
28
|
+
export function is_crash_site_cutscene(this: void, event: runtime.on_cutscene_waypoint_reached): boolean;
|
|
29
|
+
|
|
30
|
+
export function on_player_display_refresh(
|
|
31
|
+
this: void,
|
|
32
|
+
event: runtime.on_player_display_resolution_changed | runtime.on_player_display_scale_changed): void;
|
|
33
|
+
|
|
34
|
+
export function default_ship_parts(): ShipPart[];
|
|
35
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// https://github.com/wube/factorio-data/blob/master/core/lualib/data-duplicate-checker.lua
|
|
2
|
+
declare module "data-duplicate-checker" {
|
|
3
|
+
export function check_for_duplicates(this: void, prototypes: Record<string, prototype.AnyPrototype>, overwrite: prototype.AnyPrototype): void;
|
|
4
|
+
|
|
5
|
+
export function check_for_overwrites(this: void, prototypes: Record<string, prototype.AnyPrototype>, overwrite: prototype.AnyPrototype): void;
|
|
6
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// https://github.com/wube/factorio-data/blob/master/core/lualib/event_handler.lua
|
|
2
|
+
declare module "event_handler" {
|
|
3
|
+
// Looking at the implementation of these functions, the objects seem close to LuaBootstrap as they have many of the same members
|
|
4
|
+
// on_configuration_changed, on_init, on_load, etc
|
|
5
|
+
// they also have a few additional fields not mentioned elsewhere
|
|
6
|
+
// hopefull this type is close enough
|
|
7
|
+
export type Library = Partial<runtime.LuaBootstrap> & {
|
|
8
|
+
add_remote_interface?: (this: void) => void;
|
|
9
|
+
add_commands?: (this: void) => void;
|
|
10
|
+
events: Record<string, runtime.LuaEventType>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function add_lib(this: void, lib: Library): void;
|
|
14
|
+
|
|
15
|
+
export function add_libraries(this: void, libs: Record<string, Library>): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Type definitions for Factorio modding API
|
|
2
|
+
// Factorio API reference https://lua-api.factorio.com/latest/index.html
|
|
3
|
+
// src mappings manually written to cover aspects not in the machine-readable API spec
|
|
4
|
+
// Definition source https://github.com/sguest/factorio-types
|
|
5
|
+
|
|
6
|
+
/// <reference path="./autoplace_utils.d.ts" />
|
|
7
|
+
/// <reference path="./collision-mask-defaults.d.ts" />
|
|
8
|
+
/// <reference path="./collision-mask-util.d.ts" />
|
|
9
|
+
/// <reference path="./crash-site.d.ts" />
|
|
10
|
+
/// <reference path="./data-duplicate-checker.d.ts" />
|
|
11
|
+
/// <reference path="./event_handler.d.ts" />
|
|
12
|
+
/// <reference path="./kill-score.d.ts" />
|
|
13
|
+
/// <reference path="./math2d.d.ts" />
|
|
14
|
+
/// <reference path="./math3d.d.ts" />
|
|
15
|
+
/// <reference path="./meld.d.ts" />
|
|
16
|
+
/// <reference path="./mod-gui.d.ts" />
|
|
17
|
+
/// <reference path="./production-score.d.ts" />
|
|
18
|
+
/// <reference path="./resource-autoplace.d.ts" />
|
|
19
|
+
/// <reference path="./silo-script.d.ts" />
|
|
20
|
+
/// <reference path="./space-finish-script.d.ts" />
|
|
21
|
+
/// <reference path="./surface-render-parameter-effects.d.ts" />
|
|
22
|
+
/// <reference path="./util.d.ts" />
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// https://github.com/wube/factorio-data/blob/master/core/lualib/kill-score.lua
|
|
2
|
+
declare module "kill-score" {
|
|
3
|
+
export function generate_entity_prices(this: void, param?: { prices?: Record<string,number>, item_prices?: Record<string, number> }): Record<string, number>
|
|
4
|
+
|
|
5
|
+
export function get_kill_scores(this: void, price_list?: Record<string, number>): Record<string, number>;
|
|
6
|
+
|
|
7
|
+
export function get_default_prices(this: void): Record<string, number>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// https://github.com/wube/factorio-data/blob/master/core/lualib/math2d.lua
|
|
2
|
+
declare module "math2d" {
|
|
3
|
+
export const projection_constant = 0.7071067811865;
|
|
4
|
+
|
|
5
|
+
export const vector: {
|
|
6
|
+
from_orientation(this: void, orientation: number, length: number): runtime.Vector;
|
|
7
|
+
to_orientation(this: void, vec: runtime.Vector): number;
|
|
8
|
+
length(this: void, vec: runtime.Vector): number;
|
|
9
|
+
projected(this: void, vec: runtime.Vector): runtime.Vector;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const position: {
|
|
13
|
+
/**
|
|
14
|
+
* Takes a position that might be either a two element array, or a table
|
|
15
|
+
* with x and y keys, and returns a position with x and y keys.
|
|
16
|
+
*/
|
|
17
|
+
ensure_xy(this: void, pos: runtime.MapPosition): { x: number, y: number };
|
|
18
|
+
distance_squared(this: void, p1: runtime.MapPosition, p2: runtime.MapPosition): number;
|
|
19
|
+
distance(this: void, p1: runtime.MapPosition, p2: runtime.MapPosition): number;
|
|
20
|
+
rotate_vector(this: void, vector: runtime.Vector, angle_in_deg: number): runtime.Vector;
|
|
21
|
+
subtract(this: void, p1: runtime.MapPosition, p2: runtime.MapPosition): runtime.MapPosition;
|
|
22
|
+
add(this: void, p1: runtime.MapPosition, p2: runtime.MapPosition): runtime.MapPosition;
|
|
23
|
+
multiply_scalar(this: void, vec: runtime.Vector, scalar: number): runtime.Vector;
|
|
24
|
+
divide_scalar(this: void, vec: runtime.Vector, scalar: number): runtime.Vector;
|
|
25
|
+
vector_length(this: void, vec: runtime.Vector): number;
|
|
26
|
+
get_normalized(this: void, vec: runtime.Vector): runtime.Vector;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const bounding_box: {
|
|
30
|
+
/**
|
|
31
|
+
* Takes a bounding box with positions that might be either two element arrays, or tables
|
|
32
|
+
* with x and y keys, and returns a bounding box with positions with x and y keys
|
|
33
|
+
*/
|
|
34
|
+
ensure_xy(this: void, bounding_box: runtime.BoundingBox): {left_top: {x : number, y: number}, right_bottom: {x: number, y: number}};
|
|
35
|
+
get_centre(this: void, box: runtime.BoundingBox): runtime.MapPosition;
|
|
36
|
+
contains_point(this: void, box: runtime.BoundingBox, point: runtime.MapPosition): boolean;
|
|
37
|
+
contains_box(this: void, box: runtime.BoundingBox, other: runtime.BoundingBox): boolean;
|
|
38
|
+
collides_with(this: void, box1: runtime.BoundingBox, box2: runtime.BoundingBox): boolean;
|
|
39
|
+
create_from_centre(this: void, centre: runtime.MapPosition, width: number, height: number): runtime.BoundingBox;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// https://github.com/wube/factorio-data/blob/master/core/lualib/math3d.lua
|
|
2
|
+
|
|
3
|
+
// The Vector4 type doesn't exist at runtime so the vector4 references it from prototype instead of runtime like the rest of the file
|
|
4
|
+
// However, this is all just math and the Vector/Vector3D types are all equivalent between prototype and runtime stages
|
|
5
|
+
// Therefore this is a case where mixing and matching prototype and runtime stage members is OK
|
|
6
|
+
declare module "math3d" {
|
|
7
|
+
export const projection_constant = 0.7071067811865;
|
|
8
|
+
|
|
9
|
+
export function project_vec3(this: void, vec3: runtime.Vector3D): runtime.Vector;
|
|
10
|
+
|
|
11
|
+
export const vector4: {
|
|
12
|
+
zero: [0, 0, 0, 0];
|
|
13
|
+
dot_product(this: void, u: prototype.Vector4f, v: prototype.Vector4f): number;
|
|
14
|
+
add(this: void, u: prototype.Vector4f, v: prototype.Vector4f): prototype.Vector4f;
|
|
15
|
+
sub(this: void, u: prototype.Vector4f, v: prototype.Vector4f): prototype.Vector4f;
|
|
16
|
+
from_vec3(this: void, u: prototype.Vector3D): prototype.Vector4f;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const vector3: {
|
|
20
|
+
zero: [0, 0, 0];
|
|
21
|
+
dot_product(this: void, u: runtime.Vector3D, v: runtime.Vector3D): number;
|
|
22
|
+
add(this: void, u: runtime.Vector3D, v: runtime.Vector3D): runtime.Vector3D;
|
|
23
|
+
sub(this: void, u: runtime.Vector3D, v: runtime.Vector3D): runtime.Vector3D;
|
|
24
|
+
mul(this: void, u: runtime.Vector3D, v: runtime.Vector3D): runtime.Vector3D;
|
|
25
|
+
cross_product(this: void, u: runtime.Vector3D, v: runtime.Vector3D): runtime.Vector3D;
|
|
26
|
+
angle(this: void, u: runtime.Vector3D, v: runtime.Vector3D): number;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const vector2: {
|
|
30
|
+
zero: [0, 0];
|
|
31
|
+
dot_product(this: void, u: runtime.Vector, v: runtime.Vector): number;
|
|
32
|
+
add(this: void, u: runtime.Vector, v: runtime.Vector): runtime.Vector;
|
|
33
|
+
sub(this: void, u: runtime.Vector, v: runtime.Vector): runtime.Vector;
|
|
34
|
+
mul(this: void, u: runtime.Vector, k: runtime.Vector): runtime.Vector;
|
|
35
|
+
rotate(this: void, v: runtime.Vector, phi: number): runtime.Vector;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export type Matrix4x4 = [
|
|
39
|
+
[number, number, number, number],
|
|
40
|
+
[number, number, number, number],
|
|
41
|
+
[number, number, number, number],
|
|
42
|
+
[number, number, number, number],
|
|
43
|
+
];
|
|
44
|
+
|
|
45
|
+
export const matrix4x4: {
|
|
46
|
+
identity: [
|
|
47
|
+
[1, 0, 0, 0],
|
|
48
|
+
[0, 1, 0, 0],
|
|
49
|
+
[0, 0, 1, 0],
|
|
50
|
+
[0, 0, 0, 1],
|
|
51
|
+
];
|
|
52
|
+
rotation_x(this: void, phi: number): Matrix4x4;
|
|
53
|
+
rotation_y(this: void, phi: number): Matrix4x4;
|
|
54
|
+
rotation_z(this: void, phi: number): Matrix4x4;
|
|
55
|
+
translation(this: void, x: number, y: number, z: number): Matrix4x4;
|
|
56
|
+
translation_vec3(this: void, vec3: runtime.Vector3D): Matrix4x4;
|
|
57
|
+
scale(this: void, x: number, y: number, z: number): Matrix4x4;
|
|
58
|
+
column(this: void, mat: Matrix4x4, index: number): [number, number, number, number];
|
|
59
|
+
transpose(this: void, mat: Matrix4x4): Matrix4x4;
|
|
60
|
+
mul_mat(this: void, m1: Matrix4x4, m2: Matrix4x4): Matrix4x4;
|
|
61
|
+
mul_vec3(this: void, mat: Matrix4x4, vec: runtime.Vector3D): runtime.Vector3D;
|
|
62
|
+
compose(this: void, list: Matrix4x4[]): Matrix4x4;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// https://github.com/wube/factorio-data/blob/master/core/lualib/meld.lua
|
|
2
|
+
|
|
3
|
+
// Lots of "any" types in this declaration - it's not immediately obvious what it's supposed to do and not many example usages in the base mod
|
|
4
|
+
declare module "meld" {
|
|
5
|
+
|
|
6
|
+
export const control_marker: {};
|
|
7
|
+
|
|
8
|
+
export const controler_handlers: {
|
|
9
|
+
delete(this: void, target: any, k: string, v: any): void;
|
|
10
|
+
overwrite(this: void, target: any, k: string, v: any): any;
|
|
11
|
+
invoke(this: void, target: any, k: string, v: any): any;
|
|
12
|
+
append(this: void, target: any, k: string, v: any): void;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
function _delete(this: void): void;
|
|
16
|
+
export { _delete as delete };
|
|
17
|
+
|
|
18
|
+
export function overwrite(this: void, _new: any): any;
|
|
19
|
+
|
|
20
|
+
export function invoke(this: void, fct: any): any;
|
|
21
|
+
|
|
22
|
+
export function append(this: void, data: any): any;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* recursive table merge but it reuses target table (this: void, does not deepcopy it). When target is not to be reused or more than
|
|
26
|
+
* 2 tables are to be merged, consider using util.merge. When there is conflict of 2 values, a value from the source will
|
|
27
|
+
* win overwriting the existing value. There are also control structures available for extra operations that would not
|
|
28
|
+
* be possible under normal merge rules
|
|
29
|
+
*/
|
|
30
|
+
export function meld(this: void, target: Table, source: Table): Table
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
declare function meld(this: Table, target: Table, source: Table): void;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// https://github.com/wube/factorio-data/blob/master/core/lualib/mod-gui.lua
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
Hello script explorer, if you are looking to upgrade your mod to use the mod gui, its pretty simple.
|
|
5
|
+
|
|
6
|
+
Typically you will have something like:
|
|
7
|
+
player.gui.left.add{...}
|
|
8
|
+
|
|
9
|
+
All you will need to do, is change it to:
|
|
10
|
+
mod_gui.get_frame_flow(player).add{...}
|
|
11
|
+
|
|
12
|
+
And for buttons its just the same:
|
|
13
|
+
mod_gui.get_button_flow(player).add{...}
|
|
14
|
+
|
|
15
|
+
It should be as simple as find and replace.
|
|
16
|
+
|
|
17
|
+
Any other questions please feel free to ask on the modding help forum.
|
|
18
|
+
*/
|
|
19
|
+
declare module "mod-gui" {
|
|
20
|
+
export const button_style = "mod_gui_button";
|
|
21
|
+
export const frame_style = "non_draggable_frame"
|
|
22
|
+
|
|
23
|
+
export function get_button_flow(this: void, player: runtime.LuaPlayer): runtime.LuaGuiElement;
|
|
24
|
+
export function get_frame_flow(this: void, player: runtime.LuaPlayer): runtime.LuaGuiElement;
|
|
25
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare module "production-score" {
|
|
2
|
+
export function generate_price_list(this: void, param?: {
|
|
3
|
+
seed_prices?: Record<string, number>,
|
|
4
|
+
ingedient_exponent?: number,
|
|
5
|
+
raw_resource_price?: number,
|
|
6
|
+
resource_ignore?: Record<string, string>,
|
|
7
|
+
round?: (this: void, num: number) => number,
|
|
8
|
+
energy_addition?: (this: void, recipe: runtime.LuaRecipe, cost: number) => number,
|
|
9
|
+
normalise?: (this: void, num: number) => number,
|
|
10
|
+
}): Record<string, number>;
|
|
11
|
+
|
|
12
|
+
export function get_production_scores(this: void, price_list?: Record<string,number>): Record<string, number>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// https://github.com/wube/factorio-data/blob/master/core/lualib/resource-autoplace.lua
|
|
2
|
+
declare module "resource-autoplace" {
|
|
3
|
+
/**
|
|
4
|
+
* Indicate that a patch set exists and optionally that it also needs a separate starting patch set.
|
|
5
|
+
* Call this to initialize patch sets' indexes in a more deterministic order
|
|
6
|
+
* (see resources.lua for an example) before calling resource_autoplace_settings.
|
|
7
|
+
*/
|
|
8
|
+
export function initialize_patch_set(this: void, patch_set_name: string, has_starting_area_placement: boolean, autoplace_set_name: string): void
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Creates and returns an AutoplaceSpecification that will generate spot-based ore patches.
|
|
12
|
+
* @param params.name name for the type, used as the default autoplace control name and patch set name (each of which can be overridden separately)
|
|
13
|
+
* @param params.base_density amount of stuff, on average, to be placed per tile
|
|
14
|
+
* @param params.patch_set_name name of the patch set; patches sets of the same name and seed1 will overlap; default: name
|
|
15
|
+
* @param params.autoplace_control_name name of the corresponding autoplace control; default: name
|
|
16
|
+
* @param params.random_probability probability of placement at any given tile within a patch; default: 1
|
|
17
|
+
* @param params.base_spots_per_km2 number of patches per square kilometer near the starting area
|
|
18
|
+
* @param params.has_starting_area_placement true|false|nil - yes, no, and there is no special starting area, respectively
|
|
19
|
+
* @param params.seed1 random seed to use when generating patch positions; default: 100
|
|
20
|
+
*/
|
|
21
|
+
export function resource_autoplace_settings(this: void, params: {
|
|
22
|
+
name: string,
|
|
23
|
+
base_density: number,
|
|
24
|
+
patch_set_name?: string,
|
|
25
|
+
autoplace_control_name?: string,
|
|
26
|
+
random_probability?: number,
|
|
27
|
+
base_spots_per_km2?: number,
|
|
28
|
+
has_starting_area_placement?: boolean | null,
|
|
29
|
+
seed1?: number,
|
|
30
|
+
}): {
|
|
31
|
+
order: string,
|
|
32
|
+
probability_expression: string,
|
|
33
|
+
richness_expression: string,
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// https://github.com/wube/factorio-data/blob/master/core/lualib/silo-script.lua
|
|
2
|
+
declare module "silo-script" {
|
|
3
|
+
export const events: { [defines.events.on_rocket_launched]: (this: void, event: runtime.on_rocket_launched) => void };
|
|
4
|
+
|
|
5
|
+
export function on_configuration_changed(this: void): void;
|
|
6
|
+
|
|
7
|
+
export function on_init(this: void): void;
|
|
8
|
+
|
|
9
|
+
export function on_load(this: void): void;
|
|
10
|
+
|
|
11
|
+
/** legacy */
|
|
12
|
+
export function get_events(this: void): { [defines.events.on_rocket_launched]: (this: void, event: runtime.on_rocket_launched) => void };
|
|
13
|
+
|
|
14
|
+
/** legacy */
|
|
15
|
+
export function add_remote_interface(this: void): void;
|
|
16
|
+
|
|
17
|
+
/** legacy */
|
|
18
|
+
export function add_commands(this: void): void;
|
|
19
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// https://github.com/wube/factorio-data/blob/master/core/lualib/space-finish-script.lua
|
|
2
|
+
declare module "space-finish-script" {
|
|
3
|
+
export const events: { [defines.events.on_space_platform_changed_state]: (this: void, event: runtime.on_space_platform_changed_state) => void }
|
|
4
|
+
|
|
5
|
+
export function on_configuration_changed(this: void): void;
|
|
6
|
+
|
|
7
|
+
export function on_init(this: void): void;
|
|
8
|
+
|
|
9
|
+
export function on_load(this: void): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// github.com/wube/factorio-data/blob/master/core/lualib/surface-render-parameter-effects.lua
|
|
2
|
+
declare module "surface-render-parameter-effects" {
|
|
3
|
+
export function default_clouds_effect_properties(this: void): prototype.CloudsEffectProperties;
|
|
4
|
+
|
|
5
|
+
export function default_fog_effect_properties(this: void): prototype.FogEffectProperties;
|
|
6
|
+
}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
// https://github.com/wube/factorio-data/blob/master/core/lualib/util.lua
|
|
2
|
+
declare module "util" {
|
|
3
|
+
export const table: {
|
|
4
|
+
deepcopy<T>(this: void, value: T): T;
|
|
5
|
+
compare(this: void, table1: object | [], table2: object | []): boolean;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function copy<T>(this: void, value: T): T;
|
|
9
|
+
|
|
10
|
+
export function distance(this: void, position1: runtime.MapPosition, position2: runtime.MapPosition): number;
|
|
11
|
+
|
|
12
|
+
export function positiontostr(this: void, pos: runtime.MapPosition): string;
|
|
13
|
+
|
|
14
|
+
export function formattime(this: void, ticks: number): string;
|
|
15
|
+
|
|
16
|
+
/** supports 'rrggbb', 'rgb', 'rrggbbaa', 'rgba', 'ww', 'w' */
|
|
17
|
+
export function color(this: void, hex: string): runtime.Color;
|
|
18
|
+
|
|
19
|
+
export function premul_color(this: void, color: runtime.Color): runtime.Color;
|
|
20
|
+
|
|
21
|
+
export function mix_color(this: void, c1: runtime.Color, c2: runtime.Color): runtime.Color;
|
|
22
|
+
|
|
23
|
+
export function multiply_color(this: void, c1: runtime.Color, n?: number): runtime.Color;
|
|
24
|
+
|
|
25
|
+
export function get_color_with_alpha(this: void, color: runtime.Color, alpha: number, normalized_alpha: number): runtime.Color;
|
|
26
|
+
|
|
27
|
+
export const direction_vectors: Record<defines.direction, runtime.MapPosition>;
|
|
28
|
+
|
|
29
|
+
export function moveposition(this: void, position: runtime.MapPosition, direction: defines.direction, distance: number): runtime.MapPosition;
|
|
30
|
+
|
|
31
|
+
/** orientation of 1 = 360 degrees */
|
|
32
|
+
export function rotate_position(this: void, position: runtime.MapPosition, orientation: number): runtime.MapPosition;
|
|
33
|
+
|
|
34
|
+
export function oppositedirection(this: void, direction: defines.direction): defines.direction;
|
|
35
|
+
|
|
36
|
+
export function multiplystripes<T>(this: void, count: number, stripes: T[]): T[];
|
|
37
|
+
|
|
38
|
+
export function by_pixel(this: void, x: number, y: number): { x: number, y: number }
|
|
39
|
+
|
|
40
|
+
export function by_pixel_hr(this: void, x: number, y: number): { x: number, y: number }
|
|
41
|
+
|
|
42
|
+
export function foreach_sprite_definition<T>(this: void, table_: T, fun_: (table: T) => void): T
|
|
43
|
+
|
|
44
|
+
export function add_shift<T>(this: void, a: [T, T], b: [T, T]): [T, T];
|
|
45
|
+
|
|
46
|
+
export function add_shift_offset<T>(this: void, offset_: [T, T], table_: [T, T]): [T, T];
|
|
47
|
+
|
|
48
|
+
export function mul_shift(this: void, shift: runtime.MapPosition, scale: number): runtime.MapPosition;
|
|
49
|
+
|
|
50
|
+
export function format_number(this: void, amount: number, append_suffix: boolean): string;
|
|
51
|
+
|
|
52
|
+
export function increment(this: void, t: number[], k: number, v: number): void;
|
|
53
|
+
|
|
54
|
+
export function conditional_return<T>(this: void, value: bool, data: T): T | false;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Recursively merges and/or deep-copies tables.
|
|
58
|
+
* Entries in later tables override entries in earlier ones, unless
|
|
59
|
+
* both entries are themselves tables, in which case they are recursively merged.
|
|
60
|
+
* Non-merged tables are deep-copies, so that the result is brand new.
|
|
61
|
+
*/
|
|
62
|
+
export function merge(this: void, tables: object[]): object;
|
|
63
|
+
|
|
64
|
+
export function insert_safe(this: void, entity: runtime.LuaEntity, item_dict: Record<string, number>): void;
|
|
65
|
+
|
|
66
|
+
export function remove_safe(this: void, entity: runtime.LuaEntity, item_dict: Record<string, number>): void;
|
|
67
|
+
|
|
68
|
+
export function split_whitespace(this: void, string: string): string[];
|
|
69
|
+
|
|
70
|
+
export function split(this: void, inputstr: string, sep: string): string[];
|
|
71
|
+
|
|
72
|
+
export function string_starts_with(this: void, str: string, start: string): boolean;
|
|
73
|
+
|
|
74
|
+
export function string_replace(this: void, str: string, what: string, _with: string): string;
|
|
75
|
+
|
|
76
|
+
export function clamp(this: void, x: number, lower: number, upper: number): number;
|
|
77
|
+
|
|
78
|
+
export function get_walkable_tile(this: void): string;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* This function takes 2 icons tables, and adds the second to the first, but applies scale, shift and tint to the entire second set.
|
|
82
|
+
* This allows you to manulipate the entire second icons table in the same way as you would manipulate a single icon when adding to the icons table.
|
|
83
|
+
*/
|
|
84
|
+
export function combine_icons(
|
|
85
|
+
this: void,
|
|
86
|
+
icons1: prototype.IconData[],
|
|
87
|
+
icons2: prototype.IconData[],
|
|
88
|
+
inputs: {
|
|
89
|
+
scale?: number,
|
|
90
|
+
shift?: number,
|
|
91
|
+
tint?: runtime.Color,
|
|
92
|
+
},
|
|
93
|
+
default_icon_size?: prototype.SpriteSizeType): prototype.IconData[]
|
|
94
|
+
|
|
95
|
+
export function technology_icon_constant_damage(this: void, technology_icon: prototype.FileName): prototype.IconData[];
|
|
96
|
+
|
|
97
|
+
export function technology_icon_constant_speed(this: void, technology_icon: prototype.FileName): prototype.IconData[];
|
|
98
|
+
|
|
99
|
+
export function technology_icon_constant_movement_speed(this: void, technology_icon: prototype.FileName): prototype.IconData[];
|
|
100
|
+
|
|
101
|
+
export function technology_icon_constant_range(this: void, technology_icon: prototype.FileName): prototype.IconData[];
|
|
102
|
+
|
|
103
|
+
export function technology_icon_constant_planet(this: void, technology_icon: prototype.FileName): prototype.IconData[];
|
|
104
|
+
|
|
105
|
+
export function technology_icon_constant_equipment(this: void, technology_icon: prototype.FileName): prototype.IconData[];
|
|
106
|
+
|
|
107
|
+
export function technology_icon_constant_followers(this: void, technology_icon: prototype.FileName): prototype.IconData[];
|
|
108
|
+
|
|
109
|
+
export function technology_icon_constant_capacity(this: void, technology_icon: prototype.FileName): prototype.IconData[];
|
|
110
|
+
|
|
111
|
+
export function technology_icon_constant_stack_size(this: void, technology_icon: prototype.FileName): prototype.IconData[];
|
|
112
|
+
|
|
113
|
+
export function technology_icon_constant_productivity(this: void, technology_icon: prototype.FileName): prototype.IconData[];
|
|
114
|
+
|
|
115
|
+
export function technology_icon_constant_recipe_productivity(this: void, technology_icon: prototype.FileName): prototype.IconData[];
|
|
116
|
+
|
|
117
|
+
export function technology_icon_constant_braking_force(this: void, technology_icon: prototype.FileName): prototype.IconData[];
|
|
118
|
+
|
|
119
|
+
export function technology_icon_constant_mining(this: void, technology_icon: prototype.FileName): prototype.IconData[];
|
|
120
|
+
|
|
121
|
+
export function parse_energy(this: void, energy: string): number;
|
|
122
|
+
|
|
123
|
+
export function product_amount(this: void, product: prototype.ProductPrototype): number;
|
|
124
|
+
|
|
125
|
+
export function empty_sprite(this: void): prototype.IconData;
|
|
126
|
+
|
|
127
|
+
export function empty_animation(this: void, animation_length: number): prototype.RotatedAnimation;
|
|
128
|
+
|
|
129
|
+
export function empty_icon(this: void): prototype.IconData;
|
|
130
|
+
|
|
131
|
+
export function draw_as_glow<T extends prototype.AnimationPrototype | prototype.SpritePrototype>(this: void, layer: T): T;
|
|
132
|
+
|
|
133
|
+
export function sprite_load(this: void, path: prototype.FileName, table: prototype.SpriteSheet): prototype.SpriteSheet;
|
|
134
|
+
|
|
135
|
+
export function spritesheets_to_pictures(this: void, spritesheets: prototype.SpriteSheet[]): prototype.SpriteSheet[];
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Does not handle:
|
|
139
|
+
* explicit tile filters in "selection-tool" items
|
|
140
|
+
* ItemPrototype::place_as_tile
|
|
141
|
+
* TilePrototype::next_direction
|
|
142
|
+
* TilePrototype::transition_merges_with_tile
|
|
143
|
+
* general tile transitions, only removes tile names from water_tile_type_names
|
|
144
|
+
*/
|
|
145
|
+
export function remove_tile_references(this: void, data: DataType, array_of_tiles_to_remove: string[]): void;
|
|
146
|
+
|
|
147
|
+
export function remove_from_list<T>(this: void, list: T[], value: T): boolean;
|
|
148
|
+
|
|
149
|
+
export function list_to_map<T extends string | number | symbol>(this: void, list: T[]): Record<T, true>;
|
|
150
|
+
|
|
151
|
+
export function normalize_recipe_product<T extends prototype.ProductPrototype>(this: void, raw_product: T): T;
|
|
152
|
+
|
|
153
|
+
export function normalize_recipe_products(this: void, recipe: prototype.RecipePrototype): prototype.ProductPrototype[];
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Returns the normalized main product or nil if the recipe definition is invalid or there is no main product
|
|
157
|
+
*/
|
|
158
|
+
export function get_recipe_main_product(this: void, recipe: prototype.RecipePrototype, normalized_products: prototype.ProductPrototype[]): prototype.ProductPrototype;
|
|
159
|
+
|
|
160
|
+
export function is_sprite_def(this: void, array: any): array is prototype.AnimationPrototype | prototype.SpriteParameters;
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Recursively tint all sprite definitions in the given table.
|
|
164
|
+
* If `tint` is `false`, all tinting will be removed
|
|
165
|
+
*/
|
|
166
|
+
export function recursive_tint(this: void, array: Array<prototype.AnimationPrototype | prototype.SpriteParameters>, tint: prototype.Color | false): Array<prototype.AnimationPrototype | prototype.SpriteParameters>
|
|
167
|
+
}
|
package/src/serpent.d.ts
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
// Definition source https://github.com/sguest/factorio-types
|
|
5
5
|
|
|
6
6
|
interface Serpent {
|
|
7
|
-
dump(this: void, a: object, options
|
|
8
|
-
line(this: void, a: object, options
|
|
9
|
-
block(this: void, a: object, options
|
|
7
|
+
dump(this: void, a: object, options?: SerpentOptions): string
|
|
8
|
+
line(this: void, a: object, options?: SerpentOptions): string
|
|
9
|
+
block(this: void, a: object, options?: SerpentOptions): string
|
|
10
10
|
load(this: void, str: string, options?: {safe?: boolean}): string
|
|
11
11
|
}
|
|
12
12
|
|
|
@@ -17,6 +17,7 @@ interface SerpentOptions {
|
|
|
17
17
|
sparse?: boolean
|
|
18
18
|
compact?: boolean
|
|
19
19
|
fatal?: boolean
|
|
20
|
+
fixradix?: boolean
|
|
20
21
|
nocode?: boolean
|
|
21
22
|
nohuge?: boolean
|
|
22
23
|
maxlevel?: number
|
package/tsconfig.base.json
CHANGED
|
@@ -11,5 +11,24 @@
|
|
|
11
11
|
"luaTarget": "JIT",
|
|
12
12
|
"noImplicitSelf": true,
|
|
13
13
|
"noImplicitGlobalVariables": true,
|
|
14
|
+
"noResolvePaths": [
|
|
15
|
+
"autoplace_utils",
|
|
16
|
+
"collision-mask-defaults",
|
|
17
|
+
"collision-mask-util",
|
|
18
|
+
"crash-site",
|
|
19
|
+
"data-duplicate-checker",
|
|
20
|
+
"event_handler",
|
|
21
|
+
"kill-score",
|
|
22
|
+
"math2d",
|
|
23
|
+
"math3d",
|
|
24
|
+
"meld",
|
|
25
|
+
"mod-gui",
|
|
26
|
+
"production-score",
|
|
27
|
+
"resource-autoplace",
|
|
28
|
+
"silo-script",
|
|
29
|
+
"space-finish-script",
|
|
30
|
+
"surface-render-parameter-effects",
|
|
31
|
+
"util"
|
|
32
|
+
]
|
|
14
33
|
},
|
|
15
34
|
}
|