Skip to main content

JSON Room

Functions

getJSONRoomDoorSlotFlags

getJSONRoomDoorSlotFlags(jsonRoom): BitFlags<DoorSlotFlag>

Helper function to calculate what the resulting BitFlags<DoorSlotFlag> value would be for a given JSON room.

(A JSON room is an XML file converted to JSON so that it can be directly imported into your mod.)

Parameters

NameType
jsonRoomJSONRoom

Returns

BitFlags<DoorSlotFlag>

Defined in

packages/isaacscript-common/src/functions/jsonRoom.ts:24


getJSONRoomOfVariant

getJSONRoomOfVariant(jsonRooms, variant): JSONRoom | undefined

Helper function to find a specific room from an array of JSON rooms.

(A JSON room is an XML file converted to JSON so that it can be directly imported into your mod.)

Parameters

NameTypeDescription
jsonRoomsreadonly JSONRoom[]The array of rooms to search through.
variantintThe room variant to select. (The room variant can be thought of as the ID of the room.)

Returns

JSONRoom | undefined

Defined in

packages/isaacscript-common/src/functions/jsonRoom.ts:90


getJSONRoomsOfSubType

getJSONRoomsOfSubType(jsonRooms, subType): readonly JSONRoom[]

Helper function to find all of the JSON rooms that match the sub-type provided.

(A JSON room is an XML file converted to JSON so that it can be directly imported into your mod.)

Parameters

NameTypeDescription
jsonRoomsreadonly JSONRoom[]The array of rooms to search through.
subTypeintThe sub-type to match.

Returns

readonly JSONRoom[]

Defined in

packages/isaacscript-common/src/functions/jsonRoom.ts:129


getRandomJSONEntity

getRandomJSONEntity(jsonEntities, seedOrRNG, verbose?): JSONEntity

Helper function to get a random JSON entity from an array of JSON entities.

(A JSON entity is an entity inside of a JSON room. A JSON room is an XML file converted to JSON so that it can be directly imported into your mod.)

Note that this function does not simply choose a random element in the provided array; it will properly account for each room weight using the algorithm from: https://stackoverflow.com/questions/1761626/weighted-random-numbers

If you want an unseeded entity, you must explicitly pass undefined to the seedOrRNG parameter.

Parameters

NameTypeDefault valueDescription
jsonEntitiesreadonly JSONEntity[]undefinedThe array of entities to randomly choose between.
seedOrRNGundefined | RNG | SeedundefinedThe Seed or RNG object to use. If an RNG object is provided, the RNG.Next method will be called. If undefined is provided, it will default to a random seed.
verbosebooleanfalseOptional. If specified, will write entries to the "log.txt" file that describe what the function is doing. Default is false.

Returns

JSONEntity

Defined in

packages/isaacscript-common/src/functions/jsonRoom.ts:166


getRandomJSONRoom

getRandomJSONRoom(jsonRooms, seedOrRNG, verbose?): JSONRoom

Helper function to get a random JSON room from an array of JSON rooms.

(A JSON room is an XML file converted to JSON so that it can be directly imported into your mod.)

Note that this function does not simply choose a random element in the provided array; it will properly account for each room weight using the algorithm from: https://stackoverflow.com/questions/1761626/weighted-random-numbers

If you want an unseeded room, you must explicitly pass undefined to the seedOrRNG parameter.

Parameters

NameTypeDefault valueDescription
jsonRoomsreadonly JSONRoom[]undefinedThe array of rooms to randomly choose between.
seedOrRNGundefined | RNG | SeedundefinedThe Seed or RNG object to use. If an RNG object is provided, the RNG.Next method will be called. If undefined is provided, it will default to a random seed.
verbosebooleanfalseOptional. If specified, will write entries to the "log.txt" file that describe what the function is doing. Default is false.

Returns

JSONRoom

Defined in

packages/isaacscript-common/src/functions/jsonRoom.ts:211