View unanswered posts | View active topics It is currently Tue Apr 16, 2024 9:23 am



Reply to topic  [ 4 posts ] 
 Attachable help 
Author Message
User avatar

Joined: Tue Aug 09, 2011 11:43 am
Posts: 7
Reply with quote
Post Attachable help
How to detect if the device is active from the attachable attached to it?


Wed Aug 10, 2011 11:33 pm
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13143
Location: Here
Reply with quote
Post Re: Attachable help
Not exactly sure what you're asking for.

To check if a device is firing (active), use HDFirearm:IsActivated().


Thu Aug 11, 2011 2:35 am
Profile
User avatar

Joined: Tue Aug 09, 2011 11:43 am
Posts: 7
Reply with quote
Post Re: Attachable help
Let me try again..

So I have a device (TDExplosive), with an attachable attached to it. How can I detect if the device is activated from the attachable?

Tried it like this:
Code:
function Update(self)
   if (self:GetParent()):IsActivated() then
      self:Detach()
   end
end   

and various other ways, but always get error spam in my Lua console.


Thu Aug 11, 2011 1:43 pm
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13143
Location: Here
Reply with quote
Post Re: Attachable help
Try this:
Code:
function Update(self)
   for i = 1, MovableMan:GetMOIDCount()-1 do
      local part = MovableMan:GetMOFromID(i)
      if part.RootID == self.RootID and part.PresetName == "Some Explosive" and ToTDExplosive(part):IsActivated() then
         self:Detach();
         break;
      end
   end
end


Thu Aug 11, 2011 6:20 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

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.117s | 16 Queries | GZIP : Off ]