isaacscript-common 20.11.6 → 20.12.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 +25 -2
- package/dist/isaacscript-common.lua +43 -12
- package/dist/src/classes/ModFeature.d.ts +8 -0
- package/dist/src/classes/ModFeature.d.ts.map +1 -1
- package/dist/src/classes/ModFeature.lua +39 -1
- package/dist/src/classes/features/other/CustomTrapdoors.d.ts.map +1 -1
- package/dist/src/functions/log.d.ts +8 -1
- package/dist/src/functions/log.d.ts.map +1 -1
- package/dist/src/functions/log.lua +8 -1
- package/dist/src/functions/modFeatures.d.ts +3 -0
- package/dist/src/functions/modFeatures.d.ts.map +1 -1
- package/dist/src/functions/modFeatures.lua +5 -1
- package/dist/src/interfaces/TSTLClassMetatable.d.ts +4 -0
- package/dist/src/interfaces/TSTLClassMetatable.d.ts.map +1 -1
- package/dist/src/types/TSTLClass.d.ts +2 -1
- package/dist/src/types/TSTLClass.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/classes/ModFeature.ts +60 -1
- package/src/classes/features/other/CustomTrapdoors.ts +2 -0
- package/src/functions/log.ts +8 -1
- package/src/functions/modFeatures.ts +6 -1
- package/src/interfaces/TSTLClassMetatable.ts +4 -0
- package/src/types/TSTLClass.ts +2 -1
package/dist/index.d.ts
CHANGED
|
@@ -6948,6 +6948,9 @@ export declare function initArray<T>(defaultValue: T, size: int): T[];
|
|
|
6948
6948
|
* Helper function to instantiate an array of mod features all at once. Use this function if your
|
|
6949
6949
|
* mod uses the pattern of expressing mod features as `ModFeature` classes.
|
|
6950
6950
|
*
|
|
6951
|
+
* If your feature classes have `v` variables, then this function will successfully register them
|
|
6952
|
+
* with the save data manager.
|
|
6953
|
+
*
|
|
6951
6954
|
* For example:
|
|
6952
6955
|
*
|
|
6953
6956
|
* ```ts
|
|
@@ -8406,7 +8409,14 @@ export declare function lockDoor(door: GridEntityDoor): void;
|
|
|
8406
8409
|
* Helper function to avoid typing out `Isaac.DebugString()`.
|
|
8407
8410
|
*
|
|
8408
8411
|
* If you have the "--luadebug" launch flag turned on or the Racing+ sandbox enabled, then this
|
|
8409
|
-
* function will also prepend the function name and the line number before the string
|
|
8412
|
+
* function will also prepend the function name and the line number before the string, like this:
|
|
8413
|
+
*
|
|
8414
|
+
* ```text
|
|
8415
|
+
* [INFO] - Lua Debug: saveToDisk:42494 - The save data manager wrote data to the "save#.dat" file.
|
|
8416
|
+
* ```
|
|
8417
|
+
*
|
|
8418
|
+
* Subsequently, it is recommended that you turn on the "--luadebug" launch flag when developing
|
|
8419
|
+
* your mod so that debugging becomes a little bit easier.
|
|
8410
8420
|
*/
|
|
8411
8421
|
export declare function log(msg: string): void;
|
|
8412
8422
|
|
|
@@ -11434,6 +11444,14 @@ declare class ModdedElementSets extends Feature {
|
|
|
11434
11444
|
* In almost all cases, you will want the callback functions to be immediately subscribed after
|
|
11435
11445
|
* instantiating the class. However, if this is not the case, you can pass `false` as the optional
|
|
11436
11446
|
* second argument to the constructor.
|
|
11447
|
+
*
|
|
11448
|
+
* If your mod feature has a property called `v`, it will be assumed that these are variables that
|
|
11449
|
+
* should be managed by the save data manager. Subsequently, they will automatically be registered
|
|
11450
|
+
* with the save data manager upon initialization. Unfortunately, due to technical limitations with
|
|
11451
|
+
* classes, this registration will only occur if you initialize the class with the `init` boolean
|
|
11452
|
+
* argument set to false, and then explicitly call the `ModFeature.init` method yourself after the
|
|
11453
|
+
* class is constructed. (This is because the parent class does not have access to the child's
|
|
11454
|
+
* properties upon first construction.)
|
|
11437
11455
|
*/
|
|
11438
11456
|
export declare class ModFeature {
|
|
11439
11457
|
private mod;
|
|
@@ -15100,7 +15118,8 @@ export declare interface TrinketSituation {
|
|
|
15100
15118
|
}
|
|
15101
15119
|
|
|
15102
15120
|
/**
|
|
15103
|
-
* This is a type representing a user-created class from TypeScript code.
|
|
15121
|
+
* This is a type representing a user-created class from TypeScript code. (TypeScriptToLua
|
|
15122
|
+
* transpiles TypeScript classes to a Lua table with a specific kind of metatable.)
|
|
15104
15123
|
*
|
|
15105
15124
|
* This type is used by the save data manager to when copying, serializing, and deserializing.
|
|
15106
15125
|
*/
|
|
@@ -15108,6 +15127,10 @@ export declare type TSTLClass = LuaMap<AnyNotNil, unknown> & {
|
|
|
15108
15127
|
readonly __tstlClassBrand: symbol;
|
|
15109
15128
|
};
|
|
15110
15129
|
|
|
15130
|
+
/**
|
|
15131
|
+
* This is a type representing the metatable of a user-created class from TypeScript code.
|
|
15132
|
+
* (TypeScriptToLua transpiles TypeScript classes to a Lua table with a specific kind of metatable.)
|
|
15133
|
+
*/
|
|
15111
15134
|
declare interface TSTLClassMetatable {
|
|
15112
15135
|
____constructor: () => void;
|
|
15113
15136
|
__index: unknown;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
--[[
|
|
2
2
|
|
|
3
|
-
isaacscript-common 20.
|
|
3
|
+
isaacscript-common 20.12.1
|
|
4
4
|
|
|
5
5
|
This is the "isaacscript-common" library, which was created with the IsaacScript tool.
|
|
6
6
|
|
|
@@ -14516,7 +14516,7 @@ ____exports.RockVariant.NORMAL = 0
|
|
|
14516
14516
|
____exports.RockVariant[____exports.RockVariant.NORMAL] = "NORMAL"
|
|
14517
14517
|
____exports.RockVariant.EVENT = 1
|
|
14518
14518
|
____exports.RockVariant[____exports.RockVariant.EVENT] = "EVENT"
|
|
14519
|
-
--- For GridEntityType.ROCK_ALT (6), RockAltType.URN
|
|
14519
|
+
--- For GridEntityType.ROCK_ALT (6), RockAltType.URN.
|
|
14520
14520
|
--
|
|
14521
14521
|
-- Note that you are unable to spawn specific urn variants. The game will pick a random variant
|
|
14522
14522
|
-- regardless of which one you select.
|
|
@@ -14527,7 +14527,7 @@ ____exports.UrnVariant.CHIPPED_TOP_LEFT = 1
|
|
|
14527
14527
|
____exports.UrnVariant[____exports.UrnVariant.CHIPPED_TOP_LEFT] = "CHIPPED_TOP_LEFT"
|
|
14528
14528
|
____exports.UrnVariant.NARROW = 2
|
|
14529
14529
|
____exports.UrnVariant[____exports.UrnVariant.NARROW] = "NARROW"
|
|
14530
|
-
--- For GridEntityType.ROCK_ALT (6), RockAltType.MUSHROOM
|
|
14530
|
+
--- For GridEntityType.ROCK_ALT (6), RockAltType.MUSHROOM.
|
|
14531
14531
|
--
|
|
14532
14532
|
-- Note that you are unable to spawn specific mushroom variants. The game will pick a random variant
|
|
14533
14533
|
-- regardless of which one you select.
|
|
@@ -14538,7 +14538,7 @@ ____exports.MushroomVariant.CHIPPED_TOP_RIGHT = 1
|
|
|
14538
14538
|
____exports.MushroomVariant[____exports.MushroomVariant.CHIPPED_TOP_RIGHT] = "CHIPPED_TOP_RIGHT"
|
|
14539
14539
|
____exports.MushroomVariant.NARROW = 2
|
|
14540
14540
|
____exports.MushroomVariant[____exports.MushroomVariant.NARROW] = "NARROW"
|
|
14541
|
-
--- For GridEntityType.ROCK_ALT (6), RockAltType.SKULL
|
|
14541
|
+
--- For GridEntityType.ROCK_ALT (6), RockAltType.SKULL.
|
|
14542
14542
|
--
|
|
14543
14543
|
-- Note that you are unable to spawn specific skull variants. The game will pick a random variant
|
|
14544
14544
|
-- regardless of which one you select.
|
|
@@ -14549,7 +14549,7 @@ ____exports.SkullVariant.FACING_RIGHT = 1
|
|
|
14549
14549
|
____exports.SkullVariant[____exports.SkullVariant.FACING_RIGHT] = "FACING_RIGHT"
|
|
14550
14550
|
____exports.SkullVariant.FACING_LEFT = 2
|
|
14551
14551
|
____exports.SkullVariant[____exports.SkullVariant.FACING_LEFT] = "FACING_LEFT"
|
|
14552
|
-
--- For GridEntityType.ROCK_ALT (6), RockAltType.POLYP
|
|
14552
|
+
--- For GridEntityType.ROCK_ALT (6), RockAltType.POLYP.
|
|
14553
14553
|
--
|
|
14554
14554
|
-- Note that you are unable to spawn specific polyp variants. The game will pick a random variant
|
|
14555
14555
|
-- regardless of which one you select.
|
|
@@ -14560,7 +14560,7 @@ ____exports.PolypVariant.MANY_FINGERS = 1
|
|
|
14560
14560
|
____exports.PolypVariant[____exports.PolypVariant.MANY_FINGERS] = "MANY_FINGERS"
|
|
14561
14561
|
____exports.PolypVariant.FLIPPED_AND_SHIFTED_UPWARDS = 2
|
|
14562
14562
|
____exports.PolypVariant[____exports.PolypVariant.FLIPPED_AND_SHIFTED_UPWARDS] = "FLIPPED_AND_SHIFTED_UPWARDS"
|
|
14563
|
-
--- For GridEntityType.ROCK_ALT (6), RockAltType.BUCKET
|
|
14563
|
+
--- For GridEntityType.ROCK_ALT (6), RockAltType.BUCKET.
|
|
14564
14564
|
--
|
|
14565
14565
|
-- Note that you are unable to spawn specific bucket variants. The game will pick a random variant
|
|
14566
14566
|
-- regardless of which one you select.
|
|
@@ -14577,7 +14577,7 @@ ____exports.PitVariant.NORMAL = 0
|
|
|
14577
14577
|
____exports.PitVariant[____exports.PitVariant.NORMAL] = "NORMAL"
|
|
14578
14578
|
____exports.PitVariant.FISSURE_SPAWNER = 16
|
|
14579
14579
|
____exports.PitVariant[____exports.PitVariant.FISSURE_SPAWNER] = "FISSURE_SPAWNER"
|
|
14580
|
-
--- For `GridEntityType.FIREPLACE
|
|
14580
|
+
--- For `GridEntityType.FIREPLACE` (13).
|
|
14581
14581
|
--
|
|
14582
14582
|
-- This only partially corresponds to the `FireplaceVariant` for non-grid entities. (Spawning a grid
|
|
14583
14583
|
-- entity fireplace with a variant higher than 1 will result in a normal fireplace.)
|
|
@@ -14586,7 +14586,7 @@ ____exports.FireplaceGridEntityVariant.NORMAL = 0
|
|
|
14586
14586
|
____exports.FireplaceGridEntityVariant[____exports.FireplaceGridEntityVariant.NORMAL] = "NORMAL"
|
|
14587
14587
|
____exports.FireplaceGridEntityVariant.RED = 1
|
|
14588
14588
|
____exports.FireplaceGridEntityVariant[____exports.FireplaceGridEntityVariant.RED] = "RED"
|
|
14589
|
-
--- For `GridEntityType.POOP
|
|
14589
|
+
--- For `GridEntityType.POOP` (14).
|
|
14590
14590
|
____exports.PoopGridEntityVariant = {}
|
|
14591
14591
|
____exports.PoopGridEntityVariant.NORMAL = 0
|
|
14592
14592
|
____exports.PoopGridEntityVariant[____exports.PoopGridEntityVariant.NORMAL] = "NORMAL"
|
|
@@ -14612,7 +14612,7 @@ ____exports.PoopGridEntityVariant.GIGA_BOTTOM_RIGHT = 10
|
|
|
14612
14612
|
____exports.PoopGridEntityVariant[____exports.PoopGridEntityVariant.GIGA_BOTTOM_RIGHT] = "GIGA_BOTTOM_RIGHT"
|
|
14613
14613
|
____exports.PoopGridEntityVariant.CHARMING = 11
|
|
14614
14614
|
____exports.PoopGridEntityVariant[____exports.PoopGridEntityVariant.CHARMING] = "CHARMING"
|
|
14615
|
-
--- For `GridEntityType.DOOR
|
|
14615
|
+
--- For `GridEntityType.DOOR` (16).
|
|
14616
14616
|
____exports.DoorVariant = {}
|
|
14617
14617
|
____exports.DoorVariant.UNSPECIFIED = 0
|
|
14618
14618
|
____exports.DoorVariant[____exports.DoorVariant.UNSPECIFIED] = "UNSPECIFIED"
|
|
@@ -14638,7 +14638,7 @@ ____exports.TrapdoorVariant.NORMAL = 0
|
|
|
14638
14638
|
____exports.TrapdoorVariant[____exports.TrapdoorVariant.NORMAL] = "NORMAL"
|
|
14639
14639
|
____exports.TrapdoorVariant.VOID_PORTAL = 1
|
|
14640
14640
|
____exports.TrapdoorVariant[____exports.TrapdoorVariant.VOID_PORTAL] = "VOID_PORTAL"
|
|
14641
|
-
--- For `GridEntityType.CRAWL_SPACE
|
|
14641
|
+
--- For `GridEntityType.CRAWL_SPACE` (18).
|
|
14642
14642
|
____exports.CrawlSpaceVariant = {}
|
|
14643
14643
|
____exports.CrawlSpaceVariant.NORMAL = 0
|
|
14644
14644
|
____exports.CrawlSpaceVariant[____exports.CrawlSpaceVariant.NORMAL] = "NORMAL"
|
|
@@ -49900,7 +49900,7 @@ local __TS__Class = ____lualib.__TS__Class
|
|
|
49900
49900
|
local Map = ____lualib.Map
|
|
49901
49901
|
local __TS__New = ____lualib.__TS__New
|
|
49902
49902
|
local ____exports = {}
|
|
49903
|
-
local initDecoratedCallbacks, addCallback, removeCallback, WRAPPED_CALLBACK_METHODS_KEY, WRAPPED_CUSTOM_CALLBACK_METHODS_KEY
|
|
49903
|
+
local initDecoratedCallbacks, addCallback, removeCallback, initSaveDataManager, WRAPPED_CALLBACK_METHODS_KEY, WRAPPED_CUSTOM_CALLBACK_METHODS_KEY
|
|
49904
49904
|
local ____array = require("src.functions.array")
|
|
49905
49905
|
local isArray = ____array.isArray
|
|
49906
49906
|
local ____tstlClass = require("src.functions.tstlClass")
|
|
@@ -49909,6 +49909,7 @@ local getTSTLClassName = ____tstlClass.getTSTLClassName
|
|
|
49909
49909
|
local ____types = require("src.functions.types")
|
|
49910
49910
|
local isFunction = ____types.isFunction
|
|
49911
49911
|
local isNumber = ____types.isNumber
|
|
49912
|
+
local isTable = ____types.isTable
|
|
49912
49913
|
function initDecoratedCallbacks(self, modFeature, constructor, tstlClassName, vanilla, init)
|
|
49913
49914
|
local modFeatureConstructor = constructor
|
|
49914
49915
|
local callbackTuplesKey = vanilla and ____exports.MOD_FEATURE_CALLBACKS_KEY or ____exports.MOD_FEATURE_CUSTOM_CALLBACKS_KEY
|
|
@@ -50020,6 +50021,34 @@ function removeCallback(self, modFeatureConstructor, mod, modCallback, vanilla)
|
|
|
50020
50021
|
mod:RemoveCallbackCustom(modCallback, wrappedCallback)
|
|
50021
50022
|
end
|
|
50022
50023
|
end
|
|
50024
|
+
function initSaveDataManager(self, modFeature, tstlClassName, init)
|
|
50025
|
+
if tstlClassName == "AtePoopBaby" then
|
|
50026
|
+
Isaac.DebugString("GETTING HERE 1")
|
|
50027
|
+
end
|
|
50028
|
+
local ____modFeature_0 = modFeature
|
|
50029
|
+
local v = ____modFeature_0.v
|
|
50030
|
+
if v == nil then
|
|
50031
|
+
return
|
|
50032
|
+
end
|
|
50033
|
+
Isaac.DebugString("GETTING HERE 2")
|
|
50034
|
+
if not isTable(nil, v) then
|
|
50035
|
+
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.)")
|
|
50036
|
+
end
|
|
50037
|
+
local mod = modFeature.mod
|
|
50038
|
+
local saveDataManagerMethodName = init and "saveDataManager" or "saveDataManagerRemove"
|
|
50039
|
+
local saveDataManagerMethod = mod[saveDataManagerMethodName]
|
|
50040
|
+
if saveDataManagerMethod == nil then
|
|
50041
|
+
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.")
|
|
50042
|
+
end
|
|
50043
|
+
if type(saveDataManagerMethod) ~= "function" then
|
|
50044
|
+
error(("The \"" .. saveDataManagerMethodName) .. "\" property of the \"ModUpgraded\" object was not a function.")
|
|
50045
|
+
end
|
|
50046
|
+
if init then
|
|
50047
|
+
saveDataManagerMethod(nil, tstlClassName, v)
|
|
50048
|
+
else
|
|
50049
|
+
saveDataManagerMethod(nil, tstlClassName)
|
|
50050
|
+
end
|
|
50051
|
+
end
|
|
50023
50052
|
____exports.MOD_FEATURE_CALLBACKS_KEY = "__callbacks"
|
|
50024
50053
|
____exports.MOD_FEATURE_CUSTOM_CALLBACKS_KEY = "__customCallbacks"
|
|
50025
50054
|
WRAPPED_CALLBACK_METHODS_KEY = "__wrappedCallbackMethods"
|
|
@@ -50070,6 +50099,7 @@ function ModFeature.prototype.init(self, init)
|
|
|
50070
50099
|
false,
|
|
50071
50100
|
init
|
|
50072
50101
|
)
|
|
50102
|
+
initSaveDataManager(nil, self, tstlClassName, init)
|
|
50073
50103
|
end
|
|
50074
50104
|
function ModFeature.prototype.uninit(self)
|
|
50075
50105
|
self:init(false)
|
|
@@ -51003,7 +51033,8 @@ local ____exports = {}
|
|
|
51003
51033
|
function ____exports.initModFeatures(self, mod, modFeatures)
|
|
51004
51034
|
local instantiatedModFeatures = {}
|
|
51005
51035
|
for ____, modFeature in ipairs(modFeatures) do
|
|
51006
|
-
local instantiatedModFeature = __TS__New(modFeature, mod)
|
|
51036
|
+
local instantiatedModFeature = __TS__New(modFeature, mod, false)
|
|
51037
|
+
instantiatedModFeature:init()
|
|
51007
51038
|
instantiatedModFeatures[#instantiatedModFeatures + 1] = instantiatedModFeature
|
|
51008
51039
|
end
|
|
51009
51040
|
return instantiatedModFeatures
|
|
@@ -18,6 +18,14 @@ export declare const MOD_FEATURE_CUSTOM_CALLBACKS_KEY = "__customCallbacks";
|
|
|
18
18
|
* In almost all cases, you will want the callback functions to be immediately subscribed after
|
|
19
19
|
* instantiating the class. However, if this is not the case, you can pass `false` as the optional
|
|
20
20
|
* second argument to the constructor.
|
|
21
|
+
*
|
|
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.)
|
|
21
29
|
*/
|
|
22
30
|
export declare class ModFeature {
|
|
23
31
|
private mod;
|
|
@@ -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;;;;;;;;;;;;;;;;;;;;;;;GAuBG;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;;;;;OAKG;IACI,WAAW,UAAS;gBAEf,GAAG,EAAE,eAAe,EAAE,IAAI,UAAO;IAQ7C;;;;;OAKG;IACI,IAAI,CAAC,IAAI,UAAO,GAAG,IAAI;IAqB9B;;;;;OAKG;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, WRAPPED_CALLBACK_METHODS_KEY, WRAPPED_CUSTOM_CALLBACK_METHODS_KEY
|
|
6
|
+
local initDecoratedCallbacks, addCallback, removeCallback, initSaveDataManager, 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,6 +12,7 @@ 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
|
|
15
16
|
function initDecoratedCallbacks(self, modFeature, constructor, tstlClassName, vanilla, init)
|
|
16
17
|
local modFeatureConstructor = constructor
|
|
17
18
|
local callbackTuplesKey = vanilla and ____exports.MOD_FEATURE_CALLBACKS_KEY or ____exports.MOD_FEATURE_CUSTOM_CALLBACKS_KEY
|
|
@@ -123,6 +124,34 @@ function removeCallback(self, modFeatureConstructor, mod, modCallback, vanilla)
|
|
|
123
124
|
mod:RemoveCallbackCustom(modCallback, wrappedCallback)
|
|
124
125
|
end
|
|
125
126
|
end
|
|
127
|
+
function initSaveDataManager(self, modFeature, tstlClassName, init)
|
|
128
|
+
if tstlClassName == "AtePoopBaby" then
|
|
129
|
+
Isaac.DebugString("GETTING HERE 1")
|
|
130
|
+
end
|
|
131
|
+
local ____modFeature_0 = modFeature
|
|
132
|
+
local v = ____modFeature_0.v
|
|
133
|
+
if v == nil then
|
|
134
|
+
return
|
|
135
|
+
end
|
|
136
|
+
Isaac.DebugString("GETTING HERE 2")
|
|
137
|
+
if not isTable(nil, v) then
|
|
138
|
+
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.)")
|
|
139
|
+
end
|
|
140
|
+
local mod = modFeature.mod
|
|
141
|
+
local saveDataManagerMethodName = init and "saveDataManager" or "saveDataManagerRemove"
|
|
142
|
+
local saveDataManagerMethod = mod[saveDataManagerMethodName]
|
|
143
|
+
if saveDataManagerMethod == nil then
|
|
144
|
+
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.")
|
|
145
|
+
end
|
|
146
|
+
if type(saveDataManagerMethod) ~= "function" then
|
|
147
|
+
error(("The \"" .. saveDataManagerMethodName) .. "\" property of the \"ModUpgraded\" object was not a function.")
|
|
148
|
+
end
|
|
149
|
+
if init then
|
|
150
|
+
saveDataManagerMethod(nil, tstlClassName, v)
|
|
151
|
+
else
|
|
152
|
+
saveDataManagerMethod(nil, tstlClassName)
|
|
153
|
+
end
|
|
154
|
+
end
|
|
126
155
|
____exports.MOD_FEATURE_CALLBACKS_KEY = "__callbacks"
|
|
127
156
|
____exports.MOD_FEATURE_CUSTOM_CALLBACKS_KEY = "__customCallbacks"
|
|
128
157
|
WRAPPED_CALLBACK_METHODS_KEY = "__wrappedCallbackMethods"
|
|
@@ -141,6 +170,14 @@ WRAPPED_CUSTOM_CALLBACK_METHODS_KEY = "__wrappedCustomCallbacksMethods"
|
|
|
141
170
|
-- In almost all cases, you will want the callback functions to be immediately subscribed after
|
|
142
171
|
-- instantiating the class. However, if this is not the case, you can pass `false` as the optional
|
|
143
172
|
-- second argument to the constructor.
|
|
173
|
+
--
|
|
174
|
+
-- If your mod feature has a property called `v`, it will be assumed that these are variables that
|
|
175
|
+
-- should be managed by the save data manager. Subsequently, they will automatically be registered
|
|
176
|
+
-- with the save data manager upon initialization. Unfortunately, due to technical limitations with
|
|
177
|
+
-- classes, this registration will only occur if you initialize the class with the `init` boolean
|
|
178
|
+
-- argument set to false, and then explicitly call the `ModFeature.init` method yourself after the
|
|
179
|
+
-- class is constructed. (This is because the parent class does not have access to the child's
|
|
180
|
+
-- properties upon first construction.)
|
|
144
181
|
____exports.ModFeature = __TS__Class()
|
|
145
182
|
local ModFeature = ____exports.ModFeature
|
|
146
183
|
ModFeature.name = "ModFeature"
|
|
@@ -187,6 +224,7 @@ function ModFeature.prototype.init(self, init)
|
|
|
187
224
|
false,
|
|
188
225
|
init
|
|
189
226
|
)
|
|
227
|
+
initSaveDataManager(nil, self, tstlClassName, init)
|
|
190
228
|
end
|
|
191
229
|
function ModFeature.prototype.uninit(self)
|
|
192
230
|
self:init(false)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomTrapdoors.d.ts","sourceRoot":"","sources":["../../../../../src/classes/features/other/CustomTrapdoors.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,UAAU,EAKV,SAAS,EACV,MAAM,8BAA8B,CAAC;AA6BtC,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAgChD,qBAAa,eAAgB,SAAQ,OAAO;IAC1C,qCAAqC;IACrC,OAAO,CAAC,kBAAkB,CAOtB;IAqBJ;;;;;OAKG;IACH,OAAO,CAAC,WAAW,CAAY;IAE/B,OAAO,CAAC,kBAAkB,CAAqB;IAC/C,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,YAAY,CAAe;IAmDnC,OAAO,CAAC,UAAU,CAMhB;IAEF,OAAO,CAAC,2BAA2B;IA+BnC,OAAO,CAAC,8BAA8B;IAmDtC,OAAO,CAAC,6BAA6B;IAsBrC,OAAO,CAAC,kBAAkB;IAqB1B,OAAO,CAAC,4BAA4B;
|
|
1
|
+
{"version":3,"file":"CustomTrapdoors.d.ts","sourceRoot":"","sources":["../../../../../src/classes/features/other/CustomTrapdoors.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,UAAU,EAKV,SAAS,EACV,MAAM,8BAA8B,CAAC;AA6BtC,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAgChD,qBAAa,eAAgB,SAAQ,OAAO;IAC1C,qCAAqC;IACrC,OAAO,CAAC,kBAAkB,CAOtB;IAqBJ;;;;;OAKG;IACH,OAAO,CAAC,WAAW,CAAY;IAE/B,OAAO,CAAC,kBAAkB,CAAqB;IAC/C,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,YAAY,CAAe;IAmDnC,OAAO,CAAC,UAAU,CAMhB;IAEF,OAAO,CAAC,2BAA2B;IA+BnC,OAAO,CAAC,8BAA8B;IAmDtC,OAAO,CAAC,6BAA6B;IAsBrC,OAAO,CAAC,kBAAkB;IAqB1B,OAAO,CAAC,4BAA4B;IAiDpC,OAAO,CAAC,iCAAiC;IAsBzC,OAAO,CAAC,eAAe;IAqBvB,OAAO,CAAC,kCAAkC,CAaxC;IAEF,OAAO,CAAC,4BAA4B;IAcpC,OAAO,CAAC,kBAAkB;IAc1B,OAAO,CAAC,sBAAsB;IAmB9B,OAAO,CAAC,gCAAgC;IAuCxC,OAAO,CAAC,2BAA2B;IAqCnC,OAAO,CAAC,gBAAgB;IAoBxB,OAAO,CAAC,8BAA8B;IAmDtC,OAAO,CAAC,0BAA0B,CAEhC;IAEF,OAAO,CAAC,iBAAiB;IAezB,OAAO,CAAC,uBAAuB;IA4B/B,OAAO,CAAC,eAAe;IAUvB;;;;;;;;;;;;;;;;;;OAkBG;IAEI,iCAAiC,CACtC,eAAe,EAAE,MAAM,EACvB,eAAe,EAAE,CACf,eAAe,EAAE,MAAM,GAAG,SAAS,EACnC,gBAAgB,EAAE,UAAU,EAC5B,oBAAoB,EAAE,SAAS,KAC5B,IAAI,GACR,IAAI;IAUP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAqCG;IAEI,mBAAmB,CACxB,mBAAmB,EAAE,GAAG,GAAG,MAAM,EACjC,eAAe,CAAC,EAAE,MAAM,EACxB,gBAAgB,CAAC,EAAE,UAAU,EAC7B,oBAAoB,CAAC,EAAE,SAAS,EAChC,QAAQ,SAAmC,EAC3C,SAAS,CAAC,EAAE,OAAO,GAClB,UAAU;CA0Dd"}
|
|
@@ -13,7 +13,14 @@ export declare function getParentFunctionDescription(levels?: number): string |
|
|
|
13
13
|
* Helper function to avoid typing out `Isaac.DebugString()`.
|
|
14
14
|
*
|
|
15
15
|
* If you have the "--luadebug" launch flag turned on or the Racing+ sandbox enabled, then this
|
|
16
|
-
* function will also prepend the function name and the line number before the string
|
|
16
|
+
* function will also prepend the function name and the line number before the string, like this:
|
|
17
|
+
*
|
|
18
|
+
* ```text
|
|
19
|
+
* [INFO] - Lua Debug: saveToDisk:42494 - The save data manager wrote data to the "save#.dat" file.
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* Subsequently, it is recommended that you turn on the "--luadebug" launch flag when developing
|
|
23
|
+
* your mod so that debugging becomes a little bit easier.
|
|
17
24
|
*/
|
|
18
25
|
export declare function log(msg: string): void;
|
|
19
26
|
//# sourceMappingURL=log.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../../src/functions/log.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,wBAAgB,4BAA4B,CAK1C,MAAM,SAAI,GACT,MAAM,GAAG,SAAS,CAiBpB;AAED
|
|
1
|
+
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../../src/functions/log.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,wBAAgB,4BAA4B,CAK1C,MAAM,SAAI,GACT,MAAM,GAAG,SAAS,CAiBpB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAOrC"}
|
|
@@ -25,7 +25,14 @@ end
|
|
|
25
25
|
--- Helper function to avoid typing out `Isaac.DebugString()`.
|
|
26
26
|
--
|
|
27
27
|
-- If you have the "--luadebug" launch flag turned on or the Racing+ sandbox enabled, then this
|
|
28
|
-
-- function will also prepend the function name and the line number before the string
|
|
28
|
+
-- function will also prepend the function name and the line number before the string, like this:
|
|
29
|
+
--
|
|
30
|
+
-- ```text
|
|
31
|
+
-- [INFO] - Lua Debug: saveToDisk:42494 - The save data manager wrote data to the "save#.dat" file.
|
|
32
|
+
-- ```
|
|
33
|
+
--
|
|
34
|
+
-- Subsequently, it is recommended that you turn on the "--luadebug" launch flag when developing
|
|
35
|
+
-- your mod so that debugging becomes a little bit easier.
|
|
29
36
|
function ____exports.log(self, msg)
|
|
30
37
|
local parentFunctionDescription = ____exports.getParentFunctionDescription(nil)
|
|
31
38
|
local debugMsg = parentFunctionDescription == nil and msg or (parentFunctionDescription .. " - ") .. msg
|
|
@@ -4,6 +4,9 @@ import { ModUpgraded } from "../types/ModUpgraded";
|
|
|
4
4
|
* Helper function to instantiate an array of mod features all at once. Use this function if your
|
|
5
5
|
* mod uses the pattern of expressing mod features as `ModFeature` classes.
|
|
6
6
|
*
|
|
7
|
+
* If your feature classes have `v` variables, then this function will successfully register them
|
|
8
|
+
* with the save data manager.
|
|
9
|
+
*
|
|
7
10
|
* For example:
|
|
8
11
|
*
|
|
9
12
|
* ```ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modFeatures.d.ts","sourceRoot":"","sources":["../../../src/functions/modFeatures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD
|
|
1
|
+
{"version":3,"file":"modFeatures.d.ts","sourceRoot":"","sources":["../../../src/functions/modFeatures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,WAAW,EAChB,WAAW,EAAE,KAAK,CAAC,OAAO,UAAU,CAAC,GACpC,UAAU,EAAE,CAYd"}
|
|
@@ -4,6 +4,9 @@ local ____exports = {}
|
|
|
4
4
|
--- Helper function to instantiate an array of mod features all at once. Use this function if your
|
|
5
5
|
-- mod uses the pattern of expressing mod features as `ModFeature` classes.
|
|
6
6
|
--
|
|
7
|
+
-- If your feature classes have `v` variables, then this function will successfully register them
|
|
8
|
+
-- with the save data manager.
|
|
9
|
+
--
|
|
7
10
|
-- For example:
|
|
8
11
|
--
|
|
9
12
|
-- ```ts
|
|
@@ -20,7 +23,8 @@ local ____exports = {}
|
|
|
20
23
|
function ____exports.initModFeatures(self, mod, modFeatures)
|
|
21
24
|
local instantiatedModFeatures = {}
|
|
22
25
|
for ____, modFeature in ipairs(modFeatures) do
|
|
23
|
-
local instantiatedModFeature = __TS__New(modFeature, mod)
|
|
26
|
+
local instantiatedModFeature = __TS__New(modFeature, mod, false)
|
|
27
|
+
instantiatedModFeature:init()
|
|
24
28
|
instantiatedModFeatures[#instantiatedModFeatures + 1] = instantiatedModFeature
|
|
25
29
|
end
|
|
26
30
|
return instantiatedModFeatures
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
/// <reference types="lua-types/5.3" />
|
|
3
3
|
/// <reference types="lua-types/5.3" />
|
|
4
4
|
/// <reference types="@typescript-to-lua/language-extensions" />
|
|
5
|
+
/**
|
|
6
|
+
* This is a type representing the metatable of a user-created class from TypeScript code.
|
|
7
|
+
* (TypeScriptToLua transpiles TypeScript classes to a Lua table with a specific kind of metatable.)
|
|
8
|
+
*/
|
|
5
9
|
export interface TSTLClassMetatable {
|
|
6
10
|
____constructor: () => void;
|
|
7
11
|
__index: unknown;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TSTLClassMetatable.d.ts","sourceRoot":"","sources":["../../../src/interfaces/TSTLClassMetatable.ts"],"names":[],"mappings":";;;;AAAA,MAAM,WAAW,kBAAkB;IACjC,eAAe,EAAE,MAAM,IAAI,CAAC;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE;QACX,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,EAAE,YAAY,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC;KAErD,CAAC;CACH"}
|
|
1
|
+
{"version":3,"file":"TSTLClassMetatable.d.ts","sourceRoot":"","sources":["../../../src/interfaces/TSTLClassMetatable.ts"],"names":[],"mappings":";;;;AAAA;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,eAAe,EAAE,MAAM,IAAI,CAAC;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE;QACX,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,EAAE,YAAY,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC;KAErD,CAAC;CACH"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="@typescript-to-lua/language-extensions" />
|
|
2
2
|
/**
|
|
3
|
-
* This is a type representing a user-created class from TypeScript code.
|
|
3
|
+
* This is a type representing a user-created class from TypeScript code. (TypeScriptToLua
|
|
4
|
+
* transpiles TypeScript classes to a Lua table with a specific kind of metatable.)
|
|
4
5
|
*
|
|
5
6
|
* This type is used by the save data manager to when copying, serializing, and deserializing.
|
|
6
7
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TSTLClass.d.ts","sourceRoot":"","sources":["../../../src/types/TSTLClass.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"TSTLClass.d.ts","sourceRoot":"","sources":["../../../src/types/TSTLClass.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,GAAG;IACnD,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;CACnC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "isaacscript-common",
|
|
3
|
-
"version": "20.
|
|
3
|
+
"version": "20.12.1",
|
|
4
4
|
"description": "Helper functions and features for IsaacScript mods.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"isaac",
|
|
@@ -22,6 +22,6 @@
|
|
|
22
22
|
"main": "dist/src/index",
|
|
23
23
|
"types": "dist/src/index.d.ts",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"isaac-typescript-definitions": "^11.0.
|
|
25
|
+
"isaac-typescript-definitions": "^11.0.1"
|
|
26
26
|
}
|
|
27
27
|
}
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
getTSTLClassConstructor,
|
|
6
6
|
getTSTLClassName,
|
|
7
7
|
} from "../functions/tstlClass";
|
|
8
|
-
import { isFunction, isNumber } from "../functions/types";
|
|
8
|
+
import { isFunction, isNumber, isTable } from "../functions/types";
|
|
9
9
|
import { TSTLClassMetatable } from "../interfaces/TSTLClassMetatable";
|
|
10
10
|
import { AnyFunction } from "../types/AnyFunction";
|
|
11
11
|
import { ModUpgradedBase } from "./ModUpgradedBase";
|
|
@@ -51,6 +51,14 @@ type ModFeatureConstructor = TSTLClassMetatable["constructor"] & {
|
|
|
51
51
|
* In almost all cases, you will want the callback functions to be immediately subscribed after
|
|
52
52
|
* instantiating the class. However, if this is not the case, you can pass `false` as the optional
|
|
53
53
|
* second argument to the constructor.
|
|
54
|
+
*
|
|
55
|
+
* If your mod feature has a property called `v`, it will be assumed that these are variables that
|
|
56
|
+
* should be managed by the save data manager. Subsequently, they will automatically be registered
|
|
57
|
+
* with the save data manager upon initialization. Unfortunately, due to technical limitations with
|
|
58
|
+
* classes, this registration will only occur if you initialize the class with the `init` boolean
|
|
59
|
+
* argument set to false, and then explicitly call the `ModFeature.init` method yourself after the
|
|
60
|
+
* class is constructed. (This is because the parent class does not have access to the child's
|
|
61
|
+
* properties upon first construction.)
|
|
54
62
|
*/
|
|
55
63
|
|
|
56
64
|
export class ModFeature {
|
|
@@ -129,6 +137,7 @@ export class ModFeature {
|
|
|
129
137
|
|
|
130
138
|
initDecoratedCallbacks(this, constructor, tstlClassName, true, init);
|
|
131
139
|
initDecoratedCallbacks(this, constructor, tstlClassName, false, init);
|
|
140
|
+
initSaveDataManager(this, tstlClassName, init);
|
|
132
141
|
}
|
|
133
142
|
|
|
134
143
|
/**
|
|
@@ -314,3 +323,53 @@ function removeCallback(
|
|
|
314
323
|
(mod.RemoveCallbackCustom as AnyFunction)(modCallback, wrappedCallback);
|
|
315
324
|
}
|
|
316
325
|
}
|
|
326
|
+
|
|
327
|
+
/** This will only work for end-users who are calling the `ModFeature.init` method explicitly. */
|
|
328
|
+
function initSaveDataManager(
|
|
329
|
+
modFeature: ModFeature,
|
|
330
|
+
tstlClassName: string,
|
|
331
|
+
init: boolean,
|
|
332
|
+
) {
|
|
333
|
+
if (tstlClassName === "AtePoopBaby") {
|
|
334
|
+
Isaac.DebugString("GETTING HERE 1");
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
// Do nothing if this class does not have any variables.
|
|
338
|
+
const { v } = modFeature as unknown as Record<string, unknown>;
|
|
339
|
+
if (v === undefined) {
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
Isaac.DebugString("GETTING HERE 2");
|
|
344
|
+
|
|
345
|
+
if (!isTable(v)) {
|
|
346
|
+
error(
|
|
347
|
+
'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.)',
|
|
348
|
+
);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
// Do nothing if we have not enabled the save data manager.
|
|
352
|
+
// eslint-disable-next-line @typescript-eslint/dot-notation
|
|
353
|
+
const mod = modFeature["mod"] as unknown as Record<string, unknown>;
|
|
354
|
+
const saveDataManagerMethodName = init
|
|
355
|
+
? "saveDataManager"
|
|
356
|
+
: "saveDataManagerRemove";
|
|
357
|
+
const saveDataManagerMethod = mod[saveDataManagerMethodName];
|
|
358
|
+
if (saveDataManagerMethod === undefined) {
|
|
359
|
+
error(
|
|
360
|
+
'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.',
|
|
361
|
+
);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
if (typeof saveDataManagerMethod !== "function") {
|
|
365
|
+
error(
|
|
366
|
+
`The "${saveDataManagerMethodName}" property of the "ModUpgraded" object was not a function.`,
|
|
367
|
+
);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
if (init) {
|
|
371
|
+
saveDataManagerMethod(tstlClassName, v);
|
|
372
|
+
} else {
|
|
373
|
+
saveDataManagerMethod(tstlClassName);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
@@ -342,6 +342,8 @@ export class CustomTrapdoors extends Feature {
|
|
|
342
342
|
const level = game.GetLevel();
|
|
343
343
|
const stage = level.GetStage();
|
|
344
344
|
if (stage !== CUSTOM_FLOOR_STAGE) {
|
|
345
|
+
// The vanilla streak text shows just before the player stands up, which is a few frames
|
|
346
|
+
// from now. We arbitrarily play it now instead of waiting to avoid the extra complexity.
|
|
345
347
|
level.ShowName(false);
|
|
346
348
|
}
|
|
347
349
|
});
|
package/src/functions/log.ts
CHANGED
|
@@ -37,7 +37,14 @@ export function getParentFunctionDescription(
|
|
|
37
37
|
* Helper function to avoid typing out `Isaac.DebugString()`.
|
|
38
38
|
*
|
|
39
39
|
* If you have the "--luadebug" launch flag turned on or the Racing+ sandbox enabled, then this
|
|
40
|
-
* function will also prepend the function name and the line number before the string
|
|
40
|
+
* function will also prepend the function name and the line number before the string, like this:
|
|
41
|
+
*
|
|
42
|
+
* ```text
|
|
43
|
+
* [INFO] - Lua Debug: saveToDisk:42494 - The save data manager wrote data to the "save#.dat" file.
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* Subsequently, it is recommended that you turn on the "--luadebug" launch flag when developing
|
|
47
|
+
* your mod so that debugging becomes a little bit easier.
|
|
41
48
|
*/
|
|
42
49
|
export function log(msg: string): void {
|
|
43
50
|
const parentFunctionDescription = getParentFunctionDescription();
|
|
@@ -5,6 +5,9 @@ import { ModUpgraded } from "../types/ModUpgraded";
|
|
|
5
5
|
* Helper function to instantiate an array of mod features all at once. Use this function if your
|
|
6
6
|
* mod uses the pattern of expressing mod features as `ModFeature` classes.
|
|
7
7
|
*
|
|
8
|
+
* If your feature classes have `v` variables, then this function will successfully register them
|
|
9
|
+
* with the save data manager.
|
|
10
|
+
*
|
|
8
11
|
* For example:
|
|
9
12
|
*
|
|
10
13
|
* ```ts
|
|
@@ -27,7 +30,9 @@ export function initModFeatures(
|
|
|
27
30
|
|
|
28
31
|
for (const modFeature of modFeatures) {
|
|
29
32
|
// eslint-disable-next-line new-cap
|
|
30
|
-
const instantiatedModFeature = new modFeature(mod);
|
|
33
|
+
const instantiatedModFeature = new modFeature(mod, false);
|
|
34
|
+
instantiatedModFeature.init();
|
|
35
|
+
|
|
31
36
|
instantiatedModFeatures.push(instantiatedModFeature);
|
|
32
37
|
}
|
|
33
38
|
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This is a type representing the metatable of a user-created class from TypeScript code.
|
|
3
|
+
* (TypeScriptToLua transpiles TypeScript classes to a Lua table with a specific kind of metatable.)
|
|
4
|
+
*/
|
|
1
5
|
export interface TSTLClassMetatable {
|
|
2
6
|
____constructor: () => void;
|
|
3
7
|
__index: unknown;
|
package/src/types/TSTLClass.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* This is a type representing a user-created class from TypeScript code.
|
|
2
|
+
* This is a type representing a user-created class from TypeScript code. (TypeScriptToLua
|
|
3
|
+
* transpiles TypeScript classes to a Lua table with a specific kind of metatable.)
|
|
3
4
|
*
|
|
4
5
|
* This type is used by the save data manager to when copying, serializing, and deserializing.
|
|
5
6
|
*/
|