Legacy:Functions/Map
From Spherical
								
												
				Contents
Map and map engine control
- MapEngine(map_filename, fps): Start the map engine at map_filename at speed fps.
 - GetCurrentMap(): Get the filename of the loaded map.
 - ChangeMap(map_filename): Change the current map of the map engine.
 - IsMapEngineRunning(): Check if the map engine is running or not.
 - UpdateMapEngine(): Update state of map entities, animations and events in map engine.
 - ExitMapEngine(): Flag the map engine to exit on the next update.
 
- RenderMap(): Draw all map layers and persons to the back buffer.
 - GetMapEngineFrameRate(): Get the frames per second the map engine is running at.
 - SetMapEngineFrameRate(fps): Change map engine frame rate.
 - SetColorMask(color, frames): Draws color over the map engine for frames duration.
 
Map object
- Sphere Map object: Holds map data.
 
- GetMapEngine(): Obtain the current Map object.
 - Map.save(filename): Save a Map object to filename.
 - Map.layerAppend(layer_width, layer_height, tile_index): Adds a new layer to the Map object.
 
Map scripts
- SetRenderScript(script): Set script to run after each time the map is drawn.
 - SetUpdateScript(script): Set script to run after each map engine update.
 
- CallMapScript(map_event): Call map script associated with the current map.
 - CallDefaultMapScript(map_event): Call map script set by SetDefaultMapScript().
 -  SetDefaultMapScript(map_event, script): Set map engine to run script when map_event occurs for any map.
-  Map event constants:
- SCRIPT_ON_ENTER_MAP
 - SCRIPT_ON_LEAVE_MAP
 - SCRIPT_ON_LEAVE_MAP_NORTH
 - SCRIPT_ON_LEAVE_MAP_EAST
 - SCRIPT_ON_LEAVE_MAP_SOUTH
 - SCRIPT_ON_LEAVE_MAP_WEST
 
 
 -  Map event constants:
 
- SetDelayScript(frames, script): Run script after frames delay.
 
Map Elements
Zones
- AreZonesAt(x, y, layer): Check if there are any zones at (x, y) on layer.
 - ExecuteZones(x, y, layer): Run all scripts for zones that (x, y) on layer is in.
 - GetNumZones(): Get the number of zones on the current map.
 
For each zone
- GetCurrentZone(): Get the current zone index in a zone script.
 - ExecuteZoneScript(zone): Execute the script of zone.
 
Zone position
- GetZoneX(zone): Get the X coordinate of zone on the map.
 - GetZoneY(zone): Get the Y coordinate of zone on the map.
 - GetZoneWidth(zone): Get the pixel width of zone.
 - GetZoneHeight(zone): Get the pixel height of zone.
 
- GetZoneLayer(zone): Get the map layer index of zone.
 - SetZoneLayer(zone, layer): Sets the map layer of zone to layer.
 
Triggers
- IsTriggerAt(x, y, layer): Check if there is a trigger at pixel coords (x, y) on layer.
 - ExecuteTrigger(x, y, layer): Activate the trigger at (x, y) on layer if one exists.
 
Layers
- GetNumLayers(): Get number of layers in the current map.
 
- GetLayerName(layer): Get the name of layer.
 
- GetLayerWidth(layer): Get width of layer in tiles.
 - GetLayerHeight(layer): Get height of layer in tiles.
 - SetLayerWidth(layer, width): Set width of layer in tiles.
 - SetLayerHeight(layer, height): Set height of layer in tiles.
 - GetLayerAngle(layer): Get layer angle in radians.
 - SetLayerAngle(layer, angle): Set layer rotation to angle radians.
 
- GetLayerMask(layer): Get Color mask of layer.
 - SetLayerMask(layer, color_mask): Mask the layer with color_mask.
 
- IsLayerReflective(layer): Find if layer shows person entity reflections.
 - SetLayerReflective(layer, reflect): Set reflectivity of layer.
 - IsLayerVisible(layer): Find if layer is visible.
 - SetLayerVisible(layer, visible): Set visibility of layer.
 
- SetLayerScaleFactorX(layer, factor): Set width scaling of layer to factor.
 - SetLayerScaleFactorY(layer, factor): Set height scaling of layer to factor.
 
- SetLayerRenderer(layer, script): Run script after layer has been rendered.
 
Tiles
- GetNumTiles(): Get the number of tiles in the current map tileset.
 - GetTileWidth(): Get the image width of tiles in the current map tileset.
 - GetTileHeight(): Get the image height of tiles in the current map tileset.
 
- GetTile(tile_x, tile_y, layer): Get the tileset index of the tile at the given map position.
 - SetTile(tile_x, tile_y, layer, tile): Plot a tile at the given map location.
 - ReplaceTilesOnLayer(layer, old_tile, new_tile): Substitute all old_tile with new_tile on layer.
 
- GetTileName(tile): Get the name of tile.
 - GetTileImage(tile): Get the Image of tile in the current map tileset.
 - SetTileImage(tile, image): Change the Image of tile.
 - SetTileSurface(tile, surface): Change the Surface of tile.
 
Tile animations
- GetNextAnimatedTile(tile): Get next tile index of animation from tile.
 - SetNextAnimatedTile(tile, next): Set next tile in a tile animation sequence.
 
- GetTileDelay(tile): Get frame delay of animated tile.
 - SetTileDelay(tile, delay): Set a frame delay for this tile animation frame.