'Why does this list always grab the first item?
This function is supposed to go through all of the list items and check whether the argument coordinates are close to the position in the list items (the second and third numbers in the nested lists), but from the readout I can tell that it only ever checks the first one.
function CapitalProximity(x,y)
local positions = {{"lusitani",31,328},{"ebdani",78,592},{"carpetani",101,329}}
for i = 1, #positions do
local dist = distance_2D(x,y,positions[i][2],positions[i][3])
print("position is "..dist.." from "..positions[i][1])
if dist < 20 then
return true
else
return false
end
end
end
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
