View unanswered posts | View active topics It is currently Fri Dec 27, 2024 8:21 am



Reply to topic  [ 3 posts ] 
 Help with checking for scene wraps 
Author Message

Joined: Tue Aug 03, 2010 4:51 pm
Posts: 32
Reply with quote
Post 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


Last edited by goduranus on Mon Aug 09, 2010 12:30 pm, edited 1 time in total.



Mon Aug 09, 2010 9:27 am
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: Help with checking for scene wraps
Use SceneMan.SceneWidth rather than SceneMan:GetSceneWidth(); you might be getting errors with userdata from a function or something like that.

Also, how are you getting Nav? If you're using a distance finder function, you're going to be trying to subtract a vector by a constant. I'm assuming that you're just using self.Pos.X - brain.Pos.X, or something along those lines?


Mon Aug 09, 2010 7:44 pm
Profile

Joined: Tue Aug 03, 2010 4:51 pm
Posts: 32
Reply with quote
Post Re: Help with checking for scene wraps
Thanks, I think it worked.


Tue Aug 10, 2010 1:57 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.040s | 15 Queries | GZIP : Off ]