isaacscript-common 13.3.2 → 13.3.3
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 +18 -10
- package/dist/isaacscript-common.lua +3884 -3858
- package/dist/src/classes/ModUpgraded.lua +2 -2
- package/dist/src/core/upgradeMod.d.ts +2 -1
- package/dist/src/core/upgradeMod.d.ts.map +1 -1
- package/dist/src/core/upgradeMod.lua +2 -1
- package/dist/src/functions/benchmark.d.ts +0 -12
- package/dist/src/functions/benchmark.d.ts.map +1 -1
- package/dist/src/functions/benchmark.lua +0 -19
- package/dist/src/functions/debugFunctions.d.ts +18 -24
- package/dist/src/functions/debugFunctions.d.ts.map +1 -1
- package/dist/src/functions/debugFunctions.lua +53 -73
- package/dist/src/functions/dev.d.ts +20 -0
- package/dist/src/functions/dev.d.ts.map +1 -0
- package/dist/src/functions/dev.lua +36 -0
- package/dist/src/functions/globals.d.ts +7 -0
- package/dist/src/functions/globals.d.ts.map +1 -1
- package/dist/src/functions/globals.lua +24 -0
- package/dist/src/functions/gridEntitiesSpecific.d.ts.map +1 -1
- package/dist/src/functions/gridEntitiesSpecific.lua +6 -12
- 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/indexLua.d.ts +1 -0
- package/dist/src/indexLua.d.ts.map +1 -1
- package/dist/src/indexLua.lua +8 -0
- package/package.json +1 -1
- package/src/classes/ModUpgraded.ts +1 -1
- package/src/core/upgradeMod.ts +2 -1
- package/src/functions/benchmark.ts +0 -23
- package/src/functions/debugFunctions.ts +38 -55
- package/src/functions/dev.ts +32 -0
- package/src/functions/globals.ts +27 -1
- package/src/functions/gridEntitiesSpecific.ts +6 -18
- package/src/index.ts +1 -0
package/src/core/upgradeMod.ts
CHANGED
|
@@ -31,7 +31,8 @@ import { loadShaderCrashFix } from "../shaderCrashFix";
|
|
|
31
31
|
* @param debug Optional. Whether to log additional output when a callback is fired. Default is
|
|
32
32
|
* false.
|
|
33
33
|
* @param timeThreshold Optional. If provided, will only log callbacks that take longer than the
|
|
34
|
-
* specified number of seconds
|
|
34
|
+
* specified number of seconds (if the "--luadebug" launch flag is turned on)
|
|
35
|
+
* or milliseconds (if the "--luadebug" launch flag is turned off).
|
|
35
36
|
* @returns The upgraded mod object.
|
|
36
37
|
*/
|
|
37
38
|
export function upgradeMod(
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { SECOND_IN_MILLISECONDS } from "../core/constants";
|
|
2
1
|
import { log } from "./log";
|
|
3
2
|
|
|
4
3
|
/**
|
|
@@ -40,25 +39,3 @@ export function benchmark(
|
|
|
40
39
|
|
|
41
40
|
return averages;
|
|
42
41
|
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Helper function to get the current time in seconds for benchmarking / profiling purposes.
|
|
46
|
-
*
|
|
47
|
-
* - If the "--luadebug" flag is enabled, then this function will use the `socket.gettime` method,
|
|
48
|
-
* which returns the epoch timestamp in seconds (e.g. "1640320492.5779"). This is preferable over
|
|
49
|
-
* the `Isaac.GetTime` method, since it has one extra decimal point of precision.
|
|
50
|
-
* - If the "--luadebug" flag is disabled, then this function will use the `Isaac.GetTime` method,
|
|
51
|
-
* which returns the number of seconds since the computer's operating system was started (e.g.
|
|
52
|
-
* "739454.963"). (The milliseconds return value of `Isaac.GetTime` is converted to seconds to
|
|
53
|
-
* align with the return value of `socket.gettime`.)
|
|
54
|
-
*/
|
|
55
|
-
export function getTime(): float {
|
|
56
|
-
const [ok, requiredSocket] = pcall(require, "socket");
|
|
57
|
-
if (ok) {
|
|
58
|
-
const socket = requiredSocket as Socket;
|
|
59
|
-
return socket.gettime();
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// The "--luadebug" launch option is not enabled.
|
|
63
|
-
return Isaac.GetTime() / SECOND_IN_MILLISECONDS;
|
|
64
|
-
}
|
|
@@ -1,37 +1,42 @@
|
|
|
1
|
-
import { ModUpgraded } from "../classes/ModUpgraded";
|
|
2
|
-
import { enableExtraConsoleCommands } from "../features/extraConsoleCommands/exports";
|
|
3
|
-
import { removeFadeIn } from "../features/fadeInRemover";
|
|
4
|
-
import { enableFastReset } from "../features/fastReset";
|
|
5
|
-
import { saveDataManagerSetGlobal } from "../features/saveDataManager/exports";
|
|
6
|
-
import * as logExports from "./log";
|
|
7
1
|
import { log } from "./log";
|
|
8
|
-
import * as logEntitiesExports from "./logEntities";
|
|
9
|
-
import * as logMiscExports from "./logMisc";
|
|
10
2
|
|
|
11
3
|
/**
|
|
12
|
-
* Helper function to
|
|
13
|
-
* should not be enabled when your mod goes to production (i.e. when it is uploaded to the Steam
|
|
14
|
-
* Workshop).
|
|
4
|
+
* Helper function to get the current time for benchmarking / profiling purposes.
|
|
15
5
|
*
|
|
16
|
-
* The
|
|
6
|
+
* The return value will either be in seconds or milliseconds, depending on if the "--luadebug" flag
|
|
7
|
+
* is turned on or not.
|
|
17
8
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
9
|
+
* If the "--luadebug" flag is present, then this function will use the `socket.gettime` method,
|
|
10
|
+
* which returns the epoch timestamp in seconds (e.g. "1640320492.5779"). This is preferable over
|
|
11
|
+
* the more conventional `Isaac.GetTime` method, since it has one extra decimal point of precision.
|
|
12
|
+
*
|
|
13
|
+
* If the "--luadebug" flag is not present, then this function will use the `Isaac.GetTime` method,
|
|
14
|
+
* which returns the number of milliseconds since the computer's operating system was started (e.g.
|
|
15
|
+
* "739454963").
|
|
16
|
+
*
|
|
17
|
+
* @param useSocketIfAvailable Optional. Whether to use the `socket.gettime` method, if available.
|
|
18
|
+
* Default is true. If set to false, the `Isaac.GetTime()` method will
|
|
19
|
+
* always be used.
|
|
27
20
|
*/
|
|
28
|
-
export function
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
21
|
+
export function getTime(useSocketIfAvailable = true): float {
|
|
22
|
+
if (useSocketIfAvailable) {
|
|
23
|
+
if (SandboxGetTime !== undefined) {
|
|
24
|
+
return SandboxGetTime();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (isLuaDebugEnabled()) {
|
|
28
|
+
const [ok, requiredSocket] = pcall(require, "socket");
|
|
29
|
+
if (ok) {
|
|
30
|
+
const socket = requiredSocket as Socket;
|
|
31
|
+
return socket.gettime();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// We could divide the result by 1000 in order to unify the return type with `socket.gettime`.
|
|
37
|
+
// However, this causes floating point inaccuracies in the number when subtracting, so it is
|
|
38
|
+
// better to keep it as an integer.
|
|
39
|
+
return Isaac.GetTime();
|
|
35
40
|
}
|
|
36
41
|
|
|
37
42
|
/**
|
|
@@ -41,16 +46,17 @@ export function enableDevFeatures(mod: ModUpgraded): void {
|
|
|
41
46
|
* enabled.
|
|
42
47
|
*/
|
|
43
48
|
export function getTraceback(): string {
|
|
49
|
+
if (SandboxGetTraceback !== undefined) {
|
|
50
|
+
return SandboxGetTraceback();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// "debug" will be equal to undefined if the "--luadebug" launch flag is not present.
|
|
44
54
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
45
55
|
if (debug !== undefined) {
|
|
46
56
|
// The --luadebug launch flag is enabled.
|
|
47
57
|
return debug.traceback();
|
|
48
58
|
}
|
|
49
59
|
|
|
50
|
-
if (SandboxGetTraceback !== undefined) {
|
|
51
|
-
return SandboxGetTraceback();
|
|
52
|
-
}
|
|
53
|
-
|
|
54
60
|
return 'stack traceback:\n(the "--luadebug" flag is not enabled)';
|
|
55
61
|
}
|
|
56
62
|
|
|
@@ -75,29 +81,6 @@ export function isLuaDebugEnabled(): boolean {
|
|
|
75
81
|
return _G.package !== undefined;
|
|
76
82
|
}
|
|
77
83
|
|
|
78
|
-
/**
|
|
79
|
-
* Converts every `isaacscript-common` function that begins with "log" to a global function.
|
|
80
|
-
*
|
|
81
|
-
* This is useful when printing out variables from the in-game debug console.
|
|
82
|
-
*/
|
|
83
|
-
export function setLogFunctionsGlobal(): void {
|
|
84
|
-
const globals = _G as Record<string, unknown>;
|
|
85
|
-
|
|
86
|
-
for (const exports of [logExports, logMiscExports, logEntitiesExports]) {
|
|
87
|
-
// eslint-disable-next-line isaacscript/no-object-any
|
|
88
|
-
for (const [logFuncName, logFunc] of Object.entries(exports)) {
|
|
89
|
-
globals[logFuncName] = logFunc;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export function setTracebackFunctionsGlobal(): void {
|
|
95
|
-
const globals = _G as Record<string, unknown>;
|
|
96
|
-
|
|
97
|
-
globals["getTraceback"] = getTraceback;
|
|
98
|
-
globals["traceback"] = traceback;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
84
|
/**
|
|
102
85
|
* Helper function to print a stack trace to the "log.txt" file, similar to JavaScript's
|
|
103
86
|
* `console.trace` function.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ModUpgraded } from "../classes/ModUpgraded";
|
|
2
|
+
import { enableExtraConsoleCommands } from "../features/extraConsoleCommands/exports";
|
|
3
|
+
import { removeFadeIn } from "../features/fadeInRemover";
|
|
4
|
+
import { enableFastReset } from "../features/fastReset";
|
|
5
|
+
import { saveDataManagerSetGlobal } from "../features/saveDataManager/exports";
|
|
6
|
+
import { setLogFunctionsGlobal, setTracebackFunctionsGlobal } from "./globals";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Helper function to enable some IsaacScript features that are useful when developing a mod. They
|
|
10
|
+
* should not be enabled when your mod goes to production (i.e. when it is uploaded to the Steam
|
|
11
|
+
* Workshop).
|
|
12
|
+
*
|
|
13
|
+
* The list of development features that are enabled are as follows:
|
|
14
|
+
*
|
|
15
|
+
* - `saveDataManagerSetGlobal` - Sets your local variables registered with the save data manager as
|
|
16
|
+
* global variables so you can access them from the in-game console.
|
|
17
|
+
* - `setLogFunctionsGlobal` - Sets the various log functions global so that you can access them
|
|
18
|
+
* from the in-game console.
|
|
19
|
+
* - `enableExtraConsoleCommands` - Enables many extra in-game console commands that make warping
|
|
20
|
+
* around easier (like e.g. `angel` to warp to the Angel Room).
|
|
21
|
+
* - `enableFastReset` - Makes it so that the r key resets the game instantaneously.
|
|
22
|
+
* - `removeFadeIn` - Removes the slow fade in that occurs at the beginning of the run, so that you
|
|
23
|
+
* can immediately start playing or testing.
|
|
24
|
+
*/
|
|
25
|
+
export function enableDevFeatures(mod: ModUpgraded): void {
|
|
26
|
+
saveDataManagerSetGlobal();
|
|
27
|
+
setLogFunctionsGlobal();
|
|
28
|
+
setTracebackFunctionsGlobal();
|
|
29
|
+
enableExtraConsoleCommands(mod);
|
|
30
|
+
enableFastReset();
|
|
31
|
+
removeFadeIn();
|
|
32
|
+
}
|
package/src/functions/globals.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import { isLuaDebugEnabled } from "./debugFunctions";
|
|
1
|
+
import { getTraceback, isLuaDebugEnabled, traceback } from "./debugFunctions";
|
|
2
|
+
import * as logExports from "./log";
|
|
2
3
|
import { log } from "./log";
|
|
4
|
+
import * as logEntitiesExports from "./logEntities";
|
|
5
|
+
import * as logMiscExports from "./logMisc";
|
|
3
6
|
import { addSetsToSet, copySet } from "./set";
|
|
4
7
|
import { twoDimensionalSort } from "./utils";
|
|
5
8
|
|
|
@@ -240,3 +243,26 @@ export function logNewGlobals(): void {
|
|
|
240
243
|
log(`${i + 1}) ${key} - ${value}`);
|
|
241
244
|
});
|
|
242
245
|
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Converts every `isaacscript-common` function that begins with "log" to a global function.
|
|
249
|
+
*
|
|
250
|
+
* This is useful when printing out variables from the in-game debug console.
|
|
251
|
+
*/
|
|
252
|
+
export function setLogFunctionsGlobal(): void {
|
|
253
|
+
const globals = _G as Record<string, unknown>;
|
|
254
|
+
|
|
255
|
+
for (const exports of [logExports, logMiscExports, logEntitiesExports]) {
|
|
256
|
+
// eslint-disable-next-line isaacscript/no-object-any
|
|
257
|
+
for (const [logFuncName, logFunc] of Object.entries(exports)) {
|
|
258
|
+
globals[logFuncName] = logFunc;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
export function setTracebackFunctionsGlobal(): void {
|
|
264
|
+
const globals = _G as Record<string, unknown>;
|
|
265
|
+
|
|
266
|
+
globals["getTraceback"] = getTraceback;
|
|
267
|
+
globals["traceback"] = traceback;
|
|
268
|
+
}
|
|
@@ -43,10 +43,8 @@ export function getCrawlSpaces(
|
|
|
43
43
|
* is -1, which matches every variant.
|
|
44
44
|
*/
|
|
45
45
|
export function getPits(pitVariant: PitVariant = -1): GridEntityPit[] {
|
|
46
|
-
const gridEntities = getGridEntities();
|
|
47
|
-
|
|
48
46
|
const pits: GridEntityPit[] = [];
|
|
49
|
-
for (const gridEntity of
|
|
47
|
+
for (const gridEntity of getGridEntities()) {
|
|
50
48
|
const pit = gridEntity.ToPit();
|
|
51
49
|
if (pit !== undefined) {
|
|
52
50
|
const gridEntityVariant = pit.GetVariant();
|
|
@@ -68,10 +66,8 @@ export function getPits(pitVariant: PitVariant = -1): GridEntityPit[] {
|
|
|
68
66
|
export function getPoops(
|
|
69
67
|
poopVariant: PoopGridEntityVariant = -1,
|
|
70
68
|
): GridEntityPoop[] {
|
|
71
|
-
const gridEntities = getGridEntities();
|
|
72
|
-
|
|
73
69
|
const poops: GridEntityPoop[] = [];
|
|
74
|
-
for (const gridEntity of
|
|
70
|
+
for (const gridEntity of getGridEntities()) {
|
|
75
71
|
const poop = gridEntity.ToPoop();
|
|
76
72
|
if (poop !== undefined) {
|
|
77
73
|
const gridEntityVariant = poop.GetVariant();
|
|
@@ -93,10 +89,8 @@ export function getPoops(
|
|
|
93
89
|
export function getPressurePlates(
|
|
94
90
|
pressurePlateVariant: PressurePlateVariant = -1,
|
|
95
91
|
): GridEntityPressurePlate[] {
|
|
96
|
-
const gridEntities = getGridEntities();
|
|
97
|
-
|
|
98
92
|
const pressurePlates: GridEntityPressurePlate[] = [];
|
|
99
|
-
for (const gridEntity of
|
|
93
|
+
for (const gridEntity of getGridEntities()) {
|
|
100
94
|
const pressurePlate = gridEntity.ToPressurePlate();
|
|
101
95
|
if (pressurePlate !== undefined) {
|
|
102
96
|
const gridEntityVariant = pressurePlate.GetVariant();
|
|
@@ -121,10 +115,8 @@ export function getPressurePlates(
|
|
|
121
115
|
* types of grid entities can be the `GridEntityRock` class.
|
|
122
116
|
*/
|
|
123
117
|
export function getRocks(variant = -1): GridEntityRock[] {
|
|
124
|
-
const gridEntities = getGridEntities();
|
|
125
|
-
|
|
126
118
|
const rocks: GridEntityRock[] = [];
|
|
127
|
-
for (const gridEntity of
|
|
119
|
+
for (const gridEntity of getGridEntities()) {
|
|
128
120
|
const rock = gridEntity.ToRock();
|
|
129
121
|
if (rock !== undefined) {
|
|
130
122
|
const gridEntityVariant = rock.GetVariant();
|
|
@@ -139,10 +131,8 @@ export function getRocks(variant = -1): GridEntityRock[] {
|
|
|
139
131
|
|
|
140
132
|
/** Helper function to get all of the `GridEntitySpikes` in the room. */
|
|
141
133
|
export function getSpikes(variant = -1): GridEntitySpikes[] {
|
|
142
|
-
const gridEntities = getGridEntities();
|
|
143
|
-
|
|
144
134
|
const spikes: GridEntitySpikes[] = [];
|
|
145
|
-
for (const gridEntity of
|
|
135
|
+
for (const gridEntity of getGridEntities()) {
|
|
146
136
|
const spike = gridEntity.ToSpikes();
|
|
147
137
|
if (spike !== undefined) {
|
|
148
138
|
const gridEntityVariant = spike.GetVariant();
|
|
@@ -157,10 +147,8 @@ export function getSpikes(variant = -1): GridEntitySpikes[] {
|
|
|
157
147
|
|
|
158
148
|
/** Helper function to get all of the `GridEntityTNT` in the room. */
|
|
159
149
|
export function getTNT(variant = -1): GridEntityTNT[] {
|
|
160
|
-
const gridEntities = getGridEntities();
|
|
161
|
-
|
|
162
150
|
const tntArray: GridEntityTNT[] = [];
|
|
163
|
-
for (const gridEntity of
|
|
151
|
+
for (const gridEntity of getGridEntities()) {
|
|
164
152
|
const tnt = gridEntity.ToTNT();
|
|
165
153
|
if (tnt !== undefined) {
|
|
166
154
|
const gridEntityVariant = tnt.GetVariant();
|
package/src/index.ts
CHANGED
|
@@ -68,6 +68,7 @@ export * from "./functions/curses";
|
|
|
68
68
|
export * from "./functions/debugFunctions";
|
|
69
69
|
export * from "./functions/deepCopy";
|
|
70
70
|
export * from "./functions/deepCopyTests";
|
|
71
|
+
export * from "./functions/dev";
|
|
71
72
|
export * from "./functions/dimensions";
|
|
72
73
|
export * from "./functions/direction";
|
|
73
74
|
export * from "./functions/doors";
|