Page 1 of 1

Spring.AdjustHeightMap behaving oddly.

Posted: 01 Mar 2013, 16:53
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?

Re: Spring.AdjustHeightMap behaving oddly.

Posted: 01 Mar 2013, 17:50
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

Re: Spring.AdjustHeightMap behaving oddly.

Posted: 02 Mar 2013, 03:29
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?