isaacscript-common 25.4.0 → 25.5.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.rollup.d.ts
CHANGED
|
@@ -8052,6 +8052,13 @@ export declare function isRedKeyRoom(roomGridIndex?: int): boolean;
|
|
|
8052
8052
|
*/
|
|
8053
8053
|
export declare function isReflectionRender(): boolean;
|
|
8054
8054
|
|
|
8055
|
+
/**
|
|
8056
|
+
* Helper function to check if the player is using Afterbirth+ or Repentance.
|
|
8057
|
+
*
|
|
8058
|
+
* This function should always be used over the `REPENTANCE` constant, since it is not safe.
|
|
8059
|
+
*/
|
|
8060
|
+
export declare function isRepentance(): boolean;
|
|
8061
|
+
|
|
8055
8062
|
/**
|
|
8056
8063
|
* Helper function to check if the provided door leads to the "secret exit" off-grid room that takes
|
|
8057
8064
|
* you to the Repentance floor.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
--[[
|
|
2
2
|
|
|
3
|
-
isaacscript-common 25.
|
|
3
|
+
isaacscript-common 25.5.0
|
|
4
4
|
|
|
5
5
|
This is the "isaacscript-common" library, which was created with the IsaacScript tool.
|
|
6
6
|
|
|
@@ -16252,6 +16252,8 @@ local ____isaac_2Dtypescript_2Ddefinitions = require("lua_modules.isaac-typescri
|
|
|
16252
16252
|
local RenderMode = ____isaac_2Dtypescript_2Ddefinitions.RenderMode
|
|
16253
16253
|
local ____cachedClasses = require("src.core.cachedClasses")
|
|
16254
16254
|
local game = ____cachedClasses.game
|
|
16255
|
+
local ____types = require("src.functions.types")
|
|
16256
|
+
local isFunction = ____types.isFunction
|
|
16255
16257
|
function ____exports.eRange(self, start, ____end, increment)
|
|
16256
16258
|
if increment == nil then
|
|
16257
16259
|
increment = 1
|
|
@@ -16294,6 +16296,18 @@ function ____exports.isReflectionRender(self)
|
|
|
16294
16296
|
local renderMode = room:GetRenderMode()
|
|
16295
16297
|
return renderMode == RenderMode.WATER_REFLECT
|
|
16296
16298
|
end
|
|
16299
|
+
function ____exports.isRepentance(self)
|
|
16300
|
+
local metatable = getmetatable(Sprite)
|
|
16301
|
+
if metatable == nil then
|
|
16302
|
+
error("Failed to get the metatable of the Sprite global table.")
|
|
16303
|
+
end
|
|
16304
|
+
local classTable = metatable.__class
|
|
16305
|
+
if classTable == nil then
|
|
16306
|
+
error("Failed to get the \"__class\" key of the Sprite metatable.")
|
|
16307
|
+
end
|
|
16308
|
+
local getAnimation = classTable.GetAnimation
|
|
16309
|
+
return isFunction(nil, getAnimation)
|
|
16310
|
+
end
|
|
16297
16311
|
____exports["repeat"] = function(self, n, func)
|
|
16298
16312
|
do
|
|
16299
16313
|
local i = 0
|
|
@@ -51,6 +51,12 @@ export declare function inRange(num: int, start: int, end: int): boolean;
|
|
|
51
51
|
* This function is typically used to early return from a render function if it returns true.
|
|
52
52
|
*/
|
|
53
53
|
export declare function isReflectionRender(): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Helper function to check if the player is using Afterbirth+ or Repentance.
|
|
56
|
+
*
|
|
57
|
+
* This function should always be used over the `REPENTANCE` constant, since it is not safe.
|
|
58
|
+
*/
|
|
59
|
+
export declare function isRepentance(): boolean;
|
|
54
60
|
/**
|
|
55
61
|
* Helper function to repeat code N times. This is faster to type and cleaner than using a for loop.
|
|
56
62
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/functions/utils.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/functions/utils.ts"],"names":[],"mappings":";AAIA;;;;;;;;;;;GAWG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,SAAS,SAAI,GAAG,GAAG,EAAE,CAWlE;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,GAAG,EAAE,OAAO,EACZ,oBAAoB,EAAE,MAAM,GAC3B,MAAM,CAQR;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,SAAS,SAAI,GAAG,GAAG,EAAE,CAOlE;AAED;;;;;;;;;GASG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,GAAG,OAAO,CAE/D;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,IAAI,OAAO,CAI5C;AAED;;;;GAIG;AACH,wBAAgB,YAAY,IAAI,OAAO,CAetC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,IAAI,GAAG,IAAI,CAI3D;AAED;;;;;;;;;;;;GAYG;AAEH,wBAAgB,IAAI,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAG"}
|
|
@@ -3,6 +3,8 @@ local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitio
|
|
|
3
3
|
local RenderMode = ____isaac_2Dtypescript_2Ddefinitions.RenderMode
|
|
4
4
|
local ____cachedClasses = require("src.core.cachedClasses")
|
|
5
5
|
local game = ____cachedClasses.game
|
|
6
|
+
local ____types = require("src.functions.types")
|
|
7
|
+
local isFunction = ____types.isFunction
|
|
6
8
|
--- Helper function to return an array of integers with the specified range, inclusive on the lower
|
|
7
9
|
-- end and exclusive on the high end. (The "e" stands for exclusive.)
|
|
8
10
|
--
|
|
@@ -82,6 +84,21 @@ function ____exports.isReflectionRender(self)
|
|
|
82
84
|
local renderMode = room:GetRenderMode()
|
|
83
85
|
return renderMode == RenderMode.WATER_REFLECT
|
|
84
86
|
end
|
|
87
|
+
--- Helper function to check if the player is using Afterbirth+ or Repentance.
|
|
88
|
+
--
|
|
89
|
+
-- This function should always be used over the `REPENTANCE` constant, since it is not safe.
|
|
90
|
+
function ____exports.isRepentance(self)
|
|
91
|
+
local metatable = getmetatable(Sprite)
|
|
92
|
+
if metatable == nil then
|
|
93
|
+
error("Failed to get the metatable of the Sprite global table.")
|
|
94
|
+
end
|
|
95
|
+
local classTable = metatable.__class
|
|
96
|
+
if classTable == nil then
|
|
97
|
+
error("Failed to get the \"__class\" key of the Sprite metatable.")
|
|
98
|
+
end
|
|
99
|
+
local getAnimation = classTable.GetAnimation
|
|
100
|
+
return isFunction(nil, getAnimation)
|
|
101
|
+
end
|
|
85
102
|
--- Helper function to repeat code N times. This is faster to type and cleaner than using a for loop.
|
|
86
103
|
--
|
|
87
104
|
-- For example:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "isaacscript-common",
|
|
3
|
-
"version": "25.
|
|
3
|
+
"version": "25.5.0",
|
|
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/index.rollup.d.ts",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"isaac-typescript-definitions": "^11.1.
|
|
25
|
+
"isaac-typescript-definitions": "^11.1.6"
|
|
26
26
|
}
|
|
27
27
|
}
|
package/src/functions/utils.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { RenderMode } from "isaac-typescript-definitions";
|
|
2
2
|
import { game } from "../core/cachedClasses";
|
|
3
|
+
import { isFunction } from "./types";
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Helper function to return an array of integers with the specified range, inclusive on the lower
|
|
@@ -93,6 +94,28 @@ export function isReflectionRender(): boolean {
|
|
|
93
94
|
return renderMode === RenderMode.WATER_REFLECT;
|
|
94
95
|
}
|
|
95
96
|
|
|
97
|
+
/**
|
|
98
|
+
* Helper function to check if the player is using Afterbirth+ or Repentance.
|
|
99
|
+
*
|
|
100
|
+
* This function should always be used over the `REPENTANCE` constant, since it is not safe.
|
|
101
|
+
*/
|
|
102
|
+
export function isRepentance(): boolean {
|
|
103
|
+
const metatable = getmetatable(Sprite) as LuaMap<string, unknown> | undefined;
|
|
104
|
+
if (metatable === undefined) {
|
|
105
|
+
error("Failed to get the metatable of the Sprite global table.");
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const classTable = metatable.get("__class") as
|
|
109
|
+
| LuaMap<string, unknown>
|
|
110
|
+
| undefined;
|
|
111
|
+
if (classTable === undefined) {
|
|
112
|
+
error('Failed to get the "__class" key of the Sprite metatable.');
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const getAnimation = classTable.get("GetAnimation");
|
|
116
|
+
return isFunction(getAnimation);
|
|
117
|
+
}
|
|
118
|
+
|
|
96
119
|
/**
|
|
97
120
|
* Helper function to repeat code N times. This is faster to type and cleaner than using a for loop.
|
|
98
121
|
*
|