User Tools

Site Tools


scripting:reference:system_functions:townfunctions

Town information and control functions

Town Functions

sysGetNearestTown

sysGetNearestTown( WorldX, WorldY ) returns buildingID num for the nearest town to the specified world coord

sysTownGetRelationship

sysTownGetRelationship( townIDNum1, townIDNum2 ) returns the current 'political' relationship between the two towns. Exactly how much of the town relationship system is presently viable is somewhat unknown..

sysTownGetNumBuildingsOfType

Format sysTownGetNumBuildingsOfType( TownBuildingID, BuildingType )
Description Returns the number of buildings of this type currently exist within the specified town. Useful for when you want to script a system that limits the number of a particular type of building per town
Returns Number of this type of building in the town

Example:

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

    $nearestTownID = sysGetNearestTown( $gPlayerWorldX, $gPlayerWorldY )
    $numInTown = sysTownGetNumBuildingsOfType( $nearestTownID, $nBuildingType )
    if ( $numInTown >= 3 )
    {
       *msg %PLAYER% There can only be 3 of each type of building in each town
       CancelTransaction()
    }
    else
    {
	$valid = sysIsBuildingPositionValid( $nBuildingType )
	if ( $valid = 1 )
	{
		$buildingName = sysGetTextEntry()
		$constrAmount = -1
		$didAdd = sysAddBuildingWorld( $nBuildingType,$gPlayerID,$gPlayerWorldX,$gPlayerWorldY,$buildingName,$constrAmount )
	}
    }
}
scripting/reference/system_functions/townfunctions.txt · Last modified: 2020/02/07 19:33 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