isaacscript-common 1.2.241 → 1.2.244
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.
- package/dist/callbacks/postNewRoomEarly.lua +3 -3
- package/dist/features/deployJSONRoom.lua +4 -4
- package/dist/features/extraConsoleCommands/commands.lua +2 -2
- package/dist/functions/array.lua +1 -2
- package/dist/functions/benchmark.lua +1 -1
- package/dist/functions/debug.lua +12 -1
- package/dist/functions/gridEntity.d.ts +7 -7
- package/dist/functions/gridEntity.lua +23 -15
- package/dist/functions/jsonHelpers.d.ts +1 -1
- package/dist/functions/roomGrid.lua +1 -1
- package/dist/types/Primitive.d.ts +1 -0
- package/dist/types/Primitive.lua +3 -0
- package/dist/types/private/SaveData.d.ts +1 -1
- package/package.json +2 -2
|
@@ -5,7 +5,7 @@ local ____cachedClasses = require("cachedClasses")
|
|
|
5
5
|
local game = ____cachedClasses.game
|
|
6
6
|
local ____gridEntity = require("functions.gridEntity")
|
|
7
7
|
local getTopLeftWallGridIndex = ____gridEntity.getTopLeftWallGridIndex
|
|
8
|
-
local
|
|
8
|
+
local spawnGrid = ____gridEntity.spawnGrid
|
|
9
9
|
local ____log = require("functions.log")
|
|
10
10
|
local logError = ____log.logError
|
|
11
11
|
local ____postNewRoomEarly = require("callbacks.subscriptions.postNewRoomEarly")
|
|
@@ -33,14 +33,14 @@ function checkRoomChanged(self)
|
|
|
33
33
|
local topLeftWall = room:GetGridEntity(topLeftWallGridIndex)
|
|
34
34
|
local topLeftWall2 = room:GetGridEntity(rightOfTopWallGridIndex)
|
|
35
35
|
if topLeftWall == nil then
|
|
36
|
-
topLeftWall =
|
|
36
|
+
topLeftWall = spawnGrid(nil, GridEntityType.GRID_WALL, topLeftWallGridIndex)
|
|
37
37
|
if topLeftWall == nil then
|
|
38
38
|
logError("Failed to spawn a new wall (1) for the PostNewRoomEarly callback.")
|
|
39
39
|
return
|
|
40
40
|
end
|
|
41
41
|
end
|
|
42
42
|
if topLeftWall2 == nil then
|
|
43
|
-
topLeftWall2 =
|
|
43
|
+
topLeftWall2 = spawnGrid(nil, GridEntityType.GRID_WALL, rightOfTopWallGridIndex)
|
|
44
44
|
if topLeftWall2 == nil then
|
|
45
45
|
logError("Failed to spawn a new wall (2) for the PostNewRoomEarly callback.")
|
|
46
46
|
return
|
|
@@ -23,9 +23,9 @@ local removeAllPickups = ____entitySpecific.removeAllPickups
|
|
|
23
23
|
local ____gridEntity = require("functions.gridEntity")
|
|
24
24
|
local convertXMLGridEntityType = ____gridEntity.convertXMLGridEntityType
|
|
25
25
|
local getGridEntities = ____gridEntity.getGridEntities
|
|
26
|
-
local
|
|
26
|
+
local removeAllGridExcept = ____gridEntity.removeAllGridExcept
|
|
27
27
|
local setGridEntityInvisible = ____gridEntity.setGridEntityInvisible
|
|
28
|
-
local
|
|
28
|
+
local spawnGridWithVariant = ____gridEntity.spawnGridWithVariant
|
|
29
29
|
local ____jsonRoom = require("functions.jsonRoom")
|
|
30
30
|
local getRandomJSONRoom = ____jsonRoom.getRandomJSONRoom
|
|
31
31
|
local ____log = require("functions.log")
|
|
@@ -91,7 +91,7 @@ function ____exports.emptyRoom(self, fillWithDecorations)
|
|
|
91
91
|
removeSpecificNPCs(nil)
|
|
92
92
|
removeAllMatchingEntities(nil, EntityType.ENTITY_EFFECT, EffectVariant.DEVIL)
|
|
93
93
|
removeAllMatchingEntities(nil, EntityType.ENTITY_EFFECT, EffectVariant.ANGEL)
|
|
94
|
-
|
|
94
|
+
removeAllGridExcept(nil, GridEntityType.GRID_WALL, GridEntityType.GRID_DOOR)
|
|
95
95
|
setRoomCleared(nil)
|
|
96
96
|
if fillWithDecorations then
|
|
97
97
|
fillRoomWithDecorations(nil)
|
|
@@ -221,7 +221,7 @@ function spawnGridEntityForJSONRoom(self, xmlEntityType, xmlEntityVariant, x, y)
|
|
|
221
221
|
local gridEntityType, variant = table.unpack(gridEntityTuple)
|
|
222
222
|
local position = gridCoordinatesToWorldPosition(nil, x, y)
|
|
223
223
|
local gridIndex = room:GetGridIndex(position)
|
|
224
|
-
local gridEntity =
|
|
224
|
+
local gridEntity = spawnGridWithVariant(nil, gridEntityType, variant, gridIndex)
|
|
225
225
|
if gridEntity == nil then
|
|
226
226
|
return gridEntity
|
|
227
227
|
end
|
|
@@ -19,7 +19,7 @@ local getCharacterName = ____character.getCharacterName
|
|
|
19
19
|
local ____entitySpecific = require("functions.entitySpecific")
|
|
20
20
|
local getNPCs = ____entitySpecific.getNPCs
|
|
21
21
|
local ____gridEntity = require("functions.gridEntity")
|
|
22
|
-
local
|
|
22
|
+
local spawnGridWithVariant = ____gridEntity.spawnGridWithVariant
|
|
23
23
|
local ____log = require("functions.log")
|
|
24
24
|
local logEffects = ____log.logEffects
|
|
25
25
|
local logEntities = ____log.logEntities
|
|
@@ -195,7 +195,7 @@ function spawnTrapdoorOrCrawlspace(self, trapdoor)
|
|
|
195
195
|
local position = room:FindFreeTilePosition(player.Position, 0)
|
|
196
196
|
local gridIndex = room:GetGridIndex(position)
|
|
197
197
|
local gridEntityType = trapdoor and GridEntityType.GRID_TRAPDOOR or GridEntityType.GRID_STAIRS
|
|
198
|
-
|
|
198
|
+
spawnGridWithVariant(nil, gridEntityType, 0, gridIndex)
|
|
199
199
|
end
|
|
200
200
|
function warpToRoomType(self, roomType)
|
|
201
201
|
local roomTypeName = ROOM_TYPE_NAMES[roomType]
|
package/dist/functions/array.lua
CHANGED
|
@@ -203,8 +203,7 @@ end
|
|
|
203
203
|
function ____exports.sumArray(self, array)
|
|
204
204
|
return __TS__ArrayReduce(
|
|
205
205
|
array,
|
|
206
|
-
function(____, accumulator, element) return accumulator + element end
|
|
207
|
-
0
|
|
206
|
+
function(____, accumulator, element) return accumulator + element end
|
|
208
207
|
)
|
|
209
208
|
end
|
|
210
209
|
return ____exports
|
|
@@ -24,7 +24,7 @@ function ____exports.benchmark(self, numTrials, ...)
|
|
|
24
24
|
end
|
|
25
25
|
end
|
|
26
26
|
local averageTimeMilliseconds = totalTimeMilliseconds / numTrials
|
|
27
|
-
log(((("The average time of function " .. tostring(i)) .. " is: ") .. tostring(averageTimeMilliseconds)) .. " milliseconds")
|
|
27
|
+
log(((("The average time of the function at index " .. tostring(i)) .. " is: ") .. tostring(averageTimeMilliseconds)) .. " milliseconds")
|
|
28
28
|
__TS__ArrayPush(averages, averageTimeMilliseconds)
|
|
29
29
|
end
|
|
30
30
|
)
|
package/dist/functions/debug.lua
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
2
|
local ____exports = {}
|
|
3
|
+
local ____log = require("functions.log")
|
|
4
|
+
local log = ____log.log
|
|
3
5
|
function ____exports.getTraceback(self)
|
|
4
6
|
if debug ~= nil then
|
|
5
7
|
return debug.traceback()
|
|
@@ -11,6 +13,15 @@ function ____exports.getTraceback(self)
|
|
|
11
13
|
end
|
|
12
14
|
function ____exports.traceback(self)
|
|
13
15
|
local tracebackOutput = ____exports.getTraceback(nil)
|
|
14
|
-
|
|
16
|
+
log(tracebackOutput)
|
|
15
17
|
end
|
|
18
|
+
local function setDebugFunctionsGlobal(self)
|
|
19
|
+
if debug == nil then
|
|
20
|
+
return
|
|
21
|
+
end
|
|
22
|
+
local globals = _G
|
|
23
|
+
globals.getTraceback = ____exports.getTraceback
|
|
24
|
+
globals.traceback = ____exports.traceback
|
|
25
|
+
end
|
|
26
|
+
setDebugFunctionsGlobal(nil)
|
|
16
27
|
return ____exports
|
|
@@ -85,7 +85,7 @@ export declare function isPostBossVoidPortal(gridEntity: GridEntity): boolean;
|
|
|
85
85
|
*
|
|
86
86
|
* @returns True if one or more grid entities were removed, false otherwise.
|
|
87
87
|
*/
|
|
88
|
-
export declare function
|
|
88
|
+
export declare function removeAllGridExcept(...gridEntityTypes: GridEntityType[]): boolean;
|
|
89
89
|
/**
|
|
90
90
|
* Helper function to remove all of the grid entities in the room that match the grid entity types
|
|
91
91
|
* provided.
|
|
@@ -112,7 +112,7 @@ export declare function removeAllMatchingGridEntities(...gridEntityType: GridEnt
|
|
|
112
112
|
* this is expensive, since it involves a call to `Isaac.GetRoomEntities`, so set it to false if you
|
|
113
113
|
* need to invoke this function multiple times.
|
|
114
114
|
*/
|
|
115
|
-
export declare function
|
|
115
|
+
export declare function removeGrid(gridEntity: GridEntity, updateRoom?: boolean): void;
|
|
116
116
|
/**
|
|
117
117
|
* Helper function to make a grid entity invisible. This is accomplished by setting its sprite to
|
|
118
118
|
* an empty/missing PNG file.
|
|
@@ -129,23 +129,23 @@ export declare function spawnGiantPoop(topLeftGridIndex: int): void;
|
|
|
129
129
|
* Helper function to spawn a grid entity.
|
|
130
130
|
*
|
|
131
131
|
* This function assumes you want to give the grid entity a variant of 0. If you want to specify a
|
|
132
|
-
* variant, use the `
|
|
132
|
+
* variant, use the `spawnGridWithVariant` helper function instead.
|
|
133
133
|
*
|
|
134
134
|
* Use this instead of the `Isaac.GridSpawn` method since it:
|
|
135
135
|
* - handles giving pits collision
|
|
136
136
|
* - removes existing grid entities on the same tile, if any
|
|
137
|
-
* - allows you to specify the grid index
|
|
137
|
+
* - allows you to specify either the grid index or the position
|
|
138
138
|
*/
|
|
139
|
-
export declare function
|
|
139
|
+
export declare function spawnGrid(gridEntityType: GridEntityType, gridIndexOrPosition: int): GridEntity | undefined;
|
|
140
140
|
/**
|
|
141
141
|
* Helper function to spawn a grid entity with a specific variant.
|
|
142
142
|
*
|
|
143
143
|
* Use this instead of the `Isaac.GridSpawn` method since it:
|
|
144
144
|
* - handles giving pits collision
|
|
145
145
|
* - removes existing grid entities on the same tile, if any
|
|
146
|
-
* - allows you to specify the grid index
|
|
146
|
+
* - allows you to specify the grid index or the position
|
|
147
147
|
*/
|
|
148
|
-
export declare function
|
|
148
|
+
export declare function spawnGridWithVariant(gridEntityType: GridEntityType, variant: int, gridIndexOrPosition: int): GridEntity | undefined;
|
|
149
149
|
/**
|
|
150
150
|
* Helper function to spawn a Void Portal. This is more complicated than simply spawning a trapdoor
|
|
151
151
|
* with the appropriate variant, as the game does not give it the correct sprite automatically.
|
|
@@ -25,6 +25,8 @@ local ____rooms = require("functions.rooms")
|
|
|
25
25
|
local roomUpdateSafe = ____rooms.roomUpdateSafe
|
|
26
26
|
local ____sprite = require("functions.sprite")
|
|
27
27
|
local clearSprite = ____sprite.clearSprite
|
|
28
|
+
local ____vector = require("functions.vector")
|
|
29
|
+
local isVector = ____vector.isVector
|
|
28
30
|
function getAllGridEntities(self)
|
|
29
31
|
local room = game:GetRoom()
|
|
30
32
|
local gridSize = room:GetGridSize()
|
|
@@ -43,7 +45,7 @@ function ____exports.getTopLeftWallGridIndex(self)
|
|
|
43
45
|
local topLeftWallGridIndex = ROOM_SHAPE_TO_TOP_LEFT_WALL_GRID_INDEX_MAP:get(roomShape)
|
|
44
46
|
return topLeftWallGridIndex == nil and DEFAULT_TOP_LEFT_WALL_GRID_INDEX or topLeftWallGridIndex
|
|
45
47
|
end
|
|
46
|
-
function ____exports.
|
|
48
|
+
function ____exports.removeGrid(self, gridEntity, updateRoom)
|
|
47
49
|
if updateRoom == nil then
|
|
48
50
|
updateRoom = true
|
|
49
51
|
end
|
|
@@ -54,13 +56,19 @@ function ____exports.removeGridEntity(self, gridEntity, updateRoom)
|
|
|
54
56
|
roomUpdateSafe(nil)
|
|
55
57
|
end
|
|
56
58
|
end
|
|
57
|
-
function ____exports.
|
|
59
|
+
function ____exports.spawnGridWithVariant(self, gridEntityType, variant, gridIndexOrPosition)
|
|
58
60
|
local room = game:GetRoom()
|
|
59
|
-
local
|
|
61
|
+
local ____isVector_result_0
|
|
62
|
+
if isVector(nil, gridIndexOrPosition) then
|
|
63
|
+
____isVector_result_0 = room:GetGridEntityFromPos(gridIndexOrPosition)
|
|
64
|
+
else
|
|
65
|
+
____isVector_result_0 = room:GetGridEntity(gridIndexOrPosition)
|
|
66
|
+
end
|
|
67
|
+
local existingGridEntity = ____isVector_result_0
|
|
60
68
|
if existingGridEntity ~= nil then
|
|
61
|
-
____exports.
|
|
69
|
+
____exports.removeGrid(nil, existingGridEntity)
|
|
62
70
|
end
|
|
63
|
-
local position = room:GetGridPosition(
|
|
71
|
+
local position = isVector(nil, gridIndexOrPosition) and gridIndexOrPosition or room:GetGridPosition(gridIndexOrPosition)
|
|
64
72
|
local gridEntity = Isaac.GridSpawn(gridEntityType, variant, position)
|
|
65
73
|
if gridEntity == nil then
|
|
66
74
|
return gridEntity
|
|
@@ -201,7 +209,7 @@ function ____exports.isPostBossVoidPortal(self, gridEntity)
|
|
|
201
209
|
local saveState = gridEntity:GetSaveState()
|
|
202
210
|
return saveState.VarData == 1
|
|
203
211
|
end
|
|
204
|
-
function ____exports.
|
|
212
|
+
function ____exports.removeAllGridExcept(self, ...)
|
|
205
213
|
local gridEntityTypes = {...}
|
|
206
214
|
local gridEntityTypeExceptions = __TS__New(Set, gridEntityTypes)
|
|
207
215
|
local gridEntities = ____exports.getGridEntities(nil)
|
|
@@ -209,7 +217,7 @@ function ____exports.removeAllGridEntitiesExceptFor(self, ...)
|
|
|
209
217
|
for ____, gridEntity in ipairs(gridEntities) do
|
|
210
218
|
local gridEntityType = gridEntity:GetType()
|
|
211
219
|
if not gridEntityTypeExceptions:has(gridEntityType) then
|
|
212
|
-
____exports.
|
|
220
|
+
____exports.removeGrid(nil, gridEntity, false)
|
|
213
221
|
removedOneOrMoreGridEntities = true
|
|
214
222
|
end
|
|
215
223
|
end
|
|
@@ -224,7 +232,7 @@ function ____exports.removeAllMatchingGridEntities(self, ...)
|
|
|
224
232
|
return false
|
|
225
233
|
end
|
|
226
234
|
for ____, gridEntity in ipairs(gridEntities) do
|
|
227
|
-
____exports.
|
|
235
|
+
____exports.removeGrid(nil, gridEntity, false)
|
|
228
236
|
end
|
|
229
237
|
roomUpdateSafe(nil)
|
|
230
238
|
return true
|
|
@@ -239,16 +247,16 @@ function ____exports.spawnGiantPoop(self, topLeftGridIndex)
|
|
|
239
247
|
local topRightGridIndex = topLeftGridIndex + 1
|
|
240
248
|
local bottomLeftGridIndex = topLeftGridIndex + gridWidth
|
|
241
249
|
local bottomRightGridIndex = bottomLeftGridIndex + 1
|
|
242
|
-
____exports.
|
|
243
|
-
____exports.
|
|
244
|
-
____exports.
|
|
245
|
-
____exports.
|
|
250
|
+
____exports.spawnGridWithVariant(nil, GridEntityType.GRID_POOP, 7, topLeftGridIndex)
|
|
251
|
+
____exports.spawnGridWithVariant(nil, GridEntityType.GRID_POOP, 8, topRightGridIndex)
|
|
252
|
+
____exports.spawnGridWithVariant(nil, GridEntityType.GRID_POOP, 9, bottomLeftGridIndex)
|
|
253
|
+
____exports.spawnGridWithVariant(nil, GridEntityType.GRID_POOP, 10, bottomRightGridIndex)
|
|
246
254
|
end
|
|
247
|
-
function ____exports.
|
|
248
|
-
return ____exports.
|
|
255
|
+
function ____exports.spawnGrid(self, gridEntityType, gridIndexOrPosition)
|
|
256
|
+
return ____exports.spawnGridWithVariant(nil, gridEntityType, 0, gridIndexOrPosition)
|
|
249
257
|
end
|
|
250
258
|
function ____exports.spawnVoidPortal(self, gridIndex)
|
|
251
|
-
local voidPortal = ____exports.
|
|
259
|
+
local voidPortal = ____exports.spawnGridWithVariant(nil, GridEntityType.GRID_TRAPDOOR, 1, gridIndex)
|
|
252
260
|
if voidPortal == nil then
|
|
253
261
|
return voidPortal
|
|
254
262
|
end
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* (This allows execution to continue in cases where users have no current save data or have
|
|
7
7
|
* manually removed their existing save data.)
|
|
8
8
|
*/
|
|
9
|
-
export declare function jsonDecode(jsonString: string): LuaTable
|
|
9
|
+
export declare function jsonDecode(jsonString: string): LuaTable<AnyNotNil, unknown>;
|
|
10
10
|
/**
|
|
11
11
|
* Converts a Lua table to a JSON string.
|
|
12
12
|
* In most cases, this function will be used for writing data to a "save#.dat" file.
|
|
@@ -26,7 +26,7 @@ function isValidGridPositionLRoom(self, gridPosition, roomShape)
|
|
|
26
26
|
return false
|
|
27
27
|
end
|
|
28
28
|
local verticalTopLeft, verticalBottomRight, horizontalTopLeft, horizontalBottomRight = table.unpack(rectangles)
|
|
29
|
-
return inRectangle(nil, gridPosition, verticalTopLeft, verticalBottomRight)
|
|
29
|
+
return inRectangle(nil, gridPosition, verticalTopLeft, verticalBottomRight) or inRectangle(nil, gridPosition, horizontalTopLeft, horizontalBottomRight)
|
|
30
30
|
end
|
|
31
31
|
function ____exports.gridCoordinatesToWorldPosition(self, x, y)
|
|
32
32
|
local gridPosition = Vector(x, y)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare type Primitive = boolean | number | string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "isaacscript-common",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.244",
|
|
4
4
|
"description": "Helper functions for IsaacScript mods",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"isaac",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
],
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"isaac-typescript-definitions": "^1.0.388",
|
|
29
|
-
"isaacscript-lint": "^1.0.
|
|
29
|
+
"isaacscript-lint": "^1.0.98",
|
|
30
30
|
"isaacscript-tsconfig": "^1.1.8",
|
|
31
31
|
"typedoc": "^0.22.13",
|
|
32
32
|
"typescript": "4.6.3",
|