isaacscript-common 1.0.326 → 1.0.330
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/functions/collectibles.d.ts +2 -0
- package/dist/functions/collectibles.lua +18 -2
- package/dist/functions/log.d.ts +2 -0
- package/dist/functions/log.lua +12 -0
- package/dist/functions/player.d.ts +1 -1
- package/dist/functions/player.lua +1 -4
- package/dist/functions/ui.lua +5 -7
- package/dist/functions/util.d.ts +0 -2
- package/dist/functions/util.lua +4 -20
- package/package.json +4 -4
|
@@ -7,6 +7,8 @@ export declare function changeCollectibleSubType(collectible: EntityPickup, newC
|
|
|
7
7
|
export declare function collectibleHasTag(collectibleType: CollectibleType | int, tag: ItemConfigTag): boolean;
|
|
8
8
|
export declare function getCollectibleInitCharges(collectibleType: CollectibleType | int): int;
|
|
9
9
|
export declare function getCollectibleMaxCharges(collectibleType: CollectibleType | int): int;
|
|
10
|
+
/** Returns a set containing every valid collectible type in the game, including modded items. */
|
|
11
|
+
export declare function getCollectibleSet(): Set<CollectibleType | int>;
|
|
10
12
|
export declare function getMaxCollectibleID(): int;
|
|
11
13
|
export declare function isQuestCollectible(collectibleType: CollectibleType | int): boolean;
|
|
12
14
|
export declare function setCollectibleBlind(pickup: EntityPickup): void;
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
|
+
require("lualib_bundle");
|
|
2
3
|
local ____exports = {}
|
|
3
4
|
local COLLECTIBLE_SPRITE_LAYER
|
|
5
|
+
function ____exports.getMaxCollectibleID(self)
|
|
6
|
+
local itemConfig = Isaac.GetItemConfig()
|
|
7
|
+
return itemConfig:GetCollectibles().Size - 1
|
|
8
|
+
end
|
|
4
9
|
function ____exports.setCollectibleSprite(self, pickup, pngPath)
|
|
5
10
|
if pickup.Variant ~= PickupVariant.PICKUP_COLLECTIBLE then
|
|
6
11
|
error(
|
|
@@ -48,9 +53,20 @@ function ____exports.getCollectibleMaxCharges(self, collectibleType)
|
|
|
48
53
|
end
|
|
49
54
|
return itemConfigItem.MaxCharges
|
|
50
55
|
end
|
|
51
|
-
function ____exports.
|
|
56
|
+
function ____exports.getCollectibleSet(self)
|
|
52
57
|
local itemConfig = Isaac.GetItemConfig()
|
|
53
|
-
|
|
58
|
+
local collectibleSet = __TS__New(Set)
|
|
59
|
+
do
|
|
60
|
+
local collectibleType = 1
|
|
61
|
+
while collectibleType <= ____exports.getMaxCollectibleID(nil) do
|
|
62
|
+
local itemConfigItem = itemConfig:GetCollectible(collectibleType)
|
|
63
|
+
if itemConfigItem ~= nil then
|
|
64
|
+
collectibleSet:add(collectibleType)
|
|
65
|
+
end
|
|
66
|
+
collectibleType = collectibleType + 1
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
return collectibleSet
|
|
54
70
|
end
|
|
55
71
|
function ____exports.isQuestCollectible(self, collectibleType)
|
|
56
72
|
return ____exports.collectibleHasTag(nil, collectibleType, 32768)
|
package/dist/functions/log.d.ts
CHANGED
|
@@ -35,6 +35,8 @@ export declare function logAllProjectileFlags(flags: int): void;
|
|
|
35
35
|
*/
|
|
36
36
|
export declare function logAllUseFlags(flags: int): void;
|
|
37
37
|
export declare function logArray<T>(array: T[]): void;
|
|
38
|
+
export declare function logColor(color: Color): void;
|
|
38
39
|
export declare function logEntity(entity: Entity): void;
|
|
40
|
+
export declare function logKColor(kColor: KColor): void;
|
|
39
41
|
export declare function logMap(map: Map<AnyNotNil, unknown>): void;
|
|
40
42
|
export declare function logSet(set: Set<AnyNotNil>): void;
|
package/dist/functions/log.lua
CHANGED
|
@@ -74,12 +74,24 @@ function ____exports.logArray(self, array)
|
|
|
74
74
|
local arrayString = arrayToString(nil, array)
|
|
75
75
|
____exports.log(nil, "Array: " .. arrayString)
|
|
76
76
|
end
|
|
77
|
+
function ____exports.logColor(self, color)
|
|
78
|
+
____exports.log(
|
|
79
|
+
nil,
|
|
80
|
+
(((((((((((("Color: R" .. tostring(color.R)) .. ", G") .. tostring(color.G)) .. ", B") .. tostring(color.B)) .. ", A") .. tostring(color.A)) .. ", RO") .. tostring(color.RO)) .. ", BO") .. tostring(color.BO)) .. ", GO") .. tostring(color.GO)
|
|
81
|
+
)
|
|
82
|
+
end
|
|
77
83
|
function ____exports.logEntity(self, entity)
|
|
78
84
|
____exports.log(
|
|
79
85
|
nil,
|
|
80
86
|
(((("Entity: " .. tostring(entity.Type)) .. ".") .. tostring(entity.Variant)) .. ".") .. tostring(entity.SubType)
|
|
81
87
|
)
|
|
82
88
|
end
|
|
89
|
+
function ____exports.logKColor(self, kColor)
|
|
90
|
+
____exports.log(
|
|
91
|
+
nil,
|
|
92
|
+
(((((("Color: R" .. tostring(kColor.Red)) .. ", G") .. tostring(kColor.Green)) .. ", B") .. tostring(kColor.Blue)) .. ", A") .. tostring(kColor.Alpha)
|
|
93
|
+
)
|
|
94
|
+
end
|
|
83
95
|
function ____exports.logMap(self, map)
|
|
84
96
|
____exports.log(nil, "Printing out map:")
|
|
85
97
|
for ____, ____value in __TS__Iterator(
|
|
@@ -53,7 +53,7 @@ export declare function getPlayerCloserThan(position: Vector, distance: float):
|
|
|
53
53
|
* Iterates over every item in the game and returns a map containing the number of each item that
|
|
54
54
|
* the player has.
|
|
55
55
|
*/
|
|
56
|
-
export declare function getPlayerCollectibleMap(player: EntityPlayer): Map<CollectibleType | int, int>;
|
|
56
|
+
export declare function getPlayerCollectibleMap(player: EntityPlayer, collectibleSet: Set<int>): Map<CollectibleType | int, int>;
|
|
57
57
|
export declare function getPlayerFromIndex(playerIndex: PlayerIndex): EntityPlayer | undefined;
|
|
58
58
|
/**
|
|
59
59
|
* This function always excludes players with a non-undefined parent, since they are not real
|
|
@@ -3,8 +3,6 @@ require("lualib_bundle");
|
|
|
3
3
|
local ____exports = {}
|
|
4
4
|
local ____PocketItemType = require("types.PocketItemType")
|
|
5
5
|
local PocketItemType = ____PocketItemType.default
|
|
6
|
-
local ____util = require("functions.util")
|
|
7
|
-
local getCollectibleSet = ____util.getCollectibleSet
|
|
8
6
|
local EXCLUDED_CHARACTERS
|
|
9
7
|
function ____exports.getPlayers(self, performExclusions)
|
|
10
8
|
if performExclusions == nil then
|
|
@@ -154,9 +152,8 @@ function ____exports.getPlayerCloserThan(self, position, distance)
|
|
|
154
152
|
end
|
|
155
153
|
return nil
|
|
156
154
|
end
|
|
157
|
-
function ____exports.getPlayerCollectibleMap(self, player)
|
|
155
|
+
function ____exports.getPlayerCollectibleMap(self, player, collectibleSet)
|
|
158
156
|
local collectibleMap = __TS__New(Map)
|
|
159
|
-
local collectibleSet = getCollectibleSet(nil)
|
|
160
157
|
for ____, collectibleType in __TS__Iterator(
|
|
161
158
|
collectibleSet:values()
|
|
162
159
|
) do
|
package/dist/functions/ui.lua
CHANGED
|
@@ -49,13 +49,11 @@ function ____exports.getScreenCenter(self)
|
|
|
49
49
|
return bottomRight / 2
|
|
50
50
|
end
|
|
51
51
|
function ____exports.getVisibleHearts(self, player)
|
|
52
|
-
local
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
)
|
|
56
|
-
local visibleHearts = math.ceil(
|
|
57
|
-
(maxHearts + player:GetSoulHearts()) / 2
|
|
58
|
-
)
|
|
52
|
+
local effectiveMaxHearts = player:GetEffectiveMaxHearts()
|
|
53
|
+
local soulHearts = player:GetSoulHearts()
|
|
54
|
+
local boneHearts = player:GetBoneHearts()
|
|
55
|
+
local maxHearts = math.max(effectiveMaxHearts, boneHearts * 2)
|
|
56
|
+
local visibleHearts = math.ceil((maxHearts + soulHearts) / 2)
|
|
59
57
|
if visibleHearts < 1 then
|
|
60
58
|
visibleHearts = 1
|
|
61
59
|
end
|
package/dist/functions/util.d.ts
CHANGED
|
@@ -45,8 +45,6 @@ export declare const ensureAllCases: (obj: never) => never;
|
|
|
45
45
|
* https://isaacscript.github.io/docs/gotchas#iterating-over-enums
|
|
46
46
|
*/
|
|
47
47
|
export declare function getEnumValues(transpiledEnum: unknown): int[];
|
|
48
|
-
/** Returns a set containing every valid collectible type in the game, including modded items. */
|
|
49
|
-
export declare function getCollectibleSet(): Set<CollectibleType | int>;
|
|
50
48
|
/**
|
|
51
49
|
* Converts a hex string like "#33aa33" to a KColor object.
|
|
52
50
|
*
|
package/dist/functions/util.lua
CHANGED
|
@@ -3,8 +3,6 @@ require("lualib_bundle");
|
|
|
3
3
|
local ____exports = {}
|
|
4
4
|
local ____constants = require("constants")
|
|
5
5
|
local VECTOR_BRAND = ____constants.VECTOR_BRAND
|
|
6
|
-
local ____collectibles = require("functions.collectibles")
|
|
7
|
-
local getMaxCollectibleID = ____collectibles.getMaxCollectibleID
|
|
8
6
|
local ____math = require("functions.math")
|
|
9
7
|
local getAngleDifference = ____math.getAngleDifference
|
|
10
8
|
local HEX_STRING_LENGTH = 6
|
|
@@ -19,21 +17,6 @@ function ____exports.getEnumValues(self, transpiledEnum)
|
|
|
19
17
|
__TS__ArraySort(enumValues)
|
|
20
18
|
return enumValues
|
|
21
19
|
end
|
|
22
|
-
function ____exports.getCollectibleSet(self)
|
|
23
|
-
local itemConfig = Isaac.GetItemConfig()
|
|
24
|
-
local collectibleSet = __TS__New(Set)
|
|
25
|
-
do
|
|
26
|
-
local collectibleType = 1
|
|
27
|
-
while collectibleType <= getMaxCollectibleID(nil) do
|
|
28
|
-
local itemConfigItem = itemConfig:GetCollectible(collectibleType)
|
|
29
|
-
if itemConfigItem ~= nil then
|
|
30
|
-
collectibleSet:add(collectibleType)
|
|
31
|
-
end
|
|
32
|
-
collectibleType = collectibleType + 1
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
return collectibleSet
|
|
36
|
-
end
|
|
37
20
|
function ____exports.hexToKColor(self, hexString, alpha)
|
|
38
21
|
hexString = __TS__StringReplace(hexString, "#", "")
|
|
39
22
|
if #hexString ~= HEX_STRING_LENGTH then
|
|
@@ -46,17 +29,18 @@ function ____exports.hexToKColor(self, hexString, alpha)
|
|
|
46
29
|
if R == nil then
|
|
47
30
|
error(("Failed to convert `0x" .. rString) .. "` to a number.")
|
|
48
31
|
end
|
|
49
|
-
local gString = __TS__StringSubstr(hexString, 2,
|
|
32
|
+
local gString = __TS__StringSubstr(hexString, 2, 2)
|
|
50
33
|
local G = tonumber("0x" .. gString)
|
|
51
34
|
if G == nil then
|
|
52
35
|
error(("Failed to convert `0x" .. gString) .. "` to a number.")
|
|
53
36
|
end
|
|
54
|
-
local bString = __TS__StringSubstr(hexString, 4,
|
|
37
|
+
local bString = __TS__StringSubstr(hexString, 4, 2)
|
|
55
38
|
local B = tonumber("0x" .. bString)
|
|
56
39
|
if B == nil then
|
|
57
40
|
error(("Failed to convert `0x" .. bString) .. "` to a number.")
|
|
58
41
|
end
|
|
59
|
-
|
|
42
|
+
local base = 255
|
|
43
|
+
return KColor(R / base, G / base, B / base, alpha)
|
|
60
44
|
end
|
|
61
45
|
function ____exports.isGreedMode(self)
|
|
62
46
|
local game = Game()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "isaacscript-common",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.330",
|
|
4
4
|
"description": "Helper functions for IsaacScript mods",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"isaac",
|
|
@@ -25,10 +25,10 @@
|
|
|
25
25
|
"dist/**/*.d.ts"
|
|
26
26
|
],
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"isaac-typescript-definitions": "^1.0.
|
|
28
|
+
"isaac-typescript-definitions": "^1.0.190",
|
|
29
29
|
"isaacscript-lint": "^1.0.61",
|
|
30
|
-
"ts-prune": "^0.10.
|
|
31
|
-
"typedoc": "^0.22.
|
|
30
|
+
"ts-prune": "^0.10.1",
|
|
31
|
+
"typedoc": "^0.22.5",
|
|
32
32
|
"typescript": "4.4.3",
|
|
33
33
|
"typescript-to-lua": "^1.0.1"
|
|
34
34
|
}
|