isaacscript-common 1.2.141 → 1.2.144
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.
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
+
/**
|
|
3
|
+
* Helper function to get all of the collectibles that the player has gotten so far on this run, in
|
|
4
|
+
* order. This does not include active items.
|
|
5
|
+
*/
|
|
6
|
+
export declare function getPlayerInventory(player: EntityPlayer): CollectibleType[];
|
|
7
|
+
/**
|
|
8
|
+
* Helper function to add a collectible to a player. Use this instead of the
|
|
9
|
+
* `EntityPlayer.AddCollectible` method if you want the collectible that is added to be
|
|
10
|
+
* automatically tracked by the player inventory tracker feature.
|
|
11
|
+
*/
|
|
12
|
+
export declare function addCollectible(player: EntityPlayer, collectibleType: CollectibleType, charge?: int, firstTimePickingUp?: boolean, activeSlot?: ActiveSlot, varData?: int): void;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
|
+
local ____lualib = require("lualib_bundle")
|
|
3
|
+
local __TS__New = ____lualib.__TS__New
|
|
4
|
+
local Set = ____lualib.Set
|
|
5
|
+
local __TS__ArrayPush = ____lualib.__TS__ArrayPush
|
|
6
|
+
local __TS__Iterator = ____lualib.__TS__Iterator
|
|
7
|
+
local ____exports = {}
|
|
8
|
+
local newPlayerInventory, useItemD4, postPlayerInit, postItemPickup, v
|
|
9
|
+
local ____featuresInitialized = require("featuresInitialized")
|
|
10
|
+
local errorIfFeaturesNotInitialized = ____featuresInitialized.errorIfFeaturesNotInitialized
|
|
11
|
+
local ____array = require("functions.array")
|
|
12
|
+
local copyArray = ____array.copyArray
|
|
13
|
+
local ____collectibleSet = require("functions.collectibleSet")
|
|
14
|
+
local getCollectibleSet = ____collectibleSet.getCollectibleSet
|
|
15
|
+
local ____player = require("functions.player")
|
|
16
|
+
local getPlayerIndex = ____player.getPlayerIndex
|
|
17
|
+
local ____utils = require("functions.utils")
|
|
18
|
+
local ____repeat = ____utils["repeat"]
|
|
19
|
+
local ____DefaultMap = require("types.DefaultMap")
|
|
20
|
+
local DefaultMap = ____DefaultMap.DefaultMap
|
|
21
|
+
local ____ModCallbacksCustom = require("types.ModCallbacksCustom")
|
|
22
|
+
local ModCallbacksCustom = ____ModCallbacksCustom.ModCallbacksCustom
|
|
23
|
+
local ____exports = require("features.saveDataManager.exports")
|
|
24
|
+
local saveDataManager = ____exports.saveDataManager
|
|
25
|
+
function newPlayerInventory(self, player)
|
|
26
|
+
local inventory = {}
|
|
27
|
+
local collectibleSet = getCollectibleSet(nil)
|
|
28
|
+
for ____, collectibleType in __TS__Iterator(collectibleSet:values()) do
|
|
29
|
+
local numCollectibles = player:GetCollectibleNum(collectibleType, true)
|
|
30
|
+
____repeat(
|
|
31
|
+
nil,
|
|
32
|
+
numCollectibles,
|
|
33
|
+
function()
|
|
34
|
+
__TS__ArrayPush(inventory, collectibleType)
|
|
35
|
+
end
|
|
36
|
+
)
|
|
37
|
+
end
|
|
38
|
+
return inventory
|
|
39
|
+
end
|
|
40
|
+
function useItemD4(self, _collectibleType, _rng, player)
|
|
41
|
+
local playerIndex = getPlayerIndex(nil, player)
|
|
42
|
+
local inventory = newPlayerInventory(nil, player)
|
|
43
|
+
v.run.playersInventory:set(playerIndex, inventory)
|
|
44
|
+
end
|
|
45
|
+
function postPlayerInit(self, player)
|
|
46
|
+
local playerIndex = getPlayerIndex(nil, player)
|
|
47
|
+
if not v.run.playersInventory:has(playerIndex) then
|
|
48
|
+
local inventory = newPlayerInventory(nil, player)
|
|
49
|
+
v.run.playersInventory:set(playerIndex, inventory)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
function postItemPickup(self, player, pickingUpItem)
|
|
53
|
+
if pickingUpItem.itemType == ItemType.ITEM_PASSIVE or pickingUpItem.itemType == ItemType.ITEM_FAMILIAR then
|
|
54
|
+
local playerIndex = getPlayerIndex(nil, player)
|
|
55
|
+
local inventory = v.run.playersInventory:getAndSetDefault(playerIndex, player)
|
|
56
|
+
__TS__ArrayPush(inventory, pickingUpItem.subType)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
local FEATURE_NAME = "player inventory tracker"
|
|
60
|
+
v = {run = {playersInventory = __TS__New(
|
|
61
|
+
DefaultMap,
|
|
62
|
+
function(____, _key, player) return newPlayerInventory(nil, player) end
|
|
63
|
+
)}}
|
|
64
|
+
function ____exports.playerInventoryInit(self, mod)
|
|
65
|
+
saveDataManager(nil, "playerInventory", v)
|
|
66
|
+
mod:AddCallback(ModCallbacks.MC_USE_ITEM, useItemD4, CollectibleType.COLLECTIBLE_D4)
|
|
67
|
+
mod:AddCallback(ModCallbacks.MC_POST_PLAYER_INIT, postPlayerInit)
|
|
68
|
+
mod:AddCallbackCustom(ModCallbacksCustom.MC_POST_ITEM_PICKUP, postItemPickup)
|
|
69
|
+
end
|
|
70
|
+
function ____exports.getPlayerInventory(self, player)
|
|
71
|
+
errorIfFeaturesNotInitialized(nil, FEATURE_NAME)
|
|
72
|
+
local playerIndex = getPlayerIndex(nil, player)
|
|
73
|
+
local inventory = v.run.playersInventory:getAndSetDefault(playerIndex, player)
|
|
74
|
+
return copyArray(nil, inventory)
|
|
75
|
+
end
|
|
76
|
+
function ____exports.addCollectible(self, player, collectibleType, charge, firstTimePickingUp, activeSlot, varData)
|
|
77
|
+
player:AddCollectible(
|
|
78
|
+
collectibleType,
|
|
79
|
+
charge,
|
|
80
|
+
firstTimePickingUp,
|
|
81
|
+
activeSlot,
|
|
82
|
+
varData
|
|
83
|
+
)
|
|
84
|
+
local playerIndex = getPlayerIndex(nil, player)
|
|
85
|
+
local inventory = v.run.playersInventory:getAndSetDefault(playerIndex, player)
|
|
86
|
+
__TS__ArrayPush(inventory, collectibleType)
|
|
87
|
+
end
|
|
88
|
+
return ____exports
|
|
@@ -3,9 +3,9 @@ import { HealthType } from "../types/HealthType";
|
|
|
3
3
|
import { PlayerHealth } from "../types/PlayerHealth";
|
|
4
4
|
export declare function addPlayerHealthType(player: EntityPlayer, healthType: HealthType, numHearts: int): void;
|
|
5
5
|
/**
|
|
6
|
-
* Helper function to get an
|
|
7
|
-
* `setPlayerHealth` function to restore the player's health back to a certain
|
|
8
|
-
* later time.
|
|
6
|
+
* Helper function to get an object representing the player's health. You can use this in
|
|
7
|
+
* combination with the `setPlayerHealth` function to restore the player's health back to a certain
|
|
8
|
+
* configuration at a later time.
|
|
9
9
|
*
|
|
10
10
|
* This is based on the `REVEL.StoreHealth` function in the Revelations mod.
|
|
11
11
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export { addConsoleCommand, enableExtraConsoleCommands, removeConsoleCommand, }
|
|
|
9
9
|
export { forgottenSwitch } from "./features/forgottenSwitch";
|
|
10
10
|
export { getCollectibleItemPoolType } from "./features/getCollectibleItemPoolType";
|
|
11
11
|
export * from "./features/isPonyActive";
|
|
12
|
+
export { getPlayerInventory } from "./features/playerInventory";
|
|
12
13
|
export { preventCollectibleRotate } from "./features/preventCollectibleRotate";
|
|
13
14
|
export { runInNGameFrames, runInNRenderFrames, runNextGameFrame, runNextRenderFrame, } from "./features/runInNFrames";
|
|
14
15
|
export * from "./features/saveDataManager/exports";
|
package/dist/index.lua
CHANGED
|
@@ -86,6 +86,11 @@ do
|
|
|
86
86
|
end
|
|
87
87
|
end
|
|
88
88
|
end
|
|
89
|
+
do
|
|
90
|
+
local ____playerInventory = require("features.playerInventory")
|
|
91
|
+
local getPlayerInventory = ____playerInventory.getPlayerInventory
|
|
92
|
+
____exports.getPlayerInventory = getPlayerInventory
|
|
93
|
+
end
|
|
89
94
|
do
|
|
90
95
|
local ____preventCollectibleRotate = require("features.preventCollectibleRotate")
|
|
91
96
|
local preventCollectibleRotate = ____preventCollectibleRotate.preventCollectibleRotate
|
package/dist/upgradeMod.lua
CHANGED
|
@@ -85,6 +85,8 @@ local ____getCollectibleItemPoolType = require("features.getCollectibleItemPoolT
|
|
|
85
85
|
local getCollectibleItemPoolTypeInit = ____getCollectibleItemPoolType.getCollectibleItemPoolTypeInit
|
|
86
86
|
local ____isPonyActive = require("features.isPonyActive")
|
|
87
87
|
local isPonyActiveInit = ____isPonyActive.isPonyActiveInit
|
|
88
|
+
local ____playerInventory = require("features.playerInventory")
|
|
89
|
+
local playerInventoryInit = ____playerInventory.playerInventoryInit
|
|
88
90
|
local ____preventCollectibleRotate = require("features.preventCollectibleRotate")
|
|
89
91
|
local preventCollectibleRotateInit = ____preventCollectibleRotate.preventCollectibleRotateInit
|
|
90
92
|
local ____runInNFrames = require("features.runInNFrames")
|
|
@@ -146,6 +148,7 @@ function initFeatures(self, mod)
|
|
|
146
148
|
runInNFramesInit(nil, mod)
|
|
147
149
|
sirenHelpersInit(nil, mod)
|
|
148
150
|
isPonyActiveInit(nil, mod)
|
|
151
|
+
playerInventoryInit(nil, mod)
|
|
149
152
|
end
|
|
150
153
|
function ____exports.upgradeMod(self, modVanilla, verbose)
|
|
151
154
|
if verbose == nil then
|