Map

The map class stores all the information relating to a single map. This includes all game objects on the map and all the tile data for the map.
Return to Index
new ( string map_name )
new ( string map_name , integer width , integer height )
__gc ( )
__eq ( am.map rhs ) -> ( boolean )
name ( ) -> ( string )
name ( string map_name ) -> ( am.map )
full_name ( ) -> ( string )
full_name ( string full_name ) -> ( am.map )
tile ( integer x , integer y ) -> ( am.tile )
tile_instance ( integer x , integer y ) -> ( TileInstance )
tiles ( table tiles ) -> ( am.map )
tiles ( table tiles , integer width , integer height ) -> ( am.map )
map_size ( ) -> ( integer , integer )
map_size ( integer width , integer height ) -> ( am.map )
add_game_object ( am.game_object game_object ) -> ( boolean )
remove_game_object ( am.game_object The ) -> ( boolean )
has_game_object ( am.game_object game_object ) -> ( boolean )
is_valid_location ( am.game_object game_object , number position_x , number position_y ) -> ( boolean )
is_valid_grid_location ( am.game_object game_object , integer grid_x , integer grid_y ) -> ( boolean )
add_map_region ( am.map_region region ) -> ( boolean )
remove_map_region ( am.map_region region ) -> ( boolean )
has_map_region ( am.map_region region ) -> ( boolean )
map_regions ( ) -> ( table )
new ( string map_name )
Creates a new map instance. The map size will have to be set before any tile data can be set.
Parameters:
string map_name : The name of the map.
new ( string map_name , integer width , integer height )
Creates a new map instance.
Parameters:
string map_name : The name of the map.
integer width : The width of the map in tiles.
integer height : The height of the map in tiles.
__gc ( )
Releases the reference counter on this map.
__eq ( am.map rhs ) -> ( boolean )
Compares this map against another map object.
Parameters:
am.map rhs : The other map to compare with.
Returns:
boolean : True if they are the same map object.
name ( ) -> ( string )
Returns the map name which is also used as the maps id.
Returns:
string : The map name.
name ( string map_name ) -> ( am.map )
Sets the map name, which is used as the map id. TODO Currently this doesn't update the map of Maps, so it'll still be referred to by it's previous name if it's been registered with a Game instance.
Parameters:
string map_name : The new map name.
Returns:
am.map : This
full_name ( ) -> ( string )
Returns the full name of the map. This is used when displaying the map to the user.
Returns:
string : The map's full name.
full_name ( string full_name ) -> ( am.map )
Sets the map's full name. This is used when displaying the map to the user.
Parameters:
string full_name : The map's new full name.
Returns:
am.map : This
tile ( integer x , integer y ) -> ( am.tile )
Returns the tile object on the tile instance at the given grid location.
Parameters:
integer x : The x position of the tile.
integer y : The y position of the tile.
Returns:
am.tile : The found file, nil if out of bounds.
tile_instance ( integer x , integer y ) -> ( TileInstance )
Returns the tile instance at the given grid location.
Parameters:
integer x : The x position of the tile instance.
integer y : The y position of the tile instance.
Returns:
TileInstance : The found tile instance, nil if out of bounds.
tiles ( table tiles ) -> ( am.map )
Sets the tiles for this map from a table of tile names and frames. The length of the table must equal the total number of tiles, which is map_width * map_height
 am.engine.using_tile_set("nature")
 map = am.map.new("testMap", 3, 2)
 map:tiles({
     "dirt", "dirt:1", "castle/dirt:1",
     "grass:2", "water", "castle/water"
 })
Each tile name is in the following form.
 [tileSetName/]tile_name[:frameNumber]
The tileSetName is optional and allows you to specify the tile set which the tile is from. If none is provided then the top level tile set or any tile sets specified with the Engine.using_tile_set
Parameters:
table tiles : A table of tiles to set onto the map.
Returns:
am.map : This
tiles ( table tiles , integer width , integer height ) -> ( am.map )
Sets the tiles for this map from a table of tile names and frames. This function changes the size of the map to fit the parameters given.
 am.engine.using_tile_set("nature")
 map = am.map.new("testMap")
 map:tiles({
     "dirt", "dirt:1", "castle/dirt:1",
     "grass:2", "water", "castle/water"
 }, 3, 2)
Each tile name is in the following form.
 [tileSetName/]tile_name[:frameNumber]
The tileSetName is optional and allows you to specify the tile set which the tile is from. If none is provided then the top level tile set or any tile sets specified with the Engine.using_tile_set
Parameters:
table tiles : An table of tiles to set onto the map.
integer width : The width of the table given.
integer height : The height of the table given.
Returns:
am.map : This
map_size ( ) -> ( integer , integer )
Returns the size of the map.
Returns:
integer : The width of the map.
integer : The height of the map.
map_size ( integer width , integer height ) -> ( am.map )
Sets the size of the map. This destorys the old map data.
Parameters:
integer width : The new width.
integer height : The new height.
Returns:
am.map : This
add_game_object ( am.game_object game_object ) -> ( boolean )
Adds a game object to this map.
Parameters:
am.game_object game_object : The game object to add to the map.
Returns:
boolean : True if the game object was successfully added to this map.
remove_game_object ( am.game_object The ) -> ( boolean )
Removes a game object from the map.
Parameters:
am.game_object The : game object to remove from the map.
Returns:
boolean : True if the game object was successfully removed from the map.
has_game_object ( am.game_object game_object ) -> ( boolean )
Returns true if the given game object is on this map.
Parameters:
am.game_object game_object : The game object to look up.
Returns:
boolean : True if the given game object was found.
is_valid_location ( am.game_object game_object , number position_x , number position_y ) -> ( boolean )
Used to tell if the given game object can be placed at the given location. This uses the game objects passibility table to tell if it can be at the given location.
Parameters:
am.game_object game_object : The game object to test with.
number position_x : The x position to test at.
number position_y : The y position to test at.
Returns:
boolean : True if the given position is valid for the given game object.
is_valid_grid_location ( am.game_object game_object , integer grid_x , integer grid_y ) -> ( boolean )
Used to tell if the given game object can be placed at the given grid location. This uses the game objects passibility table to tell if it can be at the given grid location.
Parameters:
am.game_object game_object : The game object to test with.
integer grid_x : The x grid position to test at.
integer grid_y : The y grid position to test at.
Returns:
boolean : True if the given position is valid for the given game object.
add_map_region ( am.map_region region ) -> ( boolean )
Adds a map region to this map.
Parameters:
am.map_region region : The map region to add.
Returns:
boolean : True if the map region was successfully added to this map.
remove_map_region ( am.map_region region ) -> ( boolean )
Removes a map region from this map.
Parameters:
am.map_region region : The map region to remove.
Returns:
boolean : True if the map region was successfully removed from this map.
has_map_region ( am.map_region region ) -> ( boolean )
Returns true if the given map region is on this map.
Parameters:
am.map_region region : The map region to check.
Returns:
boolean : True if the map region was found on this map.
map_regions ( ) -> ( table )
Returns an array table of all the map regions in the map.
Returns:
table : An array of all the map regions.