isaacscript-common 1.2.108 → 1.2.111
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 +18 -69
- package/dist/callbacks/subscriptions/postPurchase.d.ts +1 -2
- package/dist/callbacks/subscriptions/postPurchase.lua +2 -2
- package/dist/features/getCollectibleItemPoolType.lua +4 -1
- package/dist/functions/collectibles.d.ts +3 -1
- package/dist/functions/collectibles.lua +9 -2
- package/dist/functions/entity.d.ts +2 -0
- package/dist/functions/entity.lua +3 -0
- package/dist/index.d.ts +0 -1
- package/dist/types/CollectiblePedestalType.d.ts +38 -0
- package/dist/types/CollectiblePedestalType.lua +36 -0
- package/dist/types/PickupDescription.d.ts +1 -0
- package/dist/types/PickupDescription.lua +10 -0
- package/package.json +1 -1
|
@@ -1,99 +1,48 @@
|
|
|
1
1
|
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
2
|
local ____lualib = require("lualib_bundle")
|
|
3
|
-
local Map = ____lualib.Map
|
|
4
3
|
local __TS__New = ____lualib.__TS__New
|
|
5
|
-
local __TS__Iterator = ____lualib.__TS__Iterator
|
|
6
4
|
local __TS__ArrayFind = ____lualib.__TS__ArrayFind
|
|
7
|
-
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
|
|
8
5
|
local ____exports = {}
|
|
9
|
-
local hasSubscriptions,
|
|
6
|
+
local hasSubscriptions, postPEffectUpdate, playerPickedUpNewItem, v
|
|
10
7
|
local ____exports = require("features.saveDataManager.exports")
|
|
11
8
|
local saveDataManager = ____exports.saveDataManager
|
|
12
9
|
local ____pickups = require("functions.pickups")
|
|
13
10
|
local getPickups = ____pickups.getPickups
|
|
14
11
|
local ____player = require("functions.player")
|
|
15
12
|
local getPlayerIndex = ____player.getPlayerIndex
|
|
16
|
-
local
|
|
13
|
+
local ____DefaultMap = require("types.DefaultMap")
|
|
14
|
+
local DefaultMap = ____DefaultMap.DefaultMap
|
|
17
15
|
local ____postPurchase = require("callbacks.subscriptions.postPurchase")
|
|
18
16
|
local postPurchaseFire = ____postPurchase.postPurchaseFire
|
|
19
17
|
local postPurchaseHasSubscriptions = ____postPurchase.postPurchaseHasSubscriptions
|
|
20
18
|
function hasSubscriptions(self)
|
|
21
19
|
return postPurchaseHasSubscriptions(nil)
|
|
22
20
|
end
|
|
23
|
-
function
|
|
21
|
+
function postPEffectUpdate(self, player)
|
|
24
22
|
if not hasSubscriptions(nil) then
|
|
25
23
|
return
|
|
26
24
|
end
|
|
27
|
-
local
|
|
28
|
-
local
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
function checkPickupsPurchased(self, pickups, players)
|
|
34
|
-
for ____, ____value in __TS__Iterator(v.room.pickupMap:entries()) do
|
|
35
|
-
local index = ____value[1]
|
|
36
|
-
local pickupDescription = ____value[2]
|
|
37
|
-
do
|
|
38
|
-
if pickupAtIndexStillExists(nil, index, pickups) then
|
|
39
|
-
goto __continue7
|
|
40
|
-
end
|
|
41
|
-
v.room.pickupMap:delete(index)
|
|
42
|
-
local player = getPlayerThatIsNoLongerHoldingAnItem(nil, players)
|
|
43
|
-
if player ~= nil then
|
|
44
|
-
postPurchaseFire(nil, player, pickupDescription)
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
::__continue7::
|
|
25
|
+
local isHoldingItem = player:IsHoldingItem()
|
|
26
|
+
local playerIndex = getPlayerIndex(nil, player)
|
|
27
|
+
local wasHoldingItemOnLastFrame = v.room.playersHoldingItemOnLastFrameMap:getAndSetDefault(playerIndex)
|
|
28
|
+
v.room.playersHoldingItemOnLastFrameMap:set(playerIndex, isHoldingItem)
|
|
29
|
+
if not wasHoldingItemOnLastFrame and isHoldingItem then
|
|
30
|
+
playerPickedUpNewItem(nil, player)
|
|
48
31
|
end
|
|
49
32
|
end
|
|
50
|
-
function
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
function(____, player)
|
|
54
|
-
local playerHoldingItem = player:IsHoldingItem()
|
|
55
|
-
local playerIndex = getPlayerIndex(nil, player)
|
|
56
|
-
local playerHoldingItemLastFrame = v.room.playerHoldingItemLastFrameMap:get(playerIndex)
|
|
57
|
-
return playerHoldingItemLastFrame == false and playerHoldingItem
|
|
58
|
-
end
|
|
59
|
-
)
|
|
60
|
-
end
|
|
61
|
-
function storePickupsInMap(self, pickups)
|
|
62
|
-
local pickupsWithPrice = __TS__ArrayFilter(
|
|
33
|
+
function playerPickedUpNewItem(self, player)
|
|
34
|
+
local pickups = getPickups(nil)
|
|
35
|
+
local disappearingPickup = __TS__ArrayFind(
|
|
63
36
|
pickups,
|
|
64
|
-
function(____, pickup) return pickup.Price ~= 0 end
|
|
37
|
+
function(____, pickup) return not pickup:Exists() and pickup.Price ~= 0 end
|
|
65
38
|
)
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
variant = pickup.Variant,
|
|
69
|
-
subType = pickup.SubType,
|
|
70
|
-
position = pickup.Position,
|
|
71
|
-
velocity = pickup.Velocity,
|
|
72
|
-
price = pickup.Price,
|
|
73
|
-
initSeed = pickup.InitSeed
|
|
74
|
-
})
|
|
39
|
+
if disappearingPickup ~= nil then
|
|
40
|
+
postPurchaseFire(nil, player, disappearingPickup)
|
|
75
41
|
end
|
|
76
42
|
end
|
|
77
|
-
|
|
78
|
-
for ____, player in ipairs(players) do
|
|
79
|
-
local playerIndex = getPlayerIndex(nil, player)
|
|
80
|
-
local holdingItem = player:IsHoldingItem()
|
|
81
|
-
v.room.playerHoldingItemLastFrameMap:set(playerIndex, holdingItem)
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
function pickupAtIndexStillExists(self, index, pickups)
|
|
85
|
-
local pickupAtIndex = __TS__ArrayFind(
|
|
86
|
-
pickups,
|
|
87
|
-
function(____, pickup) return pickup.Index end
|
|
88
|
-
)
|
|
89
|
-
return pickupAtIndex ~= nil and pickupAtIndex:Exists()
|
|
90
|
-
end
|
|
91
|
-
v = {room = {
|
|
92
|
-
pickupMap = __TS__New(Map),
|
|
93
|
-
playerHoldingItemLastFrameMap = __TS__New(Map)
|
|
94
|
-
}}
|
|
43
|
+
v = {room = {playersHoldingItemOnLastFrameMap = __TS__New(DefaultMap, false)}}
|
|
95
44
|
function ____exports.postPurchaseCallbackInit(self, mod)
|
|
96
45
|
saveDataManager(nil, "postPurchase", v, hasSubscriptions)
|
|
97
|
-
mod:AddCallback(ModCallbacks.
|
|
46
|
+
mod:AddCallback(ModCallbacks.MC_POST_PEFFECT_UPDATE, postPEffectUpdate)
|
|
98
47
|
end
|
|
99
48
|
return ____exports
|
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
-
|
|
3
|
-
export declare type PostPurchaseCallbackType = (player: EntityPlayer, pickupDescription: PickupDescription) => void;
|
|
2
|
+
export declare type PostPurchaseCallbackType = (player: EntityPlayer, pickup: EntityPickup) => void;
|
|
@@ -9,10 +9,10 @@ end
|
|
|
9
9
|
function ____exports.postPurchaseRegister(self, callback, pickupVariant, pickupSubType)
|
|
10
10
|
__TS__ArrayPush(subscriptions, {callback, pickupVariant, pickupSubType})
|
|
11
11
|
end
|
|
12
|
-
function ____exports.postPurchaseFire(self, player,
|
|
12
|
+
function ____exports.postPurchaseFire(self, player, pickup)
|
|
13
13
|
for ____, ____value in ipairs(subscriptions) do
|
|
14
14
|
local callback = ____value[1]
|
|
15
|
-
callback(nil, player,
|
|
15
|
+
callback(nil, player, pickup)
|
|
16
16
|
end
|
|
17
17
|
end
|
|
18
18
|
return ____exports
|
|
@@ -6,6 +6,8 @@ local ____exports = {}
|
|
|
6
6
|
local postPickupInitCollectible, v
|
|
7
7
|
local ____errors = require("errors")
|
|
8
8
|
local getUpgradeErrorMsg = ____errors.getUpgradeErrorMsg
|
|
9
|
+
local ____entity = require("functions.entity")
|
|
10
|
+
local getEntityID = ____entity.getEntityID
|
|
9
11
|
local ____rooms = require("functions.rooms")
|
|
10
12
|
local getRoomItemPoolType = ____rooms.getRoomItemPoolType
|
|
11
13
|
local ____exports = require("features.saveDataManager.exports")
|
|
@@ -31,7 +33,8 @@ function ____exports.getCollectibleItemPoolType(self, collectible)
|
|
|
31
33
|
error(msg)
|
|
32
34
|
end
|
|
33
35
|
if collectible.Type ~= EntityType.ENTITY_PICKUP or collectible.Variant ~= PickupVariant.PICKUP_COLLECTIBLE then
|
|
34
|
-
|
|
36
|
+
local entityID = getEntityID(nil, collectible)
|
|
37
|
+
error("The \"getCollectibleItemPoolType()\" function was given a non-collectible: " .. entityID)
|
|
35
38
|
end
|
|
36
39
|
local ptrHash = GetPtrHash(collectible)
|
|
37
40
|
local itemPoolType = v.run.collectibleItemPoolTypeMap:get(ptrHash)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
+
import { CollectiblePedestalType } from "../types/CollectiblePedestalType";
|
|
2
3
|
export declare function collectibleHasTag(collectibleType: CollectibleType | int, tag: ItemConfigTag): boolean;
|
|
3
4
|
export declare function clearCollectibleSprite(collectible: EntityPickup): void;
|
|
4
5
|
export declare function collectibleHasCacheFlag(collectibleType: CollectibleType | int, cacheFlag: CacheFlag): boolean;
|
|
@@ -48,6 +49,7 @@ export declare function getCollectibleMaxCharges(collectibleType: CollectibleTyp
|
|
|
48
49
|
* ```
|
|
49
50
|
*/
|
|
50
51
|
export declare function getCollectibleName(collectibleType: CollectibleType | int): string;
|
|
52
|
+
export declare function getCollectiblePedestalType(collectible: EntityPickup): CollectiblePedestalType;
|
|
51
53
|
/** Helper function to get all of the collectible entities in the room. */
|
|
52
54
|
export declare function getCollectibles(matchingSubType?: number): EntityPickup[];
|
|
53
55
|
export declare function getMaxCollectibleType(): int;
|
|
@@ -56,7 +58,7 @@ export declare function getMaxCollectibleType(): int;
|
|
|
56
58
|
* glitched items once a player has TMTRAINER. However, glitched items can also "naturally" appear
|
|
57
59
|
* in secret rooms and I AM ERROR rooms if the "Corrupted Data" achievement is unlocked.
|
|
58
60
|
*/
|
|
59
|
-
export declare function isGlitchedCollectible(
|
|
61
|
+
export declare function isGlitchedCollectible(pickup: EntityPickup): boolean;
|
|
60
62
|
/**
|
|
61
63
|
* Returns true if the item type in the item config is equal to `ItemType.ITEM_PASSIVE` or
|
|
62
64
|
* `ItemType.ITEM_FAMILIAR`.
|
|
@@ -138,6 +138,13 @@ function ____exports.getCollectibleName(self, collectibleType)
|
|
|
138
138
|
end
|
|
139
139
|
return itemConfigItem.Name
|
|
140
140
|
end
|
|
141
|
+
function ____exports.getCollectiblePedestalType(self, collectible)
|
|
142
|
+
if collectible.Variant ~= PickupVariant.PICKUP_COLLECTIBLE then
|
|
143
|
+
error("You cannot get the pedestal type for pickups of variant: " .. tostring(collectible.Variant))
|
|
144
|
+
end
|
|
145
|
+
local sprite = collectible:GetSprite()
|
|
146
|
+
return sprite:GetOverlayFrame()
|
|
147
|
+
end
|
|
141
148
|
function ____exports.getCollectibles(self, matchingSubType)
|
|
142
149
|
if matchingSubType == nil then
|
|
143
150
|
matchingSubType = -1
|
|
@@ -148,8 +155,8 @@ function ____exports.getMaxCollectibleType(self)
|
|
|
148
155
|
local itemConfig = Isaac.GetItemConfig()
|
|
149
156
|
return itemConfig:GetCollectibles().Size - 1
|
|
150
157
|
end
|
|
151
|
-
function ____exports.isGlitchedCollectible(self,
|
|
152
|
-
return
|
|
158
|
+
function ____exports.isGlitchedCollectible(self, pickup)
|
|
159
|
+
return pickup.Variant == PickupVariant.PICKUP_COLLECTIBLE and pickup.SubType > GLITCHED_ITEM_THRESHOLD
|
|
153
160
|
end
|
|
154
161
|
function ____exports.isPassiveCollectible(self, collectibleType)
|
|
155
162
|
local itemType = ____exports.getCollectibleItemType(nil, collectibleType)
|
|
@@ -53,6 +53,8 @@ export declare function getFilteredNewEntities<T extends AnyEntity>(oldEntities:
|
|
|
53
53
|
* returned. False by default. Will only be taken into account if `matchingEntityType` is specified.
|
|
54
54
|
*/
|
|
55
55
|
export declare function getEntities(matchingEntityType?: EntityType | int, matchingVariant?: number, matchingSubType?: number, ignoreFriendly?: boolean): Entity[];
|
|
56
|
+
/** Helper function to return a string containing an entity's type, variant, and sub-type. */
|
|
57
|
+
export declare function getEntityID(entity: Entity): string;
|
|
56
58
|
/**
|
|
57
59
|
* Helper function to measure an entity's velocity to see if it is moving.
|
|
58
60
|
*
|
|
@@ -88,6 +88,9 @@ function ____exports.getEntities(self, matchingEntityType, matchingVariant, matc
|
|
|
88
88
|
end
|
|
89
89
|
return Isaac.FindByType(matchingEntityType, matchingVariant, matchingSubType, ignoreFriendly)
|
|
90
90
|
end
|
|
91
|
+
function ____exports.getEntityID(self, entity)
|
|
92
|
+
return (((tostring(entity.Type) .. ".") .. tostring(entity.Variant)) .. ".") .. tostring(entity.SubType)
|
|
93
|
+
end
|
|
91
94
|
function ____exports.isEntityMoving(self, entity, threshold)
|
|
92
95
|
if threshold == nil then
|
|
93
96
|
threshold = 0.01
|
package/dist/index.d.ts
CHANGED
|
@@ -90,7 +90,6 @@ export * from "./types/JSONSpawn";
|
|
|
90
90
|
export * from "./types/ModCallbacksCustom";
|
|
91
91
|
export * from "./types/ModUpgraded";
|
|
92
92
|
export * from "./types/PickingUpItem";
|
|
93
|
-
export * from "./types/PickupDescription";
|
|
94
93
|
export * from "./types/PillEffectClass";
|
|
95
94
|
export * from "./types/PillEffectType";
|
|
96
95
|
export * from "./types/PlayerHealth";
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/** Corresponds to the overlay frame number in "005.100_collectible.anm2". */
|
|
2
|
+
export declare enum CollectiblePedestalType {
|
|
3
|
+
/**
|
|
4
|
+
* Used for e.g. shop collectibles. In the "005.100_collectible.anm2" file, this is represented by
|
|
5
|
+
* the final frame.
|
|
6
|
+
*/
|
|
7
|
+
NONE = -1,
|
|
8
|
+
/** The normal grey pedestal. */
|
|
9
|
+
NORMAL = 0,
|
|
10
|
+
/** From SlotVariant.FORTUNE_TELLING_MACHINE (3) */
|
|
11
|
+
FORTUNE_TELLING_MACHINE = 1,
|
|
12
|
+
/** From SlotVariant.BLOOD_DONATION_MACHINE (2) */
|
|
13
|
+
BLOOD_DONATION_MACHINE = 2,
|
|
14
|
+
/** From SlotVariant.SLOT_MACHINE (1) */
|
|
15
|
+
SLOT_MACHINE = 3,
|
|
16
|
+
/** From PickupVariant.LOCKEDCHEST (60) */
|
|
17
|
+
LOCKEDCHEST = 4,
|
|
18
|
+
/** From PickupVariant.PICKUP_REDCHEST (360) */
|
|
19
|
+
REDCHEST = 5,
|
|
20
|
+
/** From PickupVariant.PICKUP_BOMBCHEST (51) */
|
|
21
|
+
BOMBCHEST = 6,
|
|
22
|
+
/** From PickupVariant.PICKUP_SPIKEDCHEST (52) */
|
|
23
|
+
SPIKEDCHEST = 7,
|
|
24
|
+
/** From PickupVariant.PICKUP_ETERNALCHEST (53) */
|
|
25
|
+
ETERNALCHEST = 8,
|
|
26
|
+
/** From SlotVariant.MOMS_DRESSING_TABLE (12) */
|
|
27
|
+
MOMS_DRESSING_TABLE = 9,
|
|
28
|
+
/** From PickupVariant.PICKUP_CHEST (50) */
|
|
29
|
+
CHEST = 10,
|
|
30
|
+
/** From PickupVariant.PICKUP_MOMSCHEST (390) */
|
|
31
|
+
MOMSCHEST = 11,
|
|
32
|
+
/** From PickupVariant.PICKUP_OLDCHEST (55) */
|
|
33
|
+
OLDCHEST = 12,
|
|
34
|
+
/** From PickupVariant.PICKUP_WOODENCHEST (56) */
|
|
35
|
+
WOODENCHEST = 13,
|
|
36
|
+
/** From PickupVariant.PICKUP_MEGACHEST (57) */
|
|
37
|
+
MEGACHEST = 14
|
|
38
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
|
+
local ____exports = {}
|
|
3
|
+
____exports.CollectiblePedestalType = CollectiblePedestalType or ({})
|
|
4
|
+
____exports.CollectiblePedestalType.NONE = -1
|
|
5
|
+
____exports.CollectiblePedestalType[____exports.CollectiblePedestalType.NONE] = "NONE"
|
|
6
|
+
____exports.CollectiblePedestalType.NORMAL = 0
|
|
7
|
+
____exports.CollectiblePedestalType[____exports.CollectiblePedestalType.NORMAL] = "NORMAL"
|
|
8
|
+
____exports.CollectiblePedestalType.FORTUNE_TELLING_MACHINE = 1
|
|
9
|
+
____exports.CollectiblePedestalType[____exports.CollectiblePedestalType.FORTUNE_TELLING_MACHINE] = "FORTUNE_TELLING_MACHINE"
|
|
10
|
+
____exports.CollectiblePedestalType.BLOOD_DONATION_MACHINE = 2
|
|
11
|
+
____exports.CollectiblePedestalType[____exports.CollectiblePedestalType.BLOOD_DONATION_MACHINE] = "BLOOD_DONATION_MACHINE"
|
|
12
|
+
____exports.CollectiblePedestalType.SLOT_MACHINE = 3
|
|
13
|
+
____exports.CollectiblePedestalType[____exports.CollectiblePedestalType.SLOT_MACHINE] = "SLOT_MACHINE"
|
|
14
|
+
____exports.CollectiblePedestalType.LOCKEDCHEST = 4
|
|
15
|
+
____exports.CollectiblePedestalType[____exports.CollectiblePedestalType.LOCKEDCHEST] = "LOCKEDCHEST"
|
|
16
|
+
____exports.CollectiblePedestalType.REDCHEST = 5
|
|
17
|
+
____exports.CollectiblePedestalType[____exports.CollectiblePedestalType.REDCHEST] = "REDCHEST"
|
|
18
|
+
____exports.CollectiblePedestalType.BOMBCHEST = 6
|
|
19
|
+
____exports.CollectiblePedestalType[____exports.CollectiblePedestalType.BOMBCHEST] = "BOMBCHEST"
|
|
20
|
+
____exports.CollectiblePedestalType.SPIKEDCHEST = 7
|
|
21
|
+
____exports.CollectiblePedestalType[____exports.CollectiblePedestalType.SPIKEDCHEST] = "SPIKEDCHEST"
|
|
22
|
+
____exports.CollectiblePedestalType.ETERNALCHEST = 8
|
|
23
|
+
____exports.CollectiblePedestalType[____exports.CollectiblePedestalType.ETERNALCHEST] = "ETERNALCHEST"
|
|
24
|
+
____exports.CollectiblePedestalType.MOMS_DRESSING_TABLE = 9
|
|
25
|
+
____exports.CollectiblePedestalType[____exports.CollectiblePedestalType.MOMS_DRESSING_TABLE] = "MOMS_DRESSING_TABLE"
|
|
26
|
+
____exports.CollectiblePedestalType.CHEST = 10
|
|
27
|
+
____exports.CollectiblePedestalType[____exports.CollectiblePedestalType.CHEST] = "CHEST"
|
|
28
|
+
____exports.CollectiblePedestalType.MOMSCHEST = 11
|
|
29
|
+
____exports.CollectiblePedestalType[____exports.CollectiblePedestalType.MOMSCHEST] = "MOMSCHEST"
|
|
30
|
+
____exports.CollectiblePedestalType.OLDCHEST = 12
|
|
31
|
+
____exports.CollectiblePedestalType[____exports.CollectiblePedestalType.OLDCHEST] = "OLDCHEST"
|
|
32
|
+
____exports.CollectiblePedestalType.WOODENCHEST = 13
|
|
33
|
+
____exports.CollectiblePedestalType[____exports.CollectiblePedestalType.WOODENCHEST] = "WOODENCHEST"
|
|
34
|
+
____exports.CollectiblePedestalType.MEGACHEST = 14
|
|
35
|
+
____exports.CollectiblePedestalType[____exports.CollectiblePedestalType.MEGACHEST] = "MEGACHEST"
|
|
36
|
+
return ____exports
|
|
@@ -1,3 +1,13 @@
|
|
|
1
1
|
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
2
|
local ____exports = {}
|
|
3
|
+
function ____exports.getPickupDescription(self, pickup)
|
|
4
|
+
return {
|
|
5
|
+
variant = pickup.Variant,
|
|
6
|
+
subType = pickup.SubType,
|
|
7
|
+
position = pickup.Position,
|
|
8
|
+
velocity = pickup.Velocity,
|
|
9
|
+
price = pickup.Price,
|
|
10
|
+
initSeed = pickup.InitSeed
|
|
11
|
+
}
|
|
12
|
+
end
|
|
3
13
|
return ____exports
|