typed-factorio 0.13.2 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,120 +1,120 @@
1
- // Based off of https://wiki.factorio.com/Tutorial:Mod_settings
2
-
3
- export type SettingType = "bool-setting" | "int-setting" | "double-setting" | "string-setting"
4
-
5
- export interface BaseSettingDefinition {
6
- type: SettingType
7
- /**
8
- * The name of the settings prototype should be unique to avoid mod conflicts since the mod settings are global across
9
- * all mods. Because of that it is recommended to prefix mod settings with your mod name,
10
- */
11
- name: string
12
- localized_name?: LocalisedString
13
- localized_description?: LocalisedString
14
-
15
- /**
16
- * The order property can be used to change how the mod settings are ordered in the settings gui. Mod settings are sorted
17
- *
18
- * - First by mod
19
- * - Then by the setting "order" string
20
- * - Then finally by the setting name.
21
- */
22
- order?: string
23
- /**
24
- * The hidden property can be used to hide mod settings from GUIs, so that they cannot be seen or changed by players.
25
- * However, other mods can still access hidden settings. {@link https://forums.factorio.com/83316}
26
- */
27
- hidden?: boolean
28
- /**
29
- * There are the overall kinds of settings:
30
- *
31
- * - **startup**: This kind of setting is available in the prototype stage, and can not be changed runtime. They have to
32
- * be set to the same values for all players on a server.
33
- * - **runtime-global**: This kind of setting is global to an entire save game and can be changed runtime. On servers,
34
- * only admins can change these settings.
35
- * - **runtime-per-user**: This kind of setting is only available runtime in the control.lua stage and each player has
36
- * their own instance of this setting. When a player joins a server their local setting of "keep mod settings per
37
- * save" determines if the local settings they have set are synced to the loaded save or if the save's settings are used.
38
- *
39
- * This "setting_type" also determines in which tab the setting is showed in the mod settings menu.
40
- */
41
-
42
- setting_type: "startup" | "runtime-global" | "runtime-per-user"
43
- }
44
- /** A true/false checkbox */
45
- export interface BoolSettingDefinition extends BaseSettingDefinition {
46
- type: "bool-setting"
47
- /** Defines the default value of the setting, in this case whether the checkbox is checked or not. */
48
- default_value: boolean
49
- /**
50
- * Only loaded if `hidden = true`. This forces the setting to be of this value. This can be useful for mod
51
- * compatibility. {@link https://forums.factorio.com/viewtopic.php?p=531322#p531322}
52
- */
53
- forced_value?: boolean
54
- }
55
- /** A signed 64 bit integer textfield (or selection dropdown) */
56
- export interface IntSettingDefinition extends BaseSettingDefinition {
57
- type: "int-setting"
58
- /** Defines the default value of the setting. */
59
- default_value: number
60
- /** Defines the lowest possible number. */
61
- minimum_value?: number
62
- /** Defines the highest possible number. */
63
- maximum_value?: number
64
- /**
65
- * Makes it possible to force the player to choose between the defined numbers, creates a dropdown instead of a
66
- * textfield. If only one allowed value is given, the settings is forced to be of that value.
67
- */
68
- allowed_values?: number[]
69
- }
70
- /** A double precision floating point textfield (or selection dropdown) */
71
- export interface DoubleSettingDefinition extends BaseSettingDefinition {
72
- type: "double-setting"
73
- /** Defines the default value of the setting. */
74
- default_value: number
75
- /** Defines the lowest possible number. */
76
- minimum_value?: number
77
- /** Defines the highest possible number. */
78
- maximum_value?: number
79
- /**
80
- * Makes it possible to force the player to choose between the defined numbers, creates a dropdown instead of a
81
- * textfield. If only one allowed value is given, the settings is forced to be of that value.
82
- */
83
- allowed_values?: number[]
84
- }
85
- /** A string textfield (or selection dropdown) */
86
- export interface StringSettingDefinition extends BaseSettingDefinition {
87
- type: "string-setting"
88
- /** Defines the default value of the setting. */
89
- default_value: string
90
- /** Defines whether it's possible for the user to set the textfield to empty and apply the setting. */
91
- allow_blank?: boolean
92
- /** Whether values that are input by the user should have whitespace removed from both ends of the string. */
93
- auto_trim?: boolean
94
- /**
95
- * Makes it possible to force the player to choose between the defined strings, creates a dropdown instead of a
96
- * textfield. The strings in the dropdown can be localized (translated) and can have a tooltip, see below. If only one
97
- * allowed value is given, the settings is forced to be of that value.
98
- */
99
- allowed_values?: string[]
100
- }
101
- /** Setting definitions. See {@link https://wiki.factorio.com/Tutorial:Mod_settings} for more info. */
102
- export type SettingDefinition =
103
- | BoolSettingDefinition
104
- | IntSettingDefinition
105
- | DoubleSettingDefinition
106
- | StringSettingDefinition
107
-
108
- export interface Data {
109
- readonly raw: {
110
- [T in SettingDefinition["type"]]: Record<string, Extract<SettingDefinition, { type: T }>>
111
- }
112
- /**
113
- * The `data` table expects a specific format for each item in the table. Missing properties will either fall back to
114
- * default values or give an error indicating what's missing. Extra properties that the game isn't looking for are
115
- * simply ignored.
116
- */
117
- extend(prototypes: SettingDefinition[]): void
118
- }
119
- /** A mapping of mod names to mod version for all enabled mods. */
120
- export type Mods = Record<string, string>
1
+ // Based off of https://wiki.factorio.com/Tutorial:Mod_settings
2
+
3
+ export type SettingType = "bool-setting" | "int-setting" | "double-setting" | "string-setting"
4
+
5
+ export interface BaseSettingDefinition {
6
+ type: SettingType
7
+ /**
8
+ * The name of the settings prototype should be unique to avoid mod conflicts since the mod settings are global across
9
+ * all mods. Because of that it is recommended to prefix mod settings with your mod name,
10
+ */
11
+ name: string
12
+ localized_name?: LocalisedString
13
+ localized_description?: LocalisedString
14
+
15
+ /**
16
+ * The order property can be used to change how the mod settings are ordered in the settings gui. Mod settings are sorted
17
+ *
18
+ * - First by mod
19
+ * - Then by the setting "order" string
20
+ * - Then finally by the setting name.
21
+ */
22
+ order?: string
23
+ /**
24
+ * The hidden property can be used to hide mod settings from GUIs, so that they cannot be seen or changed by players.
25
+ * However, other mods can still access hidden settings. {@link https://forums.factorio.com/83316}
26
+ */
27
+ hidden?: boolean
28
+ /**
29
+ * There are the overall kinds of settings:
30
+ *
31
+ * - **startup**: This kind of setting is available in the prototype stage, and can not be changed runtime. They have to
32
+ * be set to the same values for all players on a server.
33
+ * - **runtime-global**: This kind of setting is global to an entire save game and can be changed runtime. On servers,
34
+ * only admins can change these settings.
35
+ * - **runtime-per-user**: This kind of setting is only available runtime in the control.lua stage and each player has
36
+ * their own instance of this setting. When a player joins a server their local setting of "keep mod settings per
37
+ * save" determines if the local settings they have set are synced to the loaded save or if the save's settings are used.
38
+ *
39
+ * This "setting_type" also determines in which tab the setting is showed in the mod settings menu.
40
+ */
41
+
42
+ setting_type: "startup" | "runtime-global" | "runtime-per-user"
43
+ }
44
+ /** A true/false checkbox */
45
+ export interface BoolSettingDefinition extends BaseSettingDefinition {
46
+ type: "bool-setting"
47
+ /** Defines the default value of the setting, in this case whether the checkbox is checked or not. */
48
+ default_value: boolean
49
+ /**
50
+ * Only loaded if `hidden = true`. This forces the setting to be of this value. This can be useful for mod
51
+ * compatibility. {@link https://forums.factorio.com/viewtopic.php?p=531322#p531322}
52
+ */
53
+ forced_value?: boolean
54
+ }
55
+ /** A signed 64 bit integer textfield (or selection dropdown) */
56
+ export interface IntSettingDefinition extends BaseSettingDefinition {
57
+ type: "int-setting"
58
+ /** Defines the default value of the setting. */
59
+ default_value: number
60
+ /** Defines the lowest possible number. */
61
+ minimum_value?: number
62
+ /** Defines the highest possible number. */
63
+ maximum_value?: number
64
+ /**
65
+ * Makes it possible to force the player to choose between the defined numbers, creates a dropdown instead of a
66
+ * textfield. If only one allowed value is given, the settings is forced to be of that value.
67
+ */
68
+ allowed_values?: number[]
69
+ }
70
+ /** A double precision floating point textfield (or selection dropdown) */
71
+ export interface DoubleSettingDefinition extends BaseSettingDefinition {
72
+ type: "double-setting"
73
+ /** Defines the default value of the setting. */
74
+ default_value: number
75
+ /** Defines the lowest possible number. */
76
+ minimum_value?: number
77
+ /** Defines the highest possible number. */
78
+ maximum_value?: number
79
+ /**
80
+ * Makes it possible to force the player to choose between the defined numbers, creates a dropdown instead of a
81
+ * textfield. If only one allowed value is given, the settings is forced to be of that value.
82
+ */
83
+ allowed_values?: number[]
84
+ }
85
+ /** A string textfield (or selection dropdown) */
86
+ export interface StringSettingDefinition extends BaseSettingDefinition {
87
+ type: "string-setting"
88
+ /** Defines the default value of the setting. */
89
+ default_value: string
90
+ /** Defines whether it's possible for the user to set the textfield to empty and apply the setting. */
91
+ allow_blank?: boolean
92
+ /** Whether values that are input by the user should have whitespace removed from both ends of the string. */
93
+ auto_trim?: boolean
94
+ /**
95
+ * Makes it possible to force the player to choose between the defined strings, creates a dropdown instead of a
96
+ * textfield. The strings in the dropdown can be localized (translated) and can have a tooltip, see below. If only one
97
+ * allowed value is given, the settings is forced to be of that value.
98
+ */
99
+ allowed_values?: string[]
100
+ }
101
+ /** Setting definitions. See {@link https://wiki.factorio.com/Tutorial:Mod_settings} for more info. */
102
+ export type SettingDefinition =
103
+ | BoolSettingDefinition
104
+ | IntSettingDefinition
105
+ | DoubleSettingDefinition
106
+ | StringSettingDefinition
107
+
108
+ export interface Data {
109
+ readonly raw: {
110
+ [T in SettingDefinition["type"]]: Record<string, Extract<SettingDefinition, { type: T }>>
111
+ }
112
+ /**
113
+ * The `data` table expects a specific format for each item in the table. Missing properties will either fall back to
114
+ * default values or give an error indicating what's missing. Extra properties that the game isn't looking for are
115
+ * simply ignored.
116
+ */
117
+ extend(prototypes: SettingDefinition[]): void
118
+ }
119
+ /** A mapping of mod names to mod version for all enabled mods. */
120
+ export type Mods = Record<string, string>