isaacscript-common 1.2.68 → 1.2.71

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.
@@ -88,8 +88,10 @@ export declare function openDoorFast(door: GridEntityDoor): void;
88
88
  * @returns The number of doors removed.
89
89
  */
90
90
  export declare function removeAllDoors(...roomTypes: RoomType[]): int;
91
+ /** Helper function to remove a single door. */
92
+ export declare function removeDoor(door: GridEntityDoor): void;
91
93
  /**
92
- * Helper function to remove the door(s) provided.
94
+ * Helper function to remove the doors provided.
93
95
  *
94
96
  * This function is variadic, meaning that you can specify as many doors as you want to remove.
95
97
  */
@@ -40,6 +40,17 @@ function ____exports.isSecretRoomDoor(self, door)
40
40
  local filename = sprite:GetFilename()
41
41
  return filename == "gfx/grid/Door_08_HoleInWall.anm2"
42
42
  end
43
+ function ____exports.removeDoor(self, door)
44
+ local game = Game()
45
+ local room = game:GetRoom()
46
+ room:RemoveDoor(door.Slot)
47
+ end
48
+ function ____exports.removeDoors(self, ...)
49
+ local doors = {...}
50
+ for ____, door in ipairs(doors) do
51
+ ____exports.removeDoor(nil, door)
52
+ end
53
+ end
43
54
  function ____exports.closeAllDoors(self)
44
55
  for ____, door in ipairs(____exports.getDoors(nil)) do
45
56
  door:Close(true)
@@ -167,36 +178,11 @@ function ____exports.openDoorFast(self, door)
167
178
  sprite:Play("Opened", true)
168
179
  end
169
180
  function ____exports.removeAllDoors(self, ...)
170
- local roomTypes = {...}
171
- local game = Game()
172
- local room = game:GetRoom()
173
- local roomTypesSet = __TS__New(Set, roomTypes)
174
- local numDoorsRemoved = 0
175
- do
176
- local i = 0
177
- while i < MAX_NUM_DOORS do
178
- do
179
- local door = room:GetDoor(i)
180
- if door == nil then
181
- goto __continue38
182
- end
183
- if #roomTypes == 0 or roomTypesSet:has(door.TargetRoomType) then
184
- room:RemoveDoor(i)
185
- numDoorsRemoved = numDoorsRemoved + 1
186
- end
187
- end
188
- ::__continue38::
189
- i = i + 1
190
- end
191
- end
192
- return numDoorsRemoved
193
- end
194
- function ____exports.removeDoors(self, ...)
195
- local doors = {...}
196
- local game = Game()
197
- local room = game:GetRoom()
198
- for ____, door in ipairs(doors) do
199
- room:RemoveDoor(door.Slot)
200
- end
181
+ local doors = ____exports.getDoors(nil, ...)
182
+ ____exports.removeDoors(
183
+ nil,
184
+ table.unpack(doors)
185
+ )
186
+ return #doors
201
187
  end
202
188
  return ____exports
@@ -80,3 +80,7 @@ export declare function onSetSeed(): boolean;
80
80
  * message (which `Isaac.ConsoleOutput()` does not do by default).
81
81
  */
82
82
  export declare function printConsole(msg: string): void;
83
+ /**
84
+ * Helper function to repeat code N times. This is faster to type and cleaner than using a for loop.
85
+ */
86
+ export declare function repeat(n: int, func: (i: int) => void): void;
@@ -53,4 +53,13 @@ end
53
53
  function ____exports.printConsole(self, msg)
54
54
  Isaac.ConsoleOutput(msg .. "\n")
55
55
  end
56
+ ____exports["repeat"] = function(self, n, func)
57
+ do
58
+ local i = 0
59
+ while i < n do
60
+ func(nil, i)
61
+ i = i + 1
62
+ end
63
+ end
64
+ end
56
65
  return ____exports
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.2.68",
3
+ "version": "1.2.71",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",