isaacscript-common 2.0.9 → 2.0.12

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.
Files changed (65) hide show
  1. package/dist/classes/DefaultMap.d.ts +2 -1
  2. package/dist/constantsMax.d.ts +1 -1
  3. package/dist/constantsMax.lua +3 -3
  4. package/dist/enums/ModCallbackCustom.d.ts +0 -3
  5. package/dist/features/deployJSONRoom.d.ts +16 -9
  6. package/dist/features/deployJSONRoom.lua +2 -2
  7. package/dist/features/disableInputs.d.ts +6 -6
  8. package/dist/features/disableSound.d.ts +2 -2
  9. package/dist/features/extraConsoleCommands/commands.d.ts +10 -9
  10. package/dist/features/runInNFrames.d.ts +2 -1
  11. package/dist/features/saveDataManager/exports.d.ts +8 -6
  12. package/dist/features/sirenHelpers.d.ts +1 -1
  13. package/dist/functions/array.d.ts +10 -9
  14. package/dist/functions/array.lua +1 -2
  15. package/dist/functions/benchmark.d.ts +1 -1
  16. package/dist/functions/cards.d.ts +7 -5
  17. package/dist/functions/cards.lua +2 -2
  18. package/dist/functions/charge.d.ts +6 -3
  19. package/dist/functions/collectibleCacheFlag.lua +1 -2
  20. package/dist/functions/collectibleSet.lua +2 -2
  21. package/dist/functions/collectibleTag.lua +2 -2
  22. package/dist/functions/collectibles.d.ts +9 -6
  23. package/dist/functions/color.d.ts +1 -1
  24. package/dist/functions/deepCopy.d.ts +2 -1
  25. package/dist/functions/entity.d.ts +9 -6
  26. package/dist/functions/entity.lua +1 -1
  27. package/dist/functions/entitySpecific.d.ts +20 -11
  28. package/dist/functions/enums.d.ts +11 -1
  29. package/dist/functions/enums.lua +14 -0
  30. package/dist/functions/familiars.d.ts +5 -5
  31. package/dist/functions/flag.d.ts +6 -2
  32. package/dist/functions/flying.d.ts +1 -1
  33. package/dist/functions/gridEntity.d.ts +13 -8
  34. package/dist/functions/gridEntity.lua +2 -1
  35. package/dist/functions/input.lua +2 -2
  36. package/dist/functions/kColor.d.ts +1 -1
  37. package/dist/functions/map.d.ts +2 -1
  38. package/dist/functions/math.d.ts +1 -19
  39. package/dist/functions/math.lua +0 -30
  40. package/dist/functions/npc.d.ts +2 -2
  41. package/dist/functions/pickups.d.ts +2 -2
  42. package/dist/functions/pills.d.ts +2 -1
  43. package/dist/functions/player.d.ts +2 -2
  44. package/dist/functions/playerIndex.d.ts +2 -1
  45. package/dist/functions/positionVelocity.d.ts +9 -5
  46. package/dist/functions/random.d.ts +7 -5
  47. package/dist/functions/rng.d.ts +1 -1
  48. package/dist/functions/rooms.d.ts +5 -4
  49. package/dist/functions/rooms.lua +2 -2
  50. package/dist/functions/set.d.ts +1 -1
  51. package/dist/functions/spawnCollectible.d.ts +4 -4
  52. package/dist/functions/sprite.lua +2 -2
  53. package/dist/functions/transformations.d.ts +2 -1
  54. package/dist/functions/trinketCacheFlag.lua +2 -2
  55. package/dist/functions/trinketGive.d.ts +1 -1
  56. package/dist/functions/trinketSet.lua +2 -2
  57. package/dist/functions/trinkets.d.ts +7 -4
  58. package/dist/functions/ui.d.ts +2 -2
  59. package/dist/functions/utils.d.ts +22 -2
  60. package/dist/functions/utils.lua +30 -0
  61. package/dist/functions/vector.d.ts +1 -1
  62. package/dist/types/CollectibleIndex.d.ts +2 -1
  63. package/dist/types/PlayerIndex.d.ts +2 -1
  64. package/dist/upgradeMod.d.ts +2 -4
  65. package/package.json +4 -3
@@ -41,8 +41,9 @@ export declare function getRoomTypeName(roomType: RoomType): string;
41
41
  * the list.
42
42
  *
43
43
  * @param includeExtraDimensionalRooms Optional. On some floors (e.g. Downpour 2, Mines 2),
44
- * extra-dimensional rooms are automatically be generated and can be seen when you iterate over the
45
- * `RoomList`. Default is false.
44
+ * extra-dimensional rooms are automatically be generated and
45
+ * can be seen when you iterate over the `RoomList`. Default is
46
+ * false.
46
47
  */
47
48
  export declare function getRooms(includeExtraDimensionalRooms?: boolean): RoomDescriptor[];
48
49
  /**
@@ -113,8 +114,8 @@ export declare function inStartingRoom(): boolean;
113
114
  * This function will only check rooms in the current dimension.
114
115
  *
115
116
  * @param onlyCheckRoomTypes Optional. A whitelist of room types. If specified, room types not in
116
- * the array will be ignored. If not specified, then all rooms will be checked. Undefined by
117
- * default.
117
+ * the array will be ignored. If not specified, then all rooms will be
118
+ * checked. Undefined by default.
118
119
  */
119
120
  export declare function isAllRoomsClear(onlyCheckRoomTypes?: RoomType[]): boolean;
120
121
  export declare function isDoorSlotValidAtGridIndex(doorSlot: DoorSlot, roomGridIndex: int): boolean;
@@ -39,8 +39,6 @@ local ____entity = require("functions.entity")
39
39
  local getEntities = ____entity.getEntities
40
40
  local ____flag = require("functions.flag")
41
41
  local hasFlag = ____flag.hasFlag
42
- local ____math = require("functions.math")
43
- local erange = ____math.erange
44
42
  local ____positionVelocity = require("functions.positionVelocity")
45
43
  local getEntityPositions = ____positionVelocity.getEntityPositions
46
44
  local getEntityVelocities = ____positionVelocity.getEntityVelocities
@@ -58,6 +56,8 @@ local getRoomStageID = ____roomData.getRoomStageID
58
56
  local getRoomSubType = ____roomData.getRoomSubType
59
57
  local ____roomShape = require("functions.roomShape")
60
58
  local getGridIndexDelta = ____roomShape.getGridIndexDelta
59
+ local ____utils = require("functions.utils")
60
+ local erange = ____utils.erange
61
61
  function ____exports.getRooms(self, includeExtraDimensionalRooms)
62
62
  if includeExtraDimensionalRooms == nil then
63
63
  includeExtraDimensionalRooms = false
@@ -26,7 +26,7 @@ export declare function deleteSetsFromSet<T>(mainSet: Set<T>, ...setsToRemove: A
26
26
  *
27
27
  * @param set The set to get an element from.
28
28
  * @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
29
- * `RNG.Next` method will be called. Default is `getRandomSeed()`.
29
+ * `RNG.Next` method will be called. Default is `getRandomSeed()`.
30
30
  * @param exceptions Optional. An array of elements to skip over if selected.
31
31
  */
32
32
  export declare function getRandomSetElement<T>(set: Set<T> | ReadonlySet<T>, seedOrRNG?: Seed | RNG, exceptions?: T[] | readonly T[]): T;
@@ -8,11 +8,11 @@ import { CollectibleType } from "isaac-typescript-definitions";
8
8
  * @param collectibleType The collectible type to spawn.
9
9
  * @param position The position to spawn the collectible at.
10
10
  * @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
11
- * `RNG.Next` method will be called. Default is `getRandomSeed()`.
11
+ * `RNG.Next` method will be called. Default is `getRandomSeed()`.
12
12
  * @param options Optional. Set to true to make the collectible a "There's Options" style
13
- * collectible. Default is false.
13
+ * collectible. Default is false.
14
14
  * @param forceFreeItem Optional. Set to true to disable the logic that gives the item a price for
15
- * Tainted Keeper. Default is false.
15
+ * Tainted Keeper. Default is false.
16
16
  */
17
17
  export declare function spawnCollectible(collectibleType: CollectibleType | int, position: Vector, seedOrRNG?: Seed | RNG, options?: boolean, forceFreeItem?: boolean): EntityPickup;
18
18
  /**
@@ -25,6 +25,6 @@ export declare function spawnCollectible(collectibleType: CollectibleType | int,
25
25
  *
26
26
  * @param position The position to spawn the empty collectible at.
27
27
  * @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
28
- * `RNG.Next` method will be called. Default is `getRandomSeed()`.
28
+ * `RNG.Next` method will be called. Default is `getRandomSeed()`.
29
29
  */
30
30
  export declare function spawnEmptyCollectible(position: Vector, seedOrRNG?: Seed | RNG): EntityPickup;
@@ -4,8 +4,8 @@ local EMPTY_PNG_PATH = ____constants.EMPTY_PNG_PATH
4
4
  local VectorZero = ____constants.VectorZero
5
5
  local ____kColor = require("functions.kColor")
6
6
  local kColorEquals = ____kColor.kColorEquals
7
- local ____math = require("functions.math")
8
- local erange = ____math.erange
7
+ local ____utils = require("functions.utils")
8
+ local erange = ____utils.erange
9
9
  function ____exports.texelEquals(self, sprite1, sprite2, position, layerID)
10
10
  local kColor1 = sprite1:GetTexel(position, VectorZero, 1, layerID)
11
11
  local kColor2 = sprite2:GetTexel(position, VectorZero, 1, layerID)
@@ -17,7 +17,8 @@ export declare function getPlayerTransformations(player: EntityPlayer): Set<Play
17
17
  /**
18
18
  * Helper function to get a transformation name from a PlayerForm enum.
19
19
  *
20
- * Example:
20
+ * For example:
21
+ *
21
22
  * ```ts
22
23
  * const transformationName = getTransformationName(PlayerForm.LORD_OF_THE_FLIES);
23
24
  * // transformationName is "Beelzebub"
@@ -11,12 +11,12 @@ local ____constantsMax = require("constantsMax")
11
11
  local MAX_TRINKET_TYPE = ____constantsMax.MAX_TRINKET_TYPE
12
12
  local ____enums = require("functions.enums")
13
13
  local getEnumValues = ____enums.getEnumValues
14
- local ____math = require("functions.math")
15
- local irange = ____math.irange
16
14
  local ____set = require("functions.set")
17
15
  local copySet = ____set.copySet
18
16
  local ____trinkets = require("functions.trinkets")
19
17
  local trinketHasCacheFlag = ____trinkets.trinketHasCacheFlag
18
+ local ____utils = require("functions.utils")
19
+ local irange = ____utils.irange
20
20
  function initCacheFlagMap(self)
21
21
  for ____, cacheFlag in ipairs(getEnumValues(nil, CacheFlag)) do
22
22
  local trinketsSet = __TS__New(Set)
@@ -14,7 +14,7 @@ export declare function giveTrinketsBack(player: EntityPlayer, trinketSituation:
14
14
  * @param player The player to smelt the trinkets to.
15
15
  * @param trinketType The trinket type to smelt.
16
16
  * @param numTrinkets Optional. If specified, will smelt the given number of trinkets. Use this to
17
- * avoid calling this function multiple times. Default is 1.
17
+ * avoid calling this function multiple times. Default is 1.
18
18
  */
19
19
  export declare function smeltTrinket(player: EntityPlayer, trinketType: TrinketType | int, numTrinkets?: number): void;
20
20
  /**
@@ -6,10 +6,10 @@ local ____cachedClasses = require("cachedClasses")
6
6
  local itemConfig = ____cachedClasses.itemConfig
7
7
  local ____constantsMax = require("constantsMax")
8
8
  local MAX_TRINKET_TYPE = ____constantsMax.MAX_TRINKET_TYPE
9
- local ____math = require("functions.math")
10
- local irange = ____math.irange
11
9
  local ____set = require("functions.set")
12
10
  local copySet = ____set.copySet
11
+ local ____utils = require("functions.utils")
12
+ local irange = ____utils.irange
13
13
  local TRINKET_SET = __TS__New(Set)
14
14
  local function initTrinketSet(self)
15
15
  for ____, trinketType in ipairs(irange(nil, 1, MAX_TRINKET_TYPE)) do
@@ -9,7 +9,8 @@ export declare function getGoldenTrinketType(trinketType: TrinketType | int): Tr
9
9
  /**
10
10
  * Returns the slot number corresponding to where a trinket can be safely inserted.
11
11
  *
12
- * Example:
12
+ * For example:
13
+ *
13
14
  * ```ts
14
15
  * const player = Isaac.GetPlayer();
15
16
  * const trinketSlot = getOpenTrinketSlotNum(player);
@@ -29,7 +30,8 @@ export declare function getTrinketDescription(trinketType: TrinketType | int): s
29
30
  * Helper function to get the name of a trinket. Returns "Unknown" if the provided trinket type is
30
31
  * not valid.
31
32
  *
32
- * Example:
33
+ * For example:
34
+ *
33
35
  * ```ts
34
36
  * const trinketType = TrinketType.SWALLOWED_PENNY;
35
37
  * const trinketName = getTrinketName(trinketType); // trinketName is "Swallowed Penny"
@@ -53,8 +55,9 @@ export declare function isGoldenTrinket(trinketType: TrinketType | int): boolean
53
55
  *
54
56
  * @param trinket The trinket whose sprite you want to modify.
55
57
  * @param pngPath Equal to either the spritesheet path to load (e.g.
56
- * "gfx/items/collectibles/collectibles_001_thesadonion.png") or undefined. If undefined, the sprite
57
- * will be removed, making it appear like the collectible has already been taken by the player.
58
+ * "gfx/items/collectibles/collectibles_001_thesadonion.png") or undefined. If
59
+ * undefined, the sprite will be removed, making it appear like the collectible has
60
+ * already been taken by the player.
58
61
  */
59
62
  export declare function setTrinketSprite(trinket: EntityPickup, pngPath: string | undefined): void;
60
63
  export declare function trinketHasCacheFlag(trinketType: TrinketType | int, cacheFlag: CacheFlag): boolean;
@@ -6,8 +6,8 @@
6
6
  * offset setting so that mods can render UI elements to the screen in the correct position.
7
7
  *
8
8
  * @returns If the user does not have Mod Config Menu enabled, or does not have this option set,
9
- * then this function will return `Vector.Zero.` Otherwise, it will return a Vector that represents
10
- * a HUD offset that should be added to the position of a UI element.
9
+ * then this function will return `Vector.Zero.` Otherwise, it will return a Vector that
10
+ * represents a HUD offset that should be added to the position of a UI element.
11
11
  */
12
12
  export declare function getHUDOffsetVector(): Vector;
13
13
  /**
@@ -4,7 +4,8 @@
4
4
  *
5
5
  * Very useful to be future-safe against people adding values to a type or an enum.
6
6
  *
7
- * Example:
7
+ * For example:
8
+ *
8
9
  * ```ts
9
10
  * enum Situation {
10
11
  * ONE,
@@ -35,6 +36,15 @@
35
36
  * ```
36
37
  */
37
38
  export declare const ensureAllCases: (obj: never) => never;
39
+ /**
40
+ * Helper function to return an array with the elements from start to end. It is inclusive at the
41
+ * start and exclusive at the end. (The "e" stands for exclusive.)
42
+ *
43
+ * For example, `erange(1, 3)` will return `[1, 2]`.
44
+ *
45
+ * If only one argument is specified, then it will assume that the start is 0.
46
+ */
47
+ export declare function erange(start: int, end?: int): int[];
38
48
  /**
39
49
  * Helper function to log what is happening in functions that recursively move through nested data
40
50
  * structures.
@@ -46,6 +56,15 @@ export declare function getTraversalDescription(key: unknown, traversalDescripti
46
56
  * @param hexString A hex string like "#ffffff" or "ffffff". (The "#" character is optional.)
47
57
  */
48
58
  export declare function hexToKColor(hexString: string, alpha: float): KColor;
59
+ /**
60
+ * Helper function to return an array with the elements from start to end, inclusive. (The "i"
61
+ * stands for inclusive.)
62
+ *
63
+ * For example, `irange(1, 3)` will return `[1, 2, 3]`.
64
+ *
65
+ * If only one argument is specified, then it will assume that the start is 0.
66
+ */
67
+ export declare function irange(start: int, end?: int): int[];
49
68
  /**
50
69
  * Since this is a UI element, we do not want to draw it in water reflections. `renderOffset` will
51
70
  * be a non-zero value in reflections.
@@ -62,7 +81,8 @@ export declare function printEnabled(enabled: boolean, description: string): voi
62
81
  /**
63
82
  * Helper function to repeat code N times. This is faster to type and cleaner than using a for loop.
64
83
  *
65
- * Example:
84
+ * For example:
85
+ *
66
86
  * ```ts
67
87
  * const player = Isaac.GetPlayer();
68
88
  * repeat(10, () => {
@@ -8,6 +8,21 @@ local ____cachedClasses = require("cachedClasses")
8
8
  local game = ____cachedClasses.game
9
9
  local HEX_STRING_LENGTH = 6
10
10
  ____exports.ensureAllCases = function(____, obj) return obj end
11
+ function ____exports.erange(self, start, ____end)
12
+ if ____end == nil then
13
+ ____end = start
14
+ start = 0
15
+ end
16
+ local array = {}
17
+ do
18
+ local i = start
19
+ while i < ____end do
20
+ array[#array + 1] = i
21
+ i = i + 1
22
+ end
23
+ end
24
+ return array
25
+ end
11
26
  function ____exports.getTraversalDescription(self, key, traversalDescription)
12
27
  if traversalDescription ~= "" then
13
28
  traversalDescription = traversalDescription .. " --> "
@@ -38,6 +53,21 @@ function ____exports.hexToKColor(self, hexString, alpha)
38
53
  local base = 255
39
54
  return KColor(R / base, G / base, B / base, alpha)
40
55
  end
56
+ function ____exports.irange(self, start, ____end)
57
+ if ____end == nil then
58
+ ____end = start
59
+ start = 0
60
+ end
61
+ local array = {}
62
+ do
63
+ local i = start
64
+ while i <= ____end do
65
+ array[#array + 1] = i
66
+ i = i + 1
67
+ end
68
+ end
69
+ return array
70
+ end
41
71
  function ____exports.isReflectionRender(self)
42
72
  local room = game:GetRoom()
43
73
  local renderMode = room:GetRenderMode()
@@ -13,7 +13,7 @@ interface CopyVectorReturn {
13
13
  * Helper function to copy a `Vector` object.
14
14
  *
15
15
  * @param vector The vector to copy. In the case of deserialization, this will actually be a Lua
16
- * table instead of an instantiated Vector class.
16
+ * table instead of an instantiated Vector class.
17
17
  * @param serializationType Default is `SerializationType.NONE`.
18
18
  */
19
19
  export declare function copyVector<V extends Vector | SerializedVector, S extends SerializationType>(vector: V, serializationType: S): CopyVectorReturn[S];
@@ -3,7 +3,8 @@
3
3
  * [[`getCollectibleIndex`]] function. Mods can signify that data structures handle collectibles by
4
4
  * using this type.
5
5
  *
6
- * Example:
6
+ * For example:
7
+ *
7
8
  * ```ts
8
9
  * const collectiblesNameMap = new Map<CollectibleIndex, string>();
9
10
  * ```
@@ -3,7 +3,8 @@
3
3
  * PlayerIndex is a specific type of string; see the documentation for the [[`getPlayerIndex`]]
4
4
  * function. Mods can signify that data structures handle `EntityPlayer` by using this type.
5
5
  *
6
- * Example:
6
+ * For example:
7
+ *
7
8
  * ```ts
8
9
  * const playersNameMap = new Map<PlayerIndex, string>();
9
10
  * ```
@@ -3,7 +3,8 @@ import { ModUpgraded } from "./classes/ModUpgraded";
3
3
  /**
4
4
  * Use this function to enable the custom features and callbacks provided by `isaacscript-common`.
5
5
  *
6
- * Example:
6
+ * For example:
7
+ *
7
8
  * ```ts
8
9
  * const modVanilla = RegisterMod("My Mod", 1);
9
10
  * const mod = upgradeMod(modVanilla);
@@ -15,9 +16,6 @@ import { ModUpgraded } from "./classes/ModUpgraded";
15
16
  * mod.AddCallbackCustom(ModCallbackCustom.POST_ITEM_PICKUP, postItemPickup);
16
17
  * ```
17
18
  *
18
- * For a list of all custom callbacks, check out the
19
- * [Function Signatures](https://isaacscript.github.io/docs/function-signatures#custom-callbacks).
20
- *
21
19
  * @param modVanilla The mod object returned by the `RegisterMod` function.
22
20
  * @returns The upgraded mod object.
23
21
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "2.0.9",
3
+ "version": "2.0.12",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",
@@ -25,12 +25,13 @@
25
25
  "dist/**/*.d.ts"
26
26
  ],
27
27
  "dependencies": {
28
- "isaac-typescript-definitions": "^2.0.13"
28
+ "isaac-typescript-definitions": "^2.0.14"
29
29
  },
30
30
  "devDependencies": {
31
- "isaacscript-lint": "^1.0.142",
31
+ "isaacscript-lint": "^1.0.150",
32
32
  "isaacscript-spell": "^1.0.3",
33
33
  "isaacscript-tsconfig": "^1.1.16",
34
+ "npm-check-updates": "^13.0.1",
34
35
  "ts-node": "^10.7.0",
35
36
  "typedoc": "^0.22.15",
36
37
  "typescript": "^4.6.4",