isaacscript-common 3.0.0 → 3.1.0
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/cachedClasses.d.ts +6 -4
- package/cachedClasses.lua +4 -4
- package/callbacks/postSlotDestroyed.d.ts +1 -0
- package/callbacks/postSlotDestroyed.lua +66 -0
- package/callbacks/postSlotRender.lua +3 -21
- package/callbacks/subscriptions/postCustomRevive.d.ts +1 -0
- package/callbacks/subscriptions/postDoorRender.d.ts +1 -0
- package/callbacks/subscriptions/postDoorUpdate.d.ts +1 -0
- package/callbacks/subscriptions/postPickupCollect.d.ts +1 -0
- package/callbacks/subscriptions/postPickupStateChanged.d.ts +1 -0
- package/callbacks/subscriptions/postPitRender.d.ts +1 -0
- package/callbacks/subscriptions/postPitUpdate.d.ts +1 -0
- package/callbacks/subscriptions/postPoopRender.d.ts +1 -0
- package/callbacks/subscriptions/postPoopUpdate.d.ts +1 -0
- package/callbacks/subscriptions/postPressurePlateRender.d.ts +1 -0
- package/callbacks/subscriptions/postPressurePlateUpdate.d.ts +1 -0
- package/callbacks/subscriptions/postRockRender.d.ts +1 -0
- package/callbacks/subscriptions/postRockUpdate.d.ts +1 -0
- package/callbacks/subscriptions/postSpikesRender.d.ts +1 -0
- package/callbacks/subscriptions/postSpikesUpdate.d.ts +1 -0
- package/callbacks/subscriptions/postTNTRender.d.ts +1 -0
- package/callbacks/subscriptions/postTNTUpdate.d.ts +1 -0
- package/features/debugDisplay/exports.d.ts +17 -0
- package/features/debugDisplay/v.d.ts +17 -0
- package/features/deployJSONRoom.d.ts +1 -0
- package/features/saveDataManager/load.lua +12 -8
- package/features/saveDataManager/main.lua +10 -3
- package/features/saveDataManager/merge.lua +33 -21
- package/features/saveDataManager/save.lua +12 -7
- package/functions/array.d.ts +2 -0
- package/functions/chargeBar.d.ts +1 -0
- package/functions/collectibles.d.ts +6 -1
- package/functions/collectibles.lua +16 -3
- package/functions/deepCopy.lua +35 -26
- package/functions/deepCopyTests.lua +8 -5
- package/functions/direction.d.ts +1 -0
- package/functions/direction.lua +22 -0
- package/functions/doors.d.ts +1 -0
- package/functions/doors.lua +5 -0
- package/functions/entity.d.ts +4 -4
- package/functions/entity.lua +8 -8
- package/functions/entitySpecific.d.ts +20 -20
- package/functions/entitySpecific.lua +10 -10
- package/functions/enums.d.ts +2 -0
- package/functions/globals.lua +2 -10
- package/functions/gridEntitySpecific.d.ts +5 -0
- package/functions/isaacAPIClass.d.ts +4 -4
- package/functions/isaacAPIClass.lua +6 -6
- package/functions/jsonRoom.d.ts +2 -0
- package/functions/log.lua +3 -3
- package/functions/pickups.d.ts +9 -9
- package/functions/playerHealth.d.ts +1 -0
- package/functions/playerIndex.d.ts +2 -0
- package/functions/positionVelocity.d.ts +3 -0
- package/functions/random.d.ts +2 -0
- package/functions/revive.d.ts +2 -0
- package/functions/rng.d.ts +1 -0
- package/functions/serialization.lua +2 -2
- package/functions/set.d.ts +1 -0
- package/functions/sprite.d.ts +2 -0
- package/functions/table.d.ts +12 -0
- package/functions/table.lua +34 -0
- package/functions/tears.d.ts +1 -0
- package/functions/tstlClass.d.ts +34 -0
- package/functions/tstlClass.lua +54 -9
- package/functions/ui.d.ts +2 -0
- package/functions/utils.d.ts +15 -0
- package/functions/utils.lua +20 -0
- package/functions/vector.lua +4 -16
- package/initCustomCallbacks.lua +3 -0
- package/interfaces/ChargeBarSprites.d.ts +1 -0
- package/interfaces/private/TSTLClassMetatable.d.ts +2 -0
- package/objects/oppositeDoorSlots.d.ts +4 -0
- package/objects/oppositeDoorSlots.lua +15 -0
- package/package.json +1 -1
- package/types/AnyEntity.d.ts +10 -0
package/functions/globals.lua
CHANGED
|
@@ -4,7 +4,6 @@ local __TS__New = ____lualib.__TS__New
|
|
|
4
4
|
local __TS__ArraySort = ____lualib.__TS__ArraySort
|
|
5
5
|
local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
|
|
6
6
|
local ____exports = {}
|
|
7
|
-
local twoDimensionalSort
|
|
8
7
|
local ____debug = require("functions.debug")
|
|
9
8
|
local isLuaDebugEnabled = ____debug.isLuaDebugEnabled
|
|
10
9
|
local ____log = require("functions.log")
|
|
@@ -12,15 +11,8 @@ local log = ____log.log
|
|
|
12
11
|
local ____set = require("functions.set")
|
|
13
12
|
local addSetsToSet = ____set.addSetsToSet
|
|
14
13
|
local copySet = ____set.copySet
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
error("Failed to two-dimensional sort since the first element of the array was undefined.")
|
|
18
|
-
end
|
|
19
|
-
if a[1] == b[1] then
|
|
20
|
-
return 0
|
|
21
|
-
end
|
|
22
|
-
return a[1] < b[1] and -1 or 1
|
|
23
|
-
end
|
|
14
|
+
local ____utils = require("functions.utils")
|
|
15
|
+
local twoDimensionalSort = ____utils.twoDimensionalSort
|
|
24
16
|
local DEFAULT_GLOBALS = __TS__New(Set, {
|
|
25
17
|
"ActionTriggers",
|
|
26
18
|
"ActiveSlot",
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
3
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
4
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
5
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
6
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
2
7
|
/** Helper function to get all of the `GridEntityPit` in the room. */
|
|
3
8
|
export declare function getPits(): GridEntityPit[];
|
|
4
9
|
/** Helper function to get all of the `GridEntityPoop` in the room. */
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { IsaacAPIClass } from "../types/private/IsaacAPIClass";
|
|
2
2
|
/**
|
|
3
|
-
* Helper function to get the
|
|
4
|
-
* "__type" metatable key.
|
|
3
|
+
* Helper function to get the name of a class from the Isaac API. This is contained within the
|
|
4
|
+
* "__type" metatable key.
|
|
5
5
|
*
|
|
6
|
-
* For example, a `Vector` class is has a
|
|
6
|
+
* For example, a `Vector` class is has a name of "Vector".
|
|
7
7
|
*
|
|
8
8
|
* Returns undefined if the object is not of type `userdata` or if the "__type" metatable key does
|
|
9
9
|
* not exist.
|
|
10
10
|
*/
|
|
11
|
-
export declare function
|
|
11
|
+
export declare function getIsaacAPIClassName(object: unknown): string | undefined;
|
|
12
12
|
/**
|
|
13
13
|
* Helper function to check if something is an instantiated class from the Isaac API. (All classes
|
|
14
14
|
* from the Isaac API have a type of "userdata" in Lua with a metatable key of "__type" equal to the
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
2
|
local __TS__ArrayEvery = ____lualib.__TS__ArrayEvery
|
|
3
3
|
local ____exports = {}
|
|
4
|
-
--- Helper function to get the
|
|
5
|
-
-- "__type" metatable key.
|
|
4
|
+
--- Helper function to get the name of a class from the Isaac API. This is contained within the
|
|
5
|
+
-- "__type" metatable key.
|
|
6
6
|
--
|
|
7
|
-
-- For example, a `Vector` class is has a
|
|
7
|
+
-- For example, a `Vector` class is has a name of "Vector".
|
|
8
8
|
--
|
|
9
9
|
-- Returns undefined if the object is not of type `userdata` or if the "__type" metatable key does
|
|
10
10
|
-- not exist.
|
|
11
|
-
function ____exports.
|
|
11
|
+
function ____exports.getIsaacAPIClassName(self, object)
|
|
12
12
|
local objectType = type(object)
|
|
13
13
|
if objectType ~= "userdata" then
|
|
14
14
|
return nil
|
|
@@ -27,11 +27,11 @@ end
|
|
|
27
27
|
-- from the Isaac API have a type of "userdata" in Lua with a metatable key of "__type" equal to the
|
|
28
28
|
-- name of the class.)
|
|
29
29
|
function ____exports.isIsaacAPIClass(self, object)
|
|
30
|
-
local isaacAPIClassType = ____exports.
|
|
30
|
+
local isaacAPIClassType = ____exports.getIsaacAPIClassName(nil, object)
|
|
31
31
|
return isaacAPIClassType ~= nil
|
|
32
32
|
end
|
|
33
33
|
function ____exports.isIsaacAPIClassOfType(self, object, classType)
|
|
34
|
-
local isaacAPIClassType = ____exports.
|
|
34
|
+
local isaacAPIClassType = ____exports.getIsaacAPIClassName(nil, object)
|
|
35
35
|
return isaacAPIClassType == classType or isaacAPIClassType == "const " .. classType
|
|
36
36
|
end
|
|
37
37
|
--- Helper function to check if an instantiated Isaac API class is equal to another one of the same
|
package/functions/jsonRoom.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
3
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
2
4
|
import { JSONRoom } from "../interfaces/JSONRoom";
|
|
3
5
|
export declare function getJSONRoomOfVariant(jsonRooms: JSONRoom[], variant: int): JSONRoom | undefined;
|
|
4
6
|
export declare function getJSONRoomsOfSubType(jsonRooms: JSONRoom[], subType: int): JSONRoom[];
|
package/functions/log.lua
CHANGED
|
@@ -35,7 +35,7 @@ local hasFlag = ____flag.hasFlag
|
|
|
35
35
|
local ____gridEntity = require("functions.gridEntity")
|
|
36
36
|
local getGridEntities = ____gridEntity.getGridEntities
|
|
37
37
|
local ____isaacAPIClass = require("functions.isaacAPIClass")
|
|
38
|
-
local
|
|
38
|
+
local getIsaacAPIClassName = ____isaacAPIClass.getIsaacAPIClassName
|
|
39
39
|
local ____player = require("functions.player")
|
|
40
40
|
local getEffectsList = ____player.getEffectsList
|
|
41
41
|
local getPlayerName = ____player.getPlayerName
|
|
@@ -474,7 +474,7 @@ function ____exports.logTable(____table, parentTables)
|
|
|
474
474
|
end
|
|
475
475
|
numKeys = numKeys + 1
|
|
476
476
|
end
|
|
477
|
-
____exports.log("The size of the table was: " .. tostring(numKeys))
|
|
477
|
+
____exports.log((indentation .. "The size of the table was: ") .. tostring(numKeys))
|
|
478
478
|
end
|
|
479
479
|
--- Helper function for printing out every tear flag that is turned on. Useful when debugging.
|
|
480
480
|
function ____exports.logTearFlags(flags)
|
|
@@ -497,7 +497,7 @@ function ____exports.logUserdata(userdata)
|
|
|
497
497
|
____exports.log("Userdata: [no metatable]")
|
|
498
498
|
return
|
|
499
499
|
end
|
|
500
|
-
local classType =
|
|
500
|
+
local classType = getIsaacAPIClassName(nil, userdata)
|
|
501
501
|
if classType == nil then
|
|
502
502
|
____exports.log("Userdata: [no class type]")
|
|
503
503
|
else
|
package/functions/pickups.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ export declare function isRedHeart(pickup: EntityPickup): boolean;
|
|
|
33
33
|
* @param cap Optional. If specified, will only remove the given amount of cards.
|
|
34
34
|
* @returns True if one or more cards were removed, false otherwise.
|
|
35
35
|
*/
|
|
36
|
-
export declare function removeAllBatteries(batterySubType?: BatterySubType, cap?: int):
|
|
36
|
+
export declare function removeAllBatteries(batterySubType?: BatterySubType, cap?: int): EntityPickupBattery[];
|
|
37
37
|
/**
|
|
38
38
|
* Helper function to remove all of the cards in the room.
|
|
39
39
|
*
|
|
@@ -41,7 +41,7 @@ export declare function removeAllBatteries(batterySubType?: BatterySubType, cap?
|
|
|
41
41
|
* @param cap Optional. If specified, will only remove the given amount of cards.
|
|
42
42
|
* @returns True if one or more cards were removed, false otherwise.
|
|
43
43
|
*/
|
|
44
|
-
export declare function removeAllCards(card?: Card, cap?: int):
|
|
44
|
+
export declare function removeAllCards(card?: Card, cap?: int): EntityPickupCard[];
|
|
45
45
|
/**
|
|
46
46
|
* Helper function to remove all of the coins in the room.
|
|
47
47
|
*
|
|
@@ -49,7 +49,7 @@ export declare function removeAllCards(card?: Card, cap?: int): boolean;
|
|
|
49
49
|
* @param cap Optional. If specified, will only remove the given amount of coins.
|
|
50
50
|
* @returns True if one or more coins were removed, false otherwise.
|
|
51
51
|
*/
|
|
52
|
-
export declare function removeAllCoins(coinSubType?: CoinSubType, cap?: int):
|
|
52
|
+
export declare function removeAllCoins(coinSubType?: CoinSubType, cap?: int): EntityPickupCoin[];
|
|
53
53
|
/**
|
|
54
54
|
* Helper function to remove all of the collectibles in the room.
|
|
55
55
|
*
|
|
@@ -58,7 +58,7 @@ export declare function removeAllCoins(coinSubType?: CoinSubType, cap?: int): bo
|
|
|
58
58
|
* @param cap Optional. If specified, will only remove the given amount of collectibles.
|
|
59
59
|
* @returns True if one or more collectibles were removed, false otherwise.
|
|
60
60
|
*/
|
|
61
|
-
export declare function removeAllCollectibles(collectibleType?: CollectibleType, cap?: int):
|
|
61
|
+
export declare function removeAllCollectibles(collectibleType?: CollectibleType, cap?: int): EntityPickupCollectible[];
|
|
62
62
|
/**
|
|
63
63
|
* Helper function to remove all of the hearts in the room.
|
|
64
64
|
*
|
|
@@ -66,7 +66,7 @@ export declare function removeAllCollectibles(collectibleType?: CollectibleType,
|
|
|
66
66
|
* @param cap Optional. If specified, will only remove the given amount of hearts.
|
|
67
67
|
* @returns True if one or more hearts were removed, false otherwise.
|
|
68
68
|
*/
|
|
69
|
-
export declare function removeAllHearts(heartSubType?: HeartSubType, cap?: int):
|
|
69
|
+
export declare function removeAllHearts(heartSubType?: HeartSubType, cap?: int): EntityPickupHeart[];
|
|
70
70
|
/**
|
|
71
71
|
* Helper function to remove all of the keys in the room.
|
|
72
72
|
*
|
|
@@ -74,7 +74,7 @@ export declare function removeAllHearts(heartSubType?: HeartSubType, cap?: int):
|
|
|
74
74
|
* @param cap Optional. If specified, will only remove the given amount of keys.
|
|
75
75
|
* @returns True if one or more keys were removed, false otherwise.
|
|
76
76
|
*/
|
|
77
|
-
export declare function removeAllKeys(keySubType?: KeySubType, cap?: int):
|
|
77
|
+
export declare function removeAllKeys(keySubType?: KeySubType, cap?: int): EntityPickupKey[];
|
|
78
78
|
/**
|
|
79
79
|
* Helper function to remove all of the pills in the room.
|
|
80
80
|
*
|
|
@@ -82,7 +82,7 @@ export declare function removeAllKeys(keySubType?: KeySubType, cap?: int): boole
|
|
|
82
82
|
* @param cap Optional. If specified, will only remove the given amount of pills.
|
|
83
83
|
* @returns True if one or more pills were removed, false otherwise.
|
|
84
84
|
*/
|
|
85
|
-
export declare function removeAllPills(pillColor?: PillColor, cap?: int):
|
|
85
|
+
export declare function removeAllPills(pillColor?: PillColor, cap?: int): EntityPickupPill[];
|
|
86
86
|
/**
|
|
87
87
|
* Helper function to remove all of the sacks (i.e. grab bags) in the room.
|
|
88
88
|
*
|
|
@@ -90,7 +90,7 @@ export declare function removeAllPills(pillColor?: PillColor, cap?: int): boolea
|
|
|
90
90
|
* @param cap Optional. If specified, will only remove the given amount of trinkets.
|
|
91
91
|
* @returns True if one or more trinkets were removed, false otherwise.
|
|
92
92
|
*/
|
|
93
|
-
export declare function removeAllSacks(sackSubType?: SackSubType, cap?: int):
|
|
93
|
+
export declare function removeAllSacks(sackSubType?: SackSubType, cap?: int): EntityPickupSack[];
|
|
94
94
|
/**
|
|
95
95
|
* Helper function to remove all of the trinkets in the room.
|
|
96
96
|
*
|
|
@@ -99,7 +99,7 @@ export declare function removeAllSacks(sackSubType?: SackSubType, cap?: int): bo
|
|
|
99
99
|
* @param cap Optional. If specified, will only remove the given amount of trinkets.
|
|
100
100
|
* @returns True if one or more trinkets were removed, false otherwise.
|
|
101
101
|
*/
|
|
102
|
-
export declare function removeAllTrinkets(trinketType?: TrinketType, cap?: int):
|
|
102
|
+
export declare function removeAllTrinkets(trinketType?: TrinketType, cap?: int): EntityPickupTrinket[];
|
|
103
103
|
/**
|
|
104
104
|
* Helper function to spawn a `EntityType.PICKUP` (5) with variant `PickupVariant.LIL_BATTERY` (90).
|
|
105
105
|
*/
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
2
3
|
import { HealthType } from "../enums/HealthType";
|
|
3
4
|
import { PlayerHealth } from "../interfaces/PlayerHealth";
|
|
4
5
|
export declare function addPlayerHealthType(player: EntityPlayer, healthType: HealthType, numHearts: int): void;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
3
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
2
4
|
import { PlayerIndex } from "../types/PlayerIndex";
|
|
3
5
|
/**
|
|
4
6
|
* Helper function to get every player with no restrictions, by using `Game.GetNumPlayers` and
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
3
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
4
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
2
5
|
export declare function anyEntityCloserThan(entities: Entity[], position: Vector, distance: int): boolean;
|
|
3
6
|
/** Iterates over all players and checks if any player is close enough to the specified position. */
|
|
4
7
|
export declare function anyPlayerCloserThan(position: Vector, distance: float): boolean;
|
package/functions/random.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
3
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
2
4
|
/**
|
|
3
5
|
* This returns a random float between 0 and 1. It is inclusive on the low end, but exclusive on the
|
|
4
6
|
* high end. (This is because the `RNG.RandomFloat` method will never return a value of exactly 1.)
|
package/functions/revive.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
3
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
2
4
|
/**
|
|
3
5
|
* Uses the player's current health and other miscellaneous things to determine if incoming damage
|
|
4
6
|
* will be fatal.
|
package/functions/rng.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
2
3
|
/// <reference types="typescript-to-lua/language-extensions" />
|
|
3
4
|
import { SerializationType } from "../enums/SerializationType";
|
|
4
5
|
declare type SerializedRNG = LuaTable<string, unknown> & {
|
|
@@ -13,7 +13,7 @@ local ISAAC_API_CLASS_TYPE_TO_COPY_FUNCTION = ____isaacAPIClassTypeToCopyFunctio
|
|
|
13
13
|
local ____serializedIsaacAPIClassTypeToIdentityFunction = require("objects.serializedIsaacAPIClassTypeToIdentityFunction")
|
|
14
14
|
local SERIALIZED_ISAAC_API_CLASS_TYPE_TO_IDENTITY_FUNCTION = ____serializedIsaacAPIClassTypeToIdentityFunction.SERIALIZED_ISAAC_API_CLASS_TYPE_TO_IDENTITY_FUNCTION
|
|
15
15
|
local ____isaacAPIClass = require("functions.isaacAPIClass")
|
|
16
|
-
local
|
|
16
|
+
local getIsaacAPIClassName = ____isaacAPIClass.getIsaacAPIClassName
|
|
17
17
|
function getSerializedTableType(self, serializedIsaacAPIClass)
|
|
18
18
|
for ____, ____value in ipairs(__TS__ObjectEntries(ISAAC_API_CLASS_TYPE_TO_BRAND)) do
|
|
19
19
|
local copyableIsaacAPIClassType = ____value[1]
|
|
@@ -29,7 +29,7 @@ function ____exports.copyIsaacAPIClass(self, isaacAPIClass, serializationType)
|
|
|
29
29
|
if objectType ~= "userdata" then
|
|
30
30
|
error("Failed to copy an Isaac API class since the provided object was of type: " .. objectType)
|
|
31
31
|
end
|
|
32
|
-
local isaacAPIClassType =
|
|
32
|
+
local isaacAPIClassType = getIsaacAPIClassName(nil, isaacAPIClass)
|
|
33
33
|
if isaacAPIClassType == nil then
|
|
34
34
|
error("Failed to copy an Isaac API class since it does not have a class type.")
|
|
35
35
|
end
|
package/functions/set.d.ts
CHANGED
package/functions/sprite.d.ts
CHANGED
package/functions/table.d.ts
CHANGED
|
@@ -27,6 +27,18 @@ export declare function getNumbersFromTable(table: LuaTable<string, unknown>, ob
|
|
|
27
27
|
* This function is variadic, meaning that you can specify N arguments to get N values.
|
|
28
28
|
*/
|
|
29
29
|
export declare function getStringsFromTable(table: LuaTable<string, unknown>, objectName: string, ...keys: string[]): string[];
|
|
30
|
+
/**
|
|
31
|
+
* Helper function to iterate over a table deterministically. This is useful because by default, the
|
|
32
|
+
* `pairs` function will return the keys of a Lua table in a random order.
|
|
33
|
+
*
|
|
34
|
+
* This function will sort the table entries based on the value of the key.
|
|
35
|
+
*
|
|
36
|
+
* @param table The table to iterate over.
|
|
37
|
+
* @param func The function to run for each iteration.
|
|
38
|
+
* @param deterministic Optional. Whether to iterate deterministically. True by default. You can
|
|
39
|
+
* dynamically set to false in situations where you need extra performance.
|
|
40
|
+
*/
|
|
41
|
+
export declare function iterateTableDeterministically<K, V>(table: LuaTable<K, V>, func: (key: K, value: V) => void, deterministic?: boolean): void;
|
|
30
42
|
/**
|
|
31
43
|
* Helper function to check if a Lua table has all of the provided keys.
|
|
32
44
|
*
|
package/functions/table.lua
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
2
|
local __TS__TypeOf = ____lualib.__TS__TypeOf
|
|
3
|
+
local __TS__ArraySort = ____lualib.__TS__ArraySort
|
|
3
4
|
local __TS__ArrayEvery = ____lualib.__TS__ArrayEvery
|
|
4
5
|
local ____exports = {}
|
|
6
|
+
local ____utils = require("functions.utils")
|
|
7
|
+
local twoDimensionalSort = ____utils.twoDimensionalSort
|
|
5
8
|
--- In a Map, you can use the `clear` method to delete every element. However, in a LuaTable, the
|
|
6
9
|
-- `clear` method does not exist. Use this helper function as a drop-in replacement for this.
|
|
7
10
|
function ____exports.clearTable(self, ____table)
|
|
@@ -84,6 +87,37 @@ function ____exports.getStringsFromTable(self, ____table, objectName, ...)
|
|
|
84
87
|
end
|
|
85
88
|
return strings
|
|
86
89
|
end
|
|
90
|
+
--- Helper function to iterate over a table deterministically. This is useful because by default, the
|
|
91
|
+
-- `pairs` function will return the keys of a Lua table in a random order.
|
|
92
|
+
--
|
|
93
|
+
-- This function will sort the table entries based on the value of the key.
|
|
94
|
+
--
|
|
95
|
+
-- @param table The table to iterate over.
|
|
96
|
+
-- @param func The function to run for each iteration.
|
|
97
|
+
-- @param deterministic Optional. Whether to iterate deterministically. True by default. You can
|
|
98
|
+
-- dynamically set to false in situations where you need extra performance.
|
|
99
|
+
function ____exports.iterateTableDeterministically(self, ____table, func, deterministic)
|
|
100
|
+
if deterministic == nil then
|
|
101
|
+
deterministic = true
|
|
102
|
+
end
|
|
103
|
+
if not deterministic then
|
|
104
|
+
for key, value in pairs(____table) do
|
|
105
|
+
func(nil, key, value)
|
|
106
|
+
end
|
|
107
|
+
return
|
|
108
|
+
end
|
|
109
|
+
local entriesArray = {}
|
|
110
|
+
for key, value in pairs(____table) do
|
|
111
|
+
local entry = {key, value}
|
|
112
|
+
entriesArray[#entriesArray + 1] = entry
|
|
113
|
+
end
|
|
114
|
+
__TS__ArraySort(entriesArray, twoDimensionalSort)
|
|
115
|
+
for ____, ____value in ipairs(entriesArray) do
|
|
116
|
+
local key = ____value[1]
|
|
117
|
+
local value = ____value[2]
|
|
118
|
+
func(nil, key, value)
|
|
119
|
+
end
|
|
120
|
+
end
|
|
87
121
|
--- Helper function to check if a Lua table has all of the provided keys.
|
|
88
122
|
--
|
|
89
123
|
-- This function is variadic, meaning that you can specify as many arguments as you want to check
|
package/functions/tears.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
2
3
|
/**
|
|
3
4
|
* - Converts the specified amount of tears stat into MaxFireDelay and adds it to the player.
|
|
4
5
|
* - This function should only be used inside the EvaluateCache callback.
|
package/functions/tstlClass.d.ts
CHANGED
|
@@ -1,9 +1,43 @@
|
|
|
1
|
+
/// <reference types="typescript-to-lua/language-extensions" />
|
|
2
|
+
import { DefaultMap } from "../classes/DefaultMap";
|
|
1
3
|
import { TSTLClass } from "../types/private/TSTLClass";
|
|
4
|
+
/**
|
|
5
|
+
* Helper function to get the name of a TypeScriptToLua class. TSTL classes are Lua tables created
|
|
6
|
+
* with the `__TS__Class` Lua function from the TSTL lualib. Their name is contained within
|
|
7
|
+
* "constructor.name" metatable key.
|
|
8
|
+
*
|
|
9
|
+
* For example, a `Map` class is has a name of "Map".
|
|
10
|
+
*
|
|
11
|
+
* Returns undefined if the object is not a table or if the aforementioned metatable key does not
|
|
12
|
+
* exist.
|
|
13
|
+
*/
|
|
14
|
+
export declare function getTSTLClassName(object: unknown): string | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Helper function to determine if a given object is a TypeScriptToLua `Map`.
|
|
17
|
+
*
|
|
18
|
+
* It is not reliable to use the `instanceof` operator to determine this because each Lua module has
|
|
19
|
+
* their own copies of the entire lualib and thus their own instantiated version of a `Map`.
|
|
20
|
+
*/
|
|
21
|
+
export declare function isDefaultMap(object: unknown): object is DefaultMap<AnyNotNil, unknown>;
|
|
2
22
|
/**
|
|
3
23
|
* Returns whether or not this is a class that is provided by the `isaacscript-common` library, such
|
|
4
24
|
* as a `DefaultMap`.
|
|
5
25
|
*/
|
|
6
26
|
export declare function isIsaacScriptCommonClass(object: unknown): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Helper function to determine if a given object is a TypeScriptToLua `Map`.
|
|
29
|
+
*
|
|
30
|
+
* It is not reliable to use the `instanceof` operator to determine this because each Lua module has
|
|
31
|
+
* their own copies of the entire lualib and thus their own instantiated version of a `Map`.
|
|
32
|
+
*/
|
|
33
|
+
export declare function isTSTLMap(object: unknown): object is Map<AnyNotNil, unknown>;
|
|
34
|
+
/**
|
|
35
|
+
* Helper function to determine if a given object is a TypeScriptToLua `Set`.
|
|
36
|
+
*
|
|
37
|
+
* It is not reliable to use the `instanceof` operator to determine this because each Lua module has
|
|
38
|
+
* their own copies of the entire lualib and thus their own instantiated version of a `Set`.
|
|
39
|
+
*/
|
|
40
|
+
export declare function isTSTLSet(object: unknown): object is Set<AnyNotNil>;
|
|
7
41
|
/** TypeScriptToLua classes are Lua tables that have a metatable with a certain amount of keys. */
|
|
8
42
|
export declare function isUserDefinedTSTLClass(object: unknown): object is TSTLClass;
|
|
9
43
|
/**
|
package/functions/tstlClass.lua
CHANGED
|
@@ -1,18 +1,38 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
2
|
local Set = ____lualib.Set
|
|
3
3
|
local __TS__New = ____lualib.__TS__New
|
|
4
|
-
local __TS__InstanceOf = ____lualib.__TS__InstanceOf
|
|
5
|
-
local Map = ____lualib.Map
|
|
6
|
-
local WeakMap = ____lualib.WeakMap
|
|
7
|
-
local WeakSet = ____lualib.WeakSet
|
|
8
4
|
local ____exports = {}
|
|
9
|
-
local newTSTLClassFromMetatable
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
local newTSTLClassFromMetatable, VANILLA_TSTL_CLASSES
|
|
6
|
+
--- Helper function to get the name of a TypeScriptToLua class. TSTL classes are Lua tables created
|
|
7
|
+
-- with the `__TS__Class` Lua function from the TSTL lualib. Their name is contained within
|
|
8
|
+
-- "constructor.name" metatable key.
|
|
9
|
+
--
|
|
10
|
+
-- For example, a `Map` class is has a name of "Map".
|
|
11
|
+
--
|
|
12
|
+
-- Returns undefined if the object is not a table or if the aforementioned metatable key does not
|
|
13
|
+
-- exist.
|
|
14
|
+
function ____exports.getTSTLClassName(self, object)
|
|
15
|
+
if type(object) ~= "table" then
|
|
16
|
+
return nil
|
|
17
|
+
end
|
|
18
|
+
local metatable = getmetatable(object)
|
|
19
|
+
if metatable == nil then
|
|
20
|
+
return nil
|
|
21
|
+
end
|
|
22
|
+
local constructor = metatable.constructor
|
|
23
|
+
if constructor == nil then
|
|
24
|
+
return nil
|
|
25
|
+
end
|
|
26
|
+
return constructor.name
|
|
27
|
+
end
|
|
12
28
|
--- Returns whether or not this is a class that is provided as part of the TypeScriptToLua
|
|
13
29
|
-- transpiler, such as a `Map` or a `Set`.
|
|
14
30
|
function ____exports.isVanillaTSTLClass(self, object)
|
|
15
|
-
|
|
31
|
+
local className = ____exports.getTSTLClassName(nil, object)
|
|
32
|
+
if className == nil then
|
|
33
|
+
return false
|
|
34
|
+
end
|
|
35
|
+
return VANILLA_TSTL_CLASSES:has(className)
|
|
16
36
|
end
|
|
17
37
|
function newTSTLClassFromMetatable(self, metatable)
|
|
18
38
|
local newClass = {}
|
|
@@ -20,11 +40,36 @@ function newTSTLClassFromMetatable(self, metatable)
|
|
|
20
40
|
newClassMetatable:____constructor()
|
|
21
41
|
return newClass
|
|
22
42
|
end
|
|
43
|
+
VANILLA_TSTL_CLASSES = __TS__New(Set, {"Map", "Set", "WeakMap", "WeakSet"})
|
|
23
44
|
local TSTL_CLASS_METATABLE_KEYS = __TS__New(Set, {"____constructor", "__index", "constructor"})
|
|
45
|
+
--- Helper function to determine if a given object is a TypeScriptToLua `Map`.
|
|
46
|
+
--
|
|
47
|
+
-- It is not reliable to use the `instanceof` operator to determine this because each Lua module has
|
|
48
|
+
-- their own copies of the entire lualib and thus their own instantiated version of a `Map`.
|
|
49
|
+
function ____exports.isDefaultMap(self, object)
|
|
50
|
+
local className = ____exports.getTSTLClassName(nil, object)
|
|
51
|
+
return className == "DefaultMap"
|
|
52
|
+
end
|
|
24
53
|
--- Returns whether or not this is a class that is provided by the `isaacscript-common` library, such
|
|
25
54
|
-- as a `DefaultMap`.
|
|
26
55
|
function ____exports.isIsaacScriptCommonClass(self, object)
|
|
27
|
-
return
|
|
56
|
+
return ____exports.isDefaultMap(nil, object)
|
|
57
|
+
end
|
|
58
|
+
--- Helper function to determine if a given object is a TypeScriptToLua `Map`.
|
|
59
|
+
--
|
|
60
|
+
-- It is not reliable to use the `instanceof` operator to determine this because each Lua module has
|
|
61
|
+
-- their own copies of the entire lualib and thus their own instantiated version of a `Map`.
|
|
62
|
+
function ____exports.isTSTLMap(self, object)
|
|
63
|
+
local className = ____exports.getTSTLClassName(nil, object)
|
|
64
|
+
return className == "Map"
|
|
65
|
+
end
|
|
66
|
+
--- Helper function to determine if a given object is a TypeScriptToLua `Set`.
|
|
67
|
+
--
|
|
68
|
+
-- It is not reliable to use the `instanceof` operator to determine this because each Lua module has
|
|
69
|
+
-- their own copies of the entire lualib and thus their own instantiated version of a `Set`.
|
|
70
|
+
function ____exports.isTSTLSet(self, object)
|
|
71
|
+
local className = ____exports.getTSTLClassName(nil, object)
|
|
72
|
+
return className == "Set"
|
|
28
73
|
end
|
|
29
74
|
--- TypeScriptToLua classes are Lua tables that have a metatable with a certain amount of keys.
|
|
30
75
|
function ____exports.isUserDefinedTSTLClass(self, object)
|
package/functions/ui.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
3
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
2
4
|
/**
|
|
3
5
|
* In the options menu, players have the ability to set a HUD offset. However, mods do not have
|
|
4
6
|
* access to this value. To get around this, Mod Config Menu provides a separate HUD offset setting
|
package/functions/utils.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
2
3
|
/**
|
|
3
4
|
* Helper function to get type safety on a switch statement.
|
|
4
5
|
*
|
|
@@ -111,3 +112,17 @@ export declare function repeat(n: int, func: (i: int) => void): void;
|
|
|
111
112
|
* This function does not actually do anything. (It is an "empty" function.)
|
|
112
113
|
*/
|
|
113
114
|
export declare function todo(): void;
|
|
115
|
+
/**
|
|
116
|
+
* Helper function to sort a two-dimensional array by the first element.
|
|
117
|
+
*
|
|
118
|
+
* For example:
|
|
119
|
+
*
|
|
120
|
+
* ```ts
|
|
121
|
+
* const myArray = [[1, 2], [2, 3], [3, 4]];
|
|
122
|
+
* myArray.sort(twoDimensionalSort);
|
|
123
|
+
* ```
|
|
124
|
+
*
|
|
125
|
+
* From:
|
|
126
|
+
* https://stackoverflow.com/questions/16096872/how-to-sort-2-dimensional-array-by-column-value
|
|
127
|
+
*/
|
|
128
|
+
export declare function twoDimensionalSort<T>(a: T[], b: T[]): -1 | 0 | 1;
|
package/functions/utils.lua
CHANGED
|
@@ -179,4 +179,24 @@ end
|
|
|
179
179
|
-- This function does not actually do anything. (It is an "empty" function.)
|
|
180
180
|
function ____exports.todo(self)
|
|
181
181
|
end
|
|
182
|
+
--- Helper function to sort a two-dimensional array by the first element.
|
|
183
|
+
--
|
|
184
|
+
-- For example:
|
|
185
|
+
--
|
|
186
|
+
-- ```ts
|
|
187
|
+
-- const myArray = [[1, 2], [2, 3], [3, 4]];
|
|
188
|
+
-- myArray.sort(twoDimensionalSort);
|
|
189
|
+
-- ```
|
|
190
|
+
--
|
|
191
|
+
-- From:
|
|
192
|
+
-- https://stackoverflow.com/questions/16096872/how-to-sort-2-dimensional-array-by-column-value
|
|
193
|
+
function ____exports.twoDimensionalSort(self, a, b)
|
|
194
|
+
if a[1] == nil or b[1] == nil then
|
|
195
|
+
error("Failed to two-dimensional sort since the first element of the array was undefined.")
|
|
196
|
+
end
|
|
197
|
+
if a[1] == b[1] then
|
|
198
|
+
return 0
|
|
199
|
+
end
|
|
200
|
+
return a[1] < b[1] and -1 or 1
|
|
201
|
+
end
|
|
182
202
|
return ____exports
|
package/functions/vector.lua
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
local ____exports = {}
|
|
2
2
|
local OBJECT_NAME
|
|
3
|
-
local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
|
|
4
|
-
local Direction = ____isaac_2Dtypescript_2Ddefinitions.Direction
|
|
5
3
|
local ____SerializationBrand = require("enums.private.SerializationBrand")
|
|
6
4
|
local SerializationBrand = ____SerializationBrand.SerializationBrand
|
|
7
5
|
local ____SerializationType = require("enums.SerializationType")
|
|
8
6
|
local SerializationType = ____SerializationType.SerializationType
|
|
7
|
+
local ____direction = require("functions.direction")
|
|
8
|
+
local angleToDirection = ____direction.angleToDirection
|
|
9
9
|
local ____isaacAPIClass = require("functions.isaacAPIClass")
|
|
10
10
|
local isaacAPIClassEquals = ____isaacAPIClass.isaacAPIClassEquals
|
|
11
11
|
local isIsaacAPIClassOfType = ____isaacAPIClass.isIsaacAPIClassOfType
|
|
@@ -101,20 +101,8 @@ function ____exports.vectorEquals(self, vector1, vector2)
|
|
|
101
101
|
end
|
|
102
102
|
--- Helper function for finding out which way a vector is pointing.
|
|
103
103
|
function ____exports.vectorToDirection(self, vector)
|
|
104
|
-
local
|
|
105
|
-
|
|
106
|
-
return Direction.RIGHT
|
|
107
|
-
end
|
|
108
|
-
if degrees >= 45 and degrees <= 135 then
|
|
109
|
-
return Direction.DOWN
|
|
110
|
-
end
|
|
111
|
-
if degrees <= -45 and degrees >= -135 then
|
|
112
|
-
return Direction.UP
|
|
113
|
-
end
|
|
114
|
-
if degrees > 135 or degrees < -135 then
|
|
115
|
-
return Direction.LEFT
|
|
116
|
-
end
|
|
117
|
-
return Direction.NO_DIRECTION
|
|
104
|
+
local angleDegrees = vector:GetAngleDegrees()
|
|
105
|
+
return angleToDirection(nil, angleDegrees)
|
|
118
106
|
end
|
|
119
107
|
function ____exports.vectorToString(self, vector, round)
|
|
120
108
|
if round == nil then
|
package/initCustomCallbacks.lua
CHANGED
|
@@ -89,6 +89,8 @@ local ____postRoomClearChanged = require("callbacks.postRoomClearChanged")
|
|
|
89
89
|
local postRoomClearChangedCallbackInit = ____postRoomClearChanged.postRoomClearChangedCallbackInit
|
|
90
90
|
local ____postSacrifice = require("callbacks.postSacrifice")
|
|
91
91
|
local postSacrificeCallbackInit = ____postSacrifice.postSacrificeCallbackInit
|
|
92
|
+
local ____postSlotDestroyed = require("callbacks.postSlotDestroyed")
|
|
93
|
+
local postSlotDestroyedCallbacksInit = ____postSlotDestroyed.postSlotDestroyedCallbacksInit
|
|
92
94
|
local ____postSlotInitUpdate = require("callbacks.postSlotInitUpdate")
|
|
93
95
|
local postSlotInitUpdateCallbacksInit = ____postSlotInitUpdate.postSlotInitUpdateCallbacksInit
|
|
94
96
|
local ____postSlotRender = require("callbacks.postSlotRender")
|
|
@@ -161,6 +163,7 @@ function ____exports.initCustomCallbacks(self, mod)
|
|
|
161
163
|
postRockUpdateInit(nil, mod)
|
|
162
164
|
postRoomClearChangedCallbackInit(nil, mod)
|
|
163
165
|
postSacrificeCallbackInit(nil, mod)
|
|
166
|
+
postSlotDestroyedCallbacksInit(nil, mod)
|
|
164
167
|
postSlotInitUpdateCallbacksInit(nil, mod)
|
|
165
168
|
postSlotRenderCallbacksInit(nil, mod)
|
|
166
169
|
postSpikesRenderInit(nil, mod)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
local ____exports = {}
|
|
2
|
+
local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
|
|
3
|
+
local DoorSlot = ____isaac_2Dtypescript_2Ddefinitions.DoorSlot
|
|
4
|
+
____exports.OPPOSITE_DOOR_SLOTS = {
|
|
5
|
+
[DoorSlot.NO_DOOR_SLOT] = nil,
|
|
6
|
+
[DoorSlot.LEFT_0] = DoorSlot.RIGHT_0,
|
|
7
|
+
[DoorSlot.UP_0] = DoorSlot.DOWN_0,
|
|
8
|
+
[DoorSlot.RIGHT_0] = DoorSlot.LEFT_0,
|
|
9
|
+
[DoorSlot.LEFT_1] = DoorSlot.RIGHT_1,
|
|
10
|
+
[DoorSlot.DOWN_0] = DoorSlot.UP_0,
|
|
11
|
+
[DoorSlot.UP_1] = DoorSlot.DOWN_1,
|
|
12
|
+
[DoorSlot.RIGHT_1] = DoorSlot.LEFT_1,
|
|
13
|
+
[DoorSlot.DOWN_1] = DoorSlot.UP_1
|
|
14
|
+
}
|
|
15
|
+
return ____exports
|