isaacscript-common 30.12.8 → 30.12.9

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.
@@ -7566,16 +7566,16 @@ export declare function inHomeCloset(): boolean;
7566
7566
  * For example:
7567
7567
  *
7568
7568
  * ```ts
7569
- * const features = [
7569
+ * const MOD_FEATURES = [
7570
7570
  * MyFeature1,
7571
7571
  * MyFeature2,
7572
7572
  * MyFeature3,
7573
7573
  * ] as const;
7574
- * initModFeatures(mod, modFeatures);
7574
+ * initModFeatures(mod, MOD_FEATURES);
7575
7575
  * ```
7576
7576
  *
7577
7577
  * @returns An array of the instantiated features in the same order that the constructors were
7578
- * passed in.
7578
+ * passed in. (In most cases, you probably won't need the returned array.)
7579
7579
  */
7580
7580
  export declare function initModFeatures<T extends ReadonlyArray<typeof ModFeature>>(mod: ModUpgraded, modFeatures: T): {
7581
7581
  [K in keyof T]: InstanceType<T[K]>;
@@ -12798,24 +12798,22 @@ declare class ModdedElementSets extends Feature {
12798
12798
  * mod features from this class in order to enable the `@Callback` and `@CustomCallback` decorators
12799
12799
  * that automatically subscribe to callbacks.
12800
12800
  *
12801
- * When instantiating a mod feature class, you must pass your upgraded mod as the first argument to
12802
- * the constructor.
12801
+ * It is recommended that you use the `initModFeatures` helper function to instantiate all of your
12802
+ * mod classes (instead of instantiating them yourself). This is so that any attached `v` objects
12803
+ * are properly registered with the save data manager; see below.
12803
12804
  *
12804
- * If your feature has variables that are managed by the save data manager, you need to explicitly
12805
- * register them with the save data manager yourself in your class constructor. (It can't be
12806
- * automatically done because parent classes don't have access to child class properties.)
12805
+ * If you are manually instantiating a mod feature yourself, then:
12807
12806
  *
12808
- * In almost all cases, you will want the callback functions to be immediately subscribed after
12809
- * instantiating the class. However, if this is not the case, you can pass `false` as the optional
12810
- * second argument to the constructor.
12807
+ * - You must pass your upgraded mod as the first argument to the constructor.
12808
+ * - In almost all cases, you will want the callback functions to be immediately subscribed after
12809
+ * instantiating the class. However, if this is not the case, you can pass `false` as the optional
12810
+ * second argument to the constructor.
12811
12811
  *
12812
12812
  * If your mod feature has a property called `v`, it will be assumed that these are variables that
12813
- * should be managed by the save data manager. Subsequently, they will automatically be registered
12814
- * with the save data manager upon initialization. Unfortunately, due to technical limitations with
12815
- * classes, this registration will only occur if you initialize the class with the `init` boolean
12816
- * argument set to false, and then explicitly call the `ModFeature.init` method yourself after the
12817
- * class is constructed. (This is because the parent class does not have access to the child's
12818
- * properties upon first construction.)
12813
+ * should be managed by the save data manager. Unfortunately, due to technical limitations with
12814
+ * classes, this registration will only occur if you initialize the class with the `initModFeatures`
12815
+ * helper function. (This is because the parent class does not have access to the child's properties
12816
+ * upon first construction.)
12819
12817
  */
12820
12818
  export declare class ModFeature {
12821
12819
  private readonly mod;
@@ -15169,21 +15167,20 @@ declare class SaveDataManager extends Feature {
15169
15167
  * desired).
15170
15168
  * 2. Automatic saving and loading of all tracked data to the "save#.dat" file.
15171
15169
  *
15172
- * You feed this function with an object containing your variables, and then it will automatically
15173
- * manage them for you. (See below for an example.)
15170
+ * You provide this function with an object containing your variables, and then it will
15171
+ * automatically manage them for you. (See below for an example.)
15174
15172
  *
15175
15173
  * In order to use this function, you must upgrade your mod with `ISCFeature.SAVE_DATA_MANAGER`.
15176
15174
  * (Upgrade your mod before registering any of your own callbacks so that the save data manager
15177
15175
  * will run before any of your code does.)
15178
15176
  *
15179
15177
  * The save data manager is meant to be called once for each feature of your mod. In other words,
15180
- * you should not put all of the data for your mod on the same object. Instead, scope your
15178
+ * you should not put all of the variables for your mod on the same object. Instead, scope your
15181
15179
  * variables locally to a single file that contains a mod feature, and then call this function to
15182
15180
  * register them. For example:
15183
15181
  *
15184
15182
  * ```ts
15185
15183
  * // In file: feature1.ts
15186
- * import { saveDataManager } from "isaacscript-common";
15187
15184
  *
15188
15185
  * // Declare local variables for this file or feature.
15189
15186
  * const v = {
@@ -15207,13 +15204,12 @@ declare class SaveDataManager extends Feature {
15207
15204
  * foo4: 0,
15208
15205
  * },
15209
15206
  * };
15210
- * // Every child object is optional; only create the ones that you need.
15207
+ * // The child objects of "persistent", "run", "level", and "room are optional; only create the
15208
+ * // ones that you need.
15211
15209
  *
15212
- * // Register the variables with the save data manager. (We need to provide a string key that
15213
- * // matches the name of this file.)
15214
- * function feature1Init() {
15215
- * saveDataManager("feature1", v);
15216
- * }
15210
+ * // Now, give `v` to the save data manager, and it will automatically manage the variables for
15211
+ * // you.
15212
+ * mod.saveDataManager("feature1", v);
15217
15213
  *
15218
15214
  * // Elsewhere in the file, use your variables.
15219
15215
  * function feature1Function() {
@@ -1,6 +1,6 @@
1
1
  --[[
2
2
 
3
- isaacscript-common 30.12.8
3
+ isaacscript-common 30.12.9
4
4
 
5
5
  This is the "isaacscript-common" library, which was created with the IsaacScript tool.
6
6
 
@@ -8,24 +8,22 @@ export declare const MOD_FEATURE_CUSTOM_CALLBACKS_KEY = "__customCallbacks";
8
8
  * mod features from this class in order to enable the `@Callback` and `@CustomCallback` decorators
9
9
  * that automatically subscribe to callbacks.
10
10
  *
11
- * When instantiating a mod feature class, you must pass your upgraded mod as the first argument to
12
- * the constructor.
11
+ * It is recommended that you use the `initModFeatures` helper function to instantiate all of your
12
+ * mod classes (instead of instantiating them yourself). This is so that any attached `v` objects
13
+ * are properly registered with the save data manager; see below.
13
14
  *
14
- * If your feature has variables that are managed by the save data manager, you need to explicitly
15
- * register them with the save data manager yourself in your class constructor. (It can't be
16
- * automatically done because parent classes don't have access to child class properties.)
15
+ * If you are manually instantiating a mod feature yourself, then:
17
16
  *
18
- * In almost all cases, you will want the callback functions to be immediately subscribed after
19
- * instantiating the class. However, if this is not the case, you can pass `false` as the optional
20
- * second argument to the constructor.
17
+ * - You must pass your upgraded mod as the first argument to the constructor.
18
+ * - In almost all cases, you will want the callback functions to be immediately subscribed after
19
+ * instantiating the class. However, if this is not the case, you can pass `false` as the optional
20
+ * second argument to the constructor.
21
21
  *
22
22
  * If your mod feature has a property called `v`, it will be assumed that these are variables that
23
- * should be managed by the save data manager. Subsequently, they will automatically be registered
24
- * with the save data manager upon initialization. Unfortunately, due to technical limitations with
25
- * classes, this registration will only occur if you initialize the class with the `init` boolean
26
- * argument set to false, and then explicitly call the `ModFeature.init` method yourself after the
27
- * class is constructed. (This is because the parent class does not have access to the child's
28
- * properties upon first construction.)
23
+ * should be managed by the save data manager. Unfortunately, due to technical limitations with
24
+ * classes, this registration will only occur if you initialize the class with the `initModFeatures`
25
+ * helper function. (This is because the parent class does not have access to the child's properties
26
+ * upon first construction.)
29
27
  */
30
28
  export declare class ModFeature {
31
29
  private readonly mod;
@@ -1 +1 @@
1
- {"version":3,"file":"ModFeature.d.ts","sourceRoot":"","sources":["../../../src/classes/ModFeature.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAEhE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AASpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,eAAO,MAAM,yBAAyB,gBAAgB,CAAC;AACvD,eAAO,MAAM,gCAAgC,sBAAsB,CAAC;AAyBpE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAc;IAElC;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,SAAS,CAAC,yBAAyB,EAC/B,CAAC,CAAC,CAAC,SAAS,OAAO,EACjB,OAAO,EAAE,CAAC,EACV,WAAW,EAAE,CAAC,SAAS,IAAI,GAAG,WAAW,GAAG,iBAAiB,EAC7D,GAAG,YAAY,EAAE,OAAO,EAAE,KACvB,OAAO,CAAC,GACb,IAAI,CAAQ;IAEhB;;;;;OAKG;IACI,WAAW,UAAS;gBAEf,GAAG,EAAE,WAAW,EAAE,IAAI,UAAO;IAQzC;;;;;OAKG;IACI,IAAI,CAAC,IAAI,UAAO,GAAG,IAAI;IAqB9B;;;;;OAKG;IACI,MAAM,IAAI,IAAI;CAGtB"}
1
+ {"version":3,"file":"ModFeature.d.ts","sourceRoot":"","sources":["../../../src/classes/ModFeature.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAEhE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AASpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,eAAO,MAAM,yBAAyB,gBAAgB,CAAC;AACvD,eAAO,MAAM,gCAAgC,sBAAsB,CAAC;AAyBpE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAc;IAElC;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,SAAS,CAAC,yBAAyB,EAC/B,CAAC,CAAC,CAAC,SAAS,OAAO,EACjB,OAAO,EAAE,CAAC,EACV,WAAW,EAAE,CAAC,SAAS,IAAI,GAAG,WAAW,GAAG,iBAAiB,EAC7D,GAAG,YAAY,EAAE,OAAO,EAAE,KACvB,OAAO,CAAC,GACb,IAAI,CAAQ;IAEhB;;;;;OAKG;IACI,WAAW,UAAS;gBAEf,GAAG,EAAE,WAAW,EAAE,IAAI,UAAO;IAQzC;;;;;OAKG;IACI,IAAI,CAAC,IAAI,UAAO,GAAG,IAAI;IAqB9B;;;;;OAKG;IACI,MAAM,IAAI,IAAI;CAGtB"}
@@ -163,24 +163,22 @@ WRAPPED_CUSTOM_CALLBACK_METHODS_KEY = "__wrappedCustomCallbacksMethods"
163
163
  -- mod features from this class in order to enable the `@Callback` and `@CustomCallback` decorators
164
164
  -- that automatically subscribe to callbacks.
165
165
  --
166
- -- When instantiating a mod feature class, you must pass your upgraded mod as the first argument to
167
- -- the constructor.
166
+ -- It is recommended that you use the `initModFeatures` helper function to instantiate all of your
167
+ -- mod classes (instead of instantiating them yourself). This is so that any attached `v` objects
168
+ -- are properly registered with the save data manager; see below.
168
169
  --
169
- -- If your feature has variables that are managed by the save data manager, you need to explicitly
170
- -- register them with the save data manager yourself in your class constructor. (It can't be
171
- -- automatically done because parent classes don't have access to child class properties.)
170
+ -- If you are manually instantiating a mod feature yourself, then:
172
171
  --
173
- -- In almost all cases, you will want the callback functions to be immediately subscribed after
174
- -- instantiating the class. However, if this is not the case, you can pass `false` as the optional
175
- -- second argument to the constructor.
172
+ -- - You must pass your upgraded mod as the first argument to the constructor.
173
+ -- - In almost all cases, you will want the callback functions to be immediately subscribed after
174
+ -- instantiating the class. However, if this is not the case, you can pass `false` as the optional
175
+ -- second argument to the constructor.
176
176
  --
177
177
  -- If your mod feature has a property called `v`, it will be assumed that these are variables that
178
- -- should be managed by the save data manager. Subsequently, they will automatically be registered
179
- -- with the save data manager upon initialization. Unfortunately, due to technical limitations with
180
- -- classes, this registration will only occur if you initialize the class with the `init` boolean
181
- -- argument set to false, and then explicitly call the `ModFeature.init` method yourself after the
182
- -- class is constructed. (This is because the parent class does not have access to the child's
183
- -- properties upon first construction.)
178
+ -- should be managed by the save data manager. Unfortunately, due to technical limitations with
179
+ -- classes, this registration will only occur if you initialize the class with the `initModFeatures`
180
+ -- helper function. (This is because the parent class does not have access to the child's properties
181
+ -- upon first construction.)
184
182
  ____exports.ModFeature = __TS__Class()
185
183
  local ModFeature = ____exports.ModFeature
186
184
  ModFeature.name = "ModFeature"
@@ -51,21 +51,20 @@ export declare class SaveDataManager extends Feature {
51
51
  * desired).
52
52
  * 2. Automatic saving and loading of all tracked data to the "save#.dat" file.
53
53
  *
54
- * You feed this function with an object containing your variables, and then it will automatically
55
- * manage them for you. (See below for an example.)
54
+ * You provide this function with an object containing your variables, and then it will
55
+ * automatically manage them for you. (See below for an example.)
56
56
  *
57
57
  * In order to use this function, you must upgrade your mod with `ISCFeature.SAVE_DATA_MANAGER`.
58
58
  * (Upgrade your mod before registering any of your own callbacks so that the save data manager
59
59
  * will run before any of your code does.)
60
60
  *
61
61
  * The save data manager is meant to be called once for each feature of your mod. In other words,
62
- * you should not put all of the data for your mod on the same object. Instead, scope your
62
+ * you should not put all of the variables for your mod on the same object. Instead, scope your
63
63
  * variables locally to a single file that contains a mod feature, and then call this function to
64
64
  * register them. For example:
65
65
  *
66
66
  * ```ts
67
67
  * // In file: feature1.ts
68
- * import { saveDataManager } from "isaacscript-common";
69
68
  *
70
69
  * // Declare local variables for this file or feature.
71
70
  * const v = {
@@ -89,13 +88,12 @@ export declare class SaveDataManager extends Feature {
89
88
  * foo4: 0,
90
89
  * },
91
90
  * };
92
- * // Every child object is optional; only create the ones that you need.
91
+ * // The child objects of "persistent", "run", "level", and "room are optional; only create the
92
+ * // ones that you need.
93
93
  *
94
- * // Register the variables with the save data manager. (We need to provide a string key that
95
- * // matches the name of this file.)
96
- * function feature1Init() {
97
- * saveDataManager("feature1", v);
98
- * }
94
+ * // Now, give `v` to the save data manager, and it will automatically manage the variables for
95
+ * // you.
96
+ * mod.saveDataManager("feature1", v);
99
97
  *
100
98
  * // Elsewhere in the file, use your variables.
101
99
  * function feature1Function() {
@@ -1 +1 @@
1
- {"version":3,"file":"SaveDataManager.d.ts","sourceRoot":"","sources":["../../../../../src/classes/features/other/SaveDataManager.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAOzD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAsBhD,qBAAa,eAAgB,SAAQ,OAAO;IAC1C;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAM;IAE1B;;;;OAIG;IACH,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAkC;IAE9D;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAkC;IAEtE;;;OAGG;I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;IAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiGG;IAEI,eAAe,CAAC,UAAU,EAAE,GAAG,EAAE,KAAK,EAC3C,GAAG,EAAE,MAAM,GAAG,MAAM,EACpB,CAAC,EAAE,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE,KAAK,CAAC,EACnC,eAAe,CAAC,EAAE,MAAM,OAAO,GAC9B,IAAI;IAEA,eAAe,CACpB,GAAG,EAAE,MAAM,GAAG,MAAM,EACpB,CAAC,EAAE,QAAQ,EACX,eAAe,EAAE,KAAK,GACrB,IAAI;IA6DP;;OAEG;IACH,OAAO,CAAC,gCAAgC;IAgBxC;;;;;;;;;OASG;IAEI,mBAAmB,IAAI,IAAI;IAIlC;;;;;;OAMG;IAEI,mBAAmB,IAAI,IAAI;IAIlC;;;;;;;OAOG;IAEI,wBAAwB,IAAI,IAAI;IAIvC;;;;;;;;;;;OAWG;IAEI,4BAA4B,CAAC,GAAG,WAAW,EAAE,QAAQ,EAAE,GAAG,IAAI;IAcrE;;;;;OAKG;IAEI,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAoB/C;;;;;;;;;;;;;;;;;;;;;OAqBG;IAEI,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,cAAc,EAAE,WAAW,GAAG,IAAI;IAsB3E;;;;;;;;;;;;OAYG;IAEI,qBAAqB,IAAI,OAAO;IAKhC,6BAA6B,IAAI,IAAI;CAQ7C"}
@@ -10,16 +10,16 @@ import type { ModUpgraded } from "../classes/ModUpgraded";
10
10
  * For example:
11
11
  *
12
12
  * ```ts
13
- * const features = [
13
+ * const MOD_FEATURES = [
14
14
  * MyFeature1,
15
15
  * MyFeature2,
16
16
  * MyFeature3,
17
17
  * ] as const;
18
- * initModFeatures(mod, modFeatures);
18
+ * initModFeatures(mod, MOD_FEATURES);
19
19
  * ```
20
20
  *
21
21
  * @returns An array of the instantiated features in the same order that the constructors were
22
- * passed in.
22
+ * passed in. (In most cases, you probably won't need the returned array.)
23
23
  */
24
24
  export declare function initModFeatures<T extends ReadonlyArray<typeof ModFeature>>(mod: ModUpgraded, modFeatures: T): {
25
25
  [K in keyof T]: InstanceType<T[K]>;
@@ -10,16 +10,16 @@ local ____exports = {}
10
10
  -- For example:
11
11
  --
12
12
  -- ```ts
13
- -- const features = [
13
+ -- const MOD_FEATURES = [
14
14
  -- MyFeature1,
15
15
  -- MyFeature2,
16
16
  -- MyFeature3,
17
17
  -- ] as const;
18
- -- initModFeatures(mod, modFeatures);
18
+ -- initModFeatures(mod, MOD_FEATURES);
19
19
  -- ```
20
20
  --
21
21
  -- @returns An array of the instantiated features in the same order that the constructors were
22
- -- passed in.
22
+ -- passed in. (In most cases, you probably won't need the returned array.)
23
23
  function ____exports.initModFeatures(self, mod, modFeatures)
24
24
  local instantiatedModFeatures = {}
25
25
  for ____, modFeature in ipairs(modFeatures) do
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "30.12.8",
3
+ "version": "30.12.9",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -25,6 +25,6 @@
25
25
  "main": "dist/src/index",
26
26
  "types": "dist/index.rollup.d.ts",
27
27
  "dependencies": {
28
- "isaac-typescript-definitions": "^13.0.21"
28
+ "isaac-typescript-definitions": "^13.0.22"
29
29
  }
30
30
  }
@@ -42,26 +42,23 @@ type ModFeatureConstructor = TSTLClassMetatable["constructor"] & {
42
42
  * mod features from this class in order to enable the `@Callback` and `@CustomCallback` decorators
43
43
  * that automatically subscribe to callbacks.
44
44
  *
45
- * When instantiating a mod feature class, you must pass your upgraded mod as the first argument to
46
- * the constructor.
45
+ * It is recommended that you use the `initModFeatures` helper function to instantiate all of your
46
+ * mod classes (instead of instantiating them yourself). This is so that any attached `v` objects
47
+ * are properly registered with the save data manager; see below.
47
48
  *
48
- * If your feature has variables that are managed by the save data manager, you need to explicitly
49
- * register them with the save data manager yourself in your class constructor. (It can't be
50
- * automatically done because parent classes don't have access to child class properties.)
49
+ * If you are manually instantiating a mod feature yourself, then:
51
50
  *
52
- * In almost all cases, you will want the callback functions to be immediately subscribed after
53
- * instantiating the class. However, if this is not the case, you can pass `false` as the optional
54
- * second argument to the constructor.
51
+ * - You must pass your upgraded mod as the first argument to the constructor.
52
+ * - In almost all cases, you will want the callback functions to be immediately subscribed after
53
+ * instantiating the class. However, if this is not the case, you can pass `false` as the optional
54
+ * second argument to the constructor.
55
55
  *
56
56
  * If your mod feature has a property called `v`, it will be assumed that these are variables that
57
- * should be managed by the save data manager. Subsequently, they will automatically be registered
58
- * with the save data manager upon initialization. Unfortunately, due to technical limitations with
59
- * classes, this registration will only occur if you initialize the class with the `init` boolean
60
- * argument set to false, and then explicitly call the `ModFeature.init` method yourself after the
61
- * class is constructed. (This is because the parent class does not have access to the child's
62
- * properties upon first construction.)
57
+ * should be managed by the save data manager. Unfortunately, due to technical limitations with
58
+ * classes, this registration will only occur if you initialize the class with the `initModFeatures`
59
+ * helper function. (This is because the parent class does not have access to the child's properties
60
+ * upon first construction.)
63
61
  */
64
-
65
62
  export class ModFeature {
66
63
  private readonly mod: ModUpgraded;
67
64
 
@@ -221,21 +221,20 @@ export class SaveDataManager extends Feature {
221
221
  * desired).
222
222
  * 2. Automatic saving and loading of all tracked data to the "save#.dat" file.
223
223
  *
224
- * You feed this function with an object containing your variables, and then it will automatically
225
- * manage them for you. (See below for an example.)
224
+ * You provide this function with an object containing your variables, and then it will
225
+ * automatically manage them for you. (See below for an example.)
226
226
  *
227
227
  * In order to use this function, you must upgrade your mod with `ISCFeature.SAVE_DATA_MANAGER`.
228
228
  * (Upgrade your mod before registering any of your own callbacks so that the save data manager
229
229
  * will run before any of your code does.)
230
230
  *
231
231
  * The save data manager is meant to be called once for each feature of your mod. In other words,
232
- * you should not put all of the data for your mod on the same object. Instead, scope your
232
+ * you should not put all of the variables for your mod on the same object. Instead, scope your
233
233
  * variables locally to a single file that contains a mod feature, and then call this function to
234
234
  * register them. For example:
235
235
  *
236
236
  * ```ts
237
237
  * // In file: feature1.ts
238
- * import { saveDataManager } from "isaacscript-common";
239
238
  *
240
239
  * // Declare local variables for this file or feature.
241
240
  * const v = {
@@ -259,13 +258,12 @@ export class SaveDataManager extends Feature {
259
258
  * foo4: 0,
260
259
  * },
261
260
  * };
262
- * // Every child object is optional; only create the ones that you need.
261
+ * // The child objects of "persistent", "run", "level", and "room are optional; only create the
262
+ * // ones that you need.
263
263
  *
264
- * // Register the variables with the save data manager. (We need to provide a string key that
265
- * // matches the name of this file.)
266
- * function feature1Init() {
267
- * saveDataManager("feature1", v);
268
- * }
264
+ * // Now, give `v` to the save data manager, and it will automatically manage the variables for
265
+ * // you.
266
+ * mod.saveDataManager("feature1", v);
269
267
  *
270
268
  * // Elsewhere in the file, use your variables.
271
269
  * function feature1Function() {
@@ -11,16 +11,16 @@ import type { ModUpgraded } from "../classes/ModUpgraded";
11
11
  * For example:
12
12
  *
13
13
  * ```ts
14
- * const features = [
14
+ * const MOD_FEATURES = [
15
15
  * MyFeature1,
16
16
  * MyFeature2,
17
17
  * MyFeature3,
18
18
  * ] as const;
19
- * initModFeatures(mod, modFeatures);
19
+ * initModFeatures(mod, MOD_FEATURES);
20
20
  * ```
21
21
  *
22
22
  * @returns An array of the instantiated features in the same order that the constructors were
23
- * passed in.
23
+ * passed in. (In most cases, you probably won't need the returned array.)
24
24
  */
25
25
  export function initModFeatures<T extends ReadonlyArray<typeof ModFeature>>(
26
26
  mod: ModUpgraded,