View unanswered posts | View active topics It is currently Thu Dec 26, 2024 6:27 pm



Reply to topic  [ 24 posts ]  Go to page Previous  1, 2
 Quick Actor Switching Script Needed *More help needed 
Author Message
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: Quick Actor Switching Script Needed *More help needed
I know I'm doing somthing wrong. Here's my entire script:

Code:
function Create(self)
   self.maxSpeed = 10;
   self.acceleration = 0.2;
   self.Vel = Vector(0,0);
   self.RotAngle = 0;
   self.rotFactor = 0.2;

local curdist = 50;
   for actor in MovableMan.Actors do
   local avgx = actor.Pos.X - self.Pos.X;
   local avgy = actor.Pos.Y - self.Pos.Y;
   local dist = math.sqrt(avgx ^ 2 + avgy ^ 2);
   if dist < curdist then
       curdist = dist;
       self.closestactor = actor;
         end
    end
    if self.closestactor == true then
        if self.closestactor:IsPlayerControlled() == true then
            self.ActivityMan:GetActivity():SwitchToActor(self,Activity.PLAYER_1,self.Team);
        else
            self.ToDelete = true
      end   
   end
end

function Update(self)
self.Vel.Y = self.Vel.Y - (TimerMan.DeltaTimeSecs * SceneMan.GlobalAcc.Y)

if self:GetController():IsState(Controller.WEAPON_FIRE) then
self:GibThis();
end

      if self:GetController():IsState(Controller.HOLD_LEFT) then
         self.Vel.X = self.Vel.X - self.acceleration;
         if self.Vel.X < -self.maxSpeed then
            self.Vel.X = -self.maxSpeed;
         end
      elseif self:GetController():IsState(Controller.HOLD_RIGHT) then
         self.Vel.X = self.Vel.X + self.acceleration;
         if self.Vel.X > self.maxSpeed then
            self.Vel.X = self.maxSpeed;
         end
      elseif self.Vel.X < 0 then
         self.Vel.X = self.Vel.X + self.acceleration;
         if self.Vel.X > 0 then
            self.Vel.X = 0;
         end
      elseif self.Vel.X > 0 then
         self.Vel.X = self.Vel.X - self.acceleration;
         if self.Vel.X < 0 then
            self.Vel.X = 0;
         end
      end
      if self:GetController():IsState(Controller.HOLD_UP) then
         self.Vel.Y = self.Vel.Y - self.acceleration;
         if self.Vel.Y < -self.maxSpeed then
            self.Vel.Y = -self.maxSpeed;
         end
      elseif self:GetController():IsState(Controller.HOLD_DOWN) then
         self.Vel.Y = self.Vel.Y + self.acceleration;
         if self.Vel.Y > self.maxSpeed then
            self.Vel.Y = self.maxSpeed;
         end
      elseif self.Vel.Y < 0 then
         self.Vel.Y = self.Vel.Y + self.acceleration;
         if self.Vel.Y > 0 then
            self.Vel.Y = 0;
         end
      elseif self.Vel.Y > 0 then
         self.Vel.Y = self.Vel.Y - self.acceleration;
         if self.Vel.Y < 0 then
            self.Vel.Y = 0;
         end
      end
end


Sun Aug 16, 2009 5:04 am
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: Quick Actor Switching Script Needed *More help needed
It'd help if you said what was wrong.

But try this:

http://pastebin.com/m75c6894f


Sun Aug 16, 2009 4:28 pm
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: Quick Actor Switching Script Needed *More help needed
The script doesn't switch actors properly, and yours Grif makes the hovering of the actor less effective and doesn't switch. And it gives an error.
Attachment:
Error.bmp
Error.bmp [ 36.42 KiB | Viewed 2366 times ]


The entire script is supposed to:
-Find the nearest actor within a 50 pixel range.
-Check if the actor is being controlled by a human player.
-If yes, switch control to self.
-If no, delete self.
-Entire script would not effect all human players, only one (if found).
-Fly like Darlos' Yosei.
-Gib when fire is pressed while controlling it.


Sun Aug 16, 2009 4:54 pm
Profile
User avatar

Joined: Thu Mar 06, 2008 10:54 pm
Posts: 1360
Location: USA
Reply with quote
Post Re: Quick Actor Switching Script Needed *More help needed
Code:
            self.ActivityMan:GetActivity():SwitchToActor(self,Activity.PLAYER_1,self.Team);


Is this two lines in your code? It should be one line.


Sun Aug 16, 2009 7:21 pm
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: Quick Actor Switching Script Needed *More help needed
Yes, those are in the same line.


Sun Aug 16, 2009 7:50 pm
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: Quick Actor Switching Script Needed
Grif wrote:
Just ActivityMan, not self.ActivityMan.


Sun Aug 16, 2009 10:25 pm
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: Quick Actor Switching Script Needed *More help needed
Yes, and I took out the [self.]. and I get the same error.


Sun Aug 16, 2009 10:31 pm
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: Quick Actor Switching Script Needed *More help needed
http://pastebin.com/m1f4d9b86


Sun Aug 16, 2009 10:38 pm
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: Quick Actor Switching Script Needed *More help needed
Now I get no errors, but there is no switching at all and the actor isn't deleted when there is no controlled actor nearby.


Mon Aug 17, 2009 12:39 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 24 posts ]  Go to page Previous  1, 2

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:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.182s | 15 Queries | GZIP : Off ]