isaacscript-common 1.2.141 → 1.2.142
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,6 @@
|
|
|
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[];
|
|
@@ -0,0 +1,73 @@
|
|
|
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 ____collectibleSet = require("functions.collectibleSet")
|
|
12
|
+
local getCollectibleSet = ____collectibleSet.getCollectibleSet
|
|
13
|
+
local ____player = require("functions.player")
|
|
14
|
+
local getPlayerIndex = ____player.getPlayerIndex
|
|
15
|
+
local ____utils = require("functions.utils")
|
|
16
|
+
local ____repeat = ____utils["repeat"]
|
|
17
|
+
local ____DefaultMap = require("types.DefaultMap")
|
|
18
|
+
local DefaultMap = ____DefaultMap.DefaultMap
|
|
19
|
+
local ____ModCallbacksCustom = require("types.ModCallbacksCustom")
|
|
20
|
+
local ModCallbacksCustom = ____ModCallbacksCustom.ModCallbacksCustom
|
|
21
|
+
local ____exports = require("features.saveDataManager.exports")
|
|
22
|
+
local saveDataManager = ____exports.saveDataManager
|
|
23
|
+
function newPlayerInventory(self, player)
|
|
24
|
+
local inventory = {}
|
|
25
|
+
local collectibleSet = getCollectibleSet(nil)
|
|
26
|
+
for ____, collectibleType in __TS__Iterator(collectibleSet:values()) do
|
|
27
|
+
local numCollectibles = player:GetCollectibleNum(collectibleType, true)
|
|
28
|
+
____repeat(
|
|
29
|
+
nil,
|
|
30
|
+
numCollectibles,
|
|
31
|
+
function()
|
|
32
|
+
__TS__ArrayPush(inventory, collectibleType)
|
|
33
|
+
end
|
|
34
|
+
)
|
|
35
|
+
end
|
|
36
|
+
return inventory
|
|
37
|
+
end
|
|
38
|
+
function useItemD4(self, _collectibleType, _rng, player)
|
|
39
|
+
local playerIndex = getPlayerIndex(nil, player)
|
|
40
|
+
local inventory = newPlayerInventory(nil, player)
|
|
41
|
+
v.run.playersInventory:set(playerIndex, inventory)
|
|
42
|
+
end
|
|
43
|
+
function postPlayerInit(self, player)
|
|
44
|
+
local playerIndex = getPlayerIndex(nil, player)
|
|
45
|
+
if not v.run.playersInventory:has(playerIndex) then
|
|
46
|
+
local inventory = newPlayerInventory(nil, player)
|
|
47
|
+
v.run.playersInventory:set(playerIndex, inventory)
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
function postItemPickup(self, player, pickingUpItem)
|
|
51
|
+
if pickingUpItem.itemType == ItemType.ITEM_PASSIVE or pickingUpItem.itemType == ItemType.ITEM_FAMILIAR then
|
|
52
|
+
local playerIndex = getPlayerIndex(nil, player)
|
|
53
|
+
local inventory = v.run.playersInventory:getAndSetDefault(playerIndex, player)
|
|
54
|
+
__TS__ArrayPush(inventory, pickingUpItem.subType)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
local FEATURE_NAME = "player inventory tracker"
|
|
58
|
+
v = {run = {playersInventory = __TS__New(
|
|
59
|
+
DefaultMap,
|
|
60
|
+
function(____, _key, player) return newPlayerInventory(nil, player) end
|
|
61
|
+
)}}
|
|
62
|
+
function ____exports.playerInventoryInit(self, mod)
|
|
63
|
+
saveDataManager(nil, "playerInventory", v)
|
|
64
|
+
mod:AddCallback(ModCallbacks.MC_USE_ITEM, useItemD4, CollectibleType.COLLECTIBLE_D4)
|
|
65
|
+
mod:AddCallback(ModCallbacks.MC_POST_PLAYER_INIT, postPlayerInit)
|
|
66
|
+
mod:AddCallbackCustom(ModCallbacksCustom.MC_POST_ITEM_PICKUP, postItemPickup)
|
|
67
|
+
end
|
|
68
|
+
function ____exports.getPlayerInventory(self, player)
|
|
69
|
+
errorIfFeaturesNotInitialized(nil, FEATURE_NAME)
|
|
70
|
+
local playerIndex = getPlayerIndex(nil, player)
|
|
71
|
+
return v.run.playersInventory:getAndSetDefault(playerIndex, player)
|
|
72
|
+
end
|
|
73
|
+
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
|