View unanswered posts | View active topics It is currently Sat Mar 30, 2024 12:36 am



Reply to topic  [ 5 posts ] 
 How to get parent 
Author Message

Joined: Fri Aug 03, 2012 1:59 am
Posts: 9
Reply with quote
Post How to get parent
I have a TDExplosive I am making, and I want it to get a reference to whoever is holding it, if at all. How can I do that?

Thanks :grin:


Wed Aug 08, 2012 6:53 pm
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Tue May 25, 2010 8:27 pm
Posts: 4521
Location: Constant motion
Reply with quote
Post Re: How to get parent
Code:
MovableMan:GetMOFromID(self.RootID)
You'll need to add in occasions for when there is no actor holding it though.


Wed Aug 08, 2012 6:56 pm
Profile

Joined: Fri Aug 03, 2012 1:59 am
Posts: 9
Reply with quote
Post Re: How to get parent
What would I need to do? How do I get the ID of self? I'd assume you would check if self.RootID is equal to your own ID.

Edit: Nevermind, found the documentation! :D

Edit 2: No! D:
It doesn't work. This code, in Update, just says 255 as the ID and the RootID, no matter what circumstances, or how many of the item there are:
Code:
   print("ID: "..self.ID .. "     Root: "..self.RootID)
   if self.ID ~= self.RootID then
      self.ParentActor = ToActor(MovableMan:GetMOFromID(self.RootID))
      self.FutureTeam = self.ParentActor.Team
   end

(I'm trying to find the team of the actor holding the TDExplosive)


Wed Aug 08, 2012 7:36 pm
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13143
Location: Here
Reply with quote
Post Re: How to get parent
If your TDExplosive is GetsHitByMOs = 0, then it will always report its RootID and its own ID as 255.

If an ID is 255, that means the object either doesn't exist any more or is GetsHitByMOs = 0.


Wed Aug 08, 2012 9:25 pm
Profile

Joined: Fri Aug 03, 2012 1:59 am
Posts: 9
Reply with quote
Post Re: How to get parent
CaveCricket48 wrote:
If your TDExplosive is GetsHitByMOs = 0, then it will always report its RootID and its own ID as 255.

If an ID is 255, that means the object either doesn't exist any more or is GetsHitByMOs = 0.

Okay, I understand now. I think I have this figured out.


Wed Aug 08, 2012 9:38 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 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.057s | 15 Queries | GZIP : Off ]