# [Solved]Undeclared Function distance error

Status
Not open for further replies.

#### FirstLegacy

Level 7
Hi, I tried importing the Meat Hook System [GUI] v4.2.

and encountered this error Undeclared Function distance

Code:
``set udg_Temp_Real=Distance(udg_MeatHCX , udg_MeatHChainX[udg_MeatHChainRef[udg_MeatHSize[udg_MeatHRef]]] , udg_MeatHCY , udg_MeatHChainY[udg_MeatHChainRef[udg_MeatHSize[udg_MeatHRef]]]) - udg_MeatHOffset[udg_MeatHRef]``

anyone know how to fix this?

#### Uncle

Warcraft Moderator
Level 62
You're missing the Distance() function. You should have some code somewhere that has a function like this:
vJASS:
``````function Distance takes real a, real b, real c, real d returns real
// does a bunch of distance related stuff
endfunction``````

Edit:
Found the code in the map header. You need to copy and paste this into your map header:
vJASS:
``````//TESH.scrollpos=0
//TESH.alwaysfold=0

//return DistanceBetweenPoints(Location(x1, y1), Location(x2, y2))
function distance takes real x1, real x2, real y1, real y2 returns real
return SquareRoot((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2))
endfunction

//determine wheather a point is inside the configured map bounds
function IsOutsideMap takes real x, real y returns boolean
return x < udg_minX or y < udg_minY or x > udg_maxX or y > udg_maxY
endfunction

//If MeatHLockOn != null and MeatHIgnore == true, this function is called to filter the locked unit
function FilterLockedUnit takes nothing returns boolean
return ( GetFilterUnit() == udg_MeatHLockOn[udg_MeatHRef] )
endfunction``````
Not sure if distance is supposed to be capitalized or not.

Last edited:

#### FirstLegacy

Level 7
You're missing the Distance() function. You should have some code somewhere that has a function like this:
vJASS:
``````function Distance takes real a, real b, real c, real d returns real
// does a bunch of distance related stuff
endfunction``````

Edit:
Found the code in the map header. You need to copy and paste this into your map header:
vJASS:
``````//TESH.scrollpos=0
//TESH.alwaysfold=0

//return DistanceBetweenPoints(Location(x1, y1), Location(x2, y2))
function distance takes real x1, real x2, real y1, real y2 returns real
return SquareRoot((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2))
endfunction

//determine wheather a point is inside the configured map bounds
function IsOutsideMap takes real x, real y returns boolean
return x < udg_minX or y < udg_minY or x > udg_maxX or y > udg_maxY
endfunction

//If MeatHLockOn != null and MeatHIgnore == true, this function is called to filter the locked unit
function FilterLockedUnit takes nothing returns boolean
return ( GetFilterUnit() == udg_MeatHLockOn[udg_MeatHRef] )
endfunction``````
Not sure if distance is supposed to be capitalized or not.
thank you so much. the error finally gone..

Status
Not open for further replies.

Replies
4
Views
710
Replies
1
Views
310
Replies
7
Views
713
Replies
105
Views
9K
Replies
11
Views
1K