isaacscript-common 1.0.576 → 1.0.580

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.
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;
@@ -85,6 +85,10 @@ end
85
85
  function ____exports.changeRoom(self, roomGridIndex)
86
86
  local game = Game()
87
87
  local level = game:GetLevel()
88
+ local roomData = ____exports.getRoomData(nil, roomGridIndex)
89
+ if roomData == nil then
90
+ error(("Failed to change the room to grid index " .. tostring(roomGridIndex)) .. " because that room does not exist.")
91
+ end
88
92
  level.LeaveDoor = -1
89
93
  game:ChangeRoom(roomGridIndex)
90
94
  end
@@ -246,17 +250,17 @@ function ____exports.isAllRoomsClear(self, onlyCheckRoomTypes)
246
250
  do
247
251
  local roomData = roomDescriptor.Data
248
252
  if roomData == nil then
249
- goto __continue48
253
+ goto __continue49
250
254
  end
251
255
  local roomType = roomData.Type
252
256
  if roomTypeWhitelist ~= nil and not roomTypeWhitelist:has(roomType) then
253
- goto __continue48
257
+ goto __continue49
254
258
  end
255
259
  if not roomDescriptor.Clear then
256
260
  return false
257
261
  end
258
262
  end
259
- ::__continue48::
263
+ ::__continue49::
260
264
  end
261
265
  return true
262
266
  end
@@ -292,12 +296,12 @@ function ____exports.setRoomCleared(self)
292
296
  for ____, door in ipairs(getDoors(nil)) do
293
297
  do
294
298
  if isHiddenSecretRoomDoor(nil, door) then
295
- goto __continue59
299
+ goto __continue60
296
300
  end
297
301
  openDoorFast(nil, door)
298
302
  door.ExtraVisible = false
299
303
  end
300
- ::__continue59::
304
+ ::__continue60::
301
305
  end
302
306
  sfx:Stop(SoundEffect.SOUND_DOOR_HEAVY_OPEN)
303
307
  game:ShakeScreen(0)
@@ -308,4 +312,20 @@ function ____exports.setRoomUncleared(self)
308
312
  room:SetClear(false)
309
313
  closeAllDoors(nil)
310
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 grid index " .. tostring(roomGridIndex)) .. " because that room does not exist.")
327
+ end
328
+ level.LeaveDoor = -1
329
+ game:StartRoomTransition(roomGridIndex, direction, roomTransitionAnim)
330
+ end
311
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
@@ -15,7 +15,8 @@ function errorWithTraceback(message, level)
15
15
  end
16
16
  local tracebackOutput = getTraceback(nil)
17
17
  local slimmedTracebackOutput = slimTracebackOutput(nil, tracebackOutput)
18
- Isaac.DebugString(slimmedTracebackOutput)
18
+ message = message .. "\n"
19
+ message = message .. slimmedTracebackOutput
19
20
  return vanillaError(message, level + 1)
20
21
  end
21
22
  function slimTracebackOutput(self, tracebackOutput)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.0.576",
3
+ "version": "1.0.580",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",