User Tools

Site Tools


scripting:reference:system_functions:worldmapfunctions

This is an old revision of the document!


World / Map Functions

sysGetTileCenter

Format sysGetTileCenter ( [World X or Y] )
Description Returns the world coordinate value for the center of the map tile nearest to the specified position
Parameters [World X or Y] - World coordinate value
Returns World coordinate of tile center

Example:

Event( "UseItem", "TileTeleport" )
{
    $tileCenterX = sysGetTileCenter( $gPlayerWorldX )
    $tileCenterY = sysGetTileCenter( $gPlayerWorldY )
    *setposworld %PLAYER% $tileCenterX $tileCenterY
}

sysMapToWorld

Format sysMapToWorld ( [Map X or Y] )
Description Converts a map coordinate to a world coordinate
Parameters [Map X or Y] - Map coordinate value
Returns World coordinate

Notes: There are 2 coordinate systems used in the game ; Map Coordinates range from 0 to 255 (for the default map size), 0 to 511 or 0 to 1023 (if using a larger map size) and they correspond to the 'tiles' that make up the landscape. World coordinates are in centimeters.

sysWorldToMap

Format sysWorldToMap ( [Map X or Y] )
Description Converts a world coordinate to a map coordinate
Parameters [World X or Y] - World coordinate value
Returns Nearest map coordinate value

sysGetBuildingAtWorldPos

sysWorldGetNumBuildingsOfType

Format sysWorldGetNumBuildingsOfType( [BuildingType] )
Description Returns the number of buildings of this type currently existing within the world. Useful for when you want to script a system that limits the number of a particular type of building
Parameters Type number of the building to check
Returns Number of this type of building currently in the world

Example:

Event( "PlaceAnyBuilding", "" )
{
    $nBuildingType = $gParam[1]

    $numInWorld = sysWorldGetNumBuildingsOfType( $nBuildingType )
    if ( $numInWorld >= 1 )
    {
       *msg %PLAYER% There can only be 1 of each type of building in the world
       CancelTransaction()
    }
    else
    {
	$valid = sysIsBuildingPositionValid( $nBuildingType )
	if ( $valid = 1 )
	{
		$buildingName = sysGetTextEntry()
		$constrAmount = -1
		$didAdd = sysAddBuildingWorld( $nBuildingType,$gPlayerID,$gPlayerWorldX,$gPlayerWorldY,$buildingName,$constrAmount )
	}
    }
}

sysGetNearestForest

scripting/reference/system_functions/worldmapfunctions.1580294551.txt.gz · Last modified: 2020/01/29 04:42 by mit

Except where otherwise noted, content on this wiki is licensed under the following license: Public Domain
Public Domain Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki