isaacscript-common 1.0.577 → 1.0.578

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.
@@ -1,8 +1,8 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
2
  /**
3
3
  * Helper function for quickly switching to a new room without playing a particular animation.
4
- * Always use this helper function over invoking `Game().ChangeRoom()` directly to ensure that you
5
- * do not forget to set the LeaveDoor property and to prevent crashing on invalid room grid indexes.
4
+ * Use this helper function over invoking `Game().ChangeRoom()` directly to ensure that you do not
5
+ * forget to set the LeaveDoor property and to prevent crashing on invalid room grid indexes.
6
6
  */
7
7
  export declare function changeRoom(roomGridIndex: int): void;
8
8
  export declare function getAllRoomGridIndexes(): int[];
@@ -220,3 +220,15 @@ export declare function setRoomCleared(): void;
220
220
  * spawns an NPC.
221
221
  */
222
222
  export declare function setRoomUncleared(): void;
223
+ /**
224
+ * Helper function to change the current room. It can be used for both teleportation and "normal"
225
+ * room transitions, depending on what is passed for the `direction` and `roomTransitionAnim`
226
+ * arguments. Use this function instead of invoking `Game.StartRoomTransition()` directly so that
227
+ * you do not forget to set `Level.LeaveDoor` property and to prevent crashing on invalid room grid
228
+ * indexes.
229
+ *
230
+ * @param roomGridIndex The room grid index of the destination room.
231
+ * @param direction Optional. Default is `Direction.NO_DIRECTION`.
232
+ * @param roomTransitionAnim Optional. Default is `RoomTransitionAnim.TELEPORT`.
233
+ */
234
+ export declare function teleport(roomGridIndex: int, direction?: Direction, roomTransitionAnim?: RoomTransitionAnim): void;
@@ -312,4 +312,20 @@ function ____exports.setRoomUncleared(self)
312
312
  room:SetClear(false)
313
313
  closeAllDoors(nil)
314
314
  end
315
+ function ____exports.teleport(self, roomGridIndex, direction, roomTransitionAnim)
316
+ if direction == nil then
317
+ direction = Direction.NO_DIRECTION
318
+ end
319
+ if roomTransitionAnim == nil then
320
+ roomTransitionAnim = RoomTransitionAnim.TELEPORT
321
+ end
322
+ local game = Game()
323
+ local level = game:GetLevel()
324
+ local roomData = ____exports.getRoomData(nil, roomGridIndex)
325
+ if roomData == nil then
326
+ error(("Failed to change the room to to grid index " .. tostring(roomGridIndex)) .. " because that room does not exist.")
327
+ end
328
+ level.LeaveDoor = -1
329
+ game:StartRoomTransition(roomGridIndex, direction, roomTransitionAnim)
330
+ end
315
331
  return ____exports
@@ -90,14 +90,3 @@ export declare function printConsole(msg: string): void;
90
90
  * `clear` method does not exist. Use this helper function as a drop-in replacement for this.
91
91
  */
92
92
  export declare function tableClear(table: LuaTable): void;
93
- /**
94
- * Helper function to change the current room. It can be used for both teleportation and "normal"
95
- * room transitions, depending on what is passed for the `direction` and `roomTransitionAnim`
96
- * arguments. Use this function instead of invoking `Game.StartRoomTransition()` directly so that
97
- * you don't forget to set `Level.LeaveDoor` property.
98
- *
99
- * @param roomGridIndex The room grid index of the destination room.
100
- * @param direction Optional. Default is `Direction.NO_DIRECTION`.
101
- * @param roomTransitionAnim Optional. Default is `RoomTransitionAnim.TELEPORT`.
102
- */
103
- export declare function teleport(roomGridIndex: int, direction?: Direction, roomTransitionAnim?: RoomTransitionAnim): void;
@@ -70,16 +70,4 @@ function ____exports.tableClear(self, ____table)
70
70
  ____table[key] = nil
71
71
  end
72
72
  end
73
- function ____exports.teleport(self, roomGridIndex, direction, roomTransitionAnim)
74
- if direction == nil then
75
- direction = Direction.NO_DIRECTION
76
- end
77
- if roomTransitionAnim == nil then
78
- roomTransitionAnim = RoomTransitionAnim.TELEPORT
79
- end
80
- local game = Game()
81
- local level = game:GetLevel()
82
- level.LeaveDoor = -1
83
- game:StartRoomTransition(roomGridIndex, direction, roomTransitionAnim)
84
- end
85
73
  return ____exports
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.0.577",
3
+ "version": "1.0.578",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",