- Joined
- Feb 23, 2007
- Messages
- 1,030
Can it be done? Can you use coordinates? I can't find any function but I really want to be sure.
globals
location TempLoc = Location(0,0)
endglobals
function Func takes nothing returns nothing
local real x = YourX
local real y = YourY
local real z
call MoveLocation(TempLoc,x,y)
set z = GetLocationZ(TempLoc)
.....
endfunction
You can (almost) get it by coordinates, but blizzard didn't make a full native about that.
function MoveLocation takes location whichLocation, real newX, real newY returns nothing
call RemoveLocation ( whichLocation )
set whichLocation = Location ( newX, newY )
endfunction
i'd bet my ass MoveLocation does something equivalent to this: (and i have a mighty fine ass)
function MoveLocation takes location whichLocation, real newX, real newY returns nothing call RemoveLocation ( whichLocation ) set whichLocation = Location ( newX, newY )endfunction
so, you're still clearing a location leak whether you use MoveLocation on a global location or using local locations. i think Yixx's global method is better, however, for 3 reasons:
1. you don't have to declare a new variable
2. you don't have to remove a reference leak
3. natives are fast
native MoveLocation takes location whichLocation, real newX, real newY returns nothing
library GetZ
globals
private location Loc = Location(0,0) //Here we create the location
endglobals
function GetLocZ takes real x,real y returns real
call MoveLocation(Loc,x,y) //Here we move it (NO LEAK!)
return GetLocationZ(Loc)
endfunction
endlibrary
function GetZ takes real x , real y returns real
local location loc = Location( x , y )
local real z = GetLocationZ( loc )
call RemoveLocation( loc )
set loc = null
return z
endfunction