WorldMap class, available in: Global contextEnvironment details for "Blocks" and "Heightfield" world type. The most important concept is a "Map", which is the array of Map elements.This class has 7 members:
sdleiF
int xsize ROMap x size
int ysize ROMap y size
snoitcnuF
function getAsString(string alternate_script, untyped special_arguments)returns stringString representation of the world surfaceThis function returns the universal polygonal description of the world surface (regardless of the world type). The data is provided in the following simple textual format with each line describing one vertex (3 floating point values) or one face (3 or 4 vertex indices - faces can be triangles or quads), which is a subset of the Wavefront .obj file format:

v first vertex coordinates
v second vertex coordinates
v ...etc
f first face indices
f second face indices
f ...etc

For example, the default flat world consists of 4 vertices and 1 quad face:

v 0 0 0
v 20.0 0 0
v 20.0 20.0 0
v 0 20.0 0
f 1 2 3 4

Internaly, the data returned by this function is generated by the 'scripts/worldmap-faces.script' file, so you can refer to its source if needed.
The first argument to getAsString() (if not null or empty string) selects an alternate userscript to be used instead of the default 'worldmap-faces.script', allowing for extension and customization.
Examples:
WorldMap.getAsString(null,null) //use the default script
WorldMap.getAsString("myscript","myarg") //calls "WorldMap_myscript", passing "myarg" to its main_args() function.
function getHeight(float x, float y)returns floatHeightHeight at any 2d coordinate
function getMap(int x, int y)returns objectget map element objectRetrieve the map element object for a given grid coordinates (x,y), where 0<=x<xsize, 0<=y<ysize.

The obtained value type depends on the current world type.
- Blocks world objects provide 'z' and 'type' values (z is the block height, type is 0=flat block, 1=west-east slope, 2=north-south slope).
- Heightfield world objects provide just the 'z' value (which is the grid point height).

See the 'scripts/worldmap_faces.script' file for a practical example on how to obtain the world geometry data using WorldMap.getMap().

Quirks: Internally, maps have more elements than could be deduced from the user-supplied World.wrldmap, as additional rows of elements are added to provide smooth transitions to flat surroundings, which is reflected in 'xsize' and 'ysize'.
WorldMap.getMap() arguments refer to this internal representation, so the object corresponding to the first map element is not (0,0), but (1,1) for Heightfield or (2,2) for Blocks world. Not starting from (0,0) can be convenient - for example, given any valid grid coordinates (x,y), all its neighbors are also valid and can be requested through getMap() without introducing any special cases in the code.
function intersect(Vector 3d_point, Vector 3d_direction, float range)returns VectorintersectCalculate the intersection point between the world surface and the ray projected from "3d point" towards the given direction. 3D points are actually 3-elements Vector objects. The resulting vector contains the additional fourth element - the intersection point distance. The function returns null if there is no intersection.

See "standard_events.inc" file, which uses "intersect" for calculating the world coordinates corresponding to the user-clicked screen location.
Bugs: This function does not currently handle the heightfield environment correctly (works as if it was flat)
function intersect(Vector 3d_point, Vector 3d_direction)returns VectorintersectWorks like intersect(3d point,3d direction,range) for inifinite range, that is without limiting the intersection distance
Global context