All pastes #2038378 Raw Edit

Miscellany

public lua v1 · immutable
#2038378 ·published 2011-01-04 21:19 UTC
rendered paste body
function widget:GetInfo()  return {    name      = "ground normals",    desc      = "some stuff with ground normals",    author    = "knorke",    date      = "5 Nov 2010",    license   = "GNU GPL, v2 or later or horse",    layer     = 0,    enabled   = true,  --  loaded by default?  }endlocal unit = nilfunction widget:UnitFinished(unitID, unitDefID, teamID)unit=unitID--Spring.GiveOrderToUnit(unit,31210,{UnitDefNames["bmetaltruckdepot"].id},{})endfunction widget:DrawWorldPreUnit()	if (unit==nil) then return end	local x,y,z=Spring.GetUnitPosition (unit)	gl.LineWidth(5.0)	local gnx,gny,gnz = Spring.GetGroundNormal (x,z)	gl.DrawGroundCircle (x,Spring.GetGroundHeight(x, z),z, 50, 16)	--Spring.Echo ("->" .. gnx .." " .. gny .. " " .. gnz)	local d = 100	local x2=x-(gnx*d)	local y2=y+(gny*d)	local z2=z-(gnz*d)	for i = 0, 1000, 50 do		x2=x2-(gnx*d)		y2=y2+(gny*d)		z2=z2-(gnz*d)		gl.DrawGroundCircle (x2,Spring.GetGroundHeight(x2, z2),z2, 10, 16)		gnx,gny,gnz = Spring.GetGroundNormal (x2,z2)	end	--Spring.GiveOrderToUnit(unit, CMD.MOVE , {x2, y2, z2  }, {})endfunction widget:GameFrame(frame)if (unit==nil) then return endif (frame % 2 ~=0) then return endlocal x,y,z=Spring.GetUnitPosition (unit)local gnx,gny,gnz = Spring.GetGroundNormal (x,z)--for d = 0, 1000, 50 dolocal d = 500	local x2=x-(gnx*d)	local y2=y+(gny*d)	local z2=z-(gnz*d)--end--Spring.GiveOrderToUnit(unit, CMD.MOVE , {x2, y2, z2  }, {})end