isaacscript-common 1.0.334 → 1.0.338

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.
@@ -11,6 +11,8 @@ export declare const FIRST_GLITCHED_COLLECTIBLE_TYPE: number;
11
11
  export declare const GENESIS_ROOM_VARIANT = 1000;
12
12
  export declare const GOLDEN_TRINKET_SHIFT: number;
13
13
  export declare const GRID_INDEX_CENTER_OF_1X1_ROOM = 67;
14
+ export declare const GAME_FRAMES_PER_SECOND = 30;
15
+ export declare const ISAAC_FRAMES_PER_SECOND = 60;
14
16
  /** In a 2x2 room, there can be 8 doors. */
15
17
  export declare const MAX_NUM_DOORS = 8;
16
18
  /** The game can only handle up to four different players. */
@@ -8,6 +8,8 @@ ____exports.FIRST_GLITCHED_COLLECTIBLE_TYPE = (1 << 32) - 1
8
8
  ____exports.GENESIS_ROOM_VARIANT = 1000
9
9
  ____exports.GOLDEN_TRINKET_SHIFT = 1 << 15
10
10
  ____exports.GRID_INDEX_CENTER_OF_1X1_ROOM = 67
11
+ ____exports.GAME_FRAMES_PER_SECOND = 30
12
+ ____exports.ISAAC_FRAMES_PER_SECOND = 60
11
13
  ____exports.MAX_NUM_DOORS = 8
12
14
  ____exports.MAX_NUM_INPUTS = 4
13
15
  ____exports.MAX_PLAYER_POCKET_ITEM_SLOTS = 4
@@ -0,0 +1,3 @@
1
+ /// <reference types="isaac-typescript-definitions" />
2
+ export declare function getKBitOfN(k: int, n: int): int;
3
+ export declare function getNumBitsOfN(n: int): int;
@@ -0,0 +1,14 @@
1
+ --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
+ local ____exports = {}
3
+ function ____exports.getKBitOfN(self, k, n)
4
+ return (n >> k) & 1
5
+ end
6
+ function ____exports.getNumBitsOfN(self, n)
7
+ local numBits = 0
8
+ while n > 0 do
9
+ numBits = numBits + 1
10
+ n = n >> 1
11
+ end
12
+ return numBits
13
+ end
14
+ return ____exports
@@ -10,8 +10,8 @@ import PocketItemDescription from "../types/PocketItemDescription";
10
10
  *
11
11
  * This type is branded for extra type safety.
12
12
  */
13
- export declare type PlayerIndex = string & {
14
- __playerIndexBrand: any;
13
+ export declare type PlayerIndex = int & {
14
+ __playerIndexBrand: unknown;
15
15
  };
16
16
  /** Iterates over all players and checks if any player is close enough to the specified position. */
17
17
  export declare function anyPlayerCloserThan(position: Vector, distance: float): boolean;
@@ -81,9 +81,7 @@ export declare function getPlayersOfType(playerType: PlayerType): EntityPlayer[]
81
81
  * relaunching the game.
82
82
  *
83
83
  * Instead, we use `EntityPlayer.GetCollectibleRNG()` with an arbitrary value of 1 (i.e. Sad Onion).
84
- * This works even if the player does not have any Sad Onions. We also convert the numerical seed to
85
- * a string to avoid null element creation when saving the table as JSON (which is necessary when
86
- * saving variables on run exit).
84
+ * This works even if the player does not have any Sad Onions.
87
85
  *
88
86
  * Finally, this index fails in the case of Tainted Lazarus, since the RNG will be the same for both
89
87
  * Tainted Lazarus and Dead Tainted Lazarus. We revert to using the RNG of Inner Eye for this case.
@@ -40,8 +40,7 @@ function ____exports.getPlayerIndex(self, player)
40
40
  local collectibleToUse = ((character == PlayerType.PLAYER_LAZARUS2_B) and CollectibleType.COLLECTIBLE_INNER_EYE) or CollectibleType.COLLECTIBLE_SAD_ONION
41
41
  local collectibleRNG = player:GetCollectibleRNG(collectibleToUse)
42
42
  local seed = collectibleRNG:GetSeed()
43
- local seedString = tostring(seed)
44
- return seedString
43
+ return seed
45
44
  end
46
45
  function ____exports.isChildPlayer(self, player)
47
46
  return player.Parent ~= nil
@@ -36,6 +36,12 @@ export declare function getRoomIndex(): int;
36
36
  * This function only searches through rooms in the current dimension.
37
37
  */
38
38
  export declare function getRoomIndexesForType(roomType: RoomType): Set<int>;
39
+ /**
40
+ * Helper function to get the name of the room as it appears in the STB/XML data.
41
+ *
42
+ * @returns The room name. Returns "Unknown" if the type was not found.
43
+ */
44
+ export declare function getRoomName(): string;
39
45
  /**
40
46
  * Helper function to get the stage ID for the room from the XML/STB data. The room stage ID will
41
47
  * correspond to the first number in the filename of the XML/STB file. For example, a Depths room
@@ -75,6 +75,13 @@ function ____exports.getRoomIndexesForType(self, roomType)
75
75
  end
76
76
  return roomIndexes
77
77
  end
78
+ function ____exports.getRoomName(self)
79
+ local roomData = ____exports.getRoomData(nil)
80
+ if roomData == nil then
81
+ return "Unknown"
82
+ end
83
+ return roomData.Name
84
+ end
78
85
  function ____exports.getRoomStageID(self)
79
86
  local roomData = ____exports.getRoomData(nil)
80
87
  if roomData == nil then
@@ -107,16 +107,16 @@ function ____exports.teleport(self, roomIndex, direction, roomTransitionAnim)
107
107
  end
108
108
  function ____exports.vectorToDirection(self, vector)
109
109
  local degrees = vector:GetAngleDegrees()
110
- if (degrees >= -45) and (degrees < 45) then
110
+ if (degrees > -45) and (degrees < 45) then
111
111
  return Direction.RIGHT
112
112
  end
113
- if (degrees >= 45) and (degrees < 135) then
113
+ if (degrees >= 45) and (degrees <= 135) then
114
114
  return Direction.DOWN
115
115
  end
116
- if (degrees < -45) and (degrees >= -135) then
116
+ if (degrees <= -45) and (degrees >= -135) then
117
117
  return Direction.UP
118
118
  end
119
- if (degrees >= 135) or (degrees < -135) then
119
+ if (degrees > 135) or (degrees < -135) then
120
120
  return Direction.LEFT
121
121
  end
122
122
  return Direction.NO_DIRECTION
package/dist/index.d.ts CHANGED
@@ -1,10 +1,11 @@
1
1
  export { forceNewLevelCallback, forceNewRoomCallback, } from "./callbacks/reorderedCallbacks";
2
- export { CHARACTERS_WITH_NO_RED_HEARTS, DISTANCE_OF_GRID_TILE, DOOR_HITBOX_DISTANCE, FIRST_GLITCHED_COLLECTIBLE_TYPE, GENESIS_ROOM_VARIANT, GOLDEN_TRINKET_SHIFT, GRID_INDEX_CENTER_OF_1X1_ROOM, MAX_NUM_DOORS, MAX_NUM_INPUTS, MAX_PLAYER_POCKET_ITEM_SLOTS, MAX_PLAYER_SPEED_IN_UNITS, MAX_PLAYER_TRINKET_SLOTS, MAX_ROOM_INDEX, MAX_VANILLA_COLLECTIBLE_TYPE, SINGLE_USE_ACTIVE_COLLECTIBLE_TYPES, } from "./constants";
2
+ export { CHARACTERS_WITH_NO_RED_HEARTS, DISTANCE_OF_GRID_TILE, DOOR_HITBOX_DISTANCE, FIRST_GLITCHED_COLLECTIBLE_TYPE, GAME_FRAMES_PER_SECOND, GENESIS_ROOM_VARIANT, GOLDEN_TRINKET_SHIFT, GRID_INDEX_CENTER_OF_1X1_ROOM, ISAAC_FRAMES_PER_SECOND, MAX_NUM_DOORS, MAX_NUM_INPUTS, MAX_PLAYER_POCKET_ITEM_SLOTS, MAX_PLAYER_SPEED_IN_UNITS, MAX_PLAYER_TRINKET_SLOTS, MAX_ROOM_INDEX, MAX_VANILLA_COLLECTIBLE_TYPE, SINGLE_USE_ACTIVE_COLLECTIBLE_TYPES, } from "./constants";
3
3
  export { disableAllInputs, disableAllInputsExceptFor, disableMovementInputs, disableShootingInputs, enableAllInputs, enableAllInputsExceptFor, } from "./features/disableInputs";
4
4
  export { forgottenSwitch } from "./features/forgottenSwitch";
5
5
  export { runInNFrames, runNextFrame } from "./features/runInNFrames";
6
6
  export { saveDataManager, saveDataManagerSave, saveDataManagerSetGlobal, } from "./features/saveDataManager/main";
7
7
  export * from "./functions/array";
8
+ export * from "./functions/bitwise";
8
9
  export * from "./functions/collectibles";
9
10
  export { deepCopy } from "./functions/deepCopy";
10
11
  export { deepCopyTests } from "./functions/deepCopyTests";
package/dist/index.lua CHANGED
@@ -13,9 +13,11 @@ do
13
13
  local DISTANCE_OF_GRID_TILE = ____constants.DISTANCE_OF_GRID_TILE
14
14
  local DOOR_HITBOX_DISTANCE = ____constants.DOOR_HITBOX_DISTANCE
15
15
  local FIRST_GLITCHED_COLLECTIBLE_TYPE = ____constants.FIRST_GLITCHED_COLLECTIBLE_TYPE
16
+ local GAME_FRAMES_PER_SECOND = ____constants.GAME_FRAMES_PER_SECOND
16
17
  local GENESIS_ROOM_VARIANT = ____constants.GENESIS_ROOM_VARIANT
17
18
  local GOLDEN_TRINKET_SHIFT = ____constants.GOLDEN_TRINKET_SHIFT
18
19
  local GRID_INDEX_CENTER_OF_1X1_ROOM = ____constants.GRID_INDEX_CENTER_OF_1X1_ROOM
20
+ local ISAAC_FRAMES_PER_SECOND = ____constants.ISAAC_FRAMES_PER_SECOND
19
21
  local MAX_NUM_DOORS = ____constants.MAX_NUM_DOORS
20
22
  local MAX_NUM_INPUTS = ____constants.MAX_NUM_INPUTS
21
23
  local MAX_PLAYER_POCKET_ITEM_SLOTS = ____constants.MAX_PLAYER_POCKET_ITEM_SLOTS
@@ -28,9 +30,11 @@ do
28
30
  ____exports.DISTANCE_OF_GRID_TILE = DISTANCE_OF_GRID_TILE
29
31
  ____exports.DOOR_HITBOX_DISTANCE = DOOR_HITBOX_DISTANCE
30
32
  ____exports.FIRST_GLITCHED_COLLECTIBLE_TYPE = FIRST_GLITCHED_COLLECTIBLE_TYPE
33
+ ____exports.GAME_FRAMES_PER_SECOND = GAME_FRAMES_PER_SECOND
31
34
  ____exports.GENESIS_ROOM_VARIANT = GENESIS_ROOM_VARIANT
32
35
  ____exports.GOLDEN_TRINKET_SHIFT = GOLDEN_TRINKET_SHIFT
33
36
  ____exports.GRID_INDEX_CENTER_OF_1X1_ROOM = GRID_INDEX_CENTER_OF_1X1_ROOM
37
+ ____exports.ISAAC_FRAMES_PER_SECOND = ISAAC_FRAMES_PER_SECOND
34
38
  ____exports.MAX_NUM_DOORS = MAX_NUM_DOORS
35
39
  ____exports.MAX_NUM_INPUTS = MAX_NUM_INPUTS
36
40
  ____exports.MAX_PLAYER_POCKET_ITEM_SLOTS = MAX_PLAYER_POCKET_ITEM_SLOTS
@@ -84,6 +88,14 @@ do
84
88
  end
85
89
  end
86
90
  end
91
+ do
92
+ local ____export = require("functions.bitwise")
93
+ for ____exportKey, ____exportValue in pairs(____export) do
94
+ if ____exportKey ~= "default" then
95
+ ____exports[____exportKey] = ____exportValue
96
+ end
97
+ end
98
+ end
87
99
  do
88
100
  local ____export = require("functions.collectibles")
89
101
  for ____exportKey, ____exportValue in pairs(____export) do
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.0.334",
3
+ "version": "1.0.338",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",
@@ -25,7 +25,7 @@
25
25
  "dist/**/*.d.ts"
26
26
  ],
27
27
  "devDependencies": {
28
- "isaac-typescript-definitions": "^1.0.190",
28
+ "isaac-typescript-definitions": "^1.0.207",
29
29
  "isaacscript-lint": "^1.0.61",
30
30
  "typedoc": "^0.22.5",
31
31
  "typescript": "4.4.3",