isaacscript-common 80.2.1 → 80.2.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/classes/ModUpgraded.d.ts.map +1 -1
- package/dist/classes/ModUpgraded.lua +18 -8
- package/dist/classes/features/other/DeployJSONRoom.lua +11 -10
- package/dist/classes/features/other/extraConsoleCommands/commands.d.ts +1 -1
- package/dist/classes/features/other/extraConsoleCommands/commands.d.ts.map +1 -1
- package/dist/classes/features/other/extraConsoleCommands/commands.lua +104 -102
- package/dist/classes/features/other/extraConsoleCommands/subroutines.d.ts.map +1 -1
- package/dist/classes/features/other/extraConsoleCommands/subroutines.lua +6 -4
- package/dist/core/constantsFirstLast.d.ts +4 -26
- package/dist/core/constantsFirstLast.d.ts.map +1 -1
- package/dist/core/constantsFirstLast.lua +0 -18
- package/dist/functions/cards.d.ts +1 -0
- package/dist/functions/cards.d.ts.map +1 -1
- package/dist/functions/cards.lua +7 -0
- package/dist/functions/collectibles.d.ts +1 -1
- package/dist/functions/collectibles.d.ts.map +1 -1
- package/dist/functions/collectibles.lua +3 -1
- package/dist/functions/doors.d.ts.map +1 -1
- package/dist/functions/doors.lua +14 -4
- package/dist/functions/entities.d.ts.map +1 -1
- package/dist/functions/entities.lua +19 -30
- package/dist/functions/gridEntities.d.ts.map +1 -1
- package/dist/functions/gridEntities.lua +8 -13
- package/dist/functions/jsonRoom.d.ts.map +1 -1
- package/dist/functions/jsonRoom.lua +13 -5
- package/dist/functions/pills.d.ts +1 -0
- package/dist/functions/pills.d.ts.map +1 -1
- package/dist/functions/pills.lua +6 -0
- package/dist/functions/run.d.ts +1 -2
- package/dist/functions/run.d.ts.map +1 -1
- package/dist/functions/run.lua +2 -3
- package/dist/functions/string.d.ts.map +1 -1
- package/dist/functions/string.lua +5 -3
- package/dist/functions/table.d.ts +3 -2
- package/dist/functions/table.d.ts.map +1 -1
- package/dist/functions/table.lua +3 -2
- package/dist/functions/trinkets.d.ts +1 -0
- package/dist/functions/trinkets.d.ts.map +1 -1
- package/dist/functions/trinkets.lua +6 -0
- package/dist/functions/types.d.ts +9 -0
- package/dist/functions/types.d.ts.map +1 -1
- package/dist/functions/types.lua +17 -0
- package/dist/index.rollup.d.ts +23 -32
- package/dist/isaacscript-common.lua +254 -207
- package/dist/lualib_bundle.lua +5 -0
- package/dist/objects/itemPoolTypeToCollectibleTypesSet.lua +4 -3
- package/package.json +2 -2
- package/src/classes/ModUpgraded.ts +18 -4
- package/src/classes/features/other/DeployJSONRoom.ts +11 -11
- package/src/classes/features/other/extraConsoleCommands/commands.ts +124 -118
- package/src/classes/features/other/extraConsoleCommands/subroutines.ts +5 -4
- package/src/core/constantsFirstLast.ts +3 -37
- package/src/functions/cards.ts +7 -0
- package/src/functions/collectibles.ts +5 -4
- package/src/functions/doors.ts +8 -3
- package/src/functions/entities.ts +40 -19
- package/src/functions/gridEntities.ts +15 -5
- package/src/functions/jsonRoom.ts +18 -5
- package/src/functions/pills.ts +7 -1
- package/src/functions/run.ts +6 -4
- package/src/functions/string.ts +4 -3
- package/src/functions/table.ts +3 -2
- package/src/functions/trinkets.ts +9 -1
- package/src/functions/types.ts +25 -0
- package/src/objects/itemPoolTypeToCollectibleTypesSet.ts +4 -4
package/dist/lualib_bundle.lua
CHANGED
|
@@ -1466,6 +1466,10 @@ local function __TS__NumberIsFinite(value)
|
|
|
1466
1466
|
return type(value) == "number" and value == value and value ~= math.huge and value ~= -math.huge
|
|
1467
1467
|
end
|
|
1468
1468
|
|
|
1469
|
+
local function __TS__NumberIsInteger(value)
|
|
1470
|
+
return __TS__NumberIsFinite(value) and math.floor(value) == value
|
|
1471
|
+
end
|
|
1472
|
+
|
|
1469
1473
|
local function __TS__NumberIsNaN(value)
|
|
1470
1474
|
return value ~= value
|
|
1471
1475
|
end
|
|
@@ -2567,6 +2571,7 @@ return {
|
|
|
2567
2571
|
__TS__New = __TS__New,
|
|
2568
2572
|
__TS__Number = __TS__Number,
|
|
2569
2573
|
__TS__NumberIsFinite = __TS__NumberIsFinite,
|
|
2574
|
+
__TS__NumberIsInteger = __TS__NumberIsInteger,
|
|
2570
2575
|
__TS__NumberIsNaN = __TS__NumberIsNaN,
|
|
2571
2576
|
__TS__ParseInt = __TS__ParseInt,
|
|
2572
2577
|
__TS__ParseFloat = __TS__ParseFloat,
|
|
@@ -9,6 +9,7 @@ local ITEM_POOL_TYPE_VALUES = ____cachedEnumValues.ITEM_POOL_TYPE_VALUES
|
|
|
9
9
|
local itemPoolsJSON = require("data.itempools")
|
|
10
10
|
local ____types = require("functions.types")
|
|
11
11
|
local asCollectibleType = ____types.asCollectibleType
|
|
12
|
+
local parseIntSafe = ____types.parseIntSafe
|
|
12
13
|
local ____itemPoolTypeToItemPoolName = require("maps.itemPoolTypeToItemPoolName")
|
|
13
14
|
local ITEM_POOL_TYPE_TO_ITEM_POOL_NAME = ____itemPoolTypeToItemPoolName.ITEM_POOL_TYPE_TO_ITEM_POOL_NAME
|
|
14
15
|
function getItemPoolJSON(self, itemPoolType)
|
|
@@ -28,11 +29,11 @@ ____exports.ITEM_POOL_TYPE_TO_COLLECTIBLE_TYPES_SET = (function()
|
|
|
28
29
|
else
|
|
29
30
|
local collectibleTypesSet = __TS__New(Set)
|
|
30
31
|
for ____, itemPoolJSONElement in ipairs(itemPoolJSON.Item) do
|
|
31
|
-
local
|
|
32
|
-
if
|
|
32
|
+
local collectibleTypeInt = parseIntSafe(nil, itemPoolJSONElement["$"].Id)
|
|
33
|
+
if collectibleTypeInt == nil then
|
|
33
34
|
error("Failed to parse a collectible type in the \"itempools.json\" file: " .. itemPoolJSONElement["$"].Id)
|
|
34
35
|
end
|
|
35
|
-
local collectibleType = asCollectibleType(nil,
|
|
36
|
+
local collectibleType = asCollectibleType(nil, collectibleTypeInt)
|
|
36
37
|
collectibleTypesSet:add(collectibleType)
|
|
37
38
|
end
|
|
38
39
|
itemPoolTypeToCollectibleTypes[itemPoolType] = collectibleTypesSet
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "isaacscript-common",
|
|
3
|
-
"version": "80.2.
|
|
3
|
+
"version": "80.2.3",
|
|
4
4
|
"description": "Helper functions and features for IsaacScript mods.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"isaac",
|
|
@@ -37,6 +37,6 @@
|
|
|
37
37
|
"lint": "tsx --tsconfig ./scripts/tsconfig.json ./scripts/lint.mts"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"isaac-typescript-definitions": "^39.0.
|
|
40
|
+
"isaac-typescript-definitions": "^39.0.4"
|
|
41
41
|
}
|
|
42
42
|
}
|
|
@@ -5,11 +5,13 @@ import { ISCFeature } from "../enums/ISCFeature";
|
|
|
5
5
|
import { ModCallbackCustom } from "../enums/ModCallbackCustom";
|
|
6
6
|
import { getFeatures } from "../features";
|
|
7
7
|
import { getElapsedTimeSince, getTime } from "../functions/debugFunctions";
|
|
8
|
+
import { isEnumValue } from "../functions/enums";
|
|
8
9
|
import { getParentFunctionDescription, log } from "../functions/log";
|
|
9
10
|
import {
|
|
10
11
|
getTSTLClassConstructor,
|
|
11
12
|
getTSTLClassName,
|
|
12
13
|
} from "../functions/tstlClass";
|
|
14
|
+
import { parseIntSafe } from "../functions/types";
|
|
13
15
|
import { assertDefined } from "../functions/utils";
|
|
14
16
|
import type { AddCallbackParametersCustom } from "../interfaces/private/AddCallbackParametersCustom";
|
|
15
17
|
import type { ModUpgradedInterface } from "../interfaces/private/ModUpgradedInterface";
|
|
@@ -233,12 +235,18 @@ export class ModUpgraded implements Mod {
|
|
|
233
235
|
continue;
|
|
234
236
|
}
|
|
235
237
|
|
|
236
|
-
const modCallbackCustom =
|
|
238
|
+
const modCallbackCustom = parseIntSafe(modCallbackCustomString);
|
|
237
239
|
assertDefined(
|
|
238
240
|
modCallbackCustom,
|
|
239
|
-
|
|
241
|
+
`Failed to convert the string "${modCallbackCustomString}" representing a "ModCallbackCustom" value to a number.`,
|
|
240
242
|
);
|
|
241
243
|
|
|
244
|
+
if (!isEnumValue(modCallbackCustom, ModCallbackCustom)) {
|
|
245
|
+
error(
|
|
246
|
+
`Failed to convert the number ${modCallbackCustom} to a "ModCallbackCustom" value.`,
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
|
|
242
250
|
log(
|
|
243
251
|
`- ModCallbackCustom.${ModCallbackCustom[modCallbackCustom]} (${modCallbackCustom})`,
|
|
244
252
|
);
|
|
@@ -252,12 +260,18 @@ export class ModUpgraded implements Mod {
|
|
|
252
260
|
continue;
|
|
253
261
|
}
|
|
254
262
|
|
|
255
|
-
const iscFeature =
|
|
263
|
+
const iscFeature = parseIntSafe(iscFeatureString);
|
|
256
264
|
assertDefined(
|
|
257
265
|
iscFeature,
|
|
258
|
-
|
|
266
|
+
`Failed to convert the string "${iscFeatureString}" representing a "ISCFeature" value to a number.`,
|
|
259
267
|
);
|
|
260
268
|
|
|
269
|
+
if (!isEnumValue(iscFeature, ISCFeature)) {
|
|
270
|
+
error(
|
|
271
|
+
`Failed to convert the number ${iscFeature} to a "ISCFeature" value.`,
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
|
|
261
275
|
log(`- ISCFeature.${ISCFeature[iscFeature]} (${iscFeature})`);
|
|
262
276
|
}
|
|
263
277
|
}
|
|
@@ -28,7 +28,7 @@ import { isRNG, newRNG } from "../../../functions/rng";
|
|
|
28
28
|
import { gridCoordinatesToWorldPosition } from "../../../functions/roomGrid";
|
|
29
29
|
import { setRoomCleared, setRoomUncleared } from "../../../functions/rooms";
|
|
30
30
|
import { spawnCollectible } from "../../../functions/spawnCollectible";
|
|
31
|
-
import { asCollectibleType } from "../../../functions/types";
|
|
31
|
+
import { asCollectibleType, parseIntSafe } from "../../../functions/types";
|
|
32
32
|
import { assertDefined } from "../../../functions/utils";
|
|
33
33
|
import type { JSONRoom } from "../../../interfaces/JSONRoomsFile";
|
|
34
34
|
import { ReadonlySet } from "../../../types/ReadonlySet";
|
|
@@ -60,40 +60,40 @@ export class DeployJSONRoom extends Feature {
|
|
|
60
60
|
|
|
61
61
|
for (const jsonSpawn of jsonRoom.spawn) {
|
|
62
62
|
const xString = jsonSpawn.$.x;
|
|
63
|
-
const x =
|
|
63
|
+
const x = parseIntSafe(xString);
|
|
64
64
|
assertDefined(
|
|
65
65
|
x,
|
|
66
|
-
`Failed to convert the following x coordinate to
|
|
66
|
+
`Failed to convert the following x coordinate to an integer (for a spawn): ${xString}`,
|
|
67
67
|
);
|
|
68
68
|
|
|
69
69
|
const yString = jsonSpawn.$.y;
|
|
70
|
-
const y =
|
|
70
|
+
const y = parseIntSafe(yString);
|
|
71
71
|
assertDefined(
|
|
72
72
|
y,
|
|
73
|
-
`Failed to convert the following y coordinate to
|
|
73
|
+
`Failed to convert the following y coordinate to an integer (for a spawn): ${yString}`,
|
|
74
74
|
);
|
|
75
75
|
|
|
76
76
|
const jsonEntity = getRandomJSONEntity(jsonSpawn.entity, rng);
|
|
77
77
|
|
|
78
78
|
const entityTypeString = jsonEntity.$.type;
|
|
79
|
-
const entityTypeNumber =
|
|
79
|
+
const entityTypeNumber = parseIntSafe(entityTypeString);
|
|
80
80
|
assertDefined(
|
|
81
81
|
entityTypeNumber,
|
|
82
|
-
`Failed to convert the entity type to
|
|
82
|
+
`Failed to convert the entity type to an integer: ${entityTypeString}`,
|
|
83
83
|
);
|
|
84
84
|
|
|
85
85
|
const variantString = jsonEntity.$.variant;
|
|
86
|
-
const variant =
|
|
86
|
+
const variant = parseIntSafe(variantString);
|
|
87
87
|
assertDefined(
|
|
88
88
|
variant,
|
|
89
|
-
`Failed to convert the entity variant to
|
|
89
|
+
`Failed to convert the entity variant to an integer: ${variant}`,
|
|
90
90
|
);
|
|
91
91
|
|
|
92
92
|
const subTypeString = jsonEntity.$.subtype;
|
|
93
|
-
const subType =
|
|
93
|
+
const subType = parseIntSafe(subTypeString);
|
|
94
94
|
assertDefined(
|
|
95
95
|
subType,
|
|
96
|
-
`Failed to convert the entity sub-type to
|
|
96
|
+
`Failed to convert the entity sub-type to an integer: ${subType}`,
|
|
97
97
|
);
|
|
98
98
|
|
|
99
99
|
const isGridEntity = GRID_ENTITY_XML_TYPE_SET.has(
|