| Author | 
            Message | 
        
        
			| 
				
				 Asklar 
				Data Realms Elite 
				
					 Joined: Fri Jan 07, 2011 8:01 am Posts: 6211 Location: In your office, earning your salary.
				 
				 
			 | 
			
				
				  About attachables  
					
						Is it possible to check if an actor has an attachable attached to it? 
					
  
			 | 
		
		
			| Sun Apr 17, 2011 10:03 pm | 
			
				
					 
					
					 
				  
			 | 
    	
		
	
	
		  | 
	
	
			| 
				
				 Xery 
				
				
					 Joined: Sat Feb 26, 2011 10:29 am Posts: 163
				 
				 
			 | 
			
				
				  Re: About attachables  
					
						Asklar wrote: Is it possible to check if an actor has an attachable attached to it? Search "luaguns", I remeber there's a gun can just/only take arms and legs away from body. If so, the lua shall can check attachables.  
					
  
			 | 
		
		
			| Sun Apr 17, 2011 11:03 pm | 
			
				
					 
					
					 
				  
			 | 
    	
		
	
	
		  | 
	
	
			| 
				
				 Asklar 
				Data Realms Elite 
				
					 Joined: Fri Jan 07, 2011 8:01 am Posts: 6211 Location: In your office, earning your salary.
				 
				 
			 | 
			
				
				  Re: About attachables  
					
						I think that what I want to do is a bit more complex (I think).
  I made some particles that damage actors with lua, and I made an actor that is resistant to that particles.  I made a helmet to it, that it's like a gas mask, so someone gave me the idea to make the particles damage the actor if it's helmet was blown off.
  Aside from being laggy (it will probably be, considering it's quite laggy right now), is something like this possible? 
					
  
			 | 
		
		
			| Mon Apr 18, 2011 1:38 am | 
			
				
					 
					
					 
				  
			 | 
    	
		
	
	
		  | 
	
	
			| 
				
				 zoidberg 
				
				
					 Joined: Fri Feb 25, 2011 3:52 pm Posts: 39
				 
				 
			 | 
			
				
				  Re: About attachables  
					
						yes, you can imagine that your particle already has a pointer to the actor, which you want to check for wearing helmet self.actor is a pointer "helmet" - is a word to search for, while cycling through actor attachables you can search for exact preset as snown in commented line it will make the particle to ignore collisions with "self.actor" if it has any att's with "helmet" in presetname Code:    for i = 1, MovableMan:GetMOIDCount() - 1 do       if MovableMan:GetMOFromID(i).RootID == self.actor.ID and i ~= self.actor.ID then          local att = MovableMan:GetMOFromID(i)          if string.find(string.lower(att.PresetName), "helmet") then  --         if att.PresetName == "helmet"             self:SetWhichMOToNotHit(self.actor, -1)          end       end    end
   
					
  
			 | 
		
		
			| Mon Apr 18, 2011 6:43 am | 
			
				
					 
					
					 
				  
			 | 
    	
		
	
	
		  | 
	
	
			| 
				
				 Asklar 
				Data Realms Elite 
				
					 Joined: Fri Jan 07, 2011 8:01 am Posts: 6211 Location: In your office, earning your salary.
				 
				 
			 | 
			
				
				  Re: About attachables  
					
						Excuse me, but I plainly didn't get the code.
  I mean, I read it and I can't get much of it. And a question, would it lag much? 
					
  
			 | 
		
		
			| Tue Apr 19, 2011 7:42 pm | 
			
				
					 
					
					 
				  
			 | 
    	
		
	
	
		  | 
	
	
			| 
				
				 zoidberg 
				
				
					 Joined: Fri Feb 25, 2011 3:52 pm Posts: 39
				 
				 
			 | 
			
				
				  Re: About attachables  
					
						Code: function Update(self)    local actor    for actor in MovableMan.Actors do -- cycle through all actors       if (actor.Pos-self.Pos).Magnitude < 100 then -- look for the closest one          for i = 1, MovableMan:GetMOIDCount() - 1 do -- cycle through all moids             if MovableMan:GetMOFromID(i).RootID == actor.ID and i ~= actor.ID then -- find only selected actor's children                local att = MovableMan:GetMOFromID(i) -- get the attachable from it's id                if string.find(string.lower(att.PresetName), "helmet") then -- find the word "helmet" in attachable's presetname --            if att.PresetName == "helmet" -- or search for exact preset                   self:SetWhichMOToNotHit(actor, -1) -- apply some code here (currently it forces itself to ignore any collisions with actor)                end             end          end       end    end end
  ^ this is gas particle script i don't think it would be laggy you understand me now?  
					
  
			 | 
		
		
			| Tue Apr 19, 2011 8:40 pm | 
			
				
					 
					
					 
				  
			 | 
    	
		
	
	
		  | 
	
	
			| 
				
				 Asklar 
				Data Realms Elite 
				
					 Joined: Fri Jan 07, 2011 8:01 am Posts: 6211 Location: In your office, earning your salary.
				 
				 
			 | 
			
				
				  Re: About attachables  
					
						Code: function Update(self)    local actor    for actor in MovableMan.Actors do        if (actor.Pos-self.Pos).Magnitude < 100 then          for i = 1, MovableMan:GetMOIDCount() - 1 do             if MovableMan:GetMOFromID(i).RootID == actor.ID and i ~= actor.ID then                local att = MovableMan:GetMOFromID(i)                     if att.PresetName ~= "Gas Mask" then                    actor.Health = actor.Health - 1                 end             end          end       end    end end
 
  Got it. Did some slight modifications, would it work?  
					
  
			 | 
		
		
			| Wed Apr 20, 2011 8:04 pm | 
			
				
					 
					
					 
				  
			 | 
    	
		
	
	
		  | 
	
	
			| 
				
				 zoidberg 
				
				
					 Joined: Fri Feb 25, 2011 3:52 pm Posts: 39
				 
				 
			 | 
			
				
				  Re: About attachables  
					
						yeah, i think it's right code still, you'd better test it and post the results (cause i don't want to do it >:3) 
					
  
			 | 
		
		
			| Wed Apr 20, 2011 8:44 pm | 
			
				
					 
					
					 
				  
			 | 
    	
		
	
	
		  | 
	
	
			| 
				
				 carriontrooper 
				
				
					 Joined: Mon Apr 13, 2009 12:27 pm Posts: 813 Location: Yogyakarta, Indonesia. A slice o' paradise.
				 
				 
			 | 
			
				
				  Re: About attachables  
					
						Somehow I get a feeling that script's gonna go and deduct 1 HP for every non-gas mask attachable attached to the actor.
  What if you check if the actor has a gas mask or not, then applying damage to the actors not wearing gas mask?
  So it'll go like this: -check if there's an actor within 100 pix -check if actor do not have any attachables with 'gas mask' in its name -if actor does not have gas mask then do damage
  test your code first. I think it will do wonky stuff. 
					
  
			 | 
		
		
			| Fri Apr 22, 2011 6:49 am | 
			
				
					 
					
					 
				      
			 | 
    	
		
	
	
		  | 
	
	
			| 
				
				 Asklar 
				Data Realms Elite 
				
					 Joined: Fri Jan 07, 2011 8:01 am Posts: 6211 Location: In your office, earning your salary.
				 
				 
			 | 
			
				
				  Re: About attachables  
					
						FUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU- I don't know how or when, my mod got deleted!!!  I'll have to check if I have any back-ups on my mail or something. CRAAAAAAAAAAAAAP!!!!!!!!!!!! 
					
  
			 | 
		
		
			| Fri Apr 22, 2011 6:58 am | 
			
				
					 
					
					 
				  
			 | 
    	
		
	
	
		  | 
	
	
			| 
				
				 zoidberg 
				
				
					 Joined: Fri Feb 25, 2011 3:52 pm Posts: 39
				 
				 
			 | 
			
				
				  Re: About attachables  
					
						Code: function Update(self)    local actor    for actor in MovableMan.Actors do       if (actor.Pos-self.Pos).Magnitude < 100 then          local check = false          for i = 1, MovableMan:GetMOIDCount() - 1 do             if MovableMan:GetMOFromID(i).RootID == actor.ID and i ~= actor.ID then                local att = MovableMan:GetMOFromID(i)                if att.PresetName == "Gas Mask" then                    check = true                end             end          end          if not check then             actor:AddHealth(-1)          end       end    end end
  ^ that should work good carriontrooper, thanks  
					
  
			 | 
		
		
			| Fri Apr 22, 2011 12:58 pm | 
			
				
					 
					
					 
				  
			 | 
    	
		
	
	
		  | 
	
	
	
		 |