isaacscript-common 1.2.76 → 1.2.79
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/postPurchase.lua +2 -2
- package/dist/callbacks/postSlotInitUpdate.lua +2 -2
- package/dist/callbacks/postSlotRenderBroken.lua +2 -2
- package/dist/constants.d.ts +1 -0
- package/dist/constants.lua +14 -0
- package/dist/features/deployJSONRoom.d.ts +2 -0
- package/dist/features/deployJSONRoom.lua +4 -2
- package/dist/functions/array.d.ts +7 -5
- package/dist/functions/array.lua +16 -14
- package/dist/functions/collectibles.lua +3 -3
- package/dist/functions/entity.d.ts +12 -206
- package/dist/functions/entity.lua +20 -224
- package/dist/functions/entitySpecific.d.ts +148 -0
- package/dist/functions/entitySpecific.lua +148 -0
- package/dist/functions/npc.lua +2 -1
- package/dist/functions/pickups.d.ts +21 -0
- package/dist/functions/pickups.lua +27 -16
- package/dist/functions/player.lua +2 -1
- package/dist/functions/positionVelocity.d.ts +59 -0
- package/dist/functions/positionVelocity.lua +90 -0
- package/dist/functions/rooms.lua +5 -4
- package/dist/functions/trinkets.lua +2 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.lua +9 -1
- package/package.json +1 -1
|
@@ -1,12 +1,33 @@
|
|
|
1
1
|
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
2
|
local ____lualib = require("lualib_bundle")
|
|
3
|
-
local
|
|
4
|
-
local __TS__New = ____lualib.__TS__New
|
|
3
|
+
local __TS__ArrayPush = ____lualib.__TS__ArrayPush
|
|
5
4
|
local ____exports = {}
|
|
5
|
+
local ____constants = require("constants")
|
|
6
|
+
local CHEST_PICKUP_VARIANTS = ____constants.CHEST_PICKUP_VARIANTS
|
|
6
7
|
local ____array = require("functions.array")
|
|
7
8
|
local getRandomArrayElement = ____array.getRandomArrayElement
|
|
9
|
+
local ____entity = require("functions.entity")
|
|
10
|
+
local getEntities = ____entity.getEntities
|
|
11
|
+
local removeEntities = ____entity.removeEntities
|
|
8
12
|
local ____utils = require("functions.utils")
|
|
9
13
|
local getEnumValues = ____utils.getEnumValues
|
|
14
|
+
function ____exports.getPickups(self, matchingVariant, matchingSubType)
|
|
15
|
+
if matchingVariant == nil then
|
|
16
|
+
matchingVariant = -1
|
|
17
|
+
end
|
|
18
|
+
if matchingSubType == nil then
|
|
19
|
+
matchingSubType = -1
|
|
20
|
+
end
|
|
21
|
+
local entities = getEntities(nil, EntityType.ENTITY_PICKUP, matchingVariant, matchingSubType)
|
|
22
|
+
local pickups = {}
|
|
23
|
+
for ____, entity in ipairs(entities) do
|
|
24
|
+
local pickup = entity:ToPickup()
|
|
25
|
+
if pickup ~= nil then
|
|
26
|
+
__TS__ArrayPush(pickups, pickup)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
return pickups
|
|
30
|
+
end
|
|
10
31
|
function ____exports.getRandomHeartSubType(self, seed, exceptions)
|
|
11
32
|
if seed == nil then
|
|
12
33
|
seed = Random()
|
|
@@ -17,21 +38,11 @@ function ____exports.getRandomHeartSubType(self, seed, exceptions)
|
|
|
17
38
|
local heartSubTypes = getEnumValues(nil, HeartSubType)
|
|
18
39
|
return getRandomArrayElement(nil, heartSubTypes, seed, exceptions)
|
|
19
40
|
end
|
|
20
|
-
local CHEST_PICKUP_VARIANTS = __TS__New(Set, {
|
|
21
|
-
PickupVariant.PICKUP_CHEST,
|
|
22
|
-
PickupVariant.PICKUP_BOMBCHEST,
|
|
23
|
-
PickupVariant.PICKUP_SPIKEDCHEST,
|
|
24
|
-
PickupVariant.PICKUP_ETERNALCHEST,
|
|
25
|
-
PickupVariant.PICKUP_MIMICCHEST,
|
|
26
|
-
PickupVariant.PICKUP_OLDCHEST,
|
|
27
|
-
PickupVariant.PICKUP_WOODENCHEST,
|
|
28
|
-
PickupVariant.PICKUP_MEGACHEST,
|
|
29
|
-
PickupVariant.PICKUP_HAUNTEDCHEST,
|
|
30
|
-
PickupVariant.PICKUP_LOCKEDCHEST,
|
|
31
|
-
PickupVariant.PICKUP_REDCHEST,
|
|
32
|
-
PickupVariant.PICKUP_MOMSCHEST
|
|
33
|
-
})
|
|
34
41
|
function ____exports.isChest(self, pickup)
|
|
35
42
|
return CHEST_PICKUP_VARIANTS:has(pickup.Variant)
|
|
36
43
|
end
|
|
44
|
+
function ____exports.removeAllPickups(self, variant, subType, cap)
|
|
45
|
+
local pickups = ____exports.getPickups(nil, variant, subType)
|
|
46
|
+
return removeEntities(nil, pickups, cap)
|
|
47
|
+
end
|
|
37
48
|
return ____exports
|
|
@@ -22,6 +22,7 @@ local MAX_VANILLA_CHARACTER = ____constants.MAX_VANILLA_CHARACTER
|
|
|
22
22
|
local ____HealthType = require("types.HealthType")
|
|
23
23
|
local HealthType = ____HealthType.HealthType
|
|
24
24
|
local ____array = require("functions.array")
|
|
25
|
+
local getLastElement = ____array.getLastElement
|
|
25
26
|
local sumArray = ____array.sumArray
|
|
26
27
|
local ____bitwise = require("functions.bitwise")
|
|
27
28
|
local getKBitOfN = ____bitwise.getKBitOfN
|
|
@@ -336,7 +337,7 @@ function ____exports.getEffectsList(self, player)
|
|
|
336
337
|
end
|
|
337
338
|
function ____exports.getFinalPlayer(self)
|
|
338
339
|
local players = ____exports.getPlayers(nil)
|
|
339
|
-
return players
|
|
340
|
+
return getLastElement(nil, players)
|
|
340
341
|
end
|
|
341
342
|
function ____exports.getLastHeart(self, player)
|
|
342
343
|
local hearts = player:GetHearts()
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
+
/**
|
|
3
|
+
* Helper function to get a room position that is not overlapping with a grid entity, a heaven door,
|
|
4
|
+
* or a player. The `Room.FindFreePickupSpawnPosition()` function will return locations that overlap
|
|
5
|
+
* with heaven doors and partially overlap with players, if the thing being spawned is bigger than a
|
|
6
|
+
* tile (like a Blood Donation Machine). Use this function instead if you want to account for those
|
|
7
|
+
* specific situations.
|
|
8
|
+
*
|
|
9
|
+
* @param startingPosition The position to start searching from. If this position is not overlapping
|
|
10
|
+
* with anything, then it will be returned.
|
|
11
|
+
* @param avoidActiveEntities Optional. False by default.
|
|
12
|
+
*/
|
|
13
|
+
export declare function findFreePosition(startingPosition: Vector, avoidActiveEntities?: boolean): Vector;
|
|
14
|
+
/**
|
|
15
|
+
* Helper function to get a map containing the positions of every entity in the current room.
|
|
16
|
+
*
|
|
17
|
+
* This is useful for rewinding entity positions at a later time. Also see `setEntityPositions()`.
|
|
18
|
+
*
|
|
19
|
+
* @param entities Optional. If provided, will only get the positions of the provided entities. This
|
|
20
|
+
* can be used to cache the entities to avoid invoking `Isaac.GetRoomEntities()` multiple times.
|
|
21
|
+
*/
|
|
22
|
+
export declare function getEntityPositions(entities?: Entity[]): Map<PtrHash, Vector>;
|
|
23
|
+
/**
|
|
24
|
+
* Helper function to get a map containing the velocities of every entity in the current room.
|
|
25
|
+
*
|
|
26
|
+
* This is useful for rewinding entity velocities at a later time. Also see `setEntityVelocities()`.
|
|
27
|
+
*
|
|
28
|
+
* @param entities Optional. If provided, will only get the velocities of the provided entities.
|
|
29
|
+
* This can be used to cache the entities to avoid invoking `Isaac.GetRoomEntities()` multiple
|
|
30
|
+
* times.
|
|
31
|
+
*/
|
|
32
|
+
export declare function getEntityVelocities(entities?: Entity[]): Map<PtrHash, Vector>;
|
|
33
|
+
/**
|
|
34
|
+
* Helper function to set the position of every entity in the room based on a map of positions. If
|
|
35
|
+
* an entity is found that does not have matching element in the provided map, then that entity will
|
|
36
|
+
* be skipped.
|
|
37
|
+
*
|
|
38
|
+
* This function is useful for rewinding entity positions at a later time. Also see
|
|
39
|
+
* `getEntityPositions()`.
|
|
40
|
+
*
|
|
41
|
+
* @param entityPositions The map providing the positions for every entity.
|
|
42
|
+
* @param entities Optional. If provided, will only set the positions of the provided entities. This
|
|
43
|
+
* can be used to cache the entities to avoid invoking `Isaac.GetRoomEntities()` multiple times.
|
|
44
|
+
*/
|
|
45
|
+
export declare function setEntityPositions(entityPositions: Map<PtrHash, Vector>, entities?: Entity[]): void;
|
|
46
|
+
/**
|
|
47
|
+
* Helper function to set the velocity of every entity in the room based on a map of velocities. If
|
|
48
|
+
* an entity is found that does not have matching element in the provided map, then that entity will
|
|
49
|
+
* be skipped.
|
|
50
|
+
*
|
|
51
|
+
* This function is useful for rewinding entity velocities at a later time. Also see
|
|
52
|
+
* `getEntityVelocities()`.
|
|
53
|
+
*
|
|
54
|
+
* @param entityVelocities The map providing the velocities for every entity.
|
|
55
|
+
* @param entities Optional. If provided, will only set the velocities of the provided entities.
|
|
56
|
+
* This can be used to cache the entities to avoid invoking `Isaac.GetRoomEntities()` multiple
|
|
57
|
+
* times.
|
|
58
|
+
*/
|
|
59
|
+
export declare function setEntityVelocities(entityVelocities: Map<PtrHash, Vector>, entities?: Entity[]): void;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
|
+
local ____lualib = require("lualib_bundle")
|
|
3
|
+
local Map = ____lualib.Map
|
|
4
|
+
local __TS__New = ____lualib.__TS__New
|
|
5
|
+
local ____exports = {}
|
|
6
|
+
local ____constants = require("constants")
|
|
7
|
+
local DISTANCE_OF_GRID_TILE = ____constants.DISTANCE_OF_GRID_TILE
|
|
8
|
+
local ____entity = require("functions.entity")
|
|
9
|
+
local anyEntityCloserThan = ____entity.anyEntityCloserThan
|
|
10
|
+
local getEntities = ____entity.getEntities
|
|
11
|
+
local ____entitySpecific = require("functions.entitySpecific")
|
|
12
|
+
local getEffects = ____entitySpecific.getEffects
|
|
13
|
+
local ____player = require("functions.player")
|
|
14
|
+
local getPlayerCloserThan = ____player.getPlayerCloserThan
|
|
15
|
+
local MAX_FIND_FREE_POSITION_ATTEMPTS = 100
|
|
16
|
+
function ____exports.findFreePosition(self, startingPosition, avoidActiveEntities)
|
|
17
|
+
if avoidActiveEntities == nil then
|
|
18
|
+
avoidActiveEntities = false
|
|
19
|
+
end
|
|
20
|
+
local game = Game()
|
|
21
|
+
local room = game:GetRoom()
|
|
22
|
+
local heavenDoors = getEffects(nil, EffectVariant.HEAVEN_LIGHT_DOOR, 0)
|
|
23
|
+
do
|
|
24
|
+
local i = 0
|
|
25
|
+
while i < MAX_FIND_FREE_POSITION_ATTEMPTS do
|
|
26
|
+
do
|
|
27
|
+
local position = room:FindFreePickupSpawnPosition(startingPosition, i, avoidActiveEntities)
|
|
28
|
+
local closePlayer = getPlayerCloserThan(nil, position, DISTANCE_OF_GRID_TILE)
|
|
29
|
+
if closePlayer ~= nil then
|
|
30
|
+
goto __continue3
|
|
31
|
+
end
|
|
32
|
+
local isCloseHeavenDoor = anyEntityCloserThan(nil, heavenDoors, position, DISTANCE_OF_GRID_TILE)
|
|
33
|
+
if isCloseHeavenDoor then
|
|
34
|
+
goto __continue3
|
|
35
|
+
end
|
|
36
|
+
return position
|
|
37
|
+
end
|
|
38
|
+
::__continue3::
|
|
39
|
+
i = i + 1
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
return room:FindFreePickupSpawnPosition(startingPosition)
|
|
43
|
+
end
|
|
44
|
+
function ____exports.getEntityPositions(self, entities)
|
|
45
|
+
if entities == nil then
|
|
46
|
+
entities = getEntities(nil)
|
|
47
|
+
end
|
|
48
|
+
local entityPositions = __TS__New(Map)
|
|
49
|
+
for ____, entity in ipairs(entities) do
|
|
50
|
+
local ptrHash = GetPtrHash(entity)
|
|
51
|
+
entityPositions:set(ptrHash, entity.Position)
|
|
52
|
+
end
|
|
53
|
+
return entityPositions
|
|
54
|
+
end
|
|
55
|
+
function ____exports.getEntityVelocities(self, entities)
|
|
56
|
+
if entities == nil then
|
|
57
|
+
entities = getEntities(nil)
|
|
58
|
+
end
|
|
59
|
+
local entityVelocities = __TS__New(Map)
|
|
60
|
+
for ____, entity in ipairs(entities) do
|
|
61
|
+
local ptrHash = GetPtrHash(entity)
|
|
62
|
+
entityVelocities:set(ptrHash, entity.Velocity)
|
|
63
|
+
end
|
|
64
|
+
return entityVelocities
|
|
65
|
+
end
|
|
66
|
+
function ____exports.setEntityPositions(self, entityPositions, entities)
|
|
67
|
+
if entities == nil then
|
|
68
|
+
entities = getEntities(nil)
|
|
69
|
+
end
|
|
70
|
+
for ____, entity in ipairs(entities) do
|
|
71
|
+
local ptrHash = GetPtrHash(entity)
|
|
72
|
+
local entityPosition = entityPositions:get(ptrHash)
|
|
73
|
+
if entityPosition ~= nil then
|
|
74
|
+
entity.Position = entityPosition
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
function ____exports.setEntityVelocities(self, entityVelocities, entities)
|
|
79
|
+
if entities == nil then
|
|
80
|
+
entities = getEntities(nil)
|
|
81
|
+
end
|
|
82
|
+
for ____, entity in ipairs(entities) do
|
|
83
|
+
local ptrHash = GetPtrHash(entity)
|
|
84
|
+
local entityVelocity = entityVelocities:get(ptrHash)
|
|
85
|
+
if entityVelocity ~= nil then
|
|
86
|
+
entity.Velocity = entityVelocity
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
return ____exports
|
package/dist/functions/rooms.lua
CHANGED
|
@@ -21,14 +21,15 @@ local isHiddenSecretRoomDoor = ____doors.isHiddenSecretRoomDoor
|
|
|
21
21
|
local openDoorFast = ____doors.openDoorFast
|
|
22
22
|
local ____entity = require("functions.entity")
|
|
23
23
|
local getEntities = ____entity.getEntities
|
|
24
|
-
local getEntityPositions = ____entity.getEntityPositions
|
|
25
|
-
local getEntityVelocities = ____entity.getEntityVelocities
|
|
26
|
-
local setEntityPositions = ____entity.setEntityPositions
|
|
27
|
-
local setEntityVelocities = ____entity.setEntityVelocities
|
|
28
24
|
local ____flag = require("functions.flag")
|
|
29
25
|
local hasFlag = ____flag.hasFlag
|
|
30
26
|
local ____math = require("functions.math")
|
|
31
27
|
local range = ____math.range
|
|
28
|
+
local ____positionVelocity = require("functions.positionVelocity")
|
|
29
|
+
local getEntityPositions = ____positionVelocity.getEntityPositions
|
|
30
|
+
local getEntityVelocities = ____positionVelocity.getEntityVelocities
|
|
31
|
+
local setEntityPositions = ____positionVelocity.setEntityPositions
|
|
32
|
+
local setEntityVelocities = ____positionVelocity.setEntityVelocities
|
|
32
33
|
function ____exports.getCurrentRoomDescriptorReadOnly(self)
|
|
33
34
|
local game = Game()
|
|
34
35
|
local level = game:GetLevel()
|
|
@@ -6,10 +6,10 @@ local ____trinketDescriptionMap = require("maps.trinketDescriptionMap")
|
|
|
6
6
|
local TRINKET_DESCRIPTION_MAP = ____trinketDescriptionMap.TRINKET_DESCRIPTION_MAP
|
|
7
7
|
local ____trinketNameMap = require("maps.trinketNameMap")
|
|
8
8
|
local TRINKET_NAME_MAP = ____trinketNameMap.TRINKET_NAME_MAP
|
|
9
|
-
local ____entity = require("functions.entity")
|
|
10
|
-
local getPickups = ____entity.getPickups
|
|
11
9
|
local ____flag = require("functions.flag")
|
|
12
10
|
local hasFlag = ____flag.hasFlag
|
|
11
|
+
local ____pickups = require("functions.pickups")
|
|
12
|
+
local getPickups = ____pickups.getPickups
|
|
13
13
|
local ____player = require("functions.player")
|
|
14
14
|
local useActiveItemTemp = ____player.useActiveItemTemp
|
|
15
15
|
local ____trinketGive = require("functions.trinketGive")
|
package/dist/index.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export { deepCopy } from "./functions/deepCopy";
|
|
|
22
22
|
export { deepCopyTests } from "./functions/deepCopyTests";
|
|
23
23
|
export * from "./functions/doors";
|
|
24
24
|
export * from "./functions/entity";
|
|
25
|
+
export * from "./functions/entitySpecific";
|
|
25
26
|
export * from "./functions/familiars";
|
|
26
27
|
export * from "./functions/flag";
|
|
27
28
|
export * from "./functions/flying";
|
|
@@ -40,7 +41,7 @@ export * from "./functions/pills";
|
|
|
40
41
|
export * from "./functions/player";
|
|
41
42
|
export * from "./functions/playerHealth";
|
|
42
43
|
export * from "./functions/pocketItems";
|
|
43
|
-
export * from "./functions/
|
|
44
|
+
export * from "./functions/positionVelocity";
|
|
44
45
|
export * from "./functions/random";
|
|
45
46
|
export * from "./functions/revive";
|
|
46
47
|
export * from "./functions/rooms";
|
package/dist/index.lua
CHANGED
|
@@ -186,6 +186,14 @@ do
|
|
|
186
186
|
end
|
|
187
187
|
end
|
|
188
188
|
end
|
|
189
|
+
do
|
|
190
|
+
local ____export = require("functions.entitySpecific")
|
|
191
|
+
for ____exportKey, ____exportValue in pairs(____export) do
|
|
192
|
+
if ____exportKey ~= "default" then
|
|
193
|
+
____exports[____exportKey] = ____exportValue
|
|
194
|
+
end
|
|
195
|
+
end
|
|
196
|
+
end
|
|
189
197
|
do
|
|
190
198
|
local ____export = require("functions.familiars")
|
|
191
199
|
for ____exportKey, ____exportValue in pairs(____export) do
|
|
@@ -331,7 +339,7 @@ do
|
|
|
331
339
|
end
|
|
332
340
|
end
|
|
333
341
|
do
|
|
334
|
-
local ____export = require("functions.
|
|
342
|
+
local ____export = require("functions.positionVelocity")
|
|
335
343
|
for ____exportKey, ____exportValue in pairs(____export) do
|
|
336
344
|
if ____exportKey ~= "default" then
|
|
337
345
|
____exports[____exportKey] = ____exportValue
|