-- This sets the environment in which the file is interpreted and defines additional functions available within the map definition
-- Some variables (unique, border, no_tunnels, roomcheck, prefer_location, onplace, map_data) assigned in the definition are automatically passed through to the map object (for rooms)
function_M:getLoader(t)
return{
level=self.level,
zone=self.zone,
data=self.data,
Map=require("engine.Map"),
grid_class=self.zone.grid_class,
trap_class=self.zone.trap_class,
npc_class=self.zone.npc_class,
object_class=self.zone.object_class,
specialList=function(kind,files,add_zone_lists)-- specify entity lists to use (add_zone_lists == include current list)
mapData=function(params)table.merge(self,params)end,-- add data to the map definition (for use with map generators)
roomCheck=function(testfn)self.roomcheck=testfnend,-- for rooms, set a function(room, zone, level, map) to test if the room should be added (true) to the map
onPlace=function(onplace)self.onplace=onplaceend,-- for rooms, set a function(room, zone, level, map, placement_data) to be called after the room has been added to the map(see RoomsLoader:roomAlloc)
-- load a map definition from a tmx file into the map
-- @param file the file to load the definition from
-- @returns true if successful
-- Some lua functions are available within the map file (see Static:getLoader)
-- Some properties set are passed through to the map object returned by the generator function:
-- map_data: a table of properties to merge into the map (performed first)
-- (for rooms):
-- unique: a tag (true is converted to the room name) marking the room as unique, two rooms with the same unique tag will not be generated on the same map
-- border: the width (in grids, default 0) of clear map area around the room in which no other rooms are allowed to be placed
-- prefer_location: a function(map) returning the preferred map coordinates to place a room
-- no_tunnels: set true to prevent automatically connecting tunnels to the room (handled by the map generator)
-- roomcheck: a function(room, zone, level, map) checked (if defined) before the room is added to the map (return true to add)
-- onplace: a function(room, zone, level, map, placement_data) called after the room has been added to the map (see RoomsLoader:roomPlace)