isaacscript-common 4.9.1 → 5.0.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/features/extraConsoleCommands/listCommands.lua +10 -10
- package/functions/charge.d.ts +29 -11
- package/functions/charge.lua +75 -34
- package/functions/roomShape.d.ts +16 -2
- package/functions/roomShape.lua +20 -4
- package/package.json +1 -1
|
@@ -38,6 +38,8 @@ local ____cards = require("functions.cards")
|
|
|
38
38
|
local getCardName = ____cards.getCardName
|
|
39
39
|
local ____character = require("functions.character")
|
|
40
40
|
local getCharacterName = ____character.getCharacterName
|
|
41
|
+
local ____charge = require("functions.charge")
|
|
42
|
+
local addCharge = ____charge.addCharge
|
|
41
43
|
local ____collectibles = require("functions.collectibles")
|
|
42
44
|
local isValidCollectibleType = ____collectibles.isValidCollectibleType
|
|
43
45
|
local ____entitySpecific = require("functions.entitySpecific")
|
|
@@ -199,7 +201,7 @@ function ____exports.addCharges(self, params)
|
|
|
199
201
|
printConsole(nil, "That is an invalid amount of arguments.")
|
|
200
202
|
return
|
|
201
203
|
end
|
|
202
|
-
local activeSlotString,
|
|
204
|
+
local activeSlotString, numChargeString = table.unpack(args)
|
|
203
205
|
local activeSlot = tonumber(activeSlotString)
|
|
204
206
|
if activeSlot == nil then
|
|
205
207
|
printConsole(
|
|
@@ -215,19 +217,17 @@ function ____exports.addCharges(self, params)
|
|
|
215
217
|
)
|
|
216
218
|
return
|
|
217
219
|
end
|
|
218
|
-
local
|
|
219
|
-
if
|
|
220
|
-
local
|
|
221
|
-
if
|
|
222
|
-
printConsole(nil, "The provided charge amount is invalid: " ..
|
|
220
|
+
local numCharges = 1
|
|
221
|
+
if numChargeString ~= nil then
|
|
222
|
+
local numChargesAttempt = tonumber(numChargeString)
|
|
223
|
+
if numChargesAttempt == nil then
|
|
224
|
+
printConsole(nil, "The provided charge amount is invalid: " .. numChargeString)
|
|
223
225
|
return
|
|
224
226
|
end
|
|
225
|
-
|
|
227
|
+
numCharges = numChargesAttempt
|
|
226
228
|
end
|
|
227
229
|
local player = Isaac.GetPlayer()
|
|
228
|
-
|
|
229
|
-
local newCharge = currentCharge + chargeNum
|
|
230
|
-
player:SetActiveCharge(newCharge, activeSlot)
|
|
230
|
+
addCharge(nil, player, activeSlot, numCharges)
|
|
231
231
|
end
|
|
232
232
|
--- Warps to the Angel Room for the floor. If the Devil Room has already been visited or initialized,
|
|
233
233
|
-- this will uninitialize it and make an Angel Room instead.
|
package/functions/charge.d.ts
CHANGED
|
@@ -1,19 +1,36 @@
|
|
|
1
1
|
import { ActiveSlot } from "isaac-typescript-definitions";
|
|
2
2
|
/**
|
|
3
|
-
* Helper function to add a charge to
|
|
4
|
-
*
|
|
3
|
+
* Helper function to add a charge to the player's active item. Will play the appropriate sound
|
|
4
|
+
* effect, depending on whether the charge is partially full or completely full.
|
|
5
5
|
*
|
|
6
6
|
* This function will take the following things into account:
|
|
7
|
-
* - L rooms and 2x2 rooms granting a double charge
|
|
8
7
|
* - The Battery
|
|
9
8
|
* - AAA Battery
|
|
10
9
|
*
|
|
11
10
|
* @param player The player to grant the charges to.
|
|
12
|
-
* @param
|
|
13
|
-
*
|
|
14
|
-
*
|
|
11
|
+
* @param activeSlot The slot to grant the charges to.
|
|
12
|
+
* @param numCharges Optional. The amount of charges to grant. Default is 1.
|
|
13
|
+
* @param playSoundEffect Optional. Whether to play a charge-related sound effect. Default is true.
|
|
14
|
+
* @returns The amount of charges that were actually granted. For example, if the active item was
|
|
15
|
+
* already fully charged, this function would return 0.
|
|
16
|
+
*/
|
|
17
|
+
export declare function addCharge(player: EntityPlayer, activeSlot: ActiveSlot, numCharges?: number, playSoundEffect?: boolean): int;
|
|
18
|
+
/**
|
|
19
|
+
* Helper function to add a charge to a player's active item(s), emulating what happens when a room
|
|
20
|
+
* is cleared.
|
|
21
|
+
*
|
|
22
|
+
* This function will take the following things into account:
|
|
23
|
+
* - 2x2 rooms and L rooms granting a double charge
|
|
24
|
+
* - The Battery
|
|
25
|
+
* - AAA Battery
|
|
26
|
+
*
|
|
27
|
+
* @param player The player to grant the charges to.
|
|
28
|
+
* @param bigRoomDoubleCharge Optional. If set to false, it will treat the current room as a 1x1
|
|
29
|
+
* room for the purposes of calculating how much charge to grant. Default
|
|
30
|
+
* is true.
|
|
31
|
+
* @param playSoundEffect Optional. Whether to play a charge-related sound effect. Default is true.
|
|
15
32
|
*/
|
|
16
|
-
export declare function addRoomClearCharge(player: EntityPlayer,
|
|
33
|
+
export declare function addRoomClearCharge(player: EntityPlayer, bigRoomDoubleCharge?: boolean, playSoundEffect?: boolean): void;
|
|
17
34
|
/**
|
|
18
35
|
* Helper function to add a charge to one of a player's active items, emulating what happens when a
|
|
19
36
|
* room is cleared.
|
|
@@ -25,11 +42,12 @@ export declare function addRoomClearCharge(player: EntityPlayer, ignoreBigRoomDo
|
|
|
25
42
|
*
|
|
26
43
|
* @param player The player to grant the charges to.
|
|
27
44
|
* @param activeSlot The active item slot to grant the charges to.
|
|
28
|
-
* @param
|
|
29
|
-
*
|
|
30
|
-
*
|
|
45
|
+
* @param bigRoomDoubleCharge Optional. If set to false, it will treat the current room as a 1x1
|
|
46
|
+
* room for the purposes of calculating how much charge to grant. Default
|
|
47
|
+
* is true.
|
|
48
|
+
* @param playSoundEffect Optional. Whether to play a charge-related sound effect. Default is true.
|
|
31
49
|
*/
|
|
32
|
-
export declare function addRoomClearChargeToSlot(player: EntityPlayer, activeSlot: ActiveSlot,
|
|
50
|
+
export declare function addRoomClearChargeToSlot(player: EntityPlayer, activeSlot: ActiveSlot, bigRoomDoubleCharge?: boolean, playSoundEffect?: boolean): void;
|
|
33
51
|
/**
|
|
34
52
|
* Helper function to add a charge to every player's active item, emulating what happens when a room
|
|
35
53
|
* is cleared.
|
package/functions/charge.lua
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
local ____exports = {}
|
|
2
|
-
local
|
|
2
|
+
local getClampedChargesToAdd, getNumChargesWithAAAModifier, shouldPlayFullRechargeSound
|
|
3
3
|
local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
|
|
4
4
|
local ActiveSlot = ____isaac_2Dtypescript_2Ddefinitions.ActiveSlot
|
|
5
5
|
local CollectibleType = ____isaac_2Dtypescript_2Ddefinitions.CollectibleType
|
|
6
|
-
local RoomShape = ____isaac_2Dtypescript_2Ddefinitions.RoomShape
|
|
7
6
|
local SoundEffect = ____isaac_2Dtypescript_2Ddefinitions.SoundEffect
|
|
8
7
|
local TrinketType = ____isaac_2Dtypescript_2Ddefinitions.TrinketType
|
|
9
8
|
local ____cachedClasses = require("cachedClasses")
|
|
@@ -13,41 +12,76 @@ local ____collectibles = require("functions.collectibles")
|
|
|
13
12
|
local getCollectibleMaxCharges = ____collectibles.getCollectibleMaxCharges
|
|
14
13
|
local ____playerIndex = require("functions.playerIndex")
|
|
15
14
|
local getPlayers = ____playerIndex.getPlayers
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
local ____roomShape = require("functions.roomShape")
|
|
16
|
+
local getRoomShapeCharges = ____roomShape.getRoomShapeCharges
|
|
17
|
+
--- Helper function to add a charge to the player's active item. Will play the appropriate sound
|
|
18
|
+
-- effect, depending on whether the charge is partially full or completely full.
|
|
18
19
|
--
|
|
19
20
|
-- This function will take the following things into account:
|
|
20
|
-
-- - L rooms and 2x2 rooms granting a double charge
|
|
21
21
|
-- - The Battery
|
|
22
22
|
-- - AAA Battery
|
|
23
23
|
--
|
|
24
24
|
-- @param player The player to grant the charges to.
|
|
25
|
-
-- @param activeSlot The
|
|
26
|
-
-- @param
|
|
27
|
-
--
|
|
28
|
-
--
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
25
|
+
-- @param activeSlot The slot to grant the charges to.
|
|
26
|
+
-- @param numCharges Optional. The amount of charges to grant. Default is 1.
|
|
27
|
+
-- @param playSoundEffect Optional. Whether to play a charge-related sound effect. Default is true.
|
|
28
|
+
-- @returns The amount of charges that were actually granted. For example, if the active item was
|
|
29
|
+
-- already fully charged, this function would return 0.
|
|
30
|
+
function ____exports.addCharge(self, player, activeSlot, numCharges, playSoundEffect)
|
|
31
|
+
if numCharges == nil then
|
|
32
|
+
numCharges = 1
|
|
33
|
+
end
|
|
34
|
+
if playSoundEffect == nil then
|
|
35
|
+
playSoundEffect = true
|
|
35
36
|
end
|
|
36
37
|
local hud = game:GetHUD()
|
|
37
38
|
local totalCharge = ____exports.getTotalCharge(nil, player, activeSlot)
|
|
38
|
-
local chargesToAdd =
|
|
39
|
+
local chargesToAdd = getClampedChargesToAdd(nil, player, activeSlot, numCharges)
|
|
39
40
|
local modifiedChargesToAdd = getNumChargesWithAAAModifier(nil, player, activeSlot, chargesToAdd)
|
|
40
41
|
local newCharge = totalCharge + modifiedChargesToAdd
|
|
42
|
+
if newCharge == totalCharge then
|
|
43
|
+
return 0
|
|
44
|
+
end
|
|
41
45
|
player:SetActiveCharge(newCharge, activeSlot)
|
|
42
46
|
hud:FlashChargeBar(player, activeSlot)
|
|
43
|
-
|
|
47
|
+
if playSoundEffect then
|
|
48
|
+
____exports.playChargeSoundEffect(nil, player, activeSlot)
|
|
49
|
+
end
|
|
50
|
+
return modifiedChargesToAdd
|
|
44
51
|
end
|
|
45
|
-
function
|
|
46
|
-
|
|
47
|
-
|
|
52
|
+
--- Helper function to add a charge to one of a player's active items, emulating what happens when a
|
|
53
|
+
-- room is cleared.
|
|
54
|
+
--
|
|
55
|
+
-- This function will take the following things into account:
|
|
56
|
+
-- - L rooms and 2x2 rooms granting a double charge
|
|
57
|
+
-- - The Battery
|
|
58
|
+
-- - AAA Battery
|
|
59
|
+
--
|
|
60
|
+
-- @param player The player to grant the charges to.
|
|
61
|
+
-- @param activeSlot The active item slot to grant the charges to.
|
|
62
|
+
-- @param bigRoomDoubleCharge Optional. If set to false, it will treat the current room as a 1x1
|
|
63
|
+
-- room for the purposes of calculating how much charge to grant. Default
|
|
64
|
+
-- is true.
|
|
65
|
+
-- @param playSoundEffect Optional. Whether to play a charge-related sound effect. Default is true.
|
|
66
|
+
function ____exports.addRoomClearChargeToSlot(self, player, activeSlot, bigRoomDoubleCharge, playSoundEffect)
|
|
67
|
+
if bigRoomDoubleCharge == nil then
|
|
68
|
+
bigRoomDoubleCharge = true
|
|
69
|
+
end
|
|
70
|
+
if playSoundEffect == nil then
|
|
71
|
+
playSoundEffect = true
|
|
48
72
|
end
|
|
49
73
|
local room = game:GetRoom()
|
|
50
74
|
local roomShape = room:GetRoomShape()
|
|
75
|
+
local numCharges = bigRoomDoubleCharge and getRoomShapeCharges(nil, roomShape) or 1
|
|
76
|
+
____exports.addCharge(
|
|
77
|
+
nil,
|
|
78
|
+
player,
|
|
79
|
+
activeSlot,
|
|
80
|
+
numCharges,
|
|
81
|
+
playSoundEffect
|
|
82
|
+
)
|
|
83
|
+
end
|
|
84
|
+
function getClampedChargesToAdd(self, player, activeSlot, numCharges)
|
|
51
85
|
local activeItem = player:GetActiveItem(activeSlot)
|
|
52
86
|
local activeCharge = player:GetActiveCharge(activeSlot)
|
|
53
87
|
local batteryCharge = player:GetBatteryCharge(activeSlot)
|
|
@@ -65,10 +99,7 @@ function getNumChargesToAdd(self, player, activeSlot, ignoreBigRoomDoubleCharge)
|
|
|
65
99
|
if hasBattery and batteryCharge + 1 == maxCharges then
|
|
66
100
|
return 1
|
|
67
101
|
end
|
|
68
|
-
|
|
69
|
-
return 2
|
|
70
|
-
end
|
|
71
|
-
return 1
|
|
102
|
+
return numCharges
|
|
72
103
|
end
|
|
73
104
|
function getNumChargesWithAAAModifier(self, player, activeSlot, chargesToAdd)
|
|
74
105
|
local activeItem = player:GetActiveItem(activeSlot)
|
|
@@ -114,24 +145,34 @@ function shouldPlayFullRechargeSound(self, player, activeSlot)
|
|
|
114
145
|
end
|
|
115
146
|
return not player:NeedsCharge(activeSlot) or activeCharge == maxCharges and batteryCharge == 0
|
|
116
147
|
end
|
|
117
|
-
--- Helper function to add a charge to a player's active item, emulating what happens when a room
|
|
118
|
-
-- cleared.
|
|
148
|
+
--- Helper function to add a charge to a player's active item(s), emulating what happens when a room
|
|
149
|
+
-- is cleared.
|
|
119
150
|
--
|
|
120
151
|
-- This function will take the following things into account:
|
|
121
|
-
-- -
|
|
152
|
+
-- - 2x2 rooms and L rooms granting a double charge
|
|
122
153
|
-- - The Battery
|
|
123
154
|
-- - AAA Battery
|
|
124
155
|
--
|
|
125
156
|
-- @param player The player to grant the charges to.
|
|
126
|
-
-- @param
|
|
127
|
-
--
|
|
128
|
-
--
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
157
|
+
-- @param bigRoomDoubleCharge Optional. If set to false, it will treat the current room as a 1x1
|
|
158
|
+
-- room for the purposes of calculating how much charge to grant. Default
|
|
159
|
+
-- is true.
|
|
160
|
+
-- @param playSoundEffect Optional. Whether to play a charge-related sound effect. Default is true.
|
|
161
|
+
function ____exports.addRoomClearCharge(self, player, bigRoomDoubleCharge, playSoundEffect)
|
|
162
|
+
if bigRoomDoubleCharge == nil then
|
|
163
|
+
bigRoomDoubleCharge = true
|
|
164
|
+
end
|
|
165
|
+
if playSoundEffect == nil then
|
|
166
|
+
playSoundEffect = true
|
|
132
167
|
end
|
|
133
168
|
for ____, activeSlot in ipairs({ActiveSlot.PRIMARY, ActiveSlot.SECONDARY, ActiveSlot.POCKET}) do
|
|
134
|
-
____exports.addRoomClearChargeToSlot(
|
|
169
|
+
____exports.addRoomClearChargeToSlot(
|
|
170
|
+
nil,
|
|
171
|
+
player,
|
|
172
|
+
activeSlot,
|
|
173
|
+
bigRoomDoubleCharge,
|
|
174
|
+
playSoundEffect
|
|
175
|
+
)
|
|
135
176
|
end
|
|
136
177
|
end
|
|
137
178
|
--- Helper function to add a charge to every player's active item, emulating what happens when a room
|
package/functions/roomShape.d.ts
CHANGED
|
@@ -6,18 +6,25 @@ import { DoorSlot, RoomShape } from "isaac-typescript-definitions";
|
|
|
6
6
|
* started.
|
|
7
7
|
*/
|
|
8
8
|
export declare function getGridIndexDelta(roomShape: RoomShape, doorSlot: DoorSlot): int | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* Helper function to see if a given room shape will grant a single charge or a double charge to the
|
|
11
|
+
* player's active item(s).
|
|
12
|
+
*
|
|
13
|
+
* For example, `RoomShape.SHAPE_2x2` will return 2.
|
|
14
|
+
*/
|
|
15
|
+
export declare function getRoomShapeBottomRightPosition(roomShape: RoomShape): Vector;
|
|
9
16
|
/**
|
|
10
17
|
* Helper function to get the grid position of the bottom-right tile of a given room shape.
|
|
11
18
|
*
|
|
12
19
|
* "Vector(0, 0)" corresponds to the top left tile of a room, not including the walls. (The top-left
|
|
13
20
|
* wall would be at "Vector(-1, -1)".)
|
|
14
21
|
*/
|
|
15
|
-
export declare function
|
|
22
|
+
export declare function getRoomShapeBounds(roomShape: RoomShape): readonly [width: int, height: int];
|
|
16
23
|
/**
|
|
17
24
|
* Helper function to get the bounds of a room shape, which are a box representing its contents.
|
|
18
25
|
* This does not include the tiles that the walls are on. L rooms use the same bounds as a 2x2 room.
|
|
19
26
|
*/
|
|
20
|
-
export declare function
|
|
27
|
+
export declare function getRoomShapeCharges(roomShape: RoomShape): int;
|
|
21
28
|
/**
|
|
22
29
|
* Helper function to get the dimensions of a room shape's layout. This is NOT the size of the
|
|
23
30
|
* room's actual contents! For that, use the `getRoomShapeBounds` function.
|
|
@@ -41,3 +48,10 @@ export declare function getRoomShapeTopLeftPosition(roomShape: RoomShape): Vecto
|
|
|
41
48
|
export declare function getRoomShapeVolume(roomShape: RoomShape): int;
|
|
42
49
|
export declare function getRoomShapeWidth(roomShape: RoomShape): int;
|
|
43
50
|
export declare function isLRoom(roomShape: RoomShape): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Helper function to see if a given room shape will grant a single charge or a double charge to the
|
|
53
|
+
* player's active item(s).
|
|
54
|
+
*
|
|
55
|
+
* For example, `RoomShape.SHAPE_2x2` will return true.
|
|
56
|
+
*/
|
|
57
|
+
export declare function isRoomShapeDoubleCharge(roomShape: RoomShape): boolean;
|
package/functions/roomShape.lua
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
2
|
local Map = ____lualib.Map
|
|
3
3
|
local ____exports = {}
|
|
4
|
+
local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
|
|
5
|
+
local RoomShape = ____isaac_2Dtypescript_2Ddefinitions.RoomShape
|
|
4
6
|
local ____roomShapeBounds = require("objects.roomShapeBounds")
|
|
5
7
|
local ROOM_SHAPE_BOUNDS = ____roomShapeBounds.ROOM_SHAPE_BOUNDS
|
|
6
8
|
local ____roomShapeLayoutSizes = require("objects.roomShapeLayoutSizes")
|
|
@@ -17,6 +19,13 @@ local ____roomShapeVolumes = require("objects.roomShapeVolumes")
|
|
|
17
19
|
local ROOM_SHAPE_VOLUMES = ____roomShapeVolumes.ROOM_SHAPE_VOLUMES
|
|
18
20
|
local ____LRoomShapesSet = require("sets.LRoomShapesSet")
|
|
19
21
|
local L_ROOM_SHAPES_SET = ____LRoomShapesSet.L_ROOM_SHAPES_SET
|
|
22
|
+
--- Helper function to see if a given room shape will grant a single charge or a double charge to the
|
|
23
|
+
-- player's active item(s).
|
|
24
|
+
--
|
|
25
|
+
-- For example, `RoomShape.SHAPE_2x2` will return true.
|
|
26
|
+
function ____exports.isRoomShapeDoubleCharge(self, roomShape)
|
|
27
|
+
return roomShape >= RoomShape.SHAPE_2x2
|
|
28
|
+
end
|
|
20
29
|
--- Helper function to get the grid index delta that a door out of the given room shape would lead
|
|
21
30
|
-- to. For example, if you went through the bottom door in a room of `RoomShape.SHAPE_1x2`, you
|
|
22
31
|
-- would end up in a room with a grid index that is +26 units from the `SafeGridIndex` of where you
|
|
@@ -25,17 +34,24 @@ function ____exports.getGridIndexDelta(self, roomShape, doorSlot)
|
|
|
25
34
|
local doorSlotToGridIndexMap = ROOM_SHAPE_TO_DOOR_SLOTS_TO_GRID_INDEX_DELTA[roomShape]
|
|
26
35
|
return doorSlotToGridIndexMap:get(doorSlot)
|
|
27
36
|
end
|
|
37
|
+
--- Helper function to see if a given room shape will grant a single charge or a double charge to the
|
|
38
|
+
-- player's active item(s).
|
|
39
|
+
--
|
|
40
|
+
-- For example, `RoomShape.SHAPE_2x2` will return 2.
|
|
41
|
+
function ____exports.getRoomShapeBottomRightPosition(self, roomShape)
|
|
42
|
+
return ROOM_SHAPE_TO_BOTTOM_RIGHT_POSITION[roomShape]
|
|
43
|
+
end
|
|
28
44
|
--- Helper function to get the grid position of the bottom-right tile of a given room shape.
|
|
29
45
|
--
|
|
30
46
|
-- "Vector(0, 0)" corresponds to the top left tile of a room, not including the walls. (The top-left
|
|
31
47
|
-- wall would be at "Vector(-1, -1)".)
|
|
32
|
-
function ____exports.
|
|
33
|
-
return
|
|
48
|
+
function ____exports.getRoomShapeBounds(self, roomShape)
|
|
49
|
+
return ROOM_SHAPE_BOUNDS[roomShape]
|
|
34
50
|
end
|
|
35
51
|
--- Helper function to get the bounds of a room shape, which are a box representing its contents.
|
|
36
52
|
-- This does not include the tiles that the walls are on. L rooms use the same bounds as a 2x2 room.
|
|
37
|
-
function ____exports.
|
|
38
|
-
return
|
|
53
|
+
function ____exports.getRoomShapeCharges(self, roomShape)
|
|
54
|
+
return ____exports.isRoomShapeDoubleCharge(nil, roomShape) and 2 or 1
|
|
39
55
|
end
|
|
40
56
|
--- Helper function to get the dimensions of a room shape's layout. This is NOT the size of the
|
|
41
57
|
-- room's actual contents! For that, use the `getRoomShapeBounds` function.
|