View unanswered posts | View active topics It is currently Mon Dec 30, 2024 8:29 pm



Reply to topic  [ 8 posts ] 
 Accessing attached emitters 
Author Message
User avatar

Joined: Wed Nov 22, 2006 3:19 pm
Posts: 2073
Reply with quote
Post Accessing attached emitters
Recently got back to modding and all that and i'm really rusty, more than ever really.

Anyway, now with all the new lua shenanigans of B25, what I was trying to make back in B24 should work right, buuuuuut.... It doesn't, obviously, because I knew ♥♥♥♥ in lua back then, and I know even less now.

Soooooo.... How can one access an emitter that is attached to another attachable and mess around with it's RotAngle? If that's even possible...


Wed Aug 24, 2011 7:24 pm
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: Accessing attached emitters
First, the emitter has to have GetsHitByMOs = 1 if you want to be able to mess around with it. Then you just run through all MOIDs, find which one has the emitter's PresetName and has the RootID of your object, and then you have access to the emitter.


Wed Aug 24, 2011 8:33 pm
Profile
User avatar

Joined: Wed Nov 22, 2006 3:19 pm
Posts: 2073
Reply with quote
Post Re: Accessing attached emitters
Thus, something along the lines of:
Code:
for i = 1,MovableMan:GetMOIDCount()-1 do
   self.otherblah = MovableMan:GetMOFromID(i);
   if self.otherblah.PresetName == "otherblah" and self.otherblah.ClassName == "AEmitter" and self.otherblah.RootID == self.ID then
      for i = 1,MovableMan:GetMOIDCount()-1 do
         self.blah = MovableMan:GetMOFromID(i);
         if self.blah.PresetName == "blah" and self.blah.ClassName == "AEmitter" and self.blah.RootID == self.ID then
            self.blah.RotAngle = self.otherblah.RotAngle;
         end   
      end
   end   
end

'Blah' being the attached-to-attachable emitter, and 'otherblah' being another emitter that is attached to the parent.

If so, then strangely enough, it's a no go.
No errors in the console, but no effect either.


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

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: Accessing attached emitters
I don't see why you would need to check for the attachable.

Code:
   for i = 1, MovableMan:GetMOIDCount()-1 do
      local part = MovableMan:GetMOFromID(i);
      if part.PresetName == "Some Emitter Name" and part.ClassName == "AEmitter" and part.RootID == self.RootID then
         <stuff>
         break;
      end
   end


Thu Aug 25, 2011 1:24 am
Profile
User avatar

Joined: Wed Nov 22, 2006 3:19 pm
Posts: 2073
Reply with quote
Post Re: Accessing attached emitters
Seems that attached-to-attachable emitters do not have MOIDs (According to the MOID view).
Any other way to access them?


Mon Sep 12, 2011 7:53 pm
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: Accessing attached emitters
They're only accessible using MOID tricks if they're GetsHitByMOs = 1.
MaximDude wrote:
Any other way to access them?

You could have a script attached to the emitter that drops a pointer of it into a global table, and your main script can grab the emitter off of that.


Mon Sep 12, 2011 8:28 pm
Profile
User avatar

Joined: Wed Nov 22, 2006 3:19 pm
Posts: 2073
Reply with quote
Post Re: Accessing attached emitters
Yeah, but it is GHBM = 1, that's the issue...
About the pointer blah blah, no idea what and how... :/


Mon Sep 12, 2011 10:03 pm
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: Accessing attached emitters
So pretty much on your emitter, you have something like this:

Code:
function Create(self)

   if globalAttaTable == nil then
      globalAttaTable = {};
   end

   if self.RootID ~= self.ID then
      local secondaryAttaTable = {};
      secondaryAttaTable[1] = MovableMan:GetMOFromID(self.RootID);
      secondaryAttaTable[2] = self;
      globalAttaTable[#globalAttaTable+1] = secondaryAttaTable;
   end

end

And on your root body, you have this:
Code:
function Create(self)

   self.listNumTable = {};
   self.attaTable = {};

end

function Update(self)

   if self.grabbedAtta == nil then
      self.grabbedAtta = false;
   else
      if self.grabbedAtta == false then
         self.grabbedAtta = true;
         if globalAttaTable ~= nil then
            for i = 1, i < #globalAttaTable do
               if globalAttaTable[i][1] ~= nil and globalAttaTable[i][1].ID == self.ID then
                  self.attaTable[#self.attaTable+1] = globalAttaTable[i][2];
                  self.listNumTable[#self.listNumTable+1] = i;
               end
            end
         end

      end
   end

end

function Destroy(self)

   for i = 1, i < #self.listNumTable do
      globalAttaTable[self.listNumTable[i]][1] = nil;
      globalAttaTable[self.listNumTable[i]][2] = nil;
   end

end

All of the attached things should be in self.attaTable after the first frame the script has run (so that means do a check on the attachables before you try to access them).

Edit: Whoops, a few typos in there.


Mon Sep 12, 2011 10:31 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 8 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:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.038s | 15 Queries | GZIP : Off ]