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

Accessing attached emitters
http://forums.datarealms.com/viewtopic.php?f=73&t=25307
Page 1 of 1

Author:  MaximDude [ Wed Aug 24, 2011 7:24 pm ]
Post subject:  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...

Author:  CaveCricket48 [ Wed Aug 24, 2011 8:33 pm ]
Post subject:  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.

Author:  MaximDude [ Wed Aug 24, 2011 10:11 pm ]
Post subject:  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.

Author:  CaveCricket48 [ Thu Aug 25, 2011 1:24 am ]
Post subject:  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

Author:  MaximDude [ Mon Sep 12, 2011 7:53 pm ]
Post subject:  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?

Author:  CaveCricket48 [ Mon Sep 12, 2011 8:28 pm ]
Post subject:  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.

Author:  MaximDude [ Mon Sep 12, 2011 10:03 pm ]
Post subject:  Re: Accessing attached emitters

Yeah, but it is GHBM = 1, that's the issue...
About the pointer blah blah, no idea what and how... :/

Author:  CaveCricket48 [ Mon Sep 12, 2011 10:31 pm ]
Post subject:  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.

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