Here's the offending code in question:Error: main.lua:288: attempt to index local 'v' (a number value)
stack traceback:
main.lua:288: in function <main.lua:151>
(tail call): ?
(tail call): ?
[string "boot.lua"]:407: in function <[string "boot.lua"]73>
[C]: in function 'xpcall'
Code: Select all
for i,v in ipairs(enemies) do
dx = player.X - v.X
dy = player.Y - v.Y
distance = math.sqrt(dx*dx+dy*dy)
v.X = v.X + (dx / distance * v.speed * dt)
v.Y = v.Y + (dy / distance * v.speed * dt)
if distanceFrom(player.X, player.Y, v.X, v.Y) < 100 and v.isReloading == false then
enemyShoot(v.X, v.Y)
table.insert(reloadingenemies, i)
v.isReloading = true
end
if CheckCollision(v.X,v.Y,v.width,v.height,player.X,player.Y,player.width,player.height) and player.isAlive == true then
playerDie()
end
end
for i,v in ipairs(reloadingenemies) do
if v.isReloading == true then
v.X = v.X + 50 * dt
end
end