TerrainDescriber
Package: Libraries.Game.Graphics.Worlds · Inherits from: Libraries.Language.Object
TerrainDescriber says what a terrain is like, in words, for a screen reader. DescribeTerrain gives a sense of the whole land in a few sentences: its shape and size, its mountains or hills, its rivers and lakes, and its paint, such as "A hilly island, 512 by 512. 3 mountains; the tallest is 87 high, at high x, high z. 1 river runs from high x, high z to low z, into the sea. 2 lakes. Mostly grass, with rock on the steep slopes." Anything a terrain doesn't have is left out. DescribeSpot says what one place is like, such as "18 high, grass, hillside". There are no units and no compass: places are said along x and z, as the scene editor shows them. The whole terrain is measured once after it changes, not each time it is asked: a change is noticed by the terrain's build and paint counts and its water, and the description is made again once they stop changing, so a stroke being painted doesn't make it again every frame. The cutoffs between flat, hilly and mountainous, and the categories of a spot, are first guesses, kept together in the constants below so they can be tuned by listening.
Example Code
use Libraries.Game.Graphics.Worlds.TerrainItem
use Libraries.Game.Graphics.Worlds.TerrainDescriber
TerrainItem terrain
TerrainDescriber describer
text words = describer:DescribeTerrain(terrain)
Actions
DescribeSpot(Libraries.Game.Graphics.Worlds.TerrainItem terrain, number x, number z)
This action describes one place on a terrain in a few words: the ground's height there, as "18 high", or the water's depth, as "3 deep"; the strongest paint; and what kind of place it is, such as "hillside", "peak", "lake" or "beach". Any part that doesn't apply is left out.
Parameters
terrainLibraries.Game.Graphics.Worlds.TerrainItem: The terrain.xnumber: The place along x, in world units.znumber: The place along z, in world units.
Returns
text: The description, or an empty text where there is no ground.
Example
use Libraries.Game.Graphics.Worlds.TerrainItem
use Libraries.Game.Graphics.Worlds.TerrainDescriber
TerrainItem terrain
TerrainDescriber describer
text words = describer:DescribeSpot(terrain, 12, 30)
DescribeTerrain(Libraries.Game.Graphics.Worlds.TerrainItem terrain)
This action describes the whole terrain in a few sentences: its shape and size, mountains or hills, rivers, lakes and paint, leaving out what it doesn't have. The terrain is measured again only after it changed and the change is over (see the class), so asking every frame is cheap.
Parameters
terrainLibraries.Game.Graphics.Worlds.TerrainItem: The terrain.
Returns
text: The description, or an empty text if terrain is undefined.
Example
use Libraries.Game.Graphics.Worlds.TerrainItem
use Libraries.Game.Graphics.Worlds.TerrainDescriber
TerrainItem terrain
TerrainDescriber describer
text words = describer:DescribeTerrain(terrain)
FormatAmount(number value)
This action returns a number for speaking: rounded to one place after the point, and without the point for a whole number, such as "13" or "12.5".
Parameters
valuenumber: The number.
Returns
text: The number as text.
Example
use Libraries.Game.Graphics.Worlds.TerrainDescriber
TerrainDescriber describer
text words = describer:FormatAmount(12.04)