I just started coding with LUA / LÖVE today. However, I am running in to a problem which I just cannot solve.
I am trying to use the Shape:testSegment(x1, y1, x2, y2) function, but it just won't execute. It always triggers an error: "attempt to call method 'testSegment' (a nil value)"
Here is an example of my code where this error gets triggered. Although I am pretty certain that my code is correct:
Code: Select all
function GetIntersection(cur_shape, y)
if(cur_shape ~= nil) then
local left = cur_shape:testSegment(wall_left, y)
local right = cur_shape:testSegment(wall_right, y)
if(left == nil or right == nil) then
return 0
else
return (right - left)
end
end
return 0
end