isaacscript-common 34.1.0 → 35.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/dist/index.rollup.d.ts +132 -29
- package/dist/isaacscript-common.lua +42 -14
- package/dist/src/functions/array.d.ts +4 -0
- package/dist/src/functions/array.d.ts.map +1 -1
- package/dist/src/functions/array.lua +4 -0
- package/dist/src/functions/enums.d.ts +1 -1
- package/dist/src/functions/enums.d.ts.map +1 -1
- package/dist/src/functions/jsonRoom.d.ts.map +1 -1
- package/dist/src/functions/jsonRoom.lua +4 -5
- package/dist/src/functions/roomData.d.ts +121 -28
- package/dist/src/functions/roomData.d.ts.map +1 -1
- package/dist/src/functions/roomData.lua +132 -32
- package/package.json +1 -1
- package/src/functions/array.ts +4 -0
- package/src/functions/enums.ts +4 -4
- package/src/functions/jsonRoom.ts +4 -5
- package/src/functions/roomData.ts +151 -32
package/dist/index.rollup.d.ts
CHANGED
|
@@ -4739,6 +4739,10 @@ export declare function getArrayCombinations<T>(array: T[] | readonly T[], inclu
|
|
|
4739
4739
|
* Helper function to get an array containing the indexes of an array.
|
|
4740
4740
|
*
|
|
4741
4741
|
* For example, an array of `["Apple", "Banana"]` would return an array of `[0, 1]`.
|
|
4742
|
+
*
|
|
4743
|
+
* Note that normally, you would use the `Object.keys` method to get the indexes of an array, but
|
|
4744
|
+
* due to implementation details of TypeScriptToLua, this results in an array of 1 through N
|
|
4745
|
+
* (instead of an array of 0 through N -1).
|
|
4742
4746
|
*/
|
|
4743
4747
|
export declare function getArrayIndexes<T>(array: T[] | readonly T[]): int[];
|
|
4744
4748
|
|
|
@@ -6652,8 +6656,23 @@ export declare function getRoomAdjacentGridIndexes(roomGridIndex?: int): Readonl
|
|
|
6652
6656
|
*/
|
|
6653
6657
|
export declare function getRoomAllowedDoors(roomGridIndex?: int): Set<DoorSlot>;
|
|
6654
6658
|
|
|
6659
|
+
/**
|
|
6660
|
+
* Helper function to get the room data for the current room.
|
|
6661
|
+
*
|
|
6662
|
+
* You can optionally provide a room grid index as an argument to get the data for that room
|
|
6663
|
+
* instead.
|
|
6664
|
+
*
|
|
6665
|
+
* (The version of the function without any arguments will not return undefined since the current
|
|
6666
|
+
* room is guaranteed to have data.)
|
|
6667
|
+
*/
|
|
6655
6668
|
export declare function getRoomData(): RoomConfig;
|
|
6656
6669
|
|
|
6670
|
+
/**
|
|
6671
|
+
* Helper function to get the room data for the current or provided room.
|
|
6672
|
+
*
|
|
6673
|
+
* @param roomGridIndex Optional. Default is the current room index.
|
|
6674
|
+
* @returns The room data for the room or undefined if the provided room does not have any data.
|
|
6675
|
+
*/
|
|
6657
6676
|
export declare function getRoomData(roomGridIndex?: int): RoomConfig | undefined;
|
|
6658
6677
|
|
|
6659
6678
|
/**
|
|
@@ -6718,12 +6737,15 @@ export declare function getRoomDescriptorsForType(...roomTypes: RoomType[]): Roo
|
|
|
6718
6737
|
export declare function getRoomDisplayFlags(roomGridIndex?: int, minimapAPI?: boolean): BitFlags<DisplayFlag>;
|
|
6719
6738
|
|
|
6720
6739
|
/**
|
|
6721
|
-
* Helper function to get the
|
|
6722
|
-
* as the top-left 1x1 section that the room overlaps with, or the top-right 1x1 section of a
|
|
6723
|
-
* `RoomType.SHAPE_LTL` room.)
|
|
6740
|
+
* Helper function to get the grid index of the current room.
|
|
6724
6741
|
*
|
|
6725
|
-
*
|
|
6726
|
-
*
|
|
6742
|
+
* - If the current room is inside of the grid, this function will return the `SafeGridIndex` from
|
|
6743
|
+
* the room descriptor. (The safe grid index is defined as the top-left 1x1 section that the room
|
|
6744
|
+
* overlaps with, or the top-right 1x1 section of a `RoomType.SHAPE_LTL` room.)
|
|
6745
|
+
* - If the current room is outside of the grid, it will return the index from the
|
|
6746
|
+
* `Level.GetCurrentRoomIndex` method (since `SafeGridIndex` is bugged for these cases, as
|
|
6747
|
+
* demonstrated by entering a Genesis room and entering `l
|
|
6748
|
+
* print(Game():GetLevel():GetCurrentRoomDesc().SafeGridIndex)` into the console).
|
|
6727
6749
|
*
|
|
6728
6750
|
* Use this function instead of the `Level.GetCurrentRoomIndex` method directly because the latter
|
|
6729
6751
|
* will return the specific 1x1 quadrant that the player entered the room at. For most situations,
|
|
@@ -6763,13 +6785,24 @@ export declare function getRoomItemPoolType(): ItemPoolType;
|
|
|
6763
6785
|
*/
|
|
6764
6786
|
export declare function getRoomListIndex(roomGridIndex?: int): int;
|
|
6765
6787
|
|
|
6788
|
+
/**
|
|
6789
|
+
* Helper function to get the name of the current room as it appears in the STB/XML data.
|
|
6790
|
+
*
|
|
6791
|
+
* You can optionally provide a room grid index as an argument to get the name for that room
|
|
6792
|
+
* instead.
|
|
6793
|
+
*
|
|
6794
|
+
* (The version of the function without any arguments will not return undefined since the current
|
|
6795
|
+
* room is guaranteed to have data.)
|
|
6796
|
+
*/
|
|
6797
|
+
export declare function getRoomName(): string;
|
|
6798
|
+
|
|
6766
6799
|
/**
|
|
6767
6800
|
* Helper function to get the name of the room as it appears in the STB/XML data.
|
|
6768
6801
|
*
|
|
6769
6802
|
* @param roomGridIndex Optional. Default is the current room index.
|
|
6770
|
-
* @returns The room name. Returns
|
|
6803
|
+
* @returns The room name. Returns undefined if the room data was not found.
|
|
6771
6804
|
*/
|
|
6772
|
-
export declare function getRoomName(roomGridIndex?: int): string;
|
|
6805
|
+
export declare function getRoomName(roomGridIndex?: int): string | undefined;
|
|
6773
6806
|
|
|
6774
6807
|
/**
|
|
6775
6808
|
* Helper function to get the room descriptor for every room on the level. This includes off-grid
|
|
@@ -6787,10 +6820,21 @@ export declare function getRoomName(roomGridIndex?: int): string;
|
|
|
6787
6820
|
export declare function getRooms(includeExtraDimensionalRooms?: boolean): RoomDescriptor[];
|
|
6788
6821
|
|
|
6789
6822
|
/**
|
|
6790
|
-
* Helper function to get the
|
|
6823
|
+
* Helper function to get the shape of the current room as it appears in the STB/XML data.
|
|
6824
|
+
*
|
|
6825
|
+
* You can optionally provide a room grid index as an argument to get the shape for that room
|
|
6826
|
+
* instead.
|
|
6827
|
+
*
|
|
6828
|
+
* (The version of the function without any arguments will not return undefined since the current
|
|
6829
|
+
* room is guaranteed to have data.)
|
|
6830
|
+
*/
|
|
6831
|
+
export declare function getRoomShape(): RoomShape;
|
|
6832
|
+
|
|
6833
|
+
/**
|
|
6834
|
+
* Helper function to get the shape of the room as it appears in the STB/XML data.
|
|
6791
6835
|
*
|
|
6792
6836
|
* @param roomGridIndex Optional. Default is the current room index.
|
|
6793
|
-
* @returns The room
|
|
6837
|
+
* @returns The room shape. Returns undefined if the room data was not found.
|
|
6794
6838
|
*/
|
|
6795
6839
|
export declare function getRoomShape(roomGridIndex?: int): RoomShape | undefined;
|
|
6796
6840
|
|
|
@@ -6931,33 +6975,77 @@ export declare function getRoomsOfDimension(dimension: Dimension): RoomDescripto
|
|
|
6931
6975
|
export declare function getRoomsOutsideGrid(): RoomDescriptor[];
|
|
6932
6976
|
|
|
6933
6977
|
/**
|
|
6934
|
-
* Helper function to get the stage ID for
|
|
6935
|
-
*
|
|
6936
|
-
*
|
|
6978
|
+
* Helper function to get the stage ID for the current room as it appears in the STB/XML data.
|
|
6979
|
+
*
|
|
6980
|
+
* The room stage ID will correspond to the first number in the filename of the XML/STB file. For
|
|
6981
|
+
* example, a Depths room would have a stage ID of `StageID.DEPTHS` (7).
|
|
6982
|
+
*
|
|
6983
|
+
* You can optionally provide a room grid index as an argument to get the stage ID for that room
|
|
6984
|
+
* instead.
|
|
6985
|
+
*
|
|
6986
|
+
* (The version of the function without any arguments will not return undefined since the current
|
|
6987
|
+
* room is guaranteed to have data.)
|
|
6988
|
+
*/
|
|
6989
|
+
export declare function getRoomStageID(): StageID;
|
|
6990
|
+
|
|
6991
|
+
/**
|
|
6992
|
+
* Helper function to get the stage ID for a room as it appears in the STB/XML data.
|
|
6993
|
+
*
|
|
6994
|
+
* The room stage ID will correspond to the first number in the filename of the XML/STB file. For
|
|
6995
|
+
* example, a Depths room would have a stage ID of `StageID.DEPTHS` (7).
|
|
6937
6996
|
*
|
|
6938
6997
|
* @param roomGridIndex Optional. Default is the current room index.
|
|
6939
|
-
* @returns The room stage ID. Returns
|
|
6998
|
+
* @returns The room stage ID. Returns undefined if the room data was not found.
|
|
6940
6999
|
*/
|
|
6941
|
-
export declare function getRoomStageID(roomGridIndex?: int): StageID |
|
|
7000
|
+
export declare function getRoomStageID(roomGridIndex?: int): StageID | undefined;
|
|
6942
7001
|
|
|
6943
7002
|
/**
|
|
6944
|
-
* Helper function to get the sub-type for
|
|
6945
|
-
*
|
|
6946
|
-
*
|
|
6947
|
-
*
|
|
7003
|
+
* Helper function to get the sub-type for the current room as it appears in the STB/XML data.
|
|
7004
|
+
*
|
|
7005
|
+
* The room sub-type will correspond to different things depending on what XML/STB file it draws
|
|
7006
|
+
* from. For example, in the "00.special rooms.stb" file, an Angel Room with a sub-type of 0 will
|
|
7007
|
+
* correspond to a normal Angel Room and a sub-type of 1 will correspond to an Angel Room shop from
|
|
7008
|
+
* The Stairway.
|
|
7009
|
+
*
|
|
7010
|
+
* You can optionally provide a room grid index as an argument to get the sub-type for that room
|
|
7011
|
+
* instead.
|
|
7012
|
+
*
|
|
7013
|
+
* (The version of the function without any arguments will not return undefined since the current
|
|
7014
|
+
* room is guaranteed to have data.)
|
|
7015
|
+
*/
|
|
7016
|
+
export declare function getRoomSubType(): int;
|
|
7017
|
+
|
|
7018
|
+
/**
|
|
7019
|
+
* Helper function to get the sub-type for a room as it appears in the STB/XML data.
|
|
7020
|
+
*
|
|
7021
|
+
* The room sub-type will correspond to different things depending on what XML/STB file it draws
|
|
7022
|
+
* from. For example, in the "00.special rooms.stb" file, an Angel Room with a sub-type of 0 will
|
|
7023
|
+
* correspond to a normal Angel Room and a sub-type of 1 will correspond to an Angel Room shop from
|
|
7024
|
+
* The Stairway.
|
|
6948
7025
|
*
|
|
6949
7026
|
* @param roomGridIndex Optional. Default is the current room index.
|
|
6950
|
-
* @returns The room sub-type. Returns
|
|
7027
|
+
* @returns The room sub-type. Returns undefined if the room data was not found.
|
|
7028
|
+
*/
|
|
7029
|
+
export declare function getRoomSubType(roomGridIndex?: int): int | undefined;
|
|
7030
|
+
|
|
7031
|
+
/**
|
|
7032
|
+
* Helper function to get the type for the current room as it appears in the STB/XML data.
|
|
7033
|
+
*
|
|
7034
|
+
* You can optionally provide a room grid index as an argument to get the type for that room
|
|
7035
|
+
* instead.
|
|
7036
|
+
*
|
|
7037
|
+
* (The version of the function without any arguments will not return undefined since the current
|
|
7038
|
+
* room is guaranteed to have data.)
|
|
6951
7039
|
*/
|
|
6952
|
-
export declare function
|
|
7040
|
+
export declare function getRoomType(): RoomType;
|
|
6953
7041
|
|
|
6954
7042
|
/**
|
|
6955
|
-
* Helper function
|
|
7043
|
+
* Helper function to get the type for a room as it appears in the STB/XML data.
|
|
6956
7044
|
*
|
|
6957
7045
|
* @param roomGridIndex Optional. Default is the current room index.
|
|
6958
|
-
* @returns The room
|
|
7046
|
+
* @returns The room type. Returns undefined if the room data was not found.
|
|
6959
7047
|
*/
|
|
6960
|
-
export declare function getRoomType(roomGridIndex?: int): RoomType |
|
|
7048
|
+
export declare function getRoomType(roomGridIndex?: int): RoomType | undefined;
|
|
6961
7049
|
|
|
6962
7050
|
/**
|
|
6963
7051
|
* Helper function to get the proper name of a room type.
|
|
@@ -6967,14 +7055,29 @@ export declare function getRoomType(roomGridIndex?: int): RoomType | -1;
|
|
|
6967
7055
|
export declare function getRoomTypeName(roomType: RoomType): string;
|
|
6968
7056
|
|
|
6969
7057
|
/**
|
|
6970
|
-
* Helper function to get the variant for
|
|
6971
|
-
*
|
|
6972
|
-
*
|
|
7058
|
+
* Helper function to get the variant for the current room as it appears in the STB/XML data.
|
|
7059
|
+
*
|
|
7060
|
+
* You can think of a room variant as its identifier. For example, to go to Basement room #123, you
|
|
7061
|
+
* would use a console command of `goto d.123` while on the Basement.
|
|
7062
|
+
*
|
|
7063
|
+
* You can optionally provide a room grid index as an argument to get the variant for that room
|
|
7064
|
+
* instead.
|
|
7065
|
+
*
|
|
7066
|
+
* (The version of the function without any arguments will not return undefined since the current
|
|
7067
|
+
* room is guaranteed to have data.)
|
|
7068
|
+
*/
|
|
7069
|
+
export declare function getRoomVariant(): int;
|
|
7070
|
+
|
|
7071
|
+
/**
|
|
7072
|
+
* Helper function to get the variant for a room as it appears in the STB/XML data.
|
|
7073
|
+
*
|
|
7074
|
+
* You can think of a room variant as its identifier. For example, to go to Basement room #123, you
|
|
7075
|
+
* would use a console command of `goto d.123` while on the Basement.
|
|
6973
7076
|
*
|
|
6974
7077
|
* @param roomGridIndex Optional. Default is the current room index.
|
|
6975
|
-
* @returns The room variant. Returns
|
|
7078
|
+
* @returns The room variant. Returns undefined if the room data was not found.
|
|
6976
7079
|
*/
|
|
6977
|
-
export declare function getRoomVariant(roomGridIndex?: int): int;
|
|
7080
|
+
export declare function getRoomVariant(roomGridIndex?: int): int | undefined;
|
|
6978
7081
|
|
|
6979
7082
|
/**
|
|
6980
7083
|
* Note that the room visited count will be inaccurate during the period before the `POST_NEW_ROOM`
|
|
@@ -8456,7 +8559,7 @@ export declare function isEntity(variable: unknown): variable is Entity;
|
|
|
8456
8559
|
export declare function isEntityMoving(entity: Entity, threshold?: number): boolean;
|
|
8457
8560
|
|
|
8458
8561
|
/** Helper function to validate that a particular value exists inside of an enum. */
|
|
8459
|
-
export declare function isEnumValue(value: number | string, transpiledEnum:
|
|
8562
|
+
export declare function isEnumValue<T extends Record<string, number | string>>(value: number | string, transpiledEnum: T): value is T[keyof T];
|
|
8460
8563
|
|
|
8461
8564
|
export declare function isEven(num: int): boolean;
|
|
8462
8565
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
--[[
|
|
2
2
|
|
|
3
|
-
isaacscript-common
|
|
3
|
+
isaacscript-common 35.0.0
|
|
4
4
|
|
|
5
5
|
This is the "isaacscript-common" library, which was created with the IsaacScript tool.
|
|
6
6
|
|
|
@@ -26790,6 +26790,11 @@ function ____exports.getRoomDescriptorReadOnly(self)
|
|
|
26790
26790
|
return level:GetCurrentRoomDesc()
|
|
26791
26791
|
end
|
|
26792
26792
|
function ____exports.getRoomGridIndex(self)
|
|
26793
|
+
local level = game:GetLevel()
|
|
26794
|
+
local currentRoomIndex = level:GetCurrentRoomIndex()
|
|
26795
|
+
if currentRoomIndex < 0 then
|
|
26796
|
+
return currentRoomIndex
|
|
26797
|
+
end
|
|
26793
26798
|
local roomDescriptor = ____exports.getRoomDescriptorReadOnly(nil)
|
|
26794
26799
|
return roomDescriptor.SafeGridIndex
|
|
26795
26800
|
end
|
|
@@ -26812,30 +26817,54 @@ function ____exports.getRoomListIndex(self, roomGridIndex)
|
|
|
26812
26817
|
return roomDescriptor.ListIndex
|
|
26813
26818
|
end
|
|
26814
26819
|
function ____exports.getRoomName(self, roomGridIndex)
|
|
26815
|
-
local roomData = ____exports.getRoomData(nil, roomGridIndex)
|
|
26816
|
-
return roomData == nil and "Unknown" or roomData.Name
|
|
26817
|
-
end
|
|
26818
|
-
function ____exports.getRoomShape(self, roomGridIndex)
|
|
26819
26820
|
local roomData = ____exports.getRoomData(nil, roomGridIndex)
|
|
26820
26821
|
local ____temp_0
|
|
26821
26822
|
if roomData == nil then
|
|
26822
26823
|
____temp_0 = nil
|
|
26823
26824
|
else
|
|
26824
|
-
____temp_0 = roomData.
|
|
26825
|
+
____temp_0 = roomData.Name
|
|
26825
26826
|
end
|
|
26826
26827
|
return ____temp_0
|
|
26827
26828
|
end
|
|
26829
|
+
function ____exports.getRoomShape(self, roomGridIndex)
|
|
26830
|
+
local roomData = ____exports.getRoomData(nil, roomGridIndex)
|
|
26831
|
+
local ____temp_1
|
|
26832
|
+
if roomData == nil then
|
|
26833
|
+
____temp_1 = nil
|
|
26834
|
+
else
|
|
26835
|
+
____temp_1 = roomData.Shape
|
|
26836
|
+
end
|
|
26837
|
+
return ____temp_1
|
|
26838
|
+
end
|
|
26828
26839
|
function ____exports.getRoomStageID(self, roomGridIndex)
|
|
26829
26840
|
local roomData = ____exports.getRoomData(nil, roomGridIndex)
|
|
26830
|
-
|
|
26841
|
+
local ____temp_2
|
|
26842
|
+
if roomData == nil then
|
|
26843
|
+
____temp_2 = nil
|
|
26844
|
+
else
|
|
26845
|
+
____temp_2 = roomData.StageID
|
|
26846
|
+
end
|
|
26847
|
+
return ____temp_2
|
|
26831
26848
|
end
|
|
26832
26849
|
function ____exports.getRoomSubType(self, roomGridIndex)
|
|
26833
26850
|
local roomData = ____exports.getRoomData(nil, roomGridIndex)
|
|
26834
|
-
|
|
26851
|
+
local ____temp_3
|
|
26852
|
+
if roomData == nil then
|
|
26853
|
+
____temp_3 = nil
|
|
26854
|
+
else
|
|
26855
|
+
____temp_3 = roomData.Subtype
|
|
26856
|
+
end
|
|
26857
|
+
return ____temp_3
|
|
26835
26858
|
end
|
|
26836
26859
|
function ____exports.getRoomType(self, roomGridIndex)
|
|
26837
26860
|
local roomData = ____exports.getRoomData(nil, roomGridIndex)
|
|
26838
|
-
|
|
26861
|
+
local ____temp_4
|
|
26862
|
+
if roomData == nil then
|
|
26863
|
+
____temp_4 = nil
|
|
26864
|
+
else
|
|
26865
|
+
____temp_4 = roomData.Type
|
|
26866
|
+
end
|
|
26867
|
+
return ____temp_4
|
|
26839
26868
|
end
|
|
26840
26869
|
function ____exports.getRoomVariant(self, roomGridIndex)
|
|
26841
26870
|
local roomData = ____exports.getRoomData(nil, roomGridIndex)
|
|
@@ -46725,12 +46754,11 @@ function getJSONObjectWithChosenWeight(self, jsonOjectArray, chosenWeight)
|
|
|
46725
46754
|
end
|
|
46726
46755
|
function ____exports.getJSONRoomDoorSlotFlags(self, jsonRoom)
|
|
46727
46756
|
local roomShapeString = jsonRoom["$"].shape
|
|
46728
|
-
local
|
|
46729
|
-
assertDefined(nil,
|
|
46730
|
-
if not isEnumValue(nil,
|
|
46731
|
-
error("Failed to parse the \"shape\" field of a JSON room since it was an invalid number: " .. tostring(
|
|
46757
|
+
local roomShape = tonumber(roomShapeString)
|
|
46758
|
+
assertDefined(nil, roomShape, "Failed to parse the \"shape\" field of a JSON room: " .. roomShapeString)
|
|
46759
|
+
if not isEnumValue(nil, roomShape, RoomShape) then
|
|
46760
|
+
error("Failed to parse the \"shape\" field of a JSON room since it was an invalid number: " .. tostring(roomShape))
|
|
46732
46761
|
end
|
|
46733
|
-
local roomShape = roomShapeNumber
|
|
46734
46762
|
local doorSlotFlags = DoorSlotFlagZero
|
|
46735
46763
|
for ____, door in ipairs(jsonRoom.door) do
|
|
46736
46764
|
do
|
|
@@ -134,6 +134,10 @@ export declare function getArrayCombinations<T>(array: T[] | readonly T[], inclu
|
|
|
134
134
|
* Helper function to get an array containing the indexes of an array.
|
|
135
135
|
*
|
|
136
136
|
* For example, an array of `["Apple", "Banana"]` would return an array of `[0, 1]`.
|
|
137
|
+
*
|
|
138
|
+
* Note that normally, you would use the `Object.keys` method to get the indexes of an array, but
|
|
139
|
+
* due to implementation details of TypeScriptToLua, this results in an array of 1 through N
|
|
140
|
+
* (instead of an array of 0 through N -1).
|
|
137
141
|
*/
|
|
138
142
|
export declare function getArrayIndexes<T>(array: T[] | readonly T[]): int[];
|
|
139
143
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../../src/functions/array.ts"],"names":[],"mappings":";;;AAMA;;;GAGG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAC3B,MAAM,EAAE,CAAC,EAAE,GAAG,SAAS,CAAC,EAAE,EAC1B,MAAM,EAAE,CAAC,EAAE,GAAG,SAAS,CAAC,EAAE,GACzB,OAAO,CAST;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAC3B,aAAa,EAAE,CAAC,EAAE,GAAG,SAAS,CAAC,EAAE,EACjC,GAAG,gBAAgB,EAAE,CAAC,EAAE,GACvB,CAAC,EAAE,CAIL;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAC9B,aAAa,EAAE,CAAC,EAAE,GAAG,SAAS,CAAC,EAAE,EACjC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,EAC9B,YAAY,EAAE,CAAC,EAAE,GAAG,SAAS,CAAC,EAAE,EAChC,WAAW,EAAE,KAAK,CAAC,CAAC,EAAE,GAAG,SAAS,CAAC,EAAE,CAAC,GACrC,OAAO,CAET;AAED,4EAA4E;AAC5E,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAIjE;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAC5B,aAAa,EAAE,CAAC,EAAE,GAAG,SAAS,CAAC,EAAE,EACjC,SAAS,GAAE,IAAI,GAAG,GAAqB,GACtC,CAAC,EAAE,CAKL;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EACnC,KAAK,EAAE,CAAC,EAAE,EACV,SAAS,GAAE,IAAI,GAAG,GAAqB,GACtC,IAAI,CAWN;AAED,+DAA+D;AAC/D,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,SAAS,MAAM,EAAE,GAAG,MAAM,CAEpE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAM3E"}
|
|
@@ -364,6 +364,10 @@ end
|
|
|
364
364
|
--- Helper function to get an array containing the indexes of an array.
|
|
365
365
|
--
|
|
366
366
|
-- For example, an array of `["Apple", "Banana"]` would return an array of `[0, 1]`.
|
|
367
|
+
--
|
|
368
|
+
-- Note that normally, you would use the `Object.keys` method to get the indexes of an array, but
|
|
369
|
+
-- due to implementation details of TypeScriptToLua, this results in an array of 1 through N
|
|
370
|
+
-- (instead of an array of 0 through N -1).
|
|
367
371
|
function ____exports.getArrayIndexes(self, array)
|
|
368
372
|
return eRange(nil, #array)
|
|
369
373
|
end
|
|
@@ -83,7 +83,7 @@ export declare function getLowestEnumValue<T>(transpiledEnum: T): T[keyof T];
|
|
|
83
83
|
*/
|
|
84
84
|
export declare function getRandomEnumValue<T>(transpiledEnum: T, seedOrRNG?: Seed | RNG, exceptions?: Array<T[keyof T]> | ReadonlyArray<T[keyof T]>): T[keyof T];
|
|
85
85
|
/** Helper function to validate that a particular value exists inside of an enum. */
|
|
86
|
-
export declare function isEnumValue(value: number | string, transpiledEnum:
|
|
86
|
+
export declare function isEnumValue<T extends Record<string, number | string>>(value: number | string, transpiledEnum: T): value is T[keyof T];
|
|
87
87
|
/**
|
|
88
88
|
* Helper function to check every value of a custom enum for -1. Will throw an run-time error if any
|
|
89
89
|
* -1 values are found. This is helpful because many methods of the Isaac class return -1 if they
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enums.d.ts","sourceRoot":"","sources":["../../../src/functions/enums.ts"],"names":[],"mappings":";;;AAMA;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAC9B,cAAc,EAAE,CAAC,GAChB,KAAK,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAmBzC;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,WAAW,CACzB,cAAc,EAAE,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,GACvD,MAAM,EAAE,CAGV;AAED,sEAAsE;AACtE,wBAAgB,aAAa,CAC3B,cAAc,EAAE,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,GACvD,GAAG,CAGL;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,cAAc,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAGrE;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,cAAc,EAAE,CA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E,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAEjE,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAexE;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,QAAQ,GACjB,QAAQ,CAAC,YAAY,CAAC,
|
|
1
|
+
{"version":3,"file":"jsonRoom.d.ts","sourceRoot":"","sources":["../../../src/functions/jsonRoom.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAEjE,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAexE;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,QAAQ,GACjB,QAAQ,CAAC,YAAY,CAAC,CAqDxB;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,QAAQ,EAAE,GAAG,SAAS,QAAQ,EAAE,EAC3C,OAAO,EAAE,GAAG,GACX,QAAQ,GAAG,SAAS,CAoBtB;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,QAAQ,EAAE,GAAG,SAAS,QAAQ,EAAE,EAC3C,OAAO,EAAE,GAAG,GACX,QAAQ,EAAE,CAMZ;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,UAAU,EAAE,EAC1B,SAAS,GAAE,IAAI,GAAG,GAAqB,EACvC,OAAO,UAAQ,GACd,UAAU,CAqBZ;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,QAAQ,EAAE,EACrB,SAAS,GAAE,IAAI,GAAG,GAAqB,EACvC,OAAO,UAAQ,GACd,QAAQ,CAkBV"}
|
|
@@ -62,12 +62,11 @@ end
|
|
|
62
62
|
-- (A JSON room is an XML file converted to JSON so that it can be directly imported into your mod.)
|
|
63
63
|
function ____exports.getJSONRoomDoorSlotFlags(self, jsonRoom)
|
|
64
64
|
local roomShapeString = jsonRoom["$"].shape
|
|
65
|
-
local
|
|
66
|
-
assertDefined(nil,
|
|
67
|
-
if not isEnumValue(nil,
|
|
68
|
-
error("Failed to parse the \"shape\" field of a JSON room since it was an invalid number: " .. tostring(
|
|
65
|
+
local roomShape = tonumber(roomShapeString)
|
|
66
|
+
assertDefined(nil, roomShape, "Failed to parse the \"shape\" field of a JSON room: " .. roomShapeString)
|
|
67
|
+
if not isEnumValue(nil, roomShape, RoomShape) then
|
|
68
|
+
error("Failed to parse the \"shape\" field of a JSON room since it was an invalid number: " .. tostring(roomShape))
|
|
69
69
|
end
|
|
70
|
-
local roomShape = roomShapeNumber
|
|
71
70
|
local doorSlotFlags = DoorSlotFlagZero
|
|
72
71
|
for ____, door in ipairs(jsonRoom.door) do
|
|
73
72
|
do
|
|
@@ -4,7 +4,22 @@ import type { DoorSlot, RoomShape, RoomType, StageID } from "isaac-typescript-de
|
|
|
4
4
|
* This corresponds to the doors that are enabled in the STB/XML file for the room.
|
|
5
5
|
*/
|
|
6
6
|
export declare function getRoomAllowedDoors(roomGridIndex?: int): Set<DoorSlot>;
|
|
7
|
+
/**
|
|
8
|
+
* Helper function to get the room data for the current room.
|
|
9
|
+
*
|
|
10
|
+
* You can optionally provide a room grid index as an argument to get the data for that room
|
|
11
|
+
* instead.
|
|
12
|
+
*
|
|
13
|
+
* (The version of the function without any arguments will not return undefined since the current
|
|
14
|
+
* room is guaranteed to have data.)
|
|
15
|
+
*/
|
|
7
16
|
export declare function getRoomData(): RoomConfig;
|
|
17
|
+
/**
|
|
18
|
+
* Helper function to get the room data for the current or provided room.
|
|
19
|
+
*
|
|
20
|
+
* @param roomGridIndex Optional. Default is the current room index.
|
|
21
|
+
* @returns The room data for the room or undefined if the provided room does not have any data.
|
|
22
|
+
*/
|
|
8
23
|
export declare function getRoomData(roomGridIndex?: int): RoomConfig | undefined;
|
|
9
24
|
/**
|
|
10
25
|
* Helper function to get the descriptor for a room.
|
|
@@ -18,12 +33,15 @@ export declare function getRoomDescriptor(roomGridIndex?: int): RoomDescriptor;
|
|
|
18
33
|
*/
|
|
19
34
|
export declare function getRoomDescriptorReadOnly(): Readonly<RoomDescriptor>;
|
|
20
35
|
/**
|
|
21
|
-
* Helper function to get the
|
|
22
|
-
* as the top-left 1x1 section that the room overlaps with, or the top-right 1x1 section of a
|
|
23
|
-
* `RoomType.SHAPE_LTL` room.)
|
|
36
|
+
* Helper function to get the grid index of the current room.
|
|
24
37
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
38
|
+
* - If the current room is inside of the grid, this function will return the `SafeGridIndex` from
|
|
39
|
+
* the room descriptor. (The safe grid index is defined as the top-left 1x1 section that the room
|
|
40
|
+
* overlaps with, or the top-right 1x1 section of a `RoomType.SHAPE_LTL` room.)
|
|
41
|
+
* - If the current room is outside of the grid, it will return the index from the
|
|
42
|
+
* `Level.GetCurrentRoomIndex` method (since `SafeGridIndex` is bugged for these cases, as
|
|
43
|
+
* demonstrated by entering a Genesis room and entering `l
|
|
44
|
+
* print(Game():GetLevel():GetCurrentRoomDesc().SafeGridIndex)` into the console).
|
|
27
45
|
*
|
|
28
46
|
* Use this function instead of the `Level.GetCurrentRoomIndex` method directly because the latter
|
|
29
47
|
* will return the specific 1x1 quadrant that the player entered the room at. For most situations,
|
|
@@ -44,55 +62,130 @@ export declare function getRoomGridIndex(): int;
|
|
|
44
62
|
* @param roomGridIndex Optional. Default is the current room index.
|
|
45
63
|
*/
|
|
46
64
|
export declare function getRoomListIndex(roomGridIndex?: int): int;
|
|
65
|
+
/**
|
|
66
|
+
* Helper function to get the name of the current room as it appears in the STB/XML data.
|
|
67
|
+
*
|
|
68
|
+
* You can optionally provide a room grid index as an argument to get the name for that room
|
|
69
|
+
* instead.
|
|
70
|
+
*
|
|
71
|
+
* (The version of the function without any arguments will not return undefined since the current
|
|
72
|
+
* room is guaranteed to have data.)
|
|
73
|
+
*/
|
|
74
|
+
export declare function getRoomName(): string;
|
|
47
75
|
/**
|
|
48
76
|
* Helper function to get the name of the room as it appears in the STB/XML data.
|
|
49
77
|
*
|
|
50
78
|
* @param roomGridIndex Optional. Default is the current room index.
|
|
51
|
-
* @returns The room name. Returns
|
|
79
|
+
* @returns The room name. Returns undefined if the room data was not found.
|
|
52
80
|
*/
|
|
53
|
-
export declare function getRoomName(roomGridIndex?: int): string;
|
|
81
|
+
export declare function getRoomName(roomGridIndex?: int): string | undefined;
|
|
54
82
|
/**
|
|
55
|
-
* Helper function to get the
|
|
83
|
+
* Helper function to get the shape of the current room as it appears in the STB/XML data.
|
|
84
|
+
*
|
|
85
|
+
* You can optionally provide a room grid index as an argument to get the shape for that room
|
|
86
|
+
* instead.
|
|
87
|
+
*
|
|
88
|
+
* (The version of the function without any arguments will not return undefined since the current
|
|
89
|
+
* room is guaranteed to have data.)
|
|
90
|
+
*/
|
|
91
|
+
export declare function getRoomShape(): RoomShape;
|
|
92
|
+
/**
|
|
93
|
+
* Helper function to get the shape of the room as it appears in the STB/XML data.
|
|
56
94
|
*
|
|
57
95
|
* @param roomGridIndex Optional. Default is the current room index.
|
|
58
|
-
* @returns The room
|
|
96
|
+
* @returns The room shape. Returns undefined if the room data was not found.
|
|
59
97
|
*/
|
|
60
98
|
export declare function getRoomShape(roomGridIndex?: int): RoomShape | undefined;
|
|
61
99
|
/**
|
|
62
|
-
* Helper function to get the stage ID for
|
|
63
|
-
*
|
|
64
|
-
*
|
|
100
|
+
* Helper function to get the stage ID for the current room as it appears in the STB/XML data.
|
|
101
|
+
*
|
|
102
|
+
* The room stage ID will correspond to the first number in the filename of the XML/STB file. For
|
|
103
|
+
* example, a Depths room would have a stage ID of `StageID.DEPTHS` (7).
|
|
104
|
+
*
|
|
105
|
+
* You can optionally provide a room grid index as an argument to get the stage ID for that room
|
|
106
|
+
* instead.
|
|
107
|
+
*
|
|
108
|
+
* (The version of the function without any arguments will not return undefined since the current
|
|
109
|
+
* room is guaranteed to have data.)
|
|
110
|
+
*/
|
|
111
|
+
export declare function getRoomStageID(): StageID;
|
|
112
|
+
/**
|
|
113
|
+
* Helper function to get the stage ID for a room as it appears in the STB/XML data.
|
|
114
|
+
*
|
|
115
|
+
* The room stage ID will correspond to the first number in the filename of the XML/STB file. For
|
|
116
|
+
* example, a Depths room would have a stage ID of `StageID.DEPTHS` (7).
|
|
65
117
|
*
|
|
66
118
|
* @param roomGridIndex Optional. Default is the current room index.
|
|
67
|
-
* @returns The room stage ID. Returns
|
|
119
|
+
* @returns The room stage ID. Returns undefined if the room data was not found.
|
|
120
|
+
*/
|
|
121
|
+
export declare function getRoomStageID(roomGridIndex?: int): StageID | undefined;
|
|
122
|
+
/**
|
|
123
|
+
* Helper function to get the sub-type for the current room as it appears in the STB/XML data.
|
|
124
|
+
*
|
|
125
|
+
* The room sub-type will correspond to different things depending on what XML/STB file it draws
|
|
126
|
+
* from. For example, in the "00.special rooms.stb" file, an Angel Room with a sub-type of 0 will
|
|
127
|
+
* correspond to a normal Angel Room and a sub-type of 1 will correspond to an Angel Room shop from
|
|
128
|
+
* The Stairway.
|
|
129
|
+
*
|
|
130
|
+
* You can optionally provide a room grid index as an argument to get the sub-type for that room
|
|
131
|
+
* instead.
|
|
132
|
+
*
|
|
133
|
+
* (The version of the function without any arguments will not return undefined since the current
|
|
134
|
+
* room is guaranteed to have data.)
|
|
68
135
|
*/
|
|
69
|
-
export declare function
|
|
136
|
+
export declare function getRoomSubType(): int;
|
|
70
137
|
/**
|
|
71
|
-
* Helper function to get the sub-type for a room
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
138
|
+
* Helper function to get the sub-type for a room as it appears in the STB/XML data.
|
|
139
|
+
*
|
|
140
|
+
* The room sub-type will correspond to different things depending on what XML/STB file it draws
|
|
141
|
+
* from. For example, in the "00.special rooms.stb" file, an Angel Room with a sub-type of 0 will
|
|
142
|
+
* correspond to a normal Angel Room and a sub-type of 1 will correspond to an Angel Room shop from
|
|
143
|
+
* The Stairway.
|
|
75
144
|
*
|
|
76
145
|
* @param roomGridIndex Optional. Default is the current room index.
|
|
77
|
-
* @returns The room sub-type. Returns
|
|
146
|
+
* @returns The room sub-type. Returns undefined if the room data was not found.
|
|
78
147
|
*/
|
|
79
|
-
export declare function getRoomSubType(roomGridIndex?: int): int;
|
|
148
|
+
export declare function getRoomSubType(roomGridIndex?: int): int | undefined;
|
|
80
149
|
/**
|
|
81
|
-
* Helper function
|
|
150
|
+
* Helper function to get the type for the current room as it appears in the STB/XML data.
|
|
151
|
+
*
|
|
152
|
+
* You can optionally provide a room grid index as an argument to get the type for that room
|
|
153
|
+
* instead.
|
|
154
|
+
*
|
|
155
|
+
* (The version of the function without any arguments will not return undefined since the current
|
|
156
|
+
* room is guaranteed to have data.)
|
|
157
|
+
*/
|
|
158
|
+
export declare function getRoomType(): RoomType;
|
|
159
|
+
/**
|
|
160
|
+
* Helper function to get the type for a room as it appears in the STB/XML data.
|
|
82
161
|
*
|
|
83
162
|
* @param roomGridIndex Optional. Default is the current room index.
|
|
84
|
-
* @returns The room
|
|
163
|
+
* @returns The room type. Returns undefined if the room data was not found.
|
|
85
164
|
*/
|
|
86
|
-
export declare function getRoomType(roomGridIndex?: int): RoomType |
|
|
165
|
+
export declare function getRoomType(roomGridIndex?: int): RoomType | undefined;
|
|
87
166
|
/**
|
|
88
|
-
* Helper function to get the variant for
|
|
89
|
-
*
|
|
90
|
-
*
|
|
167
|
+
* Helper function to get the variant for the current room as it appears in the STB/XML data.
|
|
168
|
+
*
|
|
169
|
+
* You can think of a room variant as its identifier. For example, to go to Basement room #123, you
|
|
170
|
+
* would use a console command of `goto d.123` while on the Basement.
|
|
171
|
+
*
|
|
172
|
+
* You can optionally provide a room grid index as an argument to get the variant for that room
|
|
173
|
+
* instead.
|
|
174
|
+
*
|
|
175
|
+
* (The version of the function without any arguments will not return undefined since the current
|
|
176
|
+
* room is guaranteed to have data.)
|
|
177
|
+
*/
|
|
178
|
+
export declare function getRoomVariant(): int;
|
|
179
|
+
/**
|
|
180
|
+
* Helper function to get the variant for a room as it appears in the STB/XML data.
|
|
181
|
+
*
|
|
182
|
+
* You can think of a room variant as its identifier. For example, to go to Basement room #123, you
|
|
183
|
+
* would use a console command of `goto d.123` while on the Basement.
|
|
91
184
|
*
|
|
92
185
|
* @param roomGridIndex Optional. Default is the current room index.
|
|
93
|
-
* @returns The room variant. Returns
|
|
186
|
+
* @returns The room variant. Returns undefined if the room data was not found.
|
|
94
187
|
*/
|
|
95
|
-
export declare function getRoomVariant(roomGridIndex?: int): int;
|
|
188
|
+
export declare function getRoomVariant(roomGridIndex?: int): int | undefined;
|
|
96
189
|
/**
|
|
97
190
|
* Note that the room visited count will be inaccurate during the period before the `POST_NEW_ROOM`
|
|
98
191
|
* callback has fired (i.e. when entities are initializing and performing their first update). This
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"roomData.d.ts","sourceRoot":"","sources":["../../../src/functions/roomData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,OAAO,EACR,MAAM,8BAA8B,CAAC;AAMtC;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,aAAa,CAAC,EAAE,GAAG,GAAG,GAAG,CAAC,QAAQ,CAAC,CAgBtE;
|
|
1
|
+
{"version":3,"file":"roomData.d.ts","sourceRoot":"","sources":["../../../src/functions/roomData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,OAAO,EACR,MAAM,8BAA8B,CAAC;AAMtC;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,aAAa,CAAC,EAAE,GAAG,GAAG,GAAG,CAAC,QAAQ,CAAC,CAgBtE;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,IAAI,UAAU,CAAC;AAE1C;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,aAAa,CAAC,EAAE,GAAG,GAAG,UAAU,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AAgB,cAAc,CAAC,aAAa,CAAC,EAAE,GAAG,GAAG,GAAG,GAAG,SAAS,CAAC;AAOrE;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,aAAa,CAAC,EAAE,GAAG,GAAG,GAAG,CAG5D;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,aAAa,EAAE,GAAG,EAAE,QAAQ,EAAE,UAAU,GAAG,IAAI,CAG1E"}
|
|
@@ -10,9 +10,17 @@ local ____doors = require("src.functions.doors")
|
|
|
10
10
|
local doorSlotFlagToDoorSlot = ____doors.doorSlotFlagToDoorSlot
|
|
11
11
|
local ____flag = require("src.functions.flag")
|
|
12
12
|
local hasFlag = ____flag.hasFlag
|
|
13
|
-
--- Helper function to get the room data for the
|
|
13
|
+
--- Helper function to get the room data for the current room.
|
|
14
|
+
--
|
|
15
|
+
-- You can optionally provide a room grid index as an argument to get the data for that room
|
|
16
|
+
-- instead.
|
|
17
|
+
--
|
|
18
|
+
-- (The version of the function without any arguments will not return undefined since the current
|
|
19
|
+
-- room is guaranteed to have data.)
|
|
20
|
+
-- Helper function to get the room data for the current or provided room.
|
|
14
21
|
--
|
|
15
22
|
-- @param roomGridIndex Optional. Default is the current room index.
|
|
23
|
+
-- @returns The room data for the room or undefined if the provided room does not have any data.
|
|
16
24
|
function ____exports.getRoomData(self, roomGridIndex)
|
|
17
25
|
local roomDescriptor = ____exports.getRoomDescriptor(nil, roomGridIndex)
|
|
18
26
|
return roomDescriptor.Data
|
|
@@ -33,12 +41,15 @@ function ____exports.getRoomDescriptorReadOnly(self)
|
|
|
33
41
|
local level = game:GetLevel()
|
|
34
42
|
return level:GetCurrentRoomDesc()
|
|
35
43
|
end
|
|
36
|
-
--- Helper function to get the
|
|
37
|
-
-- as the top-left 1x1 section that the room overlaps with, or the top-right 1x1 section of a
|
|
38
|
-
-- `RoomType.SHAPE_LTL` room.)
|
|
44
|
+
--- Helper function to get the grid index of the current room.
|
|
39
45
|
--
|
|
40
|
-
--
|
|
41
|
-
--
|
|
46
|
+
-- - If the current room is inside of the grid, this function will return the `SafeGridIndex` from
|
|
47
|
+
-- the room descriptor. (The safe grid index is defined as the top-left 1x1 section that the room
|
|
48
|
+
-- overlaps with, or the top-right 1x1 section of a `RoomType.SHAPE_LTL` room.)
|
|
49
|
+
-- - If the current room is outside of the grid, it will return the index from the
|
|
50
|
+
-- `Level.GetCurrentRoomIndex` method (since `SafeGridIndex` is bugged for these cases, as
|
|
51
|
+
-- demonstrated by entering a Genesis room and entering `l
|
|
52
|
+
-- print(Game():GetLevel():GetCurrentRoomDesc().SafeGridIndex)` into the console).
|
|
42
53
|
--
|
|
43
54
|
-- Use this function instead of the `Level.GetCurrentRoomIndex` method directly because the latter
|
|
44
55
|
-- will return the specific 1x1 quadrant that the player entered the room at. For most situations,
|
|
@@ -47,6 +58,11 @@ end
|
|
|
47
58
|
-- Data structures that store data per room should use the room's `ListIndex` instead of
|
|
48
59
|
-- `SafeGridIndex`, since the former is unique across different dimensions.
|
|
49
60
|
function ____exports.getRoomGridIndex(self)
|
|
61
|
+
local level = game:GetLevel()
|
|
62
|
+
local currentRoomIndex = level:GetCurrentRoomIndex()
|
|
63
|
+
if currentRoomIndex < 0 then
|
|
64
|
+
return currentRoomIndex
|
|
65
|
+
end
|
|
50
66
|
local roomDescriptor = ____exports.getRoomDescriptorReadOnly(nil)
|
|
51
67
|
return roomDescriptor.SafeGridIndex
|
|
52
68
|
end
|
|
@@ -78,63 +94,147 @@ function ____exports.getRoomListIndex(self, roomGridIndex)
|
|
|
78
94
|
local roomDescriptor = ____exports.getRoomDescriptor(nil, roomGridIndex)
|
|
79
95
|
return roomDescriptor.ListIndex
|
|
80
96
|
end
|
|
81
|
-
--- Helper function to get the name of the room as it appears in the STB/XML data.
|
|
97
|
+
--- Helper function to get the name of the current room as it appears in the STB/XML data.
|
|
98
|
+
--
|
|
99
|
+
-- You can optionally provide a room grid index as an argument to get the name for that room
|
|
100
|
+
-- instead.
|
|
101
|
+
--
|
|
102
|
+
-- (The version of the function without any arguments will not return undefined since the current
|
|
103
|
+
-- room is guaranteed to have data.)
|
|
104
|
+
-- Helper function to get the name of the room as it appears in the STB/XML data.
|
|
82
105
|
--
|
|
83
106
|
-- @param roomGridIndex Optional. Default is the current room index.
|
|
84
|
-
-- @returns The room name. Returns
|
|
107
|
+
-- @returns The room name. Returns undefined if the room data was not found.
|
|
85
108
|
function ____exports.getRoomName(self, roomGridIndex)
|
|
86
109
|
local roomData = ____exports.getRoomData(nil, roomGridIndex)
|
|
87
|
-
|
|
110
|
+
local ____temp_0
|
|
111
|
+
if roomData == nil then
|
|
112
|
+
____temp_0 = nil
|
|
113
|
+
else
|
|
114
|
+
____temp_0 = roomData.Name
|
|
115
|
+
end
|
|
116
|
+
return ____temp_0
|
|
88
117
|
end
|
|
89
|
-
--- Helper function to get the
|
|
118
|
+
--- Helper function to get the shape of the current room as it appears in the STB/XML data.
|
|
119
|
+
--
|
|
120
|
+
-- You can optionally provide a room grid index as an argument to get the shape for that room
|
|
121
|
+
-- instead.
|
|
122
|
+
--
|
|
123
|
+
-- (The version of the function without any arguments will not return undefined since the current
|
|
124
|
+
-- room is guaranteed to have data.)
|
|
125
|
+
-- Helper function to get the shape of the room as it appears in the STB/XML data.
|
|
90
126
|
--
|
|
91
127
|
-- @param roomGridIndex Optional. Default is the current room index.
|
|
92
|
-
-- @returns The room
|
|
128
|
+
-- @returns The room shape. Returns undefined if the room data was not found.
|
|
93
129
|
function ____exports.getRoomShape(self, roomGridIndex)
|
|
94
130
|
local roomData = ____exports.getRoomData(nil, roomGridIndex)
|
|
95
|
-
local
|
|
131
|
+
local ____temp_1
|
|
96
132
|
if roomData == nil then
|
|
97
|
-
|
|
133
|
+
____temp_1 = nil
|
|
98
134
|
else
|
|
99
|
-
|
|
135
|
+
____temp_1 = roomData.Shape
|
|
100
136
|
end
|
|
101
|
-
return
|
|
137
|
+
return ____temp_1
|
|
102
138
|
end
|
|
103
|
-
--- Helper function to get the stage ID for
|
|
104
|
-
--
|
|
105
|
-
--
|
|
139
|
+
--- Helper function to get the stage ID for the current room as it appears in the STB/XML data.
|
|
140
|
+
--
|
|
141
|
+
-- The room stage ID will correspond to the first number in the filename of the XML/STB file. For
|
|
142
|
+
-- example, a Depths room would have a stage ID of `StageID.DEPTHS` (7).
|
|
143
|
+
--
|
|
144
|
+
-- You can optionally provide a room grid index as an argument to get the stage ID for that room
|
|
145
|
+
-- instead.
|
|
146
|
+
--
|
|
147
|
+
-- (The version of the function without any arguments will not return undefined since the current
|
|
148
|
+
-- room is guaranteed to have data.)
|
|
149
|
+
-- Helper function to get the stage ID for a room as it appears in the STB/XML data.
|
|
150
|
+
--
|
|
151
|
+
-- The room stage ID will correspond to the first number in the filename of the XML/STB file. For
|
|
152
|
+
-- example, a Depths room would have a stage ID of `StageID.DEPTHS` (7).
|
|
106
153
|
--
|
|
107
154
|
-- @param roomGridIndex Optional. Default is the current room index.
|
|
108
|
-
-- @returns The room stage ID. Returns
|
|
155
|
+
-- @returns The room stage ID. Returns undefined if the room data was not found.
|
|
109
156
|
function ____exports.getRoomStageID(self, roomGridIndex)
|
|
110
157
|
local roomData = ____exports.getRoomData(nil, roomGridIndex)
|
|
111
|
-
|
|
158
|
+
local ____temp_2
|
|
159
|
+
if roomData == nil then
|
|
160
|
+
____temp_2 = nil
|
|
161
|
+
else
|
|
162
|
+
____temp_2 = roomData.StageID
|
|
163
|
+
end
|
|
164
|
+
return ____temp_2
|
|
112
165
|
end
|
|
113
|
-
--- Helper function to get the sub-type for
|
|
114
|
-
--
|
|
115
|
-
--
|
|
116
|
-
--
|
|
166
|
+
--- Helper function to get the sub-type for the current room as it appears in the STB/XML data.
|
|
167
|
+
--
|
|
168
|
+
-- The room sub-type will correspond to different things depending on what XML/STB file it draws
|
|
169
|
+
-- from. For example, in the "00.special rooms.stb" file, an Angel Room with a sub-type of 0 will
|
|
170
|
+
-- correspond to a normal Angel Room and a sub-type of 1 will correspond to an Angel Room shop from
|
|
171
|
+
-- The Stairway.
|
|
172
|
+
--
|
|
173
|
+
-- You can optionally provide a room grid index as an argument to get the sub-type for that room
|
|
174
|
+
-- instead.
|
|
175
|
+
--
|
|
176
|
+
-- (The version of the function without any arguments will not return undefined since the current
|
|
177
|
+
-- room is guaranteed to have data.)
|
|
178
|
+
-- Helper function to get the sub-type for a room as it appears in the STB/XML data.
|
|
179
|
+
--
|
|
180
|
+
-- The room sub-type will correspond to different things depending on what XML/STB file it draws
|
|
181
|
+
-- from. For example, in the "00.special rooms.stb" file, an Angel Room with a sub-type of 0 will
|
|
182
|
+
-- correspond to a normal Angel Room and a sub-type of 1 will correspond to an Angel Room shop from
|
|
183
|
+
-- The Stairway.
|
|
117
184
|
--
|
|
118
185
|
-- @param roomGridIndex Optional. Default is the current room index.
|
|
119
|
-
-- @returns The room sub-type. Returns
|
|
186
|
+
-- @returns The room sub-type. Returns undefined if the room data was not found.
|
|
120
187
|
function ____exports.getRoomSubType(self, roomGridIndex)
|
|
121
188
|
local roomData = ____exports.getRoomData(nil, roomGridIndex)
|
|
122
|
-
|
|
189
|
+
local ____temp_3
|
|
190
|
+
if roomData == nil then
|
|
191
|
+
____temp_3 = nil
|
|
192
|
+
else
|
|
193
|
+
____temp_3 = roomData.Subtype
|
|
194
|
+
end
|
|
195
|
+
return ____temp_3
|
|
123
196
|
end
|
|
124
|
-
--- Helper function
|
|
197
|
+
--- Helper function to get the type for the current room as it appears in the STB/XML data.
|
|
125
198
|
--
|
|
199
|
+
-- You can optionally provide a room grid index as an argument to get the type for that room
|
|
200
|
+
-- instead.
|
|
201
|
+
--
|
|
202
|
+
-- (The version of the function without any arguments will not return undefined since the current
|
|
203
|
+
-- room is guaranteed to have data.)
|
|
204
|
+
-- Helper function to get the type for a room as it appears in the STB/XML data.
|
|
205
|
+
-- Helper function for getting the type of the room with the given grid index.
|
|
206
|
+
--
|
|
207
|
+
-- @param roomGridIndex Optional. Default is the current room index.
|
|
208
|
+
-- @returns The room type. Returns undefined if the room data was not found.
|
|
126
209
|
-- @param roomGridIndex Optional. Default is the current room index.
|
|
127
210
|
-- @returns The room data type. Returns -1 if the room data was not found.
|
|
128
211
|
function ____exports.getRoomType(self, roomGridIndex)
|
|
129
212
|
local roomData = ____exports.getRoomData(nil, roomGridIndex)
|
|
130
|
-
|
|
213
|
+
local ____temp_4
|
|
214
|
+
if roomData == nil then
|
|
215
|
+
____temp_4 = nil
|
|
216
|
+
else
|
|
217
|
+
____temp_4 = roomData.Type
|
|
218
|
+
end
|
|
219
|
+
return ____temp_4
|
|
131
220
|
end
|
|
132
|
-
--- Helper function to get the variant for
|
|
133
|
-
--
|
|
134
|
-
--
|
|
221
|
+
--- Helper function to get the variant for the current room as it appears in the STB/XML data.
|
|
222
|
+
--
|
|
223
|
+
-- You can think of a room variant as its identifier. For example, to go to Basement room #123, you
|
|
224
|
+
-- would use a console command of `goto d.123` while on the Basement.
|
|
225
|
+
--
|
|
226
|
+
-- You can optionally provide a room grid index as an argument to get the variant for that room
|
|
227
|
+
-- instead.
|
|
228
|
+
--
|
|
229
|
+
-- (The version of the function without any arguments will not return undefined since the current
|
|
230
|
+
-- room is guaranteed to have data.)
|
|
231
|
+
-- Helper function to get the variant for a room as it appears in the STB/XML data.
|
|
232
|
+
--
|
|
233
|
+
-- You can think of a room variant as its identifier. For example, to go to Basement room #123, you
|
|
234
|
+
-- would use a console command of `goto d.123` while on the Basement.
|
|
135
235
|
--
|
|
136
236
|
-- @param roomGridIndex Optional. Default is the current room index.
|
|
137
|
-
-- @returns The room variant. Returns
|
|
237
|
+
-- @returns The room variant. Returns undefined if the room data was not found.
|
|
138
238
|
function ____exports.getRoomVariant(self, roomGridIndex)
|
|
139
239
|
local roomData = ____exports.getRoomData(nil, roomGridIndex)
|
|
140
240
|
return roomData == nil and -1 or roomData.Variant
|
package/package.json
CHANGED
package/src/functions/array.ts
CHANGED
|
@@ -335,6 +335,10 @@ function addCombinations<T>(
|
|
|
335
335
|
* Helper function to get an array containing the indexes of an array.
|
|
336
336
|
*
|
|
337
337
|
* For example, an array of `["Apple", "Banana"]` would return an array of `[0, 1]`.
|
|
338
|
+
*
|
|
339
|
+
* Note that normally, you would use the `Object.keys` method to get the indexes of an array, but
|
|
340
|
+
* due to implementation details of TypeScriptToLua, this results in an array of 1 through N
|
|
341
|
+
* (instead of an array of 0 through N -1).
|
|
338
342
|
*/
|
|
339
343
|
export function getArrayIndexes<T>(array: T[] | readonly T[]): int[] {
|
|
340
344
|
return eRange(array.length);
|
package/src/functions/enums.ts
CHANGED
|
@@ -154,12 +154,12 @@ export function getRandomEnumValue<T>(
|
|
|
154
154
|
}
|
|
155
155
|
|
|
156
156
|
/** Helper function to validate that a particular value exists inside of an enum. */
|
|
157
|
-
export function isEnumValue(
|
|
157
|
+
export function isEnumValue<T extends Record<string, number | string>>(
|
|
158
158
|
value: number | string,
|
|
159
|
-
transpiledEnum:
|
|
160
|
-
):
|
|
159
|
+
transpiledEnum: T,
|
|
160
|
+
): value is T[keyof T] {
|
|
161
161
|
const enumValues = getEnumValues(transpiledEnum);
|
|
162
|
-
return enumValues.includes(value);
|
|
162
|
+
return enumValues.includes(value as T[keyof T]);
|
|
163
163
|
}
|
|
164
164
|
|
|
165
165
|
/**
|
|
@@ -25,18 +25,17 @@ export function getJSONRoomDoorSlotFlags(
|
|
|
25
25
|
jsonRoom: JSONRoom,
|
|
26
26
|
): BitFlags<DoorSlotFlag> {
|
|
27
27
|
const roomShapeString = jsonRoom.$.shape;
|
|
28
|
-
const
|
|
28
|
+
const roomShape = tonumber(roomShapeString);
|
|
29
29
|
assertDefined(
|
|
30
|
-
|
|
30
|
+
roomShape,
|
|
31
31
|
`Failed to parse the "shape" field of a JSON room: ${roomShapeString}`,
|
|
32
32
|
);
|
|
33
33
|
|
|
34
|
-
if (!isEnumValue(
|
|
34
|
+
if (!isEnumValue(roomShape, RoomShape)) {
|
|
35
35
|
error(
|
|
36
|
-
`Failed to parse the "shape" field of a JSON room since it was an invalid number: ${
|
|
36
|
+
`Failed to parse the "shape" field of a JSON room since it was an invalid number: ${roomShape}`,
|
|
37
37
|
);
|
|
38
38
|
}
|
|
39
|
-
const roomShape = roomShapeNumber as RoomShape;
|
|
40
39
|
|
|
41
40
|
let doorSlotFlags = DoorSlotFlagZero;
|
|
42
41
|
|
|
@@ -31,15 +31,25 @@ export function getRoomAllowedDoors(roomGridIndex?: int): Set<DoorSlot> {
|
|
|
31
31
|
return allowedDoors;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Helper function to get the room data for the current room.
|
|
36
|
+
*
|
|
37
|
+
* You can optionally provide a room grid index as an argument to get the data for that room
|
|
38
|
+
* instead.
|
|
39
|
+
*
|
|
40
|
+
* (The version of the function without any arguments will not return undefined since the current
|
|
41
|
+
* room is guaranteed to have data.)
|
|
42
|
+
*/
|
|
35
43
|
export function getRoomData(): RoomConfig;
|
|
36
|
-
export function getRoomData(roomGridIndex?: int): RoomConfig | undefined;
|
|
37
44
|
|
|
38
45
|
/**
|
|
39
|
-
* Helper function to get the room data for the provided room.
|
|
46
|
+
* Helper function to get the room data for the current or provided room.
|
|
40
47
|
*
|
|
41
48
|
* @param roomGridIndex Optional. Default is the current room index.
|
|
49
|
+
* @returns The room data for the room or undefined if the provided room does not have any data.
|
|
42
50
|
*/
|
|
51
|
+
export function getRoomData(roomGridIndex?: int): RoomConfig | undefined;
|
|
52
|
+
|
|
43
53
|
export function getRoomData(roomGridIndex?: int): RoomConfig | undefined {
|
|
44
54
|
const roomDescriptor = getRoomDescriptor(roomGridIndex);
|
|
45
55
|
return roomDescriptor.Data;
|
|
@@ -70,12 +80,15 @@ export function getRoomDescriptorReadOnly(): Readonly<RoomDescriptor> {
|
|
|
70
80
|
}
|
|
71
81
|
|
|
72
82
|
/**
|
|
73
|
-
* Helper function to get the
|
|
74
|
-
* as the top-left 1x1 section that the room overlaps with, or the top-right 1x1 section of a
|
|
75
|
-
* `RoomType.SHAPE_LTL` room.)
|
|
83
|
+
* Helper function to get the grid index of the current room.
|
|
76
84
|
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
85
|
+
* - If the current room is inside of the grid, this function will return the `SafeGridIndex` from
|
|
86
|
+
* the room descriptor. (The safe grid index is defined as the top-left 1x1 section that the room
|
|
87
|
+
* overlaps with, or the top-right 1x1 section of a `RoomType.SHAPE_LTL` room.)
|
|
88
|
+
* - If the current room is outside of the grid, it will return the index from the
|
|
89
|
+
* `Level.GetCurrentRoomIndex` method (since `SafeGridIndex` is bugged for these cases, as
|
|
90
|
+
* demonstrated by entering a Genesis room and entering `l
|
|
91
|
+
* print(Game():GetLevel():GetCurrentRoomDesc().SafeGridIndex)` into the console).
|
|
79
92
|
*
|
|
80
93
|
* Use this function instead of the `Level.GetCurrentRoomIndex` method directly because the latter
|
|
81
94
|
* will return the specific 1x1 quadrant that the player entered the room at. For most situations,
|
|
@@ -85,6 +98,13 @@ export function getRoomDescriptorReadOnly(): Readonly<RoomDescriptor> {
|
|
|
85
98
|
* `SafeGridIndex`, since the former is unique across different dimensions.
|
|
86
99
|
*/
|
|
87
100
|
export function getRoomGridIndex(): int {
|
|
101
|
+
const level = game.GetLevel();
|
|
102
|
+
const currentRoomIndex = level.GetCurrentRoomIndex();
|
|
103
|
+
|
|
104
|
+
if (currentRoomIndex < 0) {
|
|
105
|
+
return currentRoomIndex;
|
|
106
|
+
}
|
|
107
|
+
|
|
88
108
|
const roomDescriptor = getRoomDescriptorReadOnly();
|
|
89
109
|
return roomDescriptor.SafeGridIndex;
|
|
90
110
|
}
|
|
@@ -104,74 +124,173 @@ export function getRoomListIndex(roomGridIndex?: int): int {
|
|
|
104
124
|
return roomDescriptor.ListIndex;
|
|
105
125
|
}
|
|
106
126
|
|
|
127
|
+
/**
|
|
128
|
+
* Helper function to get the name of the current room as it appears in the STB/XML data.
|
|
129
|
+
*
|
|
130
|
+
* You can optionally provide a room grid index as an argument to get the name for that room
|
|
131
|
+
* instead.
|
|
132
|
+
*
|
|
133
|
+
* (The version of the function without any arguments will not return undefined since the current
|
|
134
|
+
* room is guaranteed to have data.)
|
|
135
|
+
*/
|
|
136
|
+
export function getRoomName(): string;
|
|
137
|
+
|
|
107
138
|
/**
|
|
108
139
|
* Helper function to get the name of the room as it appears in the STB/XML data.
|
|
109
140
|
*
|
|
110
141
|
* @param roomGridIndex Optional. Default is the current room index.
|
|
111
|
-
* @returns The room name. Returns
|
|
142
|
+
* @returns The room name. Returns undefined if the room data was not found.
|
|
112
143
|
*/
|
|
113
|
-
export function getRoomName(roomGridIndex?: int): string
|
|
144
|
+
export function getRoomName(roomGridIndex?: int): string | undefined;
|
|
145
|
+
|
|
146
|
+
export function getRoomName(roomGridIndex?: int): string | undefined {
|
|
114
147
|
const roomData = getRoomData(roomGridIndex);
|
|
115
|
-
return roomData === undefined ?
|
|
148
|
+
return roomData === undefined ? undefined : roomData.Name;
|
|
116
149
|
}
|
|
117
150
|
|
|
118
151
|
/**
|
|
119
|
-
* Helper function to get the
|
|
152
|
+
* Helper function to get the shape of the current room as it appears in the STB/XML data.
|
|
153
|
+
*
|
|
154
|
+
* You can optionally provide a room grid index as an argument to get the shape for that room
|
|
155
|
+
* instead.
|
|
156
|
+
*
|
|
157
|
+
* (The version of the function without any arguments will not return undefined since the current
|
|
158
|
+
* room is guaranteed to have data.)
|
|
159
|
+
*/
|
|
160
|
+
export function getRoomShape(): RoomShape;
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Helper function to get the shape of the room as it appears in the STB/XML data.
|
|
120
164
|
*
|
|
121
165
|
* @param roomGridIndex Optional. Default is the current room index.
|
|
122
|
-
* @returns The room
|
|
166
|
+
* @returns The room shape. Returns undefined if the room data was not found.
|
|
123
167
|
*/
|
|
168
|
+
export function getRoomShape(roomGridIndex?: int): RoomShape | undefined;
|
|
169
|
+
|
|
124
170
|
export function getRoomShape(roomGridIndex?: int): RoomShape | undefined {
|
|
125
171
|
const roomData = getRoomData(roomGridIndex);
|
|
126
172
|
return roomData === undefined ? undefined : roomData.Shape;
|
|
127
173
|
}
|
|
128
174
|
|
|
129
175
|
/**
|
|
130
|
-
* Helper function to get the stage ID for
|
|
131
|
-
*
|
|
132
|
-
*
|
|
176
|
+
* Helper function to get the stage ID for the current room as it appears in the STB/XML data.
|
|
177
|
+
*
|
|
178
|
+
* The room stage ID will correspond to the first number in the filename of the XML/STB file. For
|
|
179
|
+
* example, a Depths room would have a stage ID of `StageID.DEPTHS` (7).
|
|
180
|
+
*
|
|
181
|
+
* You can optionally provide a room grid index as an argument to get the stage ID for that room
|
|
182
|
+
* instead.
|
|
183
|
+
*
|
|
184
|
+
* (The version of the function without any arguments will not return undefined since the current
|
|
185
|
+
* room is guaranteed to have data.)
|
|
186
|
+
*/
|
|
187
|
+
export function getRoomStageID(): StageID;
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Helper function to get the stage ID for a room as it appears in the STB/XML data.
|
|
191
|
+
*
|
|
192
|
+
* The room stage ID will correspond to the first number in the filename of the XML/STB file. For
|
|
193
|
+
* example, a Depths room would have a stage ID of `StageID.DEPTHS` (7).
|
|
133
194
|
*
|
|
134
195
|
* @param roomGridIndex Optional. Default is the current room index.
|
|
135
|
-
* @returns The room stage ID. Returns
|
|
196
|
+
* @returns The room stage ID. Returns undefined if the room data was not found.
|
|
136
197
|
*/
|
|
137
|
-
export function getRoomStageID(roomGridIndex?: int): StageID |
|
|
198
|
+
export function getRoomStageID(roomGridIndex?: int): StageID | undefined;
|
|
199
|
+
|
|
200
|
+
export function getRoomStageID(roomGridIndex?: int): StageID | undefined {
|
|
138
201
|
const roomData = getRoomData(roomGridIndex);
|
|
139
|
-
return roomData === undefined ?
|
|
202
|
+
return roomData === undefined ? undefined : roomData.StageID;
|
|
140
203
|
}
|
|
141
204
|
|
|
142
205
|
/**
|
|
143
|
-
* Helper function to get the sub-type for
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
206
|
+
* Helper function to get the sub-type for the current room as it appears in the STB/XML data.
|
|
207
|
+
*
|
|
208
|
+
* The room sub-type will correspond to different things depending on what XML/STB file it draws
|
|
209
|
+
* from. For example, in the "00.special rooms.stb" file, an Angel Room with a sub-type of 0 will
|
|
210
|
+
* correspond to a normal Angel Room and a sub-type of 1 will correspond to an Angel Room shop from
|
|
211
|
+
* The Stairway.
|
|
212
|
+
*
|
|
213
|
+
* You can optionally provide a room grid index as an argument to get the sub-type for that room
|
|
214
|
+
* instead.
|
|
215
|
+
*
|
|
216
|
+
* (The version of the function without any arguments will not return undefined since the current
|
|
217
|
+
* room is guaranteed to have data.)
|
|
218
|
+
*/
|
|
219
|
+
export function getRoomSubType(): int;
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Helper function to get the sub-type for a room as it appears in the STB/XML data.
|
|
223
|
+
*
|
|
224
|
+
* The room sub-type will correspond to different things depending on what XML/STB file it draws
|
|
225
|
+
* from. For example, in the "00.special rooms.stb" file, an Angel Room with a sub-type of 0 will
|
|
226
|
+
* correspond to a normal Angel Room and a sub-type of 1 will correspond to an Angel Room shop from
|
|
227
|
+
* The Stairway.
|
|
147
228
|
*
|
|
148
229
|
* @param roomGridIndex Optional. Default is the current room index.
|
|
149
|
-
* @returns The room sub-type. Returns
|
|
230
|
+
* @returns The room sub-type. Returns undefined if the room data was not found.
|
|
150
231
|
*/
|
|
151
|
-
export function getRoomSubType(roomGridIndex?: int): int
|
|
232
|
+
export function getRoomSubType(roomGridIndex?: int): int | undefined;
|
|
233
|
+
|
|
234
|
+
export function getRoomSubType(roomGridIndex?: int): int | undefined {
|
|
152
235
|
const roomData = getRoomData(roomGridIndex);
|
|
153
|
-
return roomData === undefined ?
|
|
236
|
+
return roomData === undefined ? undefined : roomData.Subtype;
|
|
154
237
|
}
|
|
155
238
|
|
|
239
|
+
/**
|
|
240
|
+
* Helper function to get the type for the current room as it appears in the STB/XML data.
|
|
241
|
+
*
|
|
242
|
+
* You can optionally provide a room grid index as an argument to get the type for that room
|
|
243
|
+
* instead.
|
|
244
|
+
*
|
|
245
|
+
* (The version of the function without any arguments will not return undefined since the current
|
|
246
|
+
* room is guaranteed to have data.)
|
|
247
|
+
*/
|
|
248
|
+
export function getRoomType(): RoomType;
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Helper function to get the type for a room as it appears in the STB/XML data.
|
|
252
|
+
*
|
|
253
|
+
* @param roomGridIndex Optional. Default is the current room index.
|
|
254
|
+
* @returns The room type. Returns undefined if the room data was not found.
|
|
255
|
+
*/
|
|
256
|
+
export function getRoomType(roomGridIndex?: int): RoomType | undefined;
|
|
257
|
+
|
|
156
258
|
/**
|
|
157
259
|
* Helper function for getting the type of the room with the given grid index.
|
|
158
260
|
*
|
|
159
261
|
* @param roomGridIndex Optional. Default is the current room index.
|
|
160
262
|
* @returns The room data type. Returns -1 if the room data was not found.
|
|
161
263
|
*/
|
|
162
|
-
export function getRoomType(roomGridIndex?: int): RoomType |
|
|
264
|
+
export function getRoomType(roomGridIndex?: int): RoomType | undefined {
|
|
163
265
|
const roomData = getRoomData(roomGridIndex);
|
|
164
|
-
return roomData === undefined ?
|
|
266
|
+
return roomData === undefined ? undefined : roomData.Type;
|
|
165
267
|
}
|
|
166
268
|
|
|
167
269
|
/**
|
|
168
|
-
* Helper function to get the variant for
|
|
169
|
-
*
|
|
170
|
-
*
|
|
270
|
+
* Helper function to get the variant for the current room as it appears in the STB/XML data.
|
|
271
|
+
*
|
|
272
|
+
* You can think of a room variant as its identifier. For example, to go to Basement room #123, you
|
|
273
|
+
* would use a console command of `goto d.123` while on the Basement.
|
|
274
|
+
*
|
|
275
|
+
* You can optionally provide a room grid index as an argument to get the variant for that room
|
|
276
|
+
* instead.
|
|
277
|
+
*
|
|
278
|
+
* (The version of the function without any arguments will not return undefined since the current
|
|
279
|
+
* room is guaranteed to have data.)
|
|
280
|
+
*/
|
|
281
|
+
export function getRoomVariant(): int;
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Helper function to get the variant for a room as it appears in the STB/XML data.
|
|
285
|
+
*
|
|
286
|
+
* You can think of a room variant as its identifier. For example, to go to Basement room #123, you
|
|
287
|
+
* would use a console command of `goto d.123` while on the Basement.
|
|
171
288
|
*
|
|
172
289
|
* @param roomGridIndex Optional. Default is the current room index.
|
|
173
|
-
* @returns The room variant. Returns
|
|
290
|
+
* @returns The room variant. Returns undefined if the room data was not found.
|
|
174
291
|
*/
|
|
292
|
+
export function getRoomVariant(roomGridIndex?: int): int | undefined;
|
|
293
|
+
|
|
175
294
|
export function getRoomVariant(roomGridIndex?: int): int {
|
|
176
295
|
const roomData = getRoomData(roomGridIndex);
|
|
177
296
|
return roomData === undefined ? -1 : roomData.Variant;
|