isaacscript-common 6.1.1 → 6.3.0

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.
Files changed (72) hide show
  1. package/callbacks/reorderedCallbacks.d.ts +9 -0
  2. package/callbacks/reorderedCallbacks.lua +9 -0
  3. package/classes/DefaultMap.lua +2 -2
  4. package/constants.d.ts +9 -0
  5. package/constants.lua +7 -0
  6. package/enums/CornerType.d.ts +6 -0
  7. package/enums/CornerType.lua +11 -0
  8. package/features/customStage/backdrop.d.ts +2 -0
  9. package/features/customStage/backdrop.lua +200 -0
  10. package/features/customStage/boss.d.ts +2 -0
  11. package/features/customStage/boss.lua +74 -0
  12. package/features/customStage/exports.d.ts +4 -2
  13. package/features/customStage/exports.lua +109 -3
  14. package/features/customStage/init.d.ts +2 -1
  15. package/features/customStage/init.lua +63 -4
  16. package/features/customStage/stageAPIBoss.d.ts +29 -0
  17. package/features/customStage/stageAPIBoss.lua +9 -0
  18. package/features/customStage/util.d.ts +11 -0
  19. package/features/customStage/util.lua +51 -0
  20. package/features/customStage/v.d.ts +11 -0
  21. package/features/customStage/v.lua +5 -0
  22. package/features/debugDisplay/debugDisplay.lua +2 -0
  23. package/features/debugDisplay/exports.d.ts +108 -0
  24. package/features/debugDisplay/exports.lua +145 -0
  25. package/features/debugDisplay/v.d.ts +2 -0
  26. package/features/debugDisplay/v.lua +9 -0
  27. package/features/extraConsoleCommands/init.lua +8 -1
  28. package/features/extraConsoleCommands/listCommands.d.ts +12 -4
  29. package/features/extraConsoleCommands/listCommands.lua +30 -15
  30. package/features/extraConsoleCommands/v.d.ts +1 -0
  31. package/features/extraConsoleCommands/v.lua +2 -1
  32. package/features/pause.d.ts +11 -0
  33. package/features/pause.lua +71 -0
  34. package/features/runNextRoom.d.ts +8 -0
  35. package/features/runNextRoom.lua +40 -0
  36. package/functions/chargeBar.lua +4 -6
  37. package/functions/direction.d.ts +1 -1
  38. package/functions/doors.d.ts +6 -2
  39. package/functions/doors.lua +14 -0
  40. package/functions/familiars.d.ts +2 -0
  41. package/functions/familiars.lua +16 -0
  42. package/functions/jsonRoom.d.ts +25 -3
  43. package/functions/jsonRoom.lua +64 -2
  44. package/functions/playerCenter.d.ts +10 -0
  45. package/functions/playerCenter.lua +64 -0
  46. package/functions/playerIndex.d.ts +3 -0
  47. package/functions/playerIndex.lua +3 -0
  48. package/functions/roomShape.d.ts +10 -4
  49. package/functions/roomShape.lua +15 -2
  50. package/functions/rooms.d.ts +1 -1
  51. package/functions/rooms.lua +2 -2
  52. package/functions/sprite.d.ts +1 -1
  53. package/functions/sprite.lua +1 -1
  54. package/functions/stage.d.ts +3 -3
  55. package/functions/stage.lua +5 -4
  56. package/functions/trinkets.lua +1 -1
  57. package/index.d.ts +2 -1
  58. package/index.lua +10 -0
  59. package/initFeatures.lua +7 -1
  60. package/interfaces/Corner.d.ts +6 -0
  61. package/interfaces/Corner.lua +2 -0
  62. package/interfaces/CustomStage.d.ts +9 -50
  63. package/interfaces/CustomStageLua.d.ts +122 -0
  64. package/interfaces/CustomStageLua.lua +2 -0
  65. package/objects/roomShapeCorners.d.ts +6 -0
  66. package/objects/roomShapeCorners.lua +259 -0
  67. package/objects/roomShapeToBottomRightPosition.d.ts +1 -1
  68. package/objects/roomShapeToTopLeftPosition.d.ts +1 -1
  69. package/objects/roomTypeGotoPrefixes.lua +29 -29
  70. package/package.json +1 -1
  71. package/sets/narrowRoomShapesSet.d.ts +2 -0
  72. package/sets/narrowRoomShapesSet.lua +8 -0
@@ -0,0 +1,51 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local __TS__ArrayMap = ____lualib.__TS__ArrayMap
3
+ local ____exports = {}
4
+ local getTotalWeightOfCustomStageRooms, getCustomStageRoomWithChosenWeight
5
+ local ____array = require("functions.array")
6
+ local sumArray = ____array.sumArray
7
+ local ____log = require("functions.log")
8
+ local log = ____log.log
9
+ local ____random = require("functions.random")
10
+ local getRandomFloat = ____random.getRandomFloat
11
+ local ____rng = require("functions.rng")
12
+ local getRandomSeed = ____rng.getRandomSeed
13
+ function getTotalWeightOfCustomStageRooms(self, roomsMetadata)
14
+ local weights = __TS__ArrayMap(
15
+ roomsMetadata,
16
+ function(____, roomMetadata) return roomMetadata.weight end
17
+ )
18
+ return sumArray(nil, weights)
19
+ end
20
+ function getCustomStageRoomWithChosenWeight(self, roomsMetadata, chosenWeight)
21
+ for ____, roomMetadata in ipairs(roomsMetadata) do
22
+ if chosenWeight < roomMetadata.weight then
23
+ return roomMetadata
24
+ end
25
+ chosenWeight = chosenWeight - roomMetadata.weight
26
+ end
27
+ error("Failed to get a custom stage room with chosen weight: " .. tostring(chosenWeight))
28
+ end
29
+ --- Helper function to get a random custom stage room from an array of custom stage rooms.
30
+ --
31
+ -- Note that this function does not simply choose a random element in the provided array; it will
32
+ -- properly account for each room weight using the algorithm from:
33
+ -- https://stackoverflow.com/questions/1761626/weighted-random-numbers
34
+ function ____exports.getRandomCustomStageRoom(self, roomsMetadata, seedOrRNG, verbose)
35
+ if seedOrRNG == nil then
36
+ seedOrRNG = getRandomSeed(nil)
37
+ end
38
+ if verbose == nil then
39
+ verbose = false
40
+ end
41
+ local totalWeight = getTotalWeightOfCustomStageRooms(nil, roomsMetadata)
42
+ if verbose then
43
+ log("Total weight of the custom stage rooms provided: " .. tostring(totalWeight))
44
+ end
45
+ local chosenWeight = getRandomFloat(nil, 0, totalWeight, seedOrRNG)
46
+ if verbose then
47
+ log("Randomly chose weight for custom stage room: " .. tostring(chosenWeight))
48
+ end
49
+ return getCustomStageRoomWithChosenWeight(nil, roomsMetadata, chosenWeight)
50
+ end
51
+ return ____exports
@@ -1,2 +1,13 @@
1
+ /// <reference types="isaac-typescript-definitions" />
1
2
  import { CustomStage } from "../../interfaces/CustomStage";
3
+ declare const v: {
4
+ run: {
5
+ currentCustomStage: CustomStage | null;
6
+ showingBossVersusScreen: boolean;
7
+ };
8
+ };
9
+ export default v;
10
+ /** Indexed by custom stage name. */
2
11
  export declare const customStagesMap: Map<string, CustomStage>;
12
+ /** Indexed by room variant. */
13
+ export declare const customStageCachedRoomData: Map<number, Readonly<RoomConfig>>;
@@ -2,5 +2,10 @@ local ____lualib = require("lualib_bundle")
2
2
  local Map = ____lualib.Map
3
3
  local __TS__New = ____lualib.__TS__New
4
4
  local ____exports = {}
5
+ local v = {run = {currentCustomStage = nil, showingBossVersusScreen = false}}
6
+ ____exports.default = v
7
+ --- Indexed by custom stage name.
5
8
  ____exports.customStagesMap = __TS__New(Map)
9
+ --- Indexed by room variant.
10
+ ____exports.customStageCachedRoomData = __TS__New(Map)
6
11
  return ____exports
@@ -11,6 +11,7 @@ local saveDataManager = ____exports.saveDataManager
11
11
  local ____v = require("features.debugDisplay.v")
12
12
  local v = ____v.default
13
13
  local debugDisplayTextCallbacks = ____v.debugDisplayTextCallbacks
14
+ local setDebugDisplayEnabled = ____v.setDebugDisplayEnabled
14
15
  function renderTextOnEntity(self, entity, text)
15
16
  if isReflectionRender(nil) then
16
17
  return
@@ -155,6 +156,7 @@ end
155
156
  --- The debug display feature is only initialized when the extra console commands feature is
156
157
  -- initialized.
157
158
  function ____exports.debugDisplayInit(self, mod)
159
+ setDebugDisplayEnabled(nil)
158
160
  saveDataManager(
159
161
  nil,
160
162
  "debugDisplay",
@@ -20,197 +20,305 @@
20
20
  * After using the "playerDisplay" console command, text will be drawn on each player for debugging
21
21
  * purposes. Use this function to specify a callback function that will returns the string that
22
22
  * should be drawn.
23
+ *
24
+ * Note that you have to run the `enableExtraConsoleCommands` function once at the beginning of your
25
+ * mod in order for this console command to work.
23
26
  */
24
27
  export declare function setPlayerDisplay(textCallback: (player: EntityPlayer) => string): void;
25
28
  /**
26
29
  * After using the "tearDisplay" console command, text will be drawn on each tear for debugging
27
30
  * purposes. Use this function to specify a callback function that will returns the string that
28
31
  * should be drawn.
32
+ *
33
+ * Note that you have to run the `enableExtraConsoleCommands` function once at the beginning of your
34
+ * mod in order for this console command to work.
29
35
  */
30
36
  export declare function setTearDisplay(textCallback: (tear: EntityTear) => string): void;
31
37
  /**
32
38
  * After using the "familiarDisplay" console command, text will be drawn on each familiar for
33
39
  * debugging purposes. Use this function to specify a callback function that will returns the string
34
40
  * that should be drawn.
41
+ *
42
+ * Note that you have to run the `enableExtraConsoleCommands` function once at the beginning of your
43
+ * mod in order for this console command to work.
35
44
  */
36
45
  export declare function setFamiliarDisplay(textCallback: (familiar: EntityFamiliar) => string): void;
37
46
  /**
38
47
  * After using the "bombDisplay" console command, text will be drawn on each bomb for debugging
39
48
  * purposes. Use this function to specify a callback function that will returns the string that
40
49
  * should be drawn.
50
+ *
51
+ * Note that you have to run the `enableExtraConsoleCommands` function once at the beginning of your
52
+ * mod in order for this console command to work.
41
53
  */
42
54
  export declare function setBombDisplay(textCallback: (bomb: EntityBomb) => string): void;
43
55
  /**
44
56
  * After using the "pickupDisplay" console command, text will be drawn on each pickup for debugging
45
57
  * purposes. Use this function to specify a callback function that will returns the string that
46
58
  * should be drawn.
59
+ *
60
+ * Note that you have to run the `enableExtraConsoleCommands` function once at the beginning of your
61
+ * mod in order for this console command to work.
47
62
  */
48
63
  export declare function setPickupDisplay(textCallback: (pickup: EntityPickup) => string): void;
49
64
  /**
50
65
  * After using the "slotDisplay" console command, text will be drawn on each slot for debugging
51
66
  * purposes. Use this function to specify a callback function that will returns the string that
52
67
  * should be drawn.
68
+ *
69
+ * Note that you have to run the `enableExtraConsoleCommands` function once at the beginning of your
70
+ * mod in order for this console command to work.
53
71
  */
54
72
  export declare function setSlotDisplay(textCallback: (slot: Entity) => string): void;
55
73
  /**
56
74
  * After using the "laserDisplay" console command, text will be drawn on each laser for debugging
57
75
  * purposes. Use this function to specify a callback function that will returns the string that
58
76
  * should be drawn.
77
+ *
78
+ * Note that you have to run the `enableExtraConsoleCommands` function once at the beginning of your
79
+ * mod in order for this console command to work.
59
80
  */
60
81
  export declare function setLaserDisplay(textCallback: (laser: EntityLaser) => string): void;
61
82
  /**
62
83
  * After using the "knifeDisplay" console command, text will be drawn on each knife for debugging
63
84
  * purposes. Use this function to specify a callback function that will returns the string that
64
85
  * should be drawn.
86
+ *
87
+ * Note that you have to run the `enableExtraConsoleCommands` function once at the beginning of your
88
+ * mod in order for this console command to work.
65
89
  */
66
90
  export declare function setKnifeDisplay(textCallback: (knife: EntityKnife) => string): void;
67
91
  /**
68
92
  * After using the "projectileDisplay" console command, text will be drawn on each projectile for
69
93
  * debugging purposes. Use this function to specify a callback function that will returns the string
70
94
  * that should be drawn.
95
+ *
96
+ * Note that you have to run the `enableExtraConsoleCommands` function once at the beginning of your
97
+ * mod in order for this console command to work.
71
98
  */
72
99
  export declare function setProjectileDisplay(textCallback: (projectile: EntityProjectile) => string): void;
73
100
  /**
74
101
  * After using the "effectDisplay" console command, text will be drawn on each effect for debugging
75
102
  * purposes. Use this function to specify a callback function that will returns the string that
76
103
  * should be drawn.
104
+ *
105
+ * Note that you have to run the `enableExtraConsoleCommands` function once at the beginning of your
106
+ * mod in order for this console command to work.
77
107
  */
78
108
  export declare function setEffectDisplay(textCallback: (effect: EntityEffect) => string): void;
79
109
  /**
80
110
  * After using the "npcDisplay" console command, text will be drawn on each NPC for debugging
81
111
  * purposes. Use this function to specify a callback function that will returns the string that
82
112
  * should be drawn.
113
+ *
114
+ * Note that you have to run the `enableExtraConsoleCommands` function once at the beginning of your
115
+ * mod in order for this console command to work.
83
116
  */
84
117
  export declare function setNPCDisplay(textCallback: (npc: EntityNPC) => string): void;
85
118
  /**
86
119
  * After using the "rockDisplay" console command, text will be drawn on each rock for debugging
87
120
  * purposes. Use this function to specify a callback function that will returns the string that
88
121
  * should be drawn.
122
+ *
123
+ * Note that you have to run the `enableExtraConsoleCommands` function once at the beginning of your
124
+ * mod in order for this console command to work.
89
125
  */
90
126
  export declare function setRockDisplay(textCallback: (rock: GridEntityRock) => string): void;
91
127
  /**
92
128
  * After using the "pitDisplay" console command, text will be drawn on each pit for debugging
93
129
  * purposes. Use this function to specify a callback function that will returns the string that
94
130
  * should be drawn.
131
+ *
132
+ * Note that you have to run the `enableExtraConsoleCommands` function once at the beginning of your
133
+ * mod in order for this console command to work.
95
134
  */
96
135
  export declare function setPitDisplay(textCallback: (pit: GridEntityPit) => string): void;
97
136
  /**
98
137
  * After using the "spikesDisplay" console command, text will be drawn on each spikes for debugging
99
138
  * purposes. Use this function to specify a callback function that will returns the string that
100
139
  * should be drawn.
140
+ *
141
+ * Note that you have to run the `enableExtraConsoleCommands` function once at the beginning of your
142
+ * mod in order for this console command to work.
101
143
  */
102
144
  export declare function setSpikesDisplay(textCallback: (spikes: GridEntitySpikes) => string): void;
103
145
  /**
104
146
  * After using the "tntDisplay" console command, text will be drawn on each TNT for debugging
105
147
  * purposes. Use this function to specify a callback function that will returns the string that
106
148
  * should be drawn.
149
+ *
150
+ * Note that you have to run the `enableExtraConsoleCommands` function once at the beginning of your
151
+ * mod in order for this console command to work.
107
152
  */
108
153
  export declare function setTNTDisplay(textCallback: (tnt: GridEntityTNT) => string): void;
109
154
  /**
110
155
  * After using the "poopDisplay" console command, text will be drawn on each poop for debugging
111
156
  * purposes. Use this function to specify a callback function that will returns the string that
112
157
  * should be drawn.
158
+ *
159
+ * Note that you have to run the `enableExtraConsoleCommands` function once at the beginning of your
160
+ * mod in order for this console command to work.
113
161
  */
114
162
  export declare function setPoopDisplay(textCallback: (poop: GridEntityPoop) => string): void;
115
163
  /**
116
164
  * After using the "poopDisplay" console command, text will be drawn on each poop for debugging
117
165
  * purposes. Use this function to specify a callback function that will returns the string that
118
166
  * should be drawn.
167
+ *
168
+ * Note that you have to run the `enableExtraConsoleCommands` function once at the beginning of your
169
+ * mod in order for this console command to work.
119
170
  */
120
171
  export declare function setDoorDisplay(textCallback: (door: GridEntityDoor) => string): void;
121
172
  /**
122
173
  * After using the "pressurePlateDisplay" console command, text will be drawn on each pressure plate
123
174
  * for debugging purposes. Use this function to specify a callback function that will returns the
124
175
  * string that should be drawn.
176
+ *
177
+ * Note that you have to run the `enableExtraConsoleCommands` function once at the beginning of your
178
+ * mod in order for this console command to work.
125
179
  */
126
180
  export declare function setPressurePlateDisplay(textCallback: (pressurePlate: GridEntityPressurePlate) => string): void;
127
181
  /**
128
182
  * Toggles the debug display for players. This is the function that runs when you use the
129
183
  * "playerDisplay" custom console command.
184
+ *
185
+ * Note that you have to run the `enableExtraConsoleCommands` function once at the beginning of your
186
+ * mod in order for this feature to work.
130
187
  */
131
188
  export declare function togglePlayerDisplay(): void;
132
189
  /**
133
190
  * Toggles the debug display for tears. This is the function that runs when you use the
134
191
  * "tearDisplay" custom console command.
192
+ *
193
+ * Note that you have to run the `enableExtraConsoleCommands` function once at the beginning of your
194
+ * mod in order for this feature to work.
135
195
  */
136
196
  export declare function toggleTearDisplay(): void;
137
197
  /**
138
198
  * Toggles the debug display for familiars. This is the function that runs when you use the
139
199
  * "familiarDisplay" custom console command.
200
+ *
201
+ * Note that you have to run the `enableExtraConsoleCommands` function once at the beginning of your
202
+ * mod in order for this feature to work.
140
203
  */
141
204
  export declare function toggleFamiliarDisplay(): void;
142
205
  /**
143
206
  * Toggles the debug display for bombs. This is the function that runs when you use the
144
207
  * "bombDisplay" custom console command.
208
+ *
209
+ * Note that you have to run the `enableExtraConsoleCommands` function once at the beginning of your
210
+ * mod in order for this feature to work.
145
211
  */
146
212
  export declare function toggleBombDisplay(): void;
147
213
  /**
148
214
  * Toggles the debug display for pickups. This is the function that runs when you use the
149
215
  * "pickupDisplay" custom console command.
216
+ *
217
+ * Note that you have to run the `enableExtraConsoleCommands` function once at the beginning of your
218
+ * mod in order for this feature to work.
150
219
  */
151
220
  export declare function togglePickupDisplay(): void;
152
221
  /**
153
222
  * Toggles the debug display for slots. This is the function that runs when you use the
154
223
  * "slotDisplay" custom console command.
224
+ *
225
+ * Note that you have to run the `enableExtraConsoleCommands` function once at the beginning of your
226
+ * mod in order for this feature to work.
155
227
  */
156
228
  export declare function toggleSlotDisplay(): void;
157
229
  /**
158
230
  * Toggles the debug display for lasers. This is the function that runs when you use the
159
231
  * "laserDisplay" custom console command.
232
+ *
233
+ * Note that you have to run the `enableExtraConsoleCommands` function once at the beginning of your
234
+ * mod in order for this feature to work.
160
235
  */
161
236
  export declare function toggleLaserDisplay(): void;
162
237
  /**
163
238
  * Toggles the debug display for knives. This is the function that runs when you use the
164
239
  * "knifeDisplay" custom console command.
240
+ *
241
+ * Note that you have to run the `enableExtraConsoleCommands` function once at the beginning of your
242
+ * mod in order for this feature to work.
165
243
  */
166
244
  export declare function toggleKnifeDisplay(): void;
167
245
  /**
168
246
  * Toggles the debug display for projectiles. This is the function that runs when you use the
169
247
  * "projectileDisplay" custom console command.
248
+ *
249
+ * Note that you have to run the `enableExtraConsoleCommands` function once at the beginning of your
250
+ * mod in order for this feature to work.
170
251
  */
171
252
  export declare function toggleProjectileDisplay(): void;
172
253
  /**
173
254
  * Toggles the debug display for effects. This is the function that runs when you use the
174
255
  * "effectDisplay" custom console command.
256
+ *
257
+ * Note that you have to run the `enableExtraConsoleCommands` function once at the beginning of your
258
+ * mod in order for this feature to work.
175
259
  */
176
260
  export declare function toggleEffectDisplay(): void;
177
261
  /**
178
262
  * Toggles the debug display for NPCs. This is the function that runs when you use the "npcDisplay"
179
263
  * custom console command.
264
+ *
265
+ * Note that you have to run the `enableExtraConsoleCommands` function once at the beginning of your
266
+ * mod in order for this feature to work.
180
267
  */
181
268
  export declare function toggleNPCDisplay(): void;
182
269
  /**
183
270
  * Toggles the debug display for rocks. This is the function that runs when you use the
184
271
  * "rockDisplay" custom console command.
272
+ *
273
+ * Note that you have to run the `enableExtraConsoleCommands` function once at the beginning of your
274
+ * mod in order for this feature to work.
185
275
  */
186
276
  export declare function toggleRockDisplay(): void;
187
277
  /**
188
278
  * Toggles the debug display for pits. This is the function that runs when you use the "pitDisplay"
189
279
  * custom console command.
280
+ *
281
+ * Note that you have to run the `enableExtraConsoleCommands` function once at the beginning of your
282
+ * mod in order for this feature to work.
190
283
  */
191
284
  export declare function togglePitDisplay(): void;
192
285
  /**
193
286
  * Toggles the debug display for spikes. This is the function that runs when you use the
194
287
  * "spikesDisplay" custom console command.
288
+ *
289
+ * Note that you have to run the `enableExtraConsoleCommands` function once at the beginning of your
290
+ * mod in order for this feature to work.
195
291
  */
196
292
  export declare function toggleSpikesDisplay(): void;
197
293
  /**
198
294
  * Toggles the debug display for TNT. This is the function that runs when you use the "tntDisplay"
199
295
  * custom console command.
296
+ *
297
+ * Note that you have to run the `enableExtraConsoleCommands` function once at the beginning of your
298
+ * mod in order for this feature to work.
200
299
  */
201
300
  export declare function toggleTNTDisplay(): void;
202
301
  /**
203
302
  * Toggles the debug display for poop. This is the function that runs when you use the "poopDisplay"
204
303
  * custom console command.
304
+ *
305
+ * Note that you have to run the `enableExtraConsoleCommands` function once at the beginning of your
306
+ * mod in order for this feature to work.
205
307
  */
206
308
  export declare function togglePoopDisplay(): void;
207
309
  /**
208
310
  * Toggles the debug display for doors. This is the function that runs when you use the
209
311
  * "doorDisplay" custom console command.
312
+ *
313
+ * Note that you have to run the `enableExtraConsoleCommands` function once at the beginning of your
314
+ * mod in order for this feature to work.
210
315
  */
211
316
  export declare function toggleDoorDisplay(): void;
212
317
  /**
213
318
  * Toggles the debug display for pressure plates. This is the function that runs when you use the
214
319
  * "pressurePlateDisplay" custom console command.
320
+ *
321
+ * Note that you have to run the `enableExtraConsoleCommands` function once at the beginning of your
322
+ * mod in order for this feature to work.
215
323
  */
216
324
  export declare function togglePressurePlateDisplay(): void;