Error: functions.lua:24: loop in gettable
stack traceback:
functions.lua:24: in function 'drawObjects'
main.lua:62: in function 'draw'
[string "boot.lua"]:438: in function <[string "boot.lua"]99>
[C]: in function 'xpcall'
Here is my class:
Code: Select all
bullet = {}
-- CONSTRUCTOR
function bullet:new(playerx, playery, xd, yd)
local object = {
x = playerx,
y = playery,
xd = xd,
yd = yd,
red = 255,
redUp = false,
deleteMe = false
}
setmetatable(object, { __index = bullet })
return object
end
function bullet:update(dt)
self.x = self.x + self.xd*dt
self.y = self.y + self.yd*dt
if self.redUp then
self.red = self.red + 20
if self.red > 230 then self.red = 230; self.redUp = false end
else
self.red = self.red - 20
if self.red < 100 then self.red = 100; self.redUp = true end
end
-- CHECK BOUNDS
if self.x < -100 or self.x > 1380 or self.y < -100 or self.y > 820 then self.deleteMe = true end
end
function bullet:draw()
g.setColor(self.red, 100, 100, 255)
love.graphics.circle("fill", self.x, self.y, 7, 100)
g.setColor(255, 255, 255, 255)
end
Code: Select all
function drawObjects(obj)
for i=1, table.getn(obj) do
if obj[i] then
obj[i]:draw()
end
end
end
Code: Select all
drawObjects(bullets)
Any help would be greatly appreciated.
The love file included only works with an XBOX360 pad. The sticks move and the triggers fire.