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

Detached attachables being deleted
http://forums.datarealms.com/viewtopic.php?f=73&t=18968
Page 1 of 4

Author:  MaximDude [ Fri Jun 11, 2010 8:06 pm ]
Post subject:  Detached attachables being deleted

I've been making a dropship with a detachable piece on it, but it seems that when using 'Detach()' the detached object is automatically deleted (Having 'ToDelete = false' doesn't work).
So, is there a way to disable this deletion?

Author:  CaveCricket48 [ Fri Jun 11, 2010 8:47 pm ]
Post subject:  Re: Detached attachables being deleted

What is the attached object suppposed to do? You could always make it Lua attached. Also check to see if your attachable is accidentally gibbing, maybe it's not being deleted.

Author:  MaximDude [ Fri Jun 11, 2010 9:08 pm ]
Post subject:  Re: Detached attachables being deleted

CaveCricket48 wrote:
What is the attached object suppposed to do? You could always make it Lua attached. Also check to see if your attachable is accidentally gibbing, maybe it's not being deleted.


The attachable acts as a wing for an extra engine, and no, it isn't gibbing (It has all sorts of junk that should come out but it doesn't, its a clean disappearance).
The attached wing already has an attached engine to it and it gets deleted together with it. I just need it to fall down with the engine.

Author:  CaveCricket48 [ Fri Jun 11, 2010 9:39 pm ]
Post subject:  Re: Detached attachables being deleted

Just do a psuedo attachable then, I'm not sure what's wrong.

Author:  MaximDude [ Fri Jun 11, 2010 9:53 pm ]
Post subject:  Re: Detached attachables being deleted

Eh... Screw that.
Well, that covers that issue, now, something else I encountered.

How the hell am I to access a dropship's engine and get it's 'RotAngle'?
I can't seem to get it working directly (Without having another object/etc to do a distance check and then do all that BS to access it)...

Author:  CaveCricket48 [ Fri Jun 11, 2010 9:59 pm ]
Post subject:  Re: Detached attachables being deleted

Check if the engine's RootID is the craft's ID.

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


Edit: Do that in the Create() function, and then store the "part" in a pointer to access later.

Author:  MaximDude [ Fri Jun 11, 2010 10:42 pm ]
Post subject:  Re: Detached attachables being deleted

Hmmm... What i'm trying to do isn't really working... Yeah...

I'm trying to take that RotAngle reading from the jets and applying it to the extra jets (Basically a quad-jet DS with all engines used for steering), but there's no effect...
No errors though...

Author:  CaveCricket48 [ Fri Jun 11, 2010 10:47 pm ]
Post subject:  Re: Detached attachables being deleted

Lua-applied velocity has pretty much zero effect on attachables. You'll have to use impulse-applying functions.

Author:  MaximDude [ Fri Jun 11, 2010 10:51 pm ]
Post subject:  Re: Detached attachables being deleted

CaveCricket48 wrote:
Lua-applied velocity has pretty much zero effect on attachables. You'll have to use impulse-applying functions.

Wut?
Explain please.

Author:  CaveCricket48 [ Fri Jun 11, 2010 10:55 pm ]
Post subject:  Re: Detached attachables being deleted

Changing the velocity of an attachable has little to no effect.

Use this:
Code:
AddAbsImpulseForce
Adds impulse force (or instant momentum) to this MovableObject for the next time Update() is called.

Arguments:

-An Vector with the impulse force vector that will directly be added to this MovableObject's momentum next Update(). In kg * m/s.
-A Vector with the absolute world coordinates, in PIXELS, of where the force is being applied to the center of this MovableObject.

Return value:

None.


Author:  MaximDude [ Fri Jun 11, 2010 10:58 pm ]
Post subject:  Re: Detached attachables being deleted

But i'm not trying to add velocity, i'm trying to change rotation angle...

Nevermind, I think I figured out how to get past this.
I'm gonna attach the engine to the wing via lua, then ♥♥♥♥ around with the rotation.

Author:  CaveCricket48 [ Fri Jun 11, 2010 10:59 pm ]
Post subject:  Re: Detached attachables being deleted

Oh, I thought you were trying to simulate thrust via Lua.

Author:  MaximDude [ Fri Jun 11, 2010 11:25 pm ]
Post subject:  Re: Detached attachables being deleted

CaveCricket48 wrote:
Oh, I thought you were trying to simulate thrust via Lua.

Ummm, nope.

Anyway, this is proving tougher than planned... I have a few more methods to try out, I just hope I get it working eventually.

Edit:

ARRGGHHHH!!!
My head hurts.
This is bull♥♥♥♥. I'm gonna take a break from this.

Author:  CaveCricket48 [ Fri Jun 11, 2010 11:56 pm ]
Post subject:  Re: Detached attachables being deleted

Post/pastebin your script.

Author:  MaximDude [ Sat Jun 12, 2010 1:02 pm ]
Post subject:  Re: Detached attachables being deleted

This is why I dislike lua attaching... Dammit...
Image

I have no idea how to make the jets follow the rotation of the DS as well as the rotation of the DS's jets...

Code:
function Create(self)
   self.secjetL = nil;
   self.secjetL = CreateAEmitter("Heavy Drop Ship Secondary Engine Left");
   self.secjetL.Pos.X = self.Pos.X - 100;
   self.secjetL.Pos.Y = self.Pos.Y + 4;
   MovableMan:AddParticle(self.secjetL);
   self.secjetR = nil;
   self.secjetR = CreateAEmitter("Heavy Drop Ship Secondary Engine Right");
   self.secjetR.Pos.X = self.Pos.X + 100;
   self.secjetR.Pos.Y = self.Pos.Y + 4;
   MovableMan:AddParticle(self.secjetR);
end

function Update(self)
   local curdist = 250;
   for secjets in MovableMan.Particles do
      local avgx = secjets.Pos.X - self.Pos.X;
      local avgy = secjets.Pos.Y - self.Pos.Y;
      local dist = math.sqrt(avgx ^ 2 + avgy ^ 2);
      if dist < curdist then
         if secjets.PresetName == "Heavy Drop Ship Secondary Engine Left" then
            self.secjetL.Pos.X = self.Pos.X - 100;
            self.secjetL.Pos.Y = self.Pos.Y + 4;
         elseif secjets.PresetName == "Heavy Drop Ship Secondary Engine Right" then
            self.secjetR.Pos.X = self.Pos.X + 100;
            self.secjetR.Pos.Y = self.Pos.Y + 4;
         end
      end
   end
   if (self:IsPlayerControlled()) and self:GetController():IsState(Controller.BODY_CROUCH) then
      self.Holding = 1;
   else
      self.Holding = nil;
   end
   if self.Holding == 1 then
      local detacher = nil;
      detacher = CreateMOPixel("Wing Detacher");
      detacher.Pos.X = self.Pos.X;
      detacher.Pos.Y = self.Pos.Y;
      MovableMan:AddParticle(detacher);
   end
end


My head hurts and I feel like ragequitting this ♥♥♥♥♥.

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