Help with checking for scene wraps
For my flying saucer craft, I want to check for scene wrapping, then find the closest direction to get above the enemy brain, but the following segment code doesn't work and messes up the other functions of my lua, can anyone help me find what's wrong?
Code:
local Nav = Distance to the enemy's brain
if (SceneMan:SceneWrapsX() == true) then -- if scene wraps
if (Nav > SceneMan:GetSceneWidth()/2 then -- and distance to enemy brain is more than half of map width
Nav = Nav - SceneMan:GetSceneWidth() -- go the other direction
elseif Nav < -SceneMan:GetSceneWidth()/2 then -- or if distance to enemy brain is more than half of map width the other way
Nav = Nav + SceneMan:GetSceneWidth() -- go the other direction
end
end