Skip to content
marcushutchings edited this page May 25, 2022 · 13 revisions

Original Height Map

The original height map represents the correct levels that the map should have if the map has sustained no damage and used by the restore terrain command to determine what the correct height levels should be.

Note that this does not affect the current height map. You will need to call functions such as LevelHeightMap to change the map's current terrain levels.

Spring.AdjustOriginalHeightMap( number x1, number z1 [, number x2, number z2 ], number height )

Adds the given height (which can be negative) the original height map in the specified area.

Spring.LevelOriginalHeightMap( number x1, number z1 [, number x2, number z2 ], number height )

Change the original height map to a specific value in the specified area.

Spring.RevertOriginalHeightMap( number x1, number z1 [, number x2, number z2 ], number origFactor )

Restore an area of the original height map to the levels as first read from the map file.

Spring.SetOriginalHeightMapFunc( lua_function [, arg1 [, arg2 [, ... ]]] ) -> nil | number absTotalOriginalHeightMapAmountChanged

Use a custom function to change the original height map. These custom functions have to use special function to apply the changes to the original height map: AddOriginalHeightMap and SetOriginalHeightMap (see the following functions)

Example code:

Spring.SetOriginalHeightMapFunc(function()
	for z=0,Game.mapSizeZ, Game.squareSize do
		for x=0,Game.mapSizeX, Game.squareSize do
			Spring.SetOriginalHeightMap( x, z, 200 + 20 * math.cos((x + z) / 90) )
		end
	end
end)

Spring.AddOriginalHeightMap( number x, number z, number height ) -> nil | number newHeight

Can only be called in SetOriginalHeightMapFunc(). Adds the given height (which can be negative) the original height map in the specified area.

Spring.SetOriginalHeightMap( number x, number z, number height [, number terraform = 1 ] ) -> nil | number absHeightDiff

Can only be called in SetOriginalHeightMapFunc(). Change the original height map to a specific value in the specified area. The terraform argument is a scaling factor. It represents how much towards the specified height the current height map should be changed, for exmaple:

If =0 nothing will be changed (the terraform starts) and if =1 the terraform will be finished and the specific height value will be the new current height map level.

Clone this wiki locally