Spring.AdjustHeightMap behaving oddly.

Spring.AdjustHeightMap behaving oddly.

Various things about Spring that do not fit in any of the other forums listed below, including forum rules.

Moderator: Moderators

Post Reply
yanom
Posts: 323
Joined: 10 Jul 2009, 23:34

Spring.AdjustHeightMap behaving oddly.

Post by yanom »

So I have this Lua code in a gadget:

Code: Select all

function gadget:UnitFinished(unitID, unitDefID, teamID)
	if(unitName(unitID)=="mnanoforge") then --test
		local unitx,unity,unitz = Spring.GetUnitPosition(unitID)
		unitx = math.floor((unitx+4)/8)*8
		unitz = math.floor((unitz+4)/8)*8
		
		Spring.SetHeightMapFunc(function()
			for z=0,Game.mapSizeZ, Game.squareSize do
				for x=0,Game.mapSizeX, Game.squareSize do
					currentAlt = Spring.GetGroundHeight(x,z)
					Spring.AdjustHeightMap( x, z, 200 )
				end
			end
		end)

        --Spring.LevelHeightMap(unitx-1000,unitz-1000,unitx+1000,unitz+1000,unity)
	end
end
This is supposed to raise up the whole map by 200m when a certain building is built. It sort of works:Image

All of the stuff on the map gets raised up, including the trees. If I build a tank, the tank can drive around on the "invisible ground" 200m up. But the map itself doesn't move up like it should! Bug?
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Re: Spring.AdjustHeightMap behaving oddly.

Post by gajop »

seems to me like you are misusing Spring.AdjustHeightMap,
you should either call it just once outside of SetHeightMapFunc Spring.AdjustHeightMap(0, 0 Game.mapSizeX, Game.mapSizeZ, 200), or you should use AddHeightMap instead
yanom
Posts: 323
Joined: 10 Jul 2009, 23:34

Re: Spring.AdjustHeightMap behaving oddly.

Post by yanom »

Oh, it looks like AddHeightMap is actually what I'm looking for. That raises or lowers the map by a given amount, yesyes?
Post Reply

Return to “General Discussion”