isaacscript-common 20.6.0 → 20.6.1
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/dist/index.d.ts +9 -24
- package/dist/isaacscript-common.lua +4 -28
- package/dist/src/classes/ModFeature.d.ts +5 -22
- package/dist/src/classes/ModFeature.d.ts.map +1 -1
- package/dist/src/classes/ModFeature.lua +6 -49
- package/dist/src/functions/logMisc.d.ts +3 -1
- package/dist/src/functions/logMisc.d.ts.map +1 -1
- package/dist/src/functions/logMisc.lua +5 -1
- package/dist/src/functions/rng.d.ts +1 -1
- package/dist/src/functions/rng.lua +1 -1
- package/package.json +1 -1
- package/src/classes/ModFeature.ts +6 -67
- package/src/functions/logMisc.ts +5 -1
- package/src/functions/rng.ts +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -8484,10 +8484,12 @@ export declare function logSounds(): void;
|
|
|
8484
8484
|
|
|
8485
8485
|
/**
|
|
8486
8486
|
* Helper function for logging every key and value of a Lua table. This is a deep log; the function
|
|
8487
|
-
* will recursively call itself if it
|
|
8487
|
+
* will recursively call itself if it encounters a table within a table.
|
|
8488
8488
|
*
|
|
8489
8489
|
* This function will only work on tables that have string keys (because it logs the keys in order,
|
|
8490
8490
|
* instead of randomly). It will throw a run-time error if it encounters a non-string key.
|
|
8491
|
+
*
|
|
8492
|
+
* In order to prevent infinite recursion, this function will not log deeper than 10 nested tables.
|
|
8491
8493
|
*/
|
|
8492
8494
|
export declare function logTable(luaTable: unknown, parentTables?: number): void;
|
|
8493
8495
|
|
|
@@ -11386,29 +11388,12 @@ declare class ModdedElementSets extends Feature {
|
|
|
11386
11388
|
* mod features from this class in order to enable the `@Callback` and `@CustomCallback` decorators
|
|
11387
11389
|
* that automatically subscribe to callbacks.
|
|
11388
11390
|
*
|
|
11389
|
-
*
|
|
11390
|
-
*
|
|
11391
|
-
* instantiated.
|
|
11392
|
-
*
|
|
11393
|
-
* For example:
|
|
11394
|
-
*
|
|
11395
|
-
* ```ts
|
|
11396
|
-
* export class MyFeature extends ModFeature {
|
|
11397
|
-
* v = {
|
|
11398
|
-
* run: {
|
|
11399
|
-
* foo: 123,
|
|
11400
|
-
* }
|
|
11401
|
-
* }
|
|
11402
|
-
*
|
|
11403
|
-
* @Callback(ModCallback.POST_GAME_STARTED)
|
|
11404
|
-
* postGameStarted(isContinued: boolean): void {
|
|
11405
|
-
* Isaac.DebugString(`Callback fired: POST_GAME_STARTED`);
|
|
11406
|
-
* }
|
|
11407
|
-
* }
|
|
11408
|
-
* ```
|
|
11391
|
+
* When instantiating a mod feature class, you must pass your upgraded mod as the first argument to
|
|
11392
|
+
* the constructor.
|
|
11409
11393
|
*
|
|
11410
|
-
*
|
|
11411
|
-
* constructor.
|
|
11394
|
+
* If your feature has variables that are managed by the save data manager, you need to explicitly
|
|
11395
|
+
* register them with the save data manager yourself in your class constructor. (It can't be
|
|
11396
|
+
* automatically done because parent classes don't have access to child class properties.)
|
|
11412
11397
|
*
|
|
11413
11398
|
* In almost all cases, you will want the callback functions to be immediately subscribed after
|
|
11414
11399
|
* instantiating the class. However, if this is not the case, you can pass `false` as the optional
|
|
@@ -11627,7 +11612,7 @@ export declare function newPickingUpItem(): PickingUpItem;
|
|
|
11627
11612
|
export declare function newPlayerHealth(): PlayerHealth;
|
|
11628
11613
|
|
|
11629
11614
|
/**
|
|
11630
|
-
* Helper function to initialize
|
|
11615
|
+
* Helper function to initialize a new RNG object using Blade's recommended shift index.
|
|
11631
11616
|
*
|
|
11632
11617
|
* @param seed The seed to initialize it with. Default is `getRandomSeed()`.
|
|
11633
11618
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
--[[
|
|
2
2
|
|
|
3
|
-
isaacscript-common 20.6.
|
|
3
|
+
isaacscript-common 20.6.1
|
|
4
4
|
|
|
5
5
|
This is the "isaacscript-common" library, which was created with the IsaacScript tool.
|
|
6
6
|
|
|
@@ -28091,6 +28091,8 @@ function ____exports.logTable(self, luaTable, parentTables)
|
|
|
28091
28091
|
end
|
|
28092
28092
|
if parentTables == 0 then
|
|
28093
28093
|
log(nil, "Printing out a Lua table:")
|
|
28094
|
+
elseif parentTables > 10 then
|
|
28095
|
+
return
|
|
28094
28096
|
end
|
|
28095
28097
|
local numSpaces = (parentTables + 1) * 2
|
|
28096
28098
|
local indentation = string.rep(
|
|
@@ -49795,7 +49797,7 @@ local __TS__Class = ____lualib.__TS__Class
|
|
|
49795
49797
|
local Map = ____lualib.Map
|
|
49796
49798
|
local __TS__New = ____lualib.__TS__New
|
|
49797
49799
|
local ____exports = {}
|
|
49798
|
-
local initDecoratedCallbacks, addCallback, removeCallback,
|
|
49800
|
+
local initDecoratedCallbacks, addCallback, removeCallback, WRAPPED_CALLBACK_METHODS_KEY, WRAPPED_CUSTOM_CALLBACK_METHODS_KEY
|
|
49799
49801
|
local ____array = require("src.functions.array")
|
|
49800
49802
|
local isArray = ____array.isArray
|
|
49801
49803
|
local ____tstlClass = require("src.functions.tstlClass")
|
|
@@ -49804,7 +49806,6 @@ local getTSTLClassName = ____tstlClass.getTSTLClassName
|
|
|
49804
49806
|
local ____types = require("src.functions.types")
|
|
49805
49807
|
local isFunction = ____types.isFunction
|
|
49806
49808
|
local isNumber = ____types.isNumber
|
|
49807
|
-
local isTable = ____types.isTable
|
|
49808
49809
|
function initDecoratedCallbacks(self, modFeature, constructor, tstlClassName, vanilla, init)
|
|
49809
49810
|
local modFeatureConstructor = constructor
|
|
49810
49811
|
local callbackTuplesKey = vanilla and ____exports.MOD_FEATURE_CALLBACKS_KEY or ____exports.MOD_FEATURE_CUSTOM_CALLBACKS_KEY
|
|
@@ -49916,30 +49917,6 @@ function removeCallback(self, modFeatureConstructor, mod, modCallback, vanilla)
|
|
|
49916
49917
|
mod:RemoveCallbackCustom(modCallback, wrappedCallback)
|
|
49917
49918
|
end
|
|
49918
49919
|
end
|
|
49919
|
-
function initSaveDataManager(self, modFeature, tstlClassName, init)
|
|
49920
|
-
local ____modFeature_0 = modFeature
|
|
49921
|
-
local v = ____modFeature_0.v
|
|
49922
|
-
if v == nil then
|
|
49923
|
-
return
|
|
49924
|
-
end
|
|
49925
|
-
if not isTable(nil, v) then
|
|
49926
|
-
error("Failed to initialize a mod feature class due to having a \"v\" property that is not an object. (The \"v\" property is supposed to be an object that holds the variables for the class, managed by the save data manager.)")
|
|
49927
|
-
end
|
|
49928
|
-
local mod = modFeature.mod
|
|
49929
|
-
local saveDataManagerMethodName = init and "saveDataManager" or "saveDataManagerRemove"
|
|
49930
|
-
local saveDataManagerMethod = mod[saveDataManagerMethodName]
|
|
49931
|
-
if saveDataManagerMethod == nil then
|
|
49932
|
-
error("Failed to initialize a mod feature class due to having a \"v\" object and not having the save data manager initialized. You must pass \"ISCFeature.SAVE_DATA_MANAGER\" to the \"upgradeMod\" function.")
|
|
49933
|
-
end
|
|
49934
|
-
if type(saveDataManagerMethod) ~= "function" then
|
|
49935
|
-
error(("The \"" .. saveDataManagerMethodName) .. "\" property of the \"ModUpgraded\" object was not a function.")
|
|
49936
|
-
end
|
|
49937
|
-
if init then
|
|
49938
|
-
saveDataManagerMethod(nil, tstlClassName, v)
|
|
49939
|
-
else
|
|
49940
|
-
saveDataManagerMethod(nil, tstlClassName)
|
|
49941
|
-
end
|
|
49942
|
-
end
|
|
49943
49920
|
____exports.MOD_FEATURE_CALLBACKS_KEY = "__callbacks"
|
|
49944
49921
|
____exports.MOD_FEATURE_CUSTOM_CALLBACKS_KEY = "__customCallbacks"
|
|
49945
49922
|
WRAPPED_CALLBACK_METHODS_KEY = "__wrappedCallbackMethods"
|
|
@@ -49990,7 +49967,6 @@ function ModFeature.prototype.init(self, init)
|
|
|
49990
49967
|
false,
|
|
49991
49968
|
init
|
|
49992
49969
|
)
|
|
49993
|
-
initSaveDataManager(nil, self, tstlClassName, init)
|
|
49994
49970
|
end
|
|
49995
49971
|
function ModFeature.prototype.uninit(self)
|
|
49996
49972
|
self:init(false)
|
|
@@ -8,29 +8,12 @@ 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
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* instantiated.
|
|
11
|
+
* When instantiating a mod feature class, you must pass your upgraded mod as the first argument to
|
|
12
|
+
* the constructor.
|
|
14
13
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* export class MyFeature extends ModFeature {
|
|
19
|
-
* v = {
|
|
20
|
-
* run: {
|
|
21
|
-
* foo: 123,
|
|
22
|
-
* }
|
|
23
|
-
* }
|
|
24
|
-
*
|
|
25
|
-
* @Callback(ModCallback.POST_GAME_STARTED)
|
|
26
|
-
* postGameStarted(isContinued: boolean): void {
|
|
27
|
-
* Isaac.DebugString(`Callback fired: POST_GAME_STARTED`);
|
|
28
|
-
* }
|
|
29
|
-
* }
|
|
30
|
-
* ```
|
|
31
|
-
*
|
|
32
|
-
* When instantiating a feature class, you must pass your upgraded mod as the first argument to the
|
|
33
|
-
* constructor.
|
|
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.)
|
|
34
17
|
*
|
|
35
18
|
* In almost all cases, you will want the callback functions to be immediately subscribed after
|
|
36
19
|
* instantiating the class. However, if this is not the case, you can pass `false` as the optional
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModFeature.d.ts","sourceRoot":"","sources":["../../../src/classes/ModFeature.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAS/D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,eAAO,MAAM,yBAAyB,gBAAgB,CAAC;AACvD,eAAO,MAAM,gCAAgC,sBAAsB,CAAC;AAyBpE
|
|
1
|
+
{"version":3,"file":"ModFeature.d.ts","sourceRoot":"","sources":["../../../src/classes/ModFeature.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAS/D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,eAAO,MAAM,yBAAyB,gBAAgB,CAAC;AACvD,eAAO,MAAM,gCAAgC,sBAAsB,CAAC;AAyBpE;;;;;;;;;;;;;;;GAeG;AAEH,qBAAa,UAAU;IACrB,OAAO,CAAC,GAAG,CAAkB;IAE7B;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;OAMG;IACI,WAAW,UAAS;gBAEf,GAAG,EAAE,eAAe,EAAE,IAAI,UAAO;IAQ7C;;;;;OAKG;IACI,IAAI,CAAC,IAAI,UAAO,GAAG,IAAI;IAoB9B;;;;;;OAMG;IACI,MAAM,IAAI,IAAI;CAGtB"}
|
|
@@ -3,7 +3,7 @@ local __TS__Class = ____lualib.__TS__Class
|
|
|
3
3
|
local Map = ____lualib.Map
|
|
4
4
|
local __TS__New = ____lualib.__TS__New
|
|
5
5
|
local ____exports = {}
|
|
6
|
-
local initDecoratedCallbacks, addCallback, removeCallback,
|
|
6
|
+
local initDecoratedCallbacks, addCallback, removeCallback, WRAPPED_CALLBACK_METHODS_KEY, WRAPPED_CUSTOM_CALLBACK_METHODS_KEY
|
|
7
7
|
local ____array = require("src.functions.array")
|
|
8
8
|
local isArray = ____array.isArray
|
|
9
9
|
local ____tstlClass = require("src.functions.tstlClass")
|
|
@@ -12,7 +12,6 @@ local getTSTLClassName = ____tstlClass.getTSTLClassName
|
|
|
12
12
|
local ____types = require("src.functions.types")
|
|
13
13
|
local isFunction = ____types.isFunction
|
|
14
14
|
local isNumber = ____types.isNumber
|
|
15
|
-
local isTable = ____types.isTable
|
|
16
15
|
function initDecoratedCallbacks(self, modFeature, constructor, tstlClassName, vanilla, init)
|
|
17
16
|
local modFeatureConstructor = constructor
|
|
18
17
|
local callbackTuplesKey = vanilla and ____exports.MOD_FEATURE_CALLBACKS_KEY or ____exports.MOD_FEATURE_CUSTOM_CALLBACKS_KEY
|
|
@@ -124,30 +123,6 @@ function removeCallback(self, modFeatureConstructor, mod, modCallback, vanilla)
|
|
|
124
123
|
mod:RemoveCallbackCustom(modCallback, wrappedCallback)
|
|
125
124
|
end
|
|
126
125
|
end
|
|
127
|
-
function initSaveDataManager(self, modFeature, tstlClassName, init)
|
|
128
|
-
local ____modFeature_0 = modFeature
|
|
129
|
-
local v = ____modFeature_0.v
|
|
130
|
-
if v == nil then
|
|
131
|
-
return
|
|
132
|
-
end
|
|
133
|
-
if not isTable(nil, v) then
|
|
134
|
-
error("Failed to initialize a mod feature class due to having a \"v\" property that is not an object. (The \"v\" property is supposed to be an object that holds the variables for the class, managed by the save data manager.)")
|
|
135
|
-
end
|
|
136
|
-
local mod = modFeature.mod
|
|
137
|
-
local saveDataManagerMethodName = init and "saveDataManager" or "saveDataManagerRemove"
|
|
138
|
-
local saveDataManagerMethod = mod[saveDataManagerMethodName]
|
|
139
|
-
if saveDataManagerMethod == nil then
|
|
140
|
-
error("Failed to initialize a mod feature class due to having a \"v\" object and not having the save data manager initialized. You must pass \"ISCFeature.SAVE_DATA_MANAGER\" to the \"upgradeMod\" function.")
|
|
141
|
-
end
|
|
142
|
-
if type(saveDataManagerMethod) ~= "function" then
|
|
143
|
-
error(("The \"" .. saveDataManagerMethodName) .. "\" property of the \"ModUpgraded\" object was not a function.")
|
|
144
|
-
end
|
|
145
|
-
if init then
|
|
146
|
-
saveDataManagerMethod(nil, tstlClassName, v)
|
|
147
|
-
else
|
|
148
|
-
saveDataManagerMethod(nil, tstlClassName)
|
|
149
|
-
end
|
|
150
|
-
end
|
|
151
126
|
____exports.MOD_FEATURE_CALLBACKS_KEY = "__callbacks"
|
|
152
127
|
____exports.MOD_FEATURE_CUSTOM_CALLBACKS_KEY = "__customCallbacks"
|
|
153
128
|
WRAPPED_CALLBACK_METHODS_KEY = "__wrappedCallbackMethods"
|
|
@@ -156,29 +131,12 @@ WRAPPED_CUSTOM_CALLBACK_METHODS_KEY = "__wrappedCustomCallbacksMethods"
|
|
|
156
131
|
-- mod features from this class in order to enable the `@Callback` and `@CustomCallback` decorators
|
|
157
132
|
-- that automatically subscribe to callbacks.
|
|
158
133
|
--
|
|
159
|
-
--
|
|
160
|
-
--
|
|
161
|
-
-- instantiated.
|
|
162
|
-
--
|
|
163
|
-
-- For example:
|
|
164
|
-
--
|
|
165
|
-
-- ```ts
|
|
166
|
-
-- export class MyFeature extends ModFeature {
|
|
167
|
-
-- v = {
|
|
168
|
-
-- run: {
|
|
169
|
-
-- foo: 123,
|
|
170
|
-
-- }
|
|
171
|
-
-- }
|
|
172
|
-
--
|
|
173
|
-
-- @Callback (ModCallback.POST_GAME_STARTED)
|
|
174
|
-
-- postGameStarted(isContinued: boolean): void {
|
|
175
|
-
-- Isaac.DebugString(`Callback fired: POST_GAME_STARTED`);
|
|
176
|
-
-- }
|
|
177
|
-
-- }
|
|
178
|
-
-- ```
|
|
134
|
+
-- When instantiating a mod feature class, you must pass your upgraded mod as the first argument to
|
|
135
|
+
-- the constructor.
|
|
179
136
|
--
|
|
180
|
-
--
|
|
181
|
-
-- constructor.
|
|
137
|
+
-- If your feature has variables that are managed by the save data manager, you need to explicitly
|
|
138
|
+
-- register them with the save data manager yourself in your class constructor. (It can't be
|
|
139
|
+
-- automatically done because parent classes don't have access to child class properties.)
|
|
182
140
|
--
|
|
183
141
|
-- In almost all cases, you will want the callback functions to be immediately subscribed after
|
|
184
142
|
-- instantiating the class. However, if this is not the case, you can pass `false` as the optional
|
|
@@ -229,7 +187,6 @@ function ModFeature.prototype.init(self, init)
|
|
|
229
187
|
false,
|
|
230
188
|
init
|
|
231
189
|
)
|
|
232
|
-
initSaveDataManager(nil, self, tstlClassName, init)
|
|
233
190
|
end
|
|
234
191
|
function ModFeature.prototype.uninit(self)
|
|
235
192
|
self:init(false)
|
|
@@ -46,10 +46,12 @@ export declare function logSet(set: Set<AnyNotNil> | ReadonlySet<AnyNotNil>): vo
|
|
|
46
46
|
export declare function logSounds(): void;
|
|
47
47
|
/**
|
|
48
48
|
* Helper function for logging every key and value of a Lua table. This is a deep log; the function
|
|
49
|
-
* will recursively call itself if it
|
|
49
|
+
* will recursively call itself if it encounters a table within a table.
|
|
50
50
|
*
|
|
51
51
|
* This function will only work on tables that have string keys (because it logs the keys in order,
|
|
52
52
|
* instead of randomly). It will throw a run-time error if it encounters a non-string key.
|
|
53
|
+
*
|
|
54
|
+
* In order to prevent infinite recursion, this function will not log deeper than 10 nested tables.
|
|
53
55
|
*/
|
|
54
56
|
export declare function logTable(luaTable: unknown, parentTables?: number): void;
|
|
55
57
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logMisc.d.ts","sourceRoot":"","sources":["../../../src/functions/logMisc.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,eAAe,EACf,UAAU,EACV,UAAU,EAKV,cAAc,EAGd,QAAQ,EACR,OAAO,EACR,MAAM,8BAA8B,CAAC;AAmBtC,kEAAkE;AAClE,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,SAAS,CAAC,EAAE,GAAG,IAAI,CAU3D;AAED,wBAAgB,mBAAmB,CAAC,gBAAgB,EAAE,eAAe,EAAE,GAAG,IAAI,CAS7E;AAED,wBAAgB,QAAQ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;AAED,gGAAgG;AAChG,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,IAAI,CAEpE;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CAoBnD;AAED,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,UAAQ,GAAG,IAAI,CAG7D"}
|
|
@@ -388,16 +388,20 @@ function ____exports.logSounds(self)
|
|
|
388
388
|
end
|
|
389
389
|
end
|
|
390
390
|
--- Helper function for logging every key and value of a Lua table. This is a deep log; the function
|
|
391
|
-
-- will recursively call itself if it
|
|
391
|
+
-- will recursively call itself if it encounters a table within a table.
|
|
392
392
|
--
|
|
393
393
|
-- This function will only work on tables that have string keys (because it logs the keys in order,
|
|
394
394
|
-- instead of randomly). It will throw a run-time error if it encounters a non-string key.
|
|
395
|
+
--
|
|
396
|
+
-- In order to prevent infinite recursion, this function will not log deeper than 10 nested tables.
|
|
395
397
|
function ____exports.logTable(self, luaTable, parentTables)
|
|
396
398
|
if parentTables == nil then
|
|
397
399
|
parentTables = 0
|
|
398
400
|
end
|
|
399
401
|
if parentTables == 0 then
|
|
400
402
|
log(nil, "Printing out a Lua table:")
|
|
403
|
+
elseif parentTables > 10 then
|
|
404
|
+
return
|
|
401
405
|
end
|
|
402
406
|
local numSpaces = (parentTables + 1) * 2
|
|
403
407
|
local indentation = string.rep(
|
|
@@ -25,7 +25,7 @@ export declare function isRNG(object: unknown): object is RNG;
|
|
|
25
25
|
*/
|
|
26
26
|
export declare function isSerializedRNG(object: unknown): object is SerializedRNG;
|
|
27
27
|
/**
|
|
28
|
-
* Helper function to initialize
|
|
28
|
+
* Helper function to initialize a new RNG object using Blade's recommended shift index.
|
|
29
29
|
*
|
|
30
30
|
* @param seed The seed to initialize it with. Default is `getRandomSeed()`.
|
|
31
31
|
*/
|
|
@@ -26,7 +26,7 @@ end
|
|
|
26
26
|
function ____exports.isRNG(self, object)
|
|
27
27
|
return isIsaacAPIClassOfType(nil, object, OBJECT_NAME)
|
|
28
28
|
end
|
|
29
|
-
--- Helper function to initialize
|
|
29
|
+
--- Helper function to initialize a new RNG object using Blade's recommended shift index.
|
|
30
30
|
--
|
|
31
31
|
-- @param seed The seed to initialize it with. Default is `getRandomSeed()`.
|
|
32
32
|
function ____exports.newRNG(self, seed)
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
getTSTLClassConstructor,
|
|
6
6
|
getTSTLClassName,
|
|
7
7
|
} from "../functions/tstlClass";
|
|
8
|
-
import { isFunction, isNumber
|
|
8
|
+
import { isFunction, isNumber } from "../functions/types";
|
|
9
9
|
import { TSTLClassMetatable } from "../interfaces/TSTLClassMetatable";
|
|
10
10
|
import { AnyFunction } from "../types/AnyFunction";
|
|
11
11
|
import { ModUpgradedBase } from "./ModUpgradedBase";
|
|
@@ -41,29 +41,12 @@ type ModFeatureConstructor = TSTLClassMetatable["constructor"] & {
|
|
|
41
41
|
* mod features from this class in order to enable the `@Callback` and `@CustomCallback` decorators
|
|
42
42
|
* that automatically subscribe to callbacks.
|
|
43
43
|
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
* instantiated.
|
|
44
|
+
* When instantiating a mod feature class, you must pass your upgraded mod as the first argument to
|
|
45
|
+
* the constructor.
|
|
47
46
|
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
* export class MyFeature extends ModFeature {
|
|
52
|
-
* v = {
|
|
53
|
-
* run: {
|
|
54
|
-
* foo: 123,
|
|
55
|
-
* }
|
|
56
|
-
* }
|
|
57
|
-
*
|
|
58
|
-
* @Callback(ModCallback.POST_GAME_STARTED)
|
|
59
|
-
* postGameStarted(isContinued: boolean): void {
|
|
60
|
-
* Isaac.DebugString(`Callback fired: POST_GAME_STARTED`);
|
|
61
|
-
* }
|
|
62
|
-
* }
|
|
63
|
-
* ```
|
|
64
|
-
*
|
|
65
|
-
* When instantiating a feature class, you must pass your upgraded mod as the first argument to the
|
|
66
|
-
* constructor.
|
|
47
|
+
* If your feature has variables that are managed by the save data manager, you need to explicitly
|
|
48
|
+
* register them with the save data manager yourself in your class constructor. (It can't be
|
|
49
|
+
* automatically done because parent classes don't have access to child class properties.)
|
|
67
50
|
*
|
|
68
51
|
* In almost all cases, you will want the callback functions to be immediately subscribed after
|
|
69
52
|
* instantiating the class. However, if this is not the case, you can pass `false` as the optional
|
|
@@ -147,7 +130,6 @@ export class ModFeature {
|
|
|
147
130
|
|
|
148
131
|
initDecoratedCallbacks(this, constructor, tstlClassName, true, init);
|
|
149
132
|
initDecoratedCallbacks(this, constructor, tstlClassName, false, init);
|
|
150
|
-
initSaveDataManager(this, tstlClassName, init);
|
|
151
133
|
}
|
|
152
134
|
|
|
153
135
|
/**
|
|
@@ -334,46 +316,3 @@ function removeCallback(
|
|
|
334
316
|
(mod.RemoveCallbackCustom as AnyFunction)(modCallback, wrappedCallback);
|
|
335
317
|
}
|
|
336
318
|
}
|
|
337
|
-
|
|
338
|
-
function initSaveDataManager(
|
|
339
|
-
modFeature: ModFeature,
|
|
340
|
-
tstlClassName: string,
|
|
341
|
-
init: boolean,
|
|
342
|
-
) {
|
|
343
|
-
// Do nothing if this class does not have any variables.
|
|
344
|
-
const { v } = modFeature as unknown as Record<string, unknown>;
|
|
345
|
-
if (v === undefined) {
|
|
346
|
-
return;
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
if (!isTable(v)) {
|
|
350
|
-
error(
|
|
351
|
-
'Failed to initialize a mod feature class due to having a "v" property that is not an object. (The "v" property is supposed to be an object that holds the variables for the class, managed by the save data manager.)',
|
|
352
|
-
);
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
// Do nothing if we have not enabled the save data manager.
|
|
356
|
-
// eslint-disable-next-line @typescript-eslint/dot-notation
|
|
357
|
-
const mod = modFeature["mod"] as unknown as Record<string, unknown>;
|
|
358
|
-
const saveDataManagerMethodName = init
|
|
359
|
-
? "saveDataManager"
|
|
360
|
-
: "saveDataManagerRemove";
|
|
361
|
-
const saveDataManagerMethod = mod[saveDataManagerMethodName];
|
|
362
|
-
if (saveDataManagerMethod === undefined) {
|
|
363
|
-
error(
|
|
364
|
-
'Failed to initialize a mod feature class due to having a "v" object and not having the save data manager initialized. You must pass "ISCFeature.SAVE_DATA_MANAGER" to the "upgradeMod" function.',
|
|
365
|
-
);
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
if (typeof saveDataManagerMethod !== "function") {
|
|
369
|
-
error(
|
|
370
|
-
`The "${saveDataManagerMethodName}" property of the "ModUpgraded" object was not a function.`,
|
|
371
|
-
);
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
if (init) {
|
|
375
|
-
saveDataManagerMethod(tstlClassName, v);
|
|
376
|
-
} else {
|
|
377
|
-
saveDataManagerMethod(tstlClassName);
|
|
378
|
-
}
|
|
379
|
-
}
|
package/src/functions/logMisc.ts
CHANGED
|
@@ -326,14 +326,18 @@ export function logSounds(): void {
|
|
|
326
326
|
|
|
327
327
|
/**
|
|
328
328
|
* Helper function for logging every key and value of a Lua table. This is a deep log; the function
|
|
329
|
-
* will recursively call itself if it
|
|
329
|
+
* will recursively call itself if it encounters a table within a table.
|
|
330
330
|
*
|
|
331
331
|
* This function will only work on tables that have string keys (because it logs the keys in order,
|
|
332
332
|
* instead of randomly). It will throw a run-time error if it encounters a non-string key.
|
|
333
|
+
*
|
|
334
|
+
* In order to prevent infinite recursion, this function will not log deeper than 10 nested tables.
|
|
333
335
|
*/
|
|
334
336
|
export function logTable(luaTable: unknown, parentTables = 0): void {
|
|
335
337
|
if (parentTables === 0) {
|
|
336
338
|
log("Printing out a Lua table:");
|
|
339
|
+
} else if (parentTables > 10) {
|
|
340
|
+
return;
|
|
337
341
|
}
|
|
338
342
|
|
|
339
343
|
const numSpaces = (parentTables + 1) * 2; // 2, 4, 6, etc.
|
package/src/functions/rng.ts
CHANGED
|
@@ -83,7 +83,7 @@ export function isSerializedRNG(object: unknown): object is SerializedRNG {
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
/**
|
|
86
|
-
* Helper function to initialize
|
|
86
|
+
* Helper function to initialize a new RNG object using Blade's recommended shift index.
|
|
87
87
|
*
|
|
88
88
|
* @param seed The seed to initialize it with. Default is `getRandomSeed()`.
|
|
89
89
|
*/
|