Is it possible in Wurst for a function to return multiple values? It seems it is with JASS. E.g. I would like to find the closest camp and if none are found as ready return a false. Alternatively I could wrap it into another function that returns nothing and simply doesn't do the deed if the returned integer is -1.
General code comments are also very welcome.
Thanks
General code comments are also very welcome.
Thanks
Wurst:
function findClosestReadyCamp (vec2 target) returns int
real closestDistance = REAL_MAX
bool isAccepted = false
int closest = 0 // location of the camp as index in an array (called wilds), this can be initialized instead to -1
for i = 0 to wildsLastIndex // pesky non sized arrays making me do this, array should prolly be refactored as a separated class to get sized arrays, as I've read something like
// for WildLoc w in wilds would "leak"
if not isAccepted
if wilds[i].isReady // array of classes
let dist = target.distanceToSq(wilds[i].loc) // squared distances are much cheaper, loc (location as vec2) is pre-saved on map initialization
if dist < closestDistance
closestDistance = dist
closest = i
if dist < 9000000 // if a camp is this close (3000 sq) no need to check the rest of the camps
isAccepted = true // break out of loop
return closest
Last edited: