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



Reply to topic  [ 24 posts ]  Go to page 1, 2  Next
 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 Quick Actor Switching Script Needed *More help needed
Unfortunately, my Lua skills are not good enough to do this. I need a script that is attached to an actor, and when that said actor is created, the player of its team switches control to it. Thanks.

Edit: scroll all the way down to see the problem.


Last edited by CaveCricket48 on Sun Aug 16, 2009 3:56 am, edited 1 time in total.



Sun Aug 16, 2009 12:03 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
ActivityMan:GetActivity():SwitchToActor(self,Activity.PLAYER_1,self.Team);


Sun Aug 16, 2009 12:52 am
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
Simply putting the Lua line in a Lua file doesn't work, so I tried this:
Code:
function Create(self)
self.ActivityMan:GetActivity():SwitchToActor(self,Activity.PLAYER_1,self.Team);
end
end
end


And got this:
Attachment:
Error.bmp [14.24 KiB]
Not downloaded yet


Sun Aug 16, 2009 1:20 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
Why did you put three ends?

function Create(self) needs one end.

Any logical statement (if, for, while) needs an end.

Function calls, variable changes, etc, do not need ends.

You put more ends than there are even lines of "real" code.


Sun Aug 16, 2009 1:23 am
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
function Create(self)
self.ActivityMan:GetActivity():SwitchToActor(self,Activity.PLAYER_1,self.Team);
end


Too many "end's"
;)

Crap ninja'd by grif


Sun Aug 16, 2009 1:24 am
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
Another error. :(
Attachment:
Error.bmp
Error.bmp [ 9 KiB | Viewed 4232 times ]


BTW, the actor that the script is attached to is a rocket that dies instantly and has an actor in its inventory.


Sun Aug 16, 2009 1:39 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
Just ActivityMan, not self.ActivityMan.


Sun Aug 16, 2009 1:43 am
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
It's working now, thanks!


Sun Aug 16, 2009 1:56 am
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
I need another script which is also beyond my abilities. It would be attached to an actor and would...
-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).


Sun Aug 16, 2009 3:57 am
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:
function Create(self)
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


Dunno for sure if this will work, but this is my guess for now.

This is when it's created, fyi. If it's not sposed to be that, make sure to tell me :)

Edit: the activityman is sposed to be one line :)


Sun Aug 16, 2009 4:16 am
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
Mind wrote:
Edit: the activityman is sposed to be one line


What does that mean?

And error:
Attachment:
Error.bmp [10.77 KiB]
Not downloaded yet


Sun Aug 16, 2009 4:26 am
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
Try and line up the tabs. The tabs are messed up, so make sure to line em up with the designated statement.


Sun Aug 16, 2009 4:28 am
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
Tabs seem to have no effect.


Sun Aug 16, 2009 4:37 am
Profile

Joined: Mon Jun 08, 2009 10:54 pm
Posts: 33
Reply with quote
Post Re: Quick Actor Switching Script Needed *More help needed
Remove the "()" in this line:

Code:
if self.closestactor:IsPlayerControlled == true() then


Sun Aug 16, 2009 4:43 am
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:
function Create(self)
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


Sorry, ya like the valiant said, it should be if self.closestactor:IsPlayerControlled() == true.


Sun Aug 16, 2009 4:49 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 24 posts ]  Go to page 1, 2  Next

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.080s | 15 Queries | GZIP : Off ]