Hey. I normally wouldn’t post about syntax issues, but I’m stumped as to why this isn’t working.
function starManager:checkBounds(i) if ((self.smallStarList[i]).x \< -1080) then self.smallStarList[i].x = self.smallStarList[i].x + 1080\*2; end if ((self.smallStarList[i]).x \> 1080) then self.smallStarList[i].x = self.smallStarList[i].x - 1080\*2; end if ((self.smallStarList[i]).y \< 0) then self.smallStarList[i].y = self.smallStarList[i].y - 1080\*2; end end function starManager:step() for i=1,6 do self.smallStarList[i]:translate(5,5); self.bigStarList[i]:translate(5,5); end self:checkBounds(i); end
Step is called in another method. It translates the stars just fine, but crashes when I call “self:checkBounds()”.
\Objects\starManager.lua:41: attempt to index field '?' (a nil value)
Lua is not my most proficient language, but I don’t see why I’m having trouble calling an object’s function inside itself. If I replace checkBounds() with a print statement, it outputs properly, so it’d being called; It’s just not getting the regular “self” variable.
Thanks.
Edit: To clarify, the checkBounds() function works if I shove it into step(), but that is obviously not desirable.