isaacscript-common 12.3.5 → 12.3.7
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 +6 -1
- package/dist/isaacscript-common.lua +1309 -5615
- package/dist/src/features/saveDataManager/main.d.ts.map +1 -1
- package/dist/src/features/saveDataManager/main.lua +1 -1
- package/dist/src/features/saveDataManager/maps.d.ts +3 -0
- package/dist/src/features/saveDataManager/maps.d.ts.map +1 -1
- package/dist/src/features/saveDataManager/maps.lua +3 -0
- package/dist/src/features/saveDataManager/merge.lua +16 -7
- package/dist/src/functions/collectibles.d.ts +6 -1
- package/dist/src/functions/collectibles.d.ts.map +1 -1
- package/dist/src/functions/collectibles.lua +9 -0
- package/dist/src/functions/log.d.ts.map +1 -1
- package/dist/src/indexLua.d.ts +181 -0
- package/dist/src/indexLua.d.ts.map +1 -0
- package/dist/src/indexLua.lua +1282 -0
- package/package.json +1 -1
- package/src/features/saveDataManager/main.ts +6 -1
- package/src/features/saveDataManager/maps.ts +3 -0
- package/src/features/saveDataManager/merge.ts +19 -6
- package/src/functions/collectibles.ts +15 -1
- package/src/functions/log.ts +2 -6
package/package.json
CHANGED
|
@@ -163,7 +163,12 @@ function makeGlowingHourGlassBackup() {
|
|
|
163
163
|
);
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
-
|
|
166
|
+
// We serialize the table so that we can use the `merge` function later on with no other
|
|
167
|
+
// modifications.
|
|
168
|
+
const copiedChildTable = deepCopy(
|
|
169
|
+
childTable,
|
|
170
|
+
SerializationType.SERIALIZE,
|
|
171
|
+
) as Record<string, unknown>;
|
|
167
172
|
saveDataGlowingHourGlass[saveDataKey] = copiedChildTable;
|
|
168
173
|
}
|
|
169
174
|
},
|
|
@@ -13,5 +13,8 @@ export const saveDataConditionalFuncMap = new LuaMap<string, () => boolean>();
|
|
|
13
13
|
/**
|
|
14
14
|
* We backup some save data keys on every new room for the purposes of restoring it when Glowing
|
|
15
15
|
* Hour Glass is used.
|
|
16
|
+
*
|
|
17
|
+
* Note that the save data is backed up in serialized form so that we can use the `merge` function
|
|
18
|
+
* to restore it.
|
|
16
19
|
*/
|
|
17
20
|
export const saveDataGlowingHourGlassMap = new LuaMap<string, SaveData>();
|
|
@@ -59,23 +59,28 @@ export function merge(
|
|
|
59
59
|
|
|
60
60
|
// First, handle the special case of an array with a shallow copy.
|
|
61
61
|
if (isArray(oldObject) && isArray(newTable)) {
|
|
62
|
-
|
|
62
|
+
mergeSerializedArray(oldObject, newTable, traversalDescription);
|
|
63
63
|
return;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
// Depending on whether we are working on a Lua table or a TypeScriptToLua object, we need to
|
|
67
67
|
// iterate in a specific way.
|
|
68
68
|
if (isTSTLMap(oldObject) || isTSTLSet(oldObject) || isDefaultMap(oldObject)) {
|
|
69
|
-
|
|
69
|
+
mergeSerializedTSTLObject(oldObject, newTable, traversalDescription);
|
|
70
70
|
} else {
|
|
71
|
-
|
|
71
|
+
mergeSerializedTable(oldObject, newTable, traversalDescription);
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
function
|
|
75
|
+
function mergeSerializedArray(
|
|
76
76
|
oldArray: LuaMap<AnyNotNil, unknown>,
|
|
77
77
|
newArray: LuaMap<AnyNotNil, unknown>,
|
|
78
|
+
traversalDescription: string,
|
|
78
79
|
) {
|
|
80
|
+
if (SAVE_DATA_MANAGER_DEBUG) {
|
|
81
|
+
log(`merge encountered an array: ${traversalDescription}`);
|
|
82
|
+
}
|
|
83
|
+
|
|
79
84
|
// Assume that we should blow away all array values with whatever is present in the incoming
|
|
80
85
|
// array.
|
|
81
86
|
clearTable(oldArray);
|
|
@@ -88,11 +93,15 @@ function mergeArray(
|
|
|
88
93
|
);
|
|
89
94
|
}
|
|
90
95
|
|
|
91
|
-
function
|
|
96
|
+
function mergeSerializedTSTLObject(
|
|
92
97
|
oldObject: Map<AnyNotNil, unknown> | Set<AnyNotNil>,
|
|
93
98
|
newTable: LuaMap<AnyNotNil, unknown>,
|
|
94
99
|
traversalDescription: string,
|
|
95
100
|
) {
|
|
101
|
+
if (SAVE_DATA_MANAGER_DEBUG) {
|
|
102
|
+
log(`merge encountered a TSTL object: ${traversalDescription}`);
|
|
103
|
+
}
|
|
104
|
+
|
|
96
105
|
// We blow away the old object and recursively copy over all of the incoming values.
|
|
97
106
|
oldObject.clear();
|
|
98
107
|
|
|
@@ -139,11 +148,15 @@ function mergeTSTLObject(
|
|
|
139
148
|
);
|
|
140
149
|
}
|
|
141
150
|
|
|
142
|
-
function
|
|
151
|
+
function mergeSerializedTable(
|
|
143
152
|
oldTable: LuaMap<AnyNotNil, unknown>,
|
|
144
153
|
newTable: LuaMap<AnyNotNil, unknown>,
|
|
145
154
|
traversalDescription: string,
|
|
146
155
|
) {
|
|
156
|
+
if (SAVE_DATA_MANAGER_DEBUG) {
|
|
157
|
+
log(`merge encountered a Lua table: ${traversalDescription}`);
|
|
158
|
+
}
|
|
159
|
+
|
|
147
160
|
iterateTableInOrder(
|
|
148
161
|
newTable,
|
|
149
162
|
(key, value) => {
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
ItemType,
|
|
10
10
|
PickupPrice,
|
|
11
11
|
PickupVariant,
|
|
12
|
+
RenderMode,
|
|
12
13
|
RoomType,
|
|
13
14
|
} from "isaac-typescript-definitions";
|
|
14
15
|
import { game, itemConfig } from "../core/cachedClasses";
|
|
@@ -408,7 +409,12 @@ export function isActiveCollectible(collectibleType: CollectibleType): boolean {
|
|
|
408
409
|
return itemType === ItemType.ACTIVE;
|
|
409
410
|
}
|
|
410
411
|
|
|
411
|
-
/**
|
|
412
|
+
/**
|
|
413
|
+
* Returns true if the collectible has a red question mark sprite.
|
|
414
|
+
*
|
|
415
|
+
* Note that this function will not work properly in a render callback with the `RenderMode` set to
|
|
416
|
+
* `RenderMode.WATER_REFLECT`. If this is detected, this function will throw a run-time error.
|
|
417
|
+
*/
|
|
412
418
|
export function isBlindCollectible(collectible: EntityPickup): boolean {
|
|
413
419
|
if (!isCollectible(collectible)) {
|
|
414
420
|
const entityID = getEntityID(collectible);
|
|
@@ -417,6 +423,14 @@ export function isBlindCollectible(collectible: EntityPickup): boolean {
|
|
|
417
423
|
);
|
|
418
424
|
}
|
|
419
425
|
|
|
426
|
+
const room = game.GetRoom();
|
|
427
|
+
const renderMode = room.GetRenderMode();
|
|
428
|
+
if (renderMode === RenderMode.WATER_REFLECT) {
|
|
429
|
+
error(
|
|
430
|
+
'The "isBlindCollectible" function will not work properly in a render callback with the render mode equal to "RenderMode.WATER_REFLECT". Make sure that you properly account for this case if you are calling this function in a render callback.',
|
|
431
|
+
);
|
|
432
|
+
}
|
|
433
|
+
|
|
420
434
|
const sprite = collectible.GetSprite();
|
|
421
435
|
const animation = sprite.GetAnimation();
|
|
422
436
|
const frame = sprite.GetFrame();
|
package/src/functions/log.ts
CHANGED
|
@@ -365,9 +365,7 @@ export function logTable(luaTable: unknown, parentTables = 0): void {
|
|
|
365
365
|
// Put it in an IIFE so that it will show as "func" instead of "logTable" and align with the
|
|
366
366
|
// other text. We have to use a non-arrow function to prevent Lua language server errors with
|
|
367
367
|
// the self argument.
|
|
368
|
-
|
|
369
|
-
// eslint-disable-next-line func-names
|
|
370
|
-
(function () {
|
|
368
|
+
(function func() {
|
|
371
369
|
log(
|
|
372
370
|
`${indentation}n/a (encountered a variable of type "${typeof luaTable}" instead of a table)`,
|
|
373
371
|
);
|
|
@@ -397,9 +395,7 @@ export function logTable(luaTable: unknown, parentTables = 0): void {
|
|
|
397
395
|
// Put it in an IIFE so that it will show as "func" instead of "logTable" and align with the other
|
|
398
396
|
// text. We have to use a non-arrow function to prevent Lua language server errors with the self
|
|
399
397
|
// argument.
|
|
400
|
-
|
|
401
|
-
// eslint-disable-next-line func-names
|
|
402
|
-
(function () {
|
|
398
|
+
(function func() {
|
|
403
399
|
log(`${indentation}The size of the table was: ${numElements}`);
|
|
404
400
|
})();
|
|
405
401
|
}
|