• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • ✅ HD Level Design Contest #1 POLL is now OPEN! Check out the stunning visuals of the final entries. 🔗Click here to cast your vote!

[Solved] Undeclared Function distance error

Status
Not open for further replies.
Level 7
Joined
Nov 8, 2008
Messages
174
Hi, I tried importing the Meat Hook System [GUI] v4.2.

and encountered this error Undeclared Function distance
problem 1.PNG

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
Joined
Aug 10, 2018
Messages
6,293
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:
Level 7
Joined
Nov 8, 2008
Messages
174
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.
Top