isaacscript-common 20.3.1 → 20.4.0
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 +111 -53
- package/dist/isaacscript-common.lua +414 -389
- package/dist/src/classes/callbacks/PostSlotDestroyed.d.ts +0 -8
- package/dist/src/classes/callbacks/PostSlotDestroyed.d.ts.map +1 -1
- package/dist/src/classes/callbacks/PostSlotDestroyed.lua +3 -51
- package/dist/src/classes/features/callbackLogic/SlotDestroyedDetection.d.ts +36 -0
- package/dist/src/classes/features/callbackLogic/SlotDestroyedDetection.d.ts.map +1 -0
- package/dist/src/classes/features/callbackLogic/SlotDestroyedDetection.lua +91 -0
- package/dist/src/classes/features/other/ExtraConsoleCommands.d.ts.map +1 -1
- package/dist/src/classes/features/other/ExtraConsoleCommands.lua +2 -3
- package/dist/src/classes/features/other/RoomHistory.d.ts.map +1 -1
- package/dist/src/classes/features/other/RoomHistory.lua +6 -1
- package/dist/src/classes/features/other/SaveDataManager.d.ts +3 -2
- package/dist/src/classes/features/other/SaveDataManager.d.ts.map +1 -1
- package/dist/src/classes/features/other/extraConsoleCommands/commands.d.ts.map +1 -1
- package/dist/src/classes/features/other/extraConsoleCommands/commands.lua +69 -127
- package/dist/src/classes/features/other/extraConsoleCommands/subroutines.d.ts.map +1 -1
- package/dist/src/classes/features/other/extraConsoleCommands/subroutines.lua +11 -22
- package/dist/src/enums/ISCFeature.d.ts +44 -43
- package/dist/src/enums/ISCFeature.d.ts.map +1 -1
- package/dist/src/enums/ISCFeature.lua +45 -43
- package/dist/src/enums/ModCallbackCustom.d.ts +5 -1
- package/dist/src/enums/ModCallbackCustom.d.ts.map +1 -1
- package/dist/src/enums/SlotDestructionType.d.ts +13 -0
- package/dist/src/enums/SlotDestructionType.d.ts.map +1 -1
- package/dist/src/features.d.ts +46 -43
- package/dist/src/features.d.ts.map +1 -1
- package/dist/src/features.lua +3 -0
- package/dist/src/functions/deepCopyTests.d.ts.map +1 -1
- package/dist/src/functions/deepCopyTests.lua +1 -3
- package/dist/src/functions/logMisc.d.ts.map +1 -1
- package/dist/src/functions/logMisc.lua +1 -3
- package/dist/src/functions/mergeTests.d.ts.map +1 -1
- package/dist/src/functions/mergeTests.lua +2 -5
- package/dist/src/functions/slots.d.ts +4 -0
- package/dist/src/functions/slots.d.ts.map +1 -0
- package/dist/src/functions/slots.lua +27 -0
- package/dist/src/functions/utils.d.ts +3 -4
- package/dist/src/functions/utils.d.ts.map +1 -1
- package/dist/src/functions/utils.lua +8 -6
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.lua +8 -0
- package/dist/src/interfaces/RoomDescription.d.ts +1 -0
- package/dist/src/interfaces/RoomDescription.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/classes/callbacks/PostSlotDestroyed.ts +2 -72
- package/src/classes/features/callbackLogic/SlotDestroyedDetection.ts +163 -0
- package/src/classes/features/other/ExtraConsoleCommands.ts +3 -6
- package/src/classes/features/other/RoomHistory.ts +6 -0
- package/src/classes/features/other/SaveDataManager.ts +3 -2
- package/src/classes/features/other/extraConsoleCommands/commands.ts +70 -78
- package/src/classes/features/other/extraConsoleCommands/subroutines.ts +11 -12
- package/src/enums/ISCFeature.ts +1 -0
- package/src/enums/ModCallbackCustom.ts +5 -1
- package/src/enums/SlotDestructionType.ts +14 -0
- package/src/features.ts +6 -0
- package/src/functions/deepCopyTests.ts +1 -2
- package/src/functions/logMisc.ts +1 -2
- package/src/functions/mergeTests.ts +2 -4
- package/src/functions/slots.ts +23 -0
- package/src/functions/utils.ts +7 -6
- package/src/index.ts +1 -0
- package/src/interfaces/RoomDescription.ts +1 -0
package/src/enums/ISCFeature.ts
CHANGED
|
@@ -1601,7 +1601,11 @@ export enum ModCallbackCustom {
|
|
|
1601
1601
|
* matches the sub-type provided.
|
|
1602
1602
|
*
|
|
1603
1603
|
* ```ts
|
|
1604
|
-
* function postSlotAnimationChanged(
|
|
1604
|
+
* function postSlotAnimationChanged(
|
|
1605
|
+
* slot: Entity,
|
|
1606
|
+
* previousAnimation: string,
|
|
1607
|
+
* currentAnimation: string,
|
|
1608
|
+
* ): void {}
|
|
1605
1609
|
* ```
|
|
1606
1610
|
*/
|
|
1607
1611
|
POST_SLOT_ANIMATION_CHANGED,
|
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
/** This is used in the `POST_SLOT_DESTROYED` custom callback. */
|
|
2
2
|
export enum SlotDestructionType {
|
|
3
|
+
/**
|
|
4
|
+
* When a machine or a beggar is blown up by a bomb or is otherwise removed without spawning a
|
|
5
|
+
* collectible.
|
|
6
|
+
*
|
|
7
|
+
* Note that the destruction type for a Crane Game will be `SlotDestructionType.NORMAL`, even if
|
|
8
|
+
* it destroyed via spawning three separate collectibles.
|
|
9
|
+
*/
|
|
3
10
|
NORMAL,
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* When a machine or a beggar is removed while spawning a collectible reward.
|
|
14
|
+
*
|
|
15
|
+
* Note that the destruction type for a Crane Game will be `SlotDestructionType.NORMAL`, even if
|
|
16
|
+
* it destroyed via spawning three separate collectibles.
|
|
17
|
+
*/
|
|
4
18
|
COLLECTIBLE_PAYOUT,
|
|
5
19
|
}
|
package/src/features.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { GridEntityUpdateDetection } from "./classes/features/callbackLogic/Grid
|
|
|
10
10
|
import { ItemPickupDetection } from "./classes/features/callbackLogic/ItemPickupDetection";
|
|
11
11
|
import { PlayerCollectibleDetection } from "./classes/features/callbackLogic/PlayerCollectibleDetection";
|
|
12
12
|
import { PlayerReorderedCallbacks } from "./classes/features/callbackLogic/PlayerReorderedCallbacks";
|
|
13
|
+
import { SlotDestroyedDetection } from "./classes/features/callbackLogic/SlotDestroyedDetection";
|
|
13
14
|
import { SlotRenderDetection } from "./classes/features/callbackLogic/SlotRenderDetection";
|
|
14
15
|
import { SlotUpdateDetection } from "./classes/features/callbackLogic/SlotUpdateDetection";
|
|
15
16
|
import { CharacterHealthConversion } from "./classes/features/other/CharacterHealthConversion";
|
|
@@ -71,6 +72,7 @@ export interface ISCFeatureToClass {
|
|
|
71
72
|
[ISCFeature.ITEM_PICKUP_DETECTION]: ItemPickupDetection;
|
|
72
73
|
[ISCFeature.PLAYER_COLLECTIBLE_DETECTION]: PlayerCollectibleDetection;
|
|
73
74
|
[ISCFeature.PLAYER_REORDERED_CALLBACKS]: PlayerReorderedCallbacks;
|
|
75
|
+
[ISCFeature.SLOT_DESTROYED_DETECTION]: SlotDestroyedDetection;
|
|
74
76
|
[ISCFeature.SLOT_RENDER_DETECTION]: SlotRenderDetection;
|
|
75
77
|
[ISCFeature.SLOT_UPDATE_DETECTION]: SlotUpdateDetection;
|
|
76
78
|
|
|
@@ -222,6 +224,10 @@ export function getFeatures(
|
|
|
222
224
|
callbacks[ModCallbackCustom.POST_PLAYER_RENDER_REORDERED],
|
|
223
225
|
callbacks[ModCallbackCustom.POST_PLAYER_UPDATE_REORDERED],
|
|
224
226
|
),
|
|
227
|
+
[ISCFeature.SLOT_DESTROYED_DETECTION]: new SlotDestroyedDetection(
|
|
228
|
+
callbacks[ModCallbackCustom.POST_SLOT_DESTROYED],
|
|
229
|
+
roomHistory,
|
|
230
|
+
),
|
|
225
231
|
[ISCFeature.SLOT_RENDER_DETECTION]: new SlotRenderDetection(
|
|
226
232
|
callbacks[ModCallbackCustom.POST_SLOT_RENDER],
|
|
227
233
|
callbacks[ModCallbackCustom.POST_SLOT_ANIMATION_CHANGED],
|
|
@@ -6,7 +6,6 @@ import { deepCopy } from "./deepCopy";
|
|
|
6
6
|
import { log } from "./log";
|
|
7
7
|
import { isDefaultMap, isTSTLMap, isTSTLSet } from "./tstlClass";
|
|
8
8
|
import { isNumber, isString, isTable } from "./types";
|
|
9
|
-
import { printConsole } from "./utils";
|
|
10
9
|
|
|
11
10
|
/**
|
|
12
11
|
* Run the suite of tests that prove that the "deepCopy" helper function works properly.
|
|
@@ -41,7 +40,7 @@ export function runDeepCopyTests(): void {
|
|
|
41
40
|
|
|
42
41
|
const successText = "All deep copy tests passed!";
|
|
43
42
|
log(successText);
|
|
44
|
-
|
|
43
|
+
print(successText);
|
|
45
44
|
}
|
|
46
45
|
|
|
47
46
|
function copiedObjectIsTable() {
|
package/src/functions/logMisc.ts
CHANGED
|
@@ -28,7 +28,6 @@ import { iterateTableInOrder } from "./table";
|
|
|
28
28
|
import { getTrinketName } from "./trinkets";
|
|
29
29
|
import { isDefaultMap, isTSTLMap, isTSTLSet } from "./tstlClass";
|
|
30
30
|
import { isTable, isUserdata } from "./types";
|
|
31
|
-
import { printConsole } from "./utils";
|
|
32
31
|
import { vectorToString } from "./vector";
|
|
33
32
|
|
|
34
33
|
/** Helper function to enumerate all of the values in an array. */
|
|
@@ -85,7 +84,7 @@ export function logEntityID(entity: Entity): void {
|
|
|
85
84
|
export function logError(msg: string): void {
|
|
86
85
|
const errorMsg = `Error: ${msg}`;
|
|
87
86
|
log(errorMsg);
|
|
88
|
-
|
|
87
|
+
print(errorMsg);
|
|
89
88
|
}
|
|
90
89
|
|
|
91
90
|
/** Helper function for printing out every flag that is turned on. Useful when debugging. */
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { DefaultMap } from "../classes/DefaultMap";
|
|
2
2
|
import { SerializationType } from "../enums/SerializationType";
|
|
3
3
|
import { deepCopy } from "./deepCopy";
|
|
4
|
-
import { log } from "./log";
|
|
5
4
|
import { merge } from "./merge";
|
|
6
5
|
import { isRNG, newRNG } from "./rng";
|
|
7
6
|
import { isSerializedIsaacAPIClass } from "./serialization";
|
|
8
|
-
import {
|
|
7
|
+
import { logAndPrint } from "./utils";
|
|
9
8
|
import { isVector, serializeVector } from "./vector";
|
|
10
9
|
|
|
11
10
|
/**
|
|
@@ -29,8 +28,7 @@ export function runMergeTests(): void {
|
|
|
29
28
|
oldTableHasRNGSerialized();
|
|
30
29
|
|
|
31
30
|
const successText = "All merge tests passed!";
|
|
32
|
-
|
|
33
|
-
printConsole(successText);
|
|
31
|
+
logAndPrint(successText);
|
|
34
32
|
}
|
|
35
33
|
|
|
36
34
|
function oldTableHasUpdatedValue() {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { SlotVariant } from "isaac-typescript-definitions";
|
|
2
|
+
import { isSlot } from "./entityTypes";
|
|
3
|
+
|
|
4
|
+
const SLOT_MACHINE_VARIANTS: ReadonlySet<SlotVariant> = new Set([
|
|
5
|
+
SlotVariant.SLOT_MACHINE, // 1
|
|
6
|
+
SlotVariant.BLOOD_DONATION_MACHINE, // 2,
|
|
7
|
+
SlotVariant.FORTUNE_TELLING_MACHINE, // 3
|
|
8
|
+
SlotVariant.DONATION_MACHINE, // 8
|
|
9
|
+
SlotVariant.SHOP_RESTOCK_MACHINE, // 10
|
|
10
|
+
SlotVariant.GREED_DONATION_MACHINE, // 11
|
|
11
|
+
SlotVariant.MOMS_DRESSING_TABLE, // 12
|
|
12
|
+
SlotVariant.CRANE_GAME, // 16
|
|
13
|
+
SlotVariant.CONFESSIONAL, // 17
|
|
14
|
+
]);
|
|
15
|
+
|
|
16
|
+
/** Returns true for the specific variants of `EntityType.SLOT` that are machines. */
|
|
17
|
+
export function isSlotMachine(entity: Entity): boolean {
|
|
18
|
+
if (!isSlot(entity)) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return SLOT_MACHINE_VARIANTS.has(entity.Variant);
|
|
23
|
+
}
|
package/src/functions/utils.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { RenderMode } from "isaac-typescript-definitions";
|
|
2
2
|
import { game } from "../core/cachedClasses";
|
|
3
3
|
import { CONSOLE_COMMANDS_SET } from "../sets/consoleCommandsSet";
|
|
4
|
+
import { log } from "./log";
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Helper function to return an array of integers with the specified range, inclusive on the lower
|
|
@@ -103,18 +104,18 @@ export function isVanillaConsoleCommand(commandName: string): boolean {
|
|
|
103
104
|
}
|
|
104
105
|
|
|
105
106
|
/**
|
|
106
|
-
* Helper function to
|
|
107
|
-
*
|
|
108
|
-
* of the message (which `Isaac.ConsoleOutput` does not do by default).
|
|
107
|
+
* Helper function to log a message to the "log.txt" file and to print it to the screen at the same
|
|
108
|
+
* time.
|
|
109
109
|
*/
|
|
110
|
-
export function
|
|
111
|
-
|
|
110
|
+
export function logAndPrint(msg: string): void {
|
|
111
|
+
log(msg);
|
|
112
|
+
print(msg);
|
|
112
113
|
}
|
|
113
114
|
|
|
114
115
|
/** Helper function to print whether something was enabled or disabled to the in-game console. */
|
|
115
116
|
export function printEnabled(enabled: boolean, description: string): void {
|
|
116
117
|
const enabledText = enabled ? "Enabled" : "Disabled";
|
|
117
|
-
|
|
118
|
+
print(`${enabledText} ${description}.`);
|
|
118
119
|
}
|
|
119
120
|
|
|
120
121
|
/**
|
package/src/index.ts
CHANGED
|
@@ -103,6 +103,7 @@ export * from "./functions/run";
|
|
|
103
103
|
export * from "./functions/seeds";
|
|
104
104
|
export * from "./functions/serialization";
|
|
105
105
|
export * from "./functions/set";
|
|
106
|
+
export * from "./functions/slots";
|
|
106
107
|
export * from "./functions/sound";
|
|
107
108
|
export * from "./functions/spawnCollectible";
|
|
108
109
|
export * from "./functions/sprites";
|