| Author | 
            Message | 
        
        
			| 
				
				 CaveCricket48 
				
				
					 Joined: Tue Jun 12, 2007 11:52 pm Posts: 13144 Location: Here
				 
				 
			 | 
			
				
				  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 | 
			
				
					 
					
					 
				  
			 | 
    	
		
	
	
		  | 
	
	
			| 
				
				 Grif 
				REAL AMERICAN HERO 
				
					 Joined: Sat Jan 27, 2007 10:25 pm Posts: 5655
				 
				 
			 | 
			
				
				  Re: Quick Actor Switching Script Needed  
					
						ActivityMan:GetActivity():SwitchToActor(self,Activity.PLAYER_1,self.Team); 
					
  
			 | 
		
		
			| Sun Aug 16, 2009 12:52 am | 
			
				
					 
					
					 
				  
			 | 
    	
		
	
	
		  | 
	
	
			| 
				
				 CaveCricket48 
				
				
					 Joined: Tue Jun 12, 2007 11:52 pm Posts: 13144 Location: Here
				 
				 
			 | 
			
				
				  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 | 
			
				
					 
					
					 
				  
			 | 
    	
		
	
	
		  | 
	
	
			| 
				
				 Grif 
				REAL AMERICAN HERO 
				
					 Joined: Sat Jan 27, 2007 10:25 pm Posts: 5655
				 
				 
			 | 
			
				
				  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 | 
			
				
					 
					
					 
				  
			 | 
    	
		
	
	
		  | 
	
	
			| 
				
				 Mind 
				
				
					 Joined: Thu Mar 06, 2008 10:54 pm Posts: 1360 Location: USA
				 
				 
			 | 
			
				
				  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 | 
			
				
					 
					
					 
				  
			 | 
    	
		
	
	
		  | 
	
	
			| 
				
				 CaveCricket48 
				
				
					 Joined: Tue Jun 12, 2007 11:52 pm Posts: 13144 Location: Here
				 
				 
			 | 
			
				
				  Re: Quick Actor Switching Script Needed  
					
						Another error.   Attachment: 
			 
			Error.bmp [ 9 KiB | Viewed 4996 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 | 
			
				
					 
					
					 
				  
			 | 
    	
		
	
	
		  | 
	
	
			| 
				
				 Grif 
				REAL AMERICAN HERO 
				
					 Joined: Sat Jan 27, 2007 10:25 pm Posts: 5655
				 
				 
			 | 
			
				
				  Re: Quick Actor Switching Script Needed  
					
						Just ActivityMan, not self.ActivityMan. 
					
  
			 | 
		
		
			| Sun Aug 16, 2009 1:43 am | 
			
				
					 
					
					 
				  
			 | 
    	
		
	
	
		  | 
	
	
			| 
				
				 CaveCricket48 
				
				
					 Joined: Tue Jun 12, 2007 11:52 pm Posts: 13144 Location: Here
				 
				 
			 | 
			
				
				  Re: Quick Actor Switching Script Needed  
					
						It's working now, thanks! 
					
  
			 | 
		
		
			| Sun Aug 16, 2009 1:56 am | 
			
				
					 
					
					 
				  
			 | 
    	
		
	
	
		  | 
	
	
			| 
				
				 CaveCricket48 
				
				
					 Joined: Tue Jun 12, 2007 11:52 pm Posts: 13144 Location: Here
				 
				 
			 | 
			
				
				  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 | 
			
				
					 
					
					 
				  
			 | 
    	
		
	
	
		  | 
	
	
			| 
				
				 Mind 
				
				
					 Joined: Thu Mar 06, 2008 10:54 pm Posts: 1360 Location: USA
				 
				 
			 | 
			
				
				  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 | 
			
				
					 
					
					 
				  
			 | 
    	
		
	
	
		  | 
	
	
			| 
				
				 CaveCricket48 
				
				
					 Joined: Tue Jun 12, 2007 11:52 pm Posts: 13144 Location: Here
				 
				 
			 | 
			
				
				  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 | 
			
				
					 
					
					 
				  
			 | 
    	
		
	
	
		  | 
	
	
			| 
				
				 Mind 
				
				
					 Joined: Thu Mar 06, 2008 10:54 pm Posts: 1360 Location: USA
				 
				 
			 | 
			
				
				  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 | 
			
				
					 
					
					 
				  
			 | 
    	
		
	
	
		  | 
	
	
			| 
				
				 CaveCricket48 
				
				
					 Joined: Tue Jun 12, 2007 11:52 pm Posts: 13144 Location: Here
				 
				 
			 | 
			
				
				  Re: Quick Actor Switching Script Needed *More help needed  
					
						Tabs seem to have no effect. 
					
  
			 | 
		
		
			| Sun Aug 16, 2009 4:37 am | 
			
				
					 
					
					 
				  
			 | 
    	
		
	
	
		  | 
	
	
			| 
				
				 TheValiant 
				
				
					 Joined: Mon Jun 08, 2009 10:54 pm Posts: 33
				 
				 
			 | 
			
				
				  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 | 
			
				
					 
					
					 
				  
			 | 
    	
		
	
	
		  | 
	
	
			| 
				
				 Mind 
				
				
					 Joined: Thu Mar 06, 2008 10:54 pm Posts: 1360 Location: USA
				 
				 
			 | 
			
				
				  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 | 
			
				
					 
					
					 
				  
			 | 
    	
		
	
	
		  | 
	
	
	
		 |