Data Realms Fan Forums
http://forums.datarealms.com/

Attachable help
http://forums.datarealms.com/viewtopic.php?f=73&t=25089
Page 1 of 1

Author:  teh someone [ Wed Aug 10, 2011 11:33 pm ]
Post subject:  Attachable help

How to detect if the device is active from the attachable attached to it?

Author:  Eigla [ Thu Aug 11, 2011 2:35 am ]
Post subject:  Re: Attachable help

Not exactly sure what you're asking for.

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

Author:  teh someone [ Thu Aug 11, 2011 1:43 pm ]
Post subject:  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.

Author:  Eigla [ Thu Aug 11, 2011 6:20 pm ]
Post subject:  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

Page 1 of 1 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/