isaacscript-common 1.2.2 → 1.2.6

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.
@@ -18,7 +18,7 @@ local postPlayerFatalDamageHasSubscriptions = ____postPlayerFatalDamage.postPlay
18
18
  function hasSubscriptions(self)
19
19
  return postPlayerFatalDamageHasSubscriptions(nil)
20
20
  end
21
- function entityTakeDmgPlayer(self, tookDamage, damageAmount, _damageFlags, damageSource, _damageCountdownFrames)
21
+ function entityTakeDmgPlayer(self, tookDamage, damageAmount, damageFlags, damageSource, damageCountdownFrames)
22
22
  if not hasSubscriptions(nil) then
23
23
  return nil
24
24
  end
@@ -46,7 +46,14 @@ function entityTakeDmgPlayer(self, tookDamage, damageAmount, _damageFlags, damag
46
46
  ) then
47
47
  return nil
48
48
  end
49
- local shouldSustainDeath = postPlayerFatalDamageFire(nil, player)
49
+ local shouldSustainDeath = postPlayerFatalDamageFire(
50
+ nil,
51
+ player,
52
+ damageAmount,
53
+ damageFlags,
54
+ damageSource,
55
+ damageCountdownFrames
56
+ )
50
57
  if shouldSustainDeath ~= nil then
51
58
  return shouldSustainDeath
52
59
  end
@@ -1,4 +1,7 @@
1
1
  /**
2
+ * This is a utility function for users of the `ModCallbacksCustom.POST_NEW_LEVEL_REORDERED` custom
3
+ * callback.
4
+ *
2
5
  * If some specific cases, mods can change the current level during run initialization on the 0th
3
6
  * frame. However, due to how the callback reordering works, the custom PostNewLevel callback will
4
7
  * never fire on the 0th frame. To get around this, call this function before changing levels to
@@ -6,6 +9,9 @@
6
9
  */
7
10
  export declare function forceNewLevelCallback(): void;
8
11
  /**
12
+ * This is a utility function for users of the `ModCallbacksCustom.POST_NEW_ROOM_REORDERED` custom
13
+ * callback.
14
+ *
9
15
  * If some specific cases, mods can change the current room during run initialization on the 0th
10
16
  * frame. However, due to how the callback reordering works, the custom PostNewRoom callback will
11
17
  * never fire on the 0th frame. To get around this, call this function before changing rooms to
@@ -1,2 +1,2 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
- export declare type PostPlayerFatalDamageCallbackType = (player: EntityPlayer) => boolean | void;
2
+ export declare type PostPlayerFatalDamageCallbackType = (player: EntityPlayer, damageAmount: float, damageFlags: int, damageSource: EntityRef, damageCountdownFrames: int) => boolean | void;
@@ -9,7 +9,7 @@ end
9
9
  function ____exports.postPlayerFatalDamageRegister(self, callback, playerVariant)
10
10
  __TS__ArrayPush(subscriptions, {callback, playerVariant})
11
11
  end
12
- function ____exports.postPlayerFatalDamageFire(self, player)
12
+ function ____exports.postPlayerFatalDamageFire(self, player, damageAmount, damageFlags, damageSource, damageCountdownFrames)
13
13
  for ____, ____value in ipairs(subscriptions) do
14
14
  local callback = ____value[1]
15
15
  local playerVariant = ____value[2]
@@ -17,7 +17,14 @@ function ____exports.postPlayerFatalDamageFire(self, player)
17
17
  if playerVariant ~= nil and playerVariant ~= player.Variant then
18
18
  goto __continue5
19
19
  end
20
- local shouldSustainDeath = callback(nil, player)
20
+ local shouldSustainDeath = callback(
21
+ nil,
22
+ player,
23
+ damageAmount,
24
+ damageFlags,
25
+ damageSource,
26
+ damageCountdownFrames
27
+ )
21
28
  if shouldSustainDeath ~= nil then
22
29
  return shouldSustainDeath
23
30
  end
@@ -102,6 +102,8 @@ export declare const MAX_PLAYER_TRINKET_SLOTS = 2;
102
102
  export declare const MAX_ROOM_INDEX = 168;
103
103
  export declare const MAX_VANILLA_CHARACTER = PlayerType.PLAYER_THESOUL_B;
104
104
  export declare const MAX_VANILLA_COLLECTIBLE_TYPE = CollectibleType.COLLECTIBLE_MOMS_RING;
105
+ export declare const SECOND_IN_MILLISECONDS = 1000;
106
+ export declare const MINUTE_IN_MILLISECONDS: number;
105
107
  export declare const MOVEMENT_ACTIONS: Set<ButtonAction>;
106
108
  export declare const ONE_BY_ONE_ROOM_GRID_SIZE = 135;
107
109
  export declare const SINGLE_USE_ACTIVE_COLLECTIBLE_TYPES: Set<CollectibleType>;
@@ -88,6 +88,8 @@ ____exports.MAX_PLAYER_TRINKET_SLOTS = 2
88
88
  ____exports.MAX_ROOM_INDEX = 168
89
89
  ____exports.MAX_VANILLA_CHARACTER = PlayerType.PLAYER_THESOUL_B
90
90
  ____exports.MAX_VANILLA_COLLECTIBLE_TYPE = CollectibleType.COLLECTIBLE_MOMS_RING
91
+ ____exports.SECOND_IN_MILLISECONDS = 1000
92
+ ____exports.MINUTE_IN_MILLISECONDS = 60 * ____exports.SECOND_IN_MILLISECONDS
91
93
  ____exports.MOVEMENT_ACTIONS = __TS__New(Set, {ButtonAction.ACTION_LEFT, ButtonAction.ACTION_RIGHT, ButtonAction.ACTION_UP, ButtonAction.ACTION_DOWN})
92
94
  ____exports.ONE_BY_ONE_ROOM_GRID_SIZE = 135
93
95
  ____exports.SINGLE_USE_ACTIVE_COLLECTIBLE_TYPES = __TS__New(Set, {
@@ -61,6 +61,15 @@ export declare function arrayRemoveInPlace<T>(array: T[], ...elements: T[]): boo
61
61
  * @param exceptions Optional. An array of elements to skip over if selected.
62
62
  */
63
63
  export declare function getRandomArrayElement<T>(array: T[], seed?: number, exceptions?: T[]): T;
64
+ /**
65
+ * Helper function to get a random element from the provided array. Once the random element is
66
+ * decided, it is then removed from the array (in-place).
67
+ *
68
+ * @param array The array to get an element from.
69
+ * @param seed Optional. The seed used to select the random element. `Random()` by default.
70
+ * @param exceptions Optional. An array of elements to skip over if selected.
71
+ */
72
+ export declare function getRandomArrayElementAndRemove<T>(array: T[], seed?: number, exceptions?: T[]): T;
64
73
  export declare function getRandomArrayIndex<T>(array: T[], seed?: number): int;
65
74
  /**
66
75
  * Since Lua uses tables for every non-primitive data structure, it is non-trivial to determine if a
@@ -145,6 +145,17 @@ function ____exports.getRandomArrayElement(self, array, seed, exceptions)
145
145
  local randomIndex = ____exports.getRandomArrayIndex(nil, arrayWithoutExceptions, seed)
146
146
  return arrayWithoutExceptions[randomIndex + 1]
147
147
  end
148
+ function ____exports.getRandomArrayElementAndRemove(self, array, seed, exceptions)
149
+ if seed == nil then
150
+ seed = Random()
151
+ end
152
+ if exceptions == nil then
153
+ exceptions = {}
154
+ end
155
+ local randomArrayElement = ____exports.getRandomArrayElement(nil, array, seed, exceptions)
156
+ ____exports.arrayRemoveInPlace(nil, array, randomArrayElement)
157
+ return randomArrayElement
158
+ end
148
159
  function ____exports.isArray(self, ____table)
149
160
  local metatable = getmetatable(____table)
150
161
  if metatable ~= nil then
@@ -89,6 +89,11 @@ export declare function removeCollectiblePickupDelay(collectible: EntityPickup):
89
89
  * Python program located at: https://github.com/Rchardon/RebirthItemTracker
90
90
  */
91
91
  export declare function removeCollectibleFromItemTracker(collectibleType: CollectibleType | int): void;
92
+ /**
93
+ * Helper function to put a message in the log.txt file to let the Rebirth Item Tracker know that
94
+ * the build has been rerolled.
95
+ */
96
+ export declare function setCollectiblesRerolledForItemTracker(): void;
92
97
  export declare function setCollectibleBlind(collectible: EntityPickup): void;
93
98
  /**
94
99
  * Helper function to remove the collectible from a collectible pedestal and make it appear as if a
@@ -164,6 +164,9 @@ function ____exports.removeCollectibleFromItemTracker(self, collectibleType)
164
164
  local collectibleName = ____exports.getCollectibleName(nil, collectibleType)
165
165
  Isaac.DebugString(((("Removing collectible " .. tostring(collectibleType)) .. " (") .. collectibleName) .. ") on player 0 (Player)")
166
166
  end
167
+ function ____exports.setCollectiblesRerolledForItemTracker(self)
168
+ Isaac.DebugString("Added 3 Collectibles")
169
+ end
167
170
  function ____exports.setCollectibleBlind(self, collectible)
168
171
  if collectible.Variant ~= PickupVariant.PICKUP_COLLECTIBLE then
169
172
  error("You cannot set a collectible to be blind for pickups of variant: " .. tostring(collectible.Variant))
@@ -541,7 +541,8 @@ function ____exports.useActiveItemTemp(self, player, collectibleType)
541
541
  false,
542
542
  false,
543
543
  true,
544
- false
544
+ false,
545
+ -1
545
546
  )
546
547
  end
547
548
  return ____exports
@@ -1,3 +1,7 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
+ /**
3
+ * Only used for special room shapes where the top left wall grid index is not equal to
4
+ * `DEFAULT_TOP_LEFT_WALL_GRID_INDEX`.
5
+ */
2
6
  export declare const ROOM_SHAPE_TO_TOP_LEFT_WALL_GRID_INDEX_MAP: Map<RoomShape, number>;
3
7
  export declare const DEFAULT_TOP_LEFT_WALL_GRID_INDEX = 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.2.2",
3
+ "version": "1.2.6",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",