| Author | Message | 
        
			| Coops 
					Joined: Wed Feb 17, 2010 12:07 am
 Posts: 1545
 Location: That small peaceful place called Hell.
   |   Pointer to AttachablesIs there any known way to find an attachable when its not the scripted object? I added this script to the Coalition Heavy: Code: function Update(self)for attachable in MovableMan.Particles do
 if attachable.ClassName == "Attachable" then
 if attachable:IsAttached() then
 print(attachable.PresetName)
 end
 end
 end
 end
 
I start a skirmish and nothing shows up in the console, ever. Is there something I'm missing or is this currently impossible? EDIT: It seemed to have passed the ClassName check but then it tells me that ::IsAttached() isnt a function.
 
 | 
		
			| Fri Aug 05, 2011 11:23 am | 
					
					   | 
	
	
		|  | 
	
			| Abdul Alhazred DRL Developer 
					Joined: Tue Aug 11, 2009 5:09 am
 Posts: 395
   |   Re: Pointer to AttachablesOnly for AHumans. Look at the documentation under Properties: TFM wrote: HeadRead-only property. The head AttachableA pointer to the head Attachable of this. Ownership is NOT transferred!
 
 FGArm
 Read-only property. The FG Arm as an Attachable. This is for Lua binding mostly.A pointer to the FG Arm Attachable of this. Ownership is NOT transferred!
 
 BGArm
 Read-only property. The BG Arm as an Attachable. This is for Lua binding mostly.A pointer to the BG Arm Attachable of this. Ownership is NOT transferred!
 
 FGLeg
 Read-only property. The FG Leg as an Attachable. This is for Lua binding mostly.A pointer to the FG Leg Attachable of this. Ownership is NOT transferred!
 
 BGLeg
 Read-only property. The BG Leg as an Attachable. This is for Lua binding mostly.A pointer to the BG Leg Attachable of this. Ownership is NOT transferred!
 
 EquippedItem
 Read-only property. Returns whatever is equipped in the FG Arm, if anything. OINT.The currently equipped item, if any.
 
 
 | 
		
			| Fri Aug 05, 2011 12:09 pm | 
					
					   | 
	
	
		|  | 
	
			| Coops 
					Joined: Wed Feb 17, 2010 12:07 am
 Posts: 1545
 Location: That small peaceful place called Hell.
   |   Re: Pointer to AttachablesThat seems a little redundant.
 Why would we have seperate functions for something thats only meant for actors?
 
 
 | 
		
			| Fri Aug 05, 2011 12:24 pm | 
					
					   | 
	
	
		|  | 
	
			| Abdul Alhazred DRL Developer 
					Joined: Tue Aug 11, 2009 5:09 am
 Posts: 395
   |   Re: Pointer to AttachablesI'm not sure what you are trying to do, but if you wanted to find the head of the AHuman "TargetActor" in B24 you would have to use one of Mail's tricks: Code:    local MoObjfor i = 1, MovableMan:GetMOIDCount()-1 do
 if MovableMan:GetRootMOID(i) == TargetActor.ID then -- this MO has a root ID so we know it is an attachable. and it belongs to TargetActor since the IDs match
 MoObj = MovableMan:GetMOFromID(i)
 if MoObj.PresetName == "The Name of the Head" then
 self.Head = ToAttachable(MoObj)
 break
 end
 end
 end
Now you can just do this:
 
 | 
		
			| Fri Aug 05, 2011 12:48 pm | 
					
					   | 
	
	
		|  | 
	
			| Coops 
					Joined: Wed Feb 17, 2010 12:07 am
 Posts: 1545
 Location: That small peaceful place called Hell.
   |   Re: Pointer to AttachablesWell its useful for actors but only actors, I was hoping for the attachable functions to work with Chestplates or Helmets and whatnot. 
 
 | 
		
			| Fri Aug 05, 2011 12:57 pm | 
					
					   | 
	
	
		|  | 
	
			| Abdul Alhazred DRL Developer 
					Joined: Tue Aug 11, 2009 5:09 am
 Posts: 395
   |   Re: Pointer to AttachablesIf the attachable is a Movable Object with GetsHitByMOs set to 1 you can still use Mail's method described above. 
 
 | 
		
			| Fri Aug 05, 2011 1:38 pm | 
					
					   | 
	
	
		|  | 
	
			| Coops 
					Joined: Wed Feb 17, 2010 12:07 am
 Posts: 1545
 Location: That small peaceful place called Hell.
   |   Re: Pointer to AttachablesI'm talking about these.Those functions dont work with any kind of MO. Only the AHuman's, it seems. 
 
 | 
		
			| Fri Aug 05, 2011 1:41 pm | 
					
					   | 
	
	
		|  | 
	
			| Abdul Alhazred DRL Developer 
					Joined: Tue Aug 11, 2009 5:09 am
 Posts: 395
   |   Re: Pointer to AttachablesIt is probably because you have the wrong pointer type. Try casting the pointer before you try to access those functions: Code: -- find the attachable and store it in "Armor"...
 if Armor.ClassName == "Attachable" then
 Armor = ToAttachable(Armor)
 Armor:Detach() -- should work now
 end
 
 
 | 
		
			| Fri Aug 05, 2011 2:36 pm | 
					
					   | 
	
	
		|  | 
	
			| Coops 
					Joined: Wed Feb 17, 2010 12:07 am
 Posts: 1545
 Location: That small peaceful place called Hell.
   |   Re: Pointer to AttachablesNope, 
 unless the attachable is not attached to anything then it picks it up, if it is attached, then nothing.
 
 
 | 
		
			| Fri Aug 05, 2011 2:46 pm | 
					
					   | 
	
	
		|  | 
	
			| Abdul Alhazred DRL Developer 
					Joined: Tue Aug 11, 2009 5:09 am
 Posts: 395
   |   Re: Pointer to AttachablesAttach this to a Coalition "Soldier Light". Code: function Create(self)local MoObj
 for i = 1, MovableMan:GetMOIDCount()-1 do
 if MovableMan:GetRootMOID(i) == self.ID then
 MoObj = MovableMan:GetMOFromID(i)
 if MoObj.PresetName == "Soldier Helmet A" then
 self.Helmet = ToAttachable(MoObj)
 break
 end
 end
 end
 end
 
 function Update(self)
 if self.Helmet then
 if self.Helmet:IsAttached() then   -- check if the pointer is safe to access
 self.Helmet:Detach()
 else
 self.Helmet = nil
 end
 end
 end
 
 
 | 
		
			| Fri Aug 05, 2011 4:13 pm | 
					
					   | 
	
	
		|  | 
	
			| Coops 
					Joined: Wed Feb 17, 2010 12:07 am
 Posts: 1545
 Location: That small peaceful place called Hell.
   |   Re: Pointer to AttachablesThat does work.
 Looking at that script I think I didn't get it to work is because I did it all in one frame update, or attachables are not listed in MovableMan.Particles.
 
 Anyhow, thanks for your help. I'll be playing around with this some more to see what works and what doesn't.
 
 
 | 
		
			| Fri Aug 05, 2011 4:24 pm | 
					
					   | 
	
	
		|  | 
	
	
		|  |