Room functions
define_room_template
function define_room_template(room_template: string, type: ROOM_TEMPLATE_TYPE): integerroom_template:stringtype:ROOM_TEMPLATE_TYPE
Returns integer
Define a new room template to use with set_room_template
get_room_index
function get_room_index(x: number, y: number): integer, integerx:numbery:number
Returns integer, integer
Transform a position to a room index to be used in get_room_template and PostRoomGenerationContext.set_room_template
get_room_pos
function get_room_pos(x: integer, y: integer): number, numberx:integery:integer
Returns number, number
Transform a room index into the top left corner position in the room
get_room_template
function get_room_template(x: integer, y: integer, layer: LAYER): integer?x:integery:integerlayer:LAYER
Returns integer? (may be nil)
Get the room template given a certain index, returns nil if coordinates are out of bounds
get_room_template_name
function get_room_template_name(room_template: integer): stringroom_template:integer
Returns string
For debugging only, get the name of a room template, returns 'invalid' if room template is not defined
is_machine_room_origin
function is_machine_room_origin(x: integer, y: integer): booleanx:integery:integer
Returns boolean
Get whether a room is the origin of a machine room
is_room_flipped
function is_room_flipped(x: integer, y: integer): booleanx:integery:integer
Returns boolean
Get whether a room is flipped at the given index, returns false if coordinates are out of bounds
set_room_template_size
function set_room_template_size(room_template: integer, width: integer, height: integer): booleanroom_template:integerwidth:integerheight:integer
Returns boolean
Set the size of room template in tiles, the template must be of type ROOM_TEMPLATE_TYPE.MACHINE_ROOM.
spawn_roomowner
documented onlysource
-- spawns waddler selling pets-- all the aggro etc mechanics from a normal shop still applylocal x, y, l = get_position(get_player(1).uid)local owner = spawn_roomowner(ENT_TYPE.MONS_STORAGEGUY, x+1, y, l, ROOM_TEMPLATE.SHOP)add_item_to_shop(spawn_on_floor(ENT_TYPE.MONS_PET_DOG, x-1, y, l), owner)add_item_to_shop(spawn_on_floor(ENT_TYPE.MONS_PET_CAT, x-2, y, l), owner)add_item_to_shop(spawn_on_floor(ENT_TYPE.MONS_PET_HAMSTER, x-3, y, l), owner)
-- use in a tile code to add shops to custom levels-- this may spawn some shop related decorations toodefine_tile_code("pet_shop_boys")set_pre_tile_code_callback(function(x, y, layer) local owner = spawn_roomowner(ENT_TYPE.MONS_YANG, x, y, layer, ROOM_TEMPLATE.SHOP) -- another dude for the meme, this has nothing to do with the shop spawn_on_floor(ENT_TYPE.MONS_BODYGUARD, x+1, y, layer) add_item_to_shop(spawn_on_floor(ENT_TYPE.MONS_PET_HAMSTER, x+2, y, layer), owner) return trueend, "pet_shop_boys")function spawn_roomowner(owner_type: ENT_TYPE, x: number, y: number, layer: LAYER, room_template?: ROOM_TEMPLATE): integerowner_type:ENT_TYPEx:numbery:numberlayer:LAYERroom_template?:ROOM_TEMPLATEoptional
Returns integer
Spawn a RoomOwner (or a few other like CavemanShopkeeper) in the coordinates and make them own the room, optionally changing the room template. Returns the RoomOwner uid.