Skip to content
marcushutchings edited this page May 23, 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 level should be.

Note that this does not affect the current height map. You will need to call 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 SetHeightMapFunc()