isaacscript-common 12.3.6 → 12.3.8
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 +7 -2
- package/dist/isaacscript-common.lua +1315 -5624
- package/dist/src/features/fadeInRemover.lua +1 -6
- package/dist/src/features/saveDataManager/exports.d.ts +1 -1
- package/dist/src/features/saveDataManager/exports.lua +1 -1
- package/dist/src/features/saveDataManager/main.d.ts.map +1 -1
- package/dist/src/features/saveDataManager/main.lua +22 -8
- 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/package.json +1 -1
- package/src/features/fadeInRemover.ts +1 -1
- package/src/features/saveDataManager/exports.ts +1 -1
- package/src/features/saveDataManager/main.ts +24 -0
- package/src/functions/collectibles.ts +15 -1
|
@@ -28,12 +28,7 @@ v = {run = {removedFadeIn = false}}
|
|
|
28
28
|
---
|
|
29
29
|
-- @internal
|
|
30
30
|
function ____exports.fadeInRemoverInit(self, mod)
|
|
31
|
-
saveDataManager(
|
|
32
|
-
nil,
|
|
33
|
-
FEATURE_NAME,
|
|
34
|
-
v,
|
|
35
|
-
function() return false end
|
|
36
|
-
)
|
|
31
|
+
saveDataManager(nil, FEATURE_NAME, v, false)
|
|
37
32
|
mod:AddCallback(ModCallback.POST_RENDER, postRender)
|
|
38
33
|
end
|
|
39
34
|
--- Removes the fade-in that occurs at the beginning of a run. If this behavior is desired, call this
|
|
@@ -74,7 +74,7 @@ import { SaveData } from "../../interfaces/SaveData";
|
|
|
74
74
|
*
|
|
75
75
|
* Some features may have variables that need to be automatically reset per run/level, but not saved
|
|
76
76
|
* to disk on game exit. (For example, if they contain functions or other non-serializable data.)
|
|
77
|
-
* For these cases, set the second argument to `
|
|
77
|
+
* For these cases, set the second argument to `false`.
|
|
78
78
|
*
|
|
79
79
|
* Note that when the player uses Glowing Hour Glass, the save data manager will automatically
|
|
80
80
|
* restore any variables on a "run" or "level" object with a backup that was created when the room
|
|
@@ -93,7 +93,7 @@ local saveDataMap = ____maps.saveDataMap
|
|
|
93
93
|
--
|
|
94
94
|
-- Some features may have variables that need to be automatically reset per run/level, but not saved
|
|
95
95
|
-- to disk on game exit. (For example, if they contain functions or other non-serializable data.)
|
|
96
|
-
-- For these cases, set the second argument to `
|
|
96
|
+
-- For these cases, set the second argument to `false`.
|
|
97
97
|
--
|
|
98
98
|
-- Note that when the player uses Glowing Hour Glass, the save data manager will automatically
|
|
99
99
|
-- restore any variables on a "run" or "level" object with a backup that was created when the room
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../../src/features/saveDataManager/main.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAGxD,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAMtD,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AA2BrD,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI,CAelE;
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../../src/features/saveDataManager/main.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAGxD,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAMtD,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AA2BrD,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI,CAelE;AAkND,wBAAgB,sBAAsB,CACpC,cAAc,EAAE,MAAM,EACtB,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,WAAW,GACvB,IAAI,CA4CN;AAiBD,wBAAgB,wBAAwB,IAAI,IAAI,CAM/C;AAED,wBAAgB,wBAAwB,IAAI,IAAI,CAM/C"}
|
|
@@ -89,15 +89,22 @@ function makeGlowingHourGlassBackup(self)
|
|
|
89
89
|
nil,
|
|
90
90
|
saveDataMap,
|
|
91
91
|
function(____, subscriberName, saveData)
|
|
92
|
+
local conditionalFunc = saveDataConditionalFuncMap[subscriberName]
|
|
93
|
+
if conditionalFunc ~= nil then
|
|
94
|
+
local shouldSave = conditionalFunc(nil)
|
|
95
|
+
if not shouldSave then
|
|
96
|
+
return
|
|
97
|
+
end
|
|
98
|
+
end
|
|
92
99
|
for ____, saveDataKey in ipairs(SAVE_DATA_MANAGER_GLOWING_HOUR_GLASS_BACKUP_KEYS) do
|
|
93
100
|
do
|
|
94
101
|
local childTable = saveData[saveDataKey]
|
|
95
102
|
if childTable == nil then
|
|
96
|
-
goto
|
|
103
|
+
goto __continue20
|
|
97
104
|
end
|
|
98
105
|
local childTableLuaMap = childTable
|
|
99
106
|
if childTableLuaMap[SAVE_DATA_MANAGER_GLOWING_HOUR_GLASS_IGNORE_KEY] ~= nil then
|
|
100
|
-
goto
|
|
107
|
+
goto __continue20
|
|
101
108
|
end
|
|
102
109
|
local saveDataGlowingHourGlass = saveDataGlowingHourGlassMap[subscriberName]
|
|
103
110
|
if saveDataGlowingHourGlass == nil then
|
|
@@ -107,7 +114,7 @@ function makeGlowingHourGlassBackup(self)
|
|
|
107
114
|
local copiedChildTable = deepCopy(nil, childTable, SerializationType.SERIALIZE)
|
|
108
115
|
saveDataGlowingHourGlass[saveDataKey] = copiedChildTable
|
|
109
116
|
end
|
|
110
|
-
::
|
|
117
|
+
::__continue20::
|
|
111
118
|
end
|
|
112
119
|
end,
|
|
113
120
|
SAVE_DATA_MANAGER_DEBUG
|
|
@@ -118,27 +125,34 @@ function restoreGlowingHourGlassBackup(self)
|
|
|
118
125
|
nil,
|
|
119
126
|
saveDataMap,
|
|
120
127
|
function(____, subscriberName, saveData)
|
|
128
|
+
local conditionalFunc = saveDataConditionalFuncMap[subscriberName]
|
|
129
|
+
if conditionalFunc ~= nil then
|
|
130
|
+
local shouldSave = conditionalFunc(nil)
|
|
131
|
+
if not shouldSave then
|
|
132
|
+
return
|
|
133
|
+
end
|
|
134
|
+
end
|
|
121
135
|
for ____, saveDataKey in ipairs(SAVE_DATA_MANAGER_GLOWING_HOUR_GLASS_BACKUP_KEYS) do
|
|
122
136
|
do
|
|
123
137
|
local childTable = saveData[saveDataKey]
|
|
124
138
|
if childTable == nil then
|
|
125
|
-
goto
|
|
139
|
+
goto __continue29
|
|
126
140
|
end
|
|
127
141
|
local childTableLuaMap = childTable
|
|
128
142
|
if childTableLuaMap[SAVE_DATA_MANAGER_GLOWING_HOUR_GLASS_IGNORE_KEY] ~= nil then
|
|
129
|
-
goto
|
|
143
|
+
goto __continue29
|
|
130
144
|
end
|
|
131
145
|
local saveDataGlowingHourGlass = saveDataGlowingHourGlassMap[subscriberName]
|
|
132
146
|
if saveDataGlowingHourGlass == nil then
|
|
133
|
-
goto
|
|
147
|
+
goto __continue29
|
|
134
148
|
end
|
|
135
149
|
local childTableBackup = saveDataGlowingHourGlass[saveDataKey]
|
|
136
150
|
if childTableBackup == nil then
|
|
137
|
-
goto
|
|
151
|
+
goto __continue29
|
|
138
152
|
end
|
|
139
153
|
merge(nil, childTable, childTableBackup, subscriberName .. "__glowingHourGlass")
|
|
140
154
|
end
|
|
141
|
-
::
|
|
155
|
+
::__continue29::
|
|
142
156
|
end
|
|
143
157
|
end,
|
|
144
158
|
SAVE_DATA_MANAGER_DEBUG
|
|
@@ -143,7 +143,12 @@ export declare function getCollectibleTags(collectibleType: CollectibleType): Bi
|
|
|
143
143
|
export declare function getVanillaCollectibleTypeRange(): CollectibleType[];
|
|
144
144
|
/** Returns true if the item type in the item config is equal to `ItemType.ITEM_ACTIVE`. */
|
|
145
145
|
export declare function isActiveCollectible(collectibleType: CollectibleType): boolean;
|
|
146
|
-
/**
|
|
146
|
+
/**
|
|
147
|
+
* Returns true if the collectible has a red question mark sprite.
|
|
148
|
+
*
|
|
149
|
+
* Note that this function will not work properly in a render callback with the `RenderMode` set to
|
|
150
|
+
* `RenderMode.WATER_REFLECT`. If this is detected, this function will throw a run-time error.
|
|
151
|
+
*/
|
|
147
152
|
export declare function isBlindCollectible(collectible: EntityPickup): boolean;
|
|
148
153
|
/**
|
|
149
154
|
* Returns whether or not the given collectible is a "glitched" item. All items are replaced by
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collectibles.d.ts","sourceRoot":"","sources":["../../../src/functions/collectibles.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EAEvB,eAAe,EAEf,oBAAoB,EACpB,aAAa,EAEb,QAAQ,EACR,WAAW,
|
|
1
|
+
{"version":3,"file":"collectibles.d.ts","sourceRoot":"","sources":["../../../src/functions/collectibles.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EAEvB,eAAe,EAEf,oBAAoB,EACpB,aAAa,EAEb,QAAQ,EACR,WAAW,EAIZ,MAAM,8BAA8B,CAAC;AAgBtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAwB7D,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,YAAY,GAAG,IAAI,CAEtE;AAED,6FAA6F;AAC7F,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,GACd,OAAO,CAsBT;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,eAAe,EAAE,eAAe,GAC/B,oBAAoB,CAOtB;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CACvC,eAAe,EAAE,eAAe,GAC/B,MAAM,CAeR;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAC1C,eAAe,EAAE,eAAe,GAC/B,GAAG,CAYL;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,CAC3C,eAAe,EAAE,eAAe,EAChC,MAAM,EAAE,YAAY,GACnB,WAAW,CAyBb;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CACvC,eAAe,EAAE,eAAe,GAC/B,MAAM,CAOR;A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AC/B,OAAO,CAGT;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,eAAe,EAAE,eAAe,GAC/B,OAAO,CAET;AAED,wBAAgB,sBAAsB,CACpC,eAAe,EAAE,eAAe,GAC/B,OAAO,CAGT;AAED,wBAAgB,wBAAwB,CACtC,eAAe,EAAE,eAAe,GAC/B,OAAO,CAET;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,eAAe,EAAE,eAAe,GAAG,MAAM,CAa7E;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gCAAgC,CAC9C,eAAe,EAAE,eAAe,GAC/B,IAAI,CAQN;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,WAAW,EAAE,YAAY,GAAG,IAAI,CAS5E;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,YAAY,GAAG,IAAI,CASnE;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,YAAY,GAAG,IAAI,CAUnE;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,YAAY,GAAG,IAAI,CAuBtE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,YAAY,EACzB,OAAO,EAAE,MAAM,GAAG,SAAS,GAC1B,IAAI,CAqBN;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,YAAY,EACzB,kBAAkB,EAAE,eAAe,GAClC,IAAI,CA2BN;AAED;;;GAGG;AACH,wBAAgB,qCAAqC,IAAI,IAAI,CAK5D"}
|
|
@@ -9,6 +9,7 @@ local ItemConfigTagZero = ____isaac_2Dtypescript_2Ddefinitions.ItemConfigTagZero
|
|
|
9
9
|
local ItemType = ____isaac_2Dtypescript_2Ddefinitions.ItemType
|
|
10
10
|
local PickupPrice = ____isaac_2Dtypescript_2Ddefinitions.PickupPrice
|
|
11
11
|
local PickupVariant = ____isaac_2Dtypescript_2Ddefinitions.PickupVariant
|
|
12
|
+
local RenderMode = ____isaac_2Dtypescript_2Ddefinitions.RenderMode
|
|
12
13
|
local RoomType = ____isaac_2Dtypescript_2Ddefinitions.RoomType
|
|
13
14
|
local ____cachedClasses = require("src.core.cachedClasses")
|
|
14
15
|
local game = ____cachedClasses.game
|
|
@@ -356,11 +357,19 @@ function ____exports.isActiveCollectible(self, collectibleType)
|
|
|
356
357
|
return itemType == ItemType.ACTIVE
|
|
357
358
|
end
|
|
358
359
|
--- Returns true if the collectible has a red question mark sprite.
|
|
360
|
+
--
|
|
361
|
+
-- Note that this function will not work properly in a render callback with the `RenderMode` set to
|
|
362
|
+
-- `RenderMode.WATER_REFLECT`. If this is detected, this function will throw a run-time error.
|
|
359
363
|
function ____exports.isBlindCollectible(self, collectible)
|
|
360
364
|
if not isCollectible(nil, collectible) then
|
|
361
365
|
local entityID = getEntityID(nil, collectible)
|
|
362
366
|
error("The \"isBlindCollectible\" function was given a non-collectible: " .. entityID)
|
|
363
367
|
end
|
|
368
|
+
local room = game:GetRoom()
|
|
369
|
+
local renderMode = room:GetRenderMode()
|
|
370
|
+
if renderMode == RenderMode.WATER_REFLECT then
|
|
371
|
+
error("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.")
|
|
372
|
+
end
|
|
364
373
|
local sprite = collectible:GetSprite()
|
|
365
374
|
local animation = sprite:GetAnimation()
|
|
366
375
|
local frame = sprite:GetFrame()
|
package/package.json
CHANGED
|
@@ -90,7 +90,7 @@ import {
|
|
|
90
90
|
*
|
|
91
91
|
* Some features may have variables that need to be automatically reset per run/level, but not saved
|
|
92
92
|
* to disk on game exit. (For example, if they contain functions or other non-serializable data.)
|
|
93
|
-
* For these cases, set the second argument to `
|
|
93
|
+
* For these cases, set the second argument to `false`.
|
|
94
94
|
*
|
|
95
95
|
* Note that when the player uses Glowing Hour Glass, the save data manager will automatically
|
|
96
96
|
* restore any variables on a "run" or "level" object with a backup that was created when the room
|
|
@@ -138,6 +138,18 @@ function makeGlowingHourGlassBackup() {
|
|
|
138
138
|
iterateTableInOrder(
|
|
139
139
|
saveDataMap,
|
|
140
140
|
(subscriberName, saveData) => {
|
|
141
|
+
// We make the Glowing Hour Glass backup using `SerializationType.SERIALIZE`, which means that
|
|
142
|
+
// we cannot operate on unserializable data, such as functions. Save data that utilizes
|
|
143
|
+
// unserializable data will typically be marked using a conditional function that evaluates to
|
|
144
|
+
// false, so we skip all save data that matches this criteria.
|
|
145
|
+
const conditionalFunc = saveDataConditionalFuncMap.get(subscriberName);
|
|
146
|
+
if (conditionalFunc !== undefined) {
|
|
147
|
+
const shouldSave = conditionalFunc();
|
|
148
|
+
if (!shouldSave) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
141
153
|
for (const saveDataKey of SAVE_DATA_MANAGER_GLOWING_HOUR_GLASS_BACKUP_KEYS) {
|
|
142
154
|
const childTable = saveData[saveDataKey];
|
|
143
155
|
if (childTable === undefined) {
|
|
@@ -180,6 +192,18 @@ function restoreGlowingHourGlassBackup() {
|
|
|
180
192
|
iterateTableInOrder(
|
|
181
193
|
saveDataMap,
|
|
182
194
|
(subscriberName, saveData) => {
|
|
195
|
+
// We make the Glowing Hour Glass backup using `SerializationType.SERIALIZE`, which means that
|
|
196
|
+
// we cannot operate on unserializable data, such as functions. Save data that utilizes
|
|
197
|
+
// unserializable data will typically be marked using a conditional function that evaluates to
|
|
198
|
+
// false, so we skip all save data that matches this criteria.
|
|
199
|
+
const conditionalFunc = saveDataConditionalFuncMap.get(subscriberName);
|
|
200
|
+
if (conditionalFunc !== undefined) {
|
|
201
|
+
const shouldSave = conditionalFunc();
|
|
202
|
+
if (!shouldSave) {
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
183
207
|
for (const saveDataKey of SAVE_DATA_MANAGER_GLOWING_HOUR_GLASS_BACKUP_KEYS) {
|
|
184
208
|
const childTable = saveData[saveDataKey];
|
|
185
209
|
if (childTable === undefined) {
|
|
@@ -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();
|