When I call the function the game locks up and eventually just closes, presumably because it fills up its Share of Memory.
The length of radiusold is 1, however when I put a "print(i)" in the for loop it shows that the loop increments i until it the Program closes.
Before you ask, the function is unfinished, I will wrap the loop in another one to extend the Range.
Code: Select all
function unitMovementRadius(position,range)
local radius={}
local radiusold={}
table.insert(radius,position)
radiusold=radius
for i,position in ipairs(radiusold) do
table.insert(radius,position+1)
table.insert(radius,position-1)
table.insert(radius,position+map.width)
table.insert(radius,position-map.width)
if position % 2 == 0 then
table.insert(radius,position+map.width+1)
table.insert(radius,position+map.width-1)
else
table.insert(radius,position-map.width+1)
table.insert(radius,position-map.width-1)
end
end
return radius
end