View unanswered posts | View active topics It is currently Sat Apr 20, 2019 9:47 am



Reply to topic  [ 49 posts ]  Go to page 1, 2, 3, 4  Next
 Detached attachables being deleted 
Author Message
User avatar

Joined: Wed Nov 22, 2006 3:19 pm
Posts: 2070
Reply with quote
Post 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?


Fri Jun 11, 2010 8:06 pm
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 11008
Location: Here
Reply with quote
Post 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.


Fri Jun 11, 2010 8:47 pm
Profile
User avatar

Joined: Wed Nov 22, 2006 3:19 pm
Posts: 2070
Reply with quote
Post 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.


Fri Jun 11, 2010 9:08 pm
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 11008
Location: Here
Reply with quote
Post Re: Detached attachables being deleted
Just do a psuedo attachable then, I'm not sure what's wrong.


Fri Jun 11, 2010 9:39 pm
Profile
User avatar

Joined: Wed Nov 22, 2006 3:19 pm
Posts: 2070
Reply with quote
Post 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)...


Fri Jun 11, 2010 9:53 pm
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 11008
Location: Here
Reply with quote
Post 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.


Fri Jun 11, 2010 9:59 pm
Profile
User avatar

Joined: Wed Nov 22, 2006 3:19 pm
Posts: 2070
Reply with quote
Post 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...


Fri Jun 11, 2010 10:42 pm
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 11008
Location: Here
Reply with quote
Post Re: Detached attachables being deleted
Lua-applied velocity has pretty much zero effect on attachables. You'll have to use impulse-applying functions.


Fri Jun 11, 2010 10:47 pm
Profile
User avatar

Joined: Wed Nov 22, 2006 3:19 pm
Posts: 2070
Reply with quote
Post 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.


Fri Jun 11, 2010 10:51 pm
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 11008
Location: Here
Reply with quote
Post 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.



Fri Jun 11, 2010 10:55 pm
Profile
User avatar

Joined: Wed Nov 22, 2006 3:19 pm
Posts: 2070
Reply with quote
Post 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.


Last edited by MaximDude on Fri Jun 11, 2010 10:59 pm, edited 2 times in total.



Fri Jun 11, 2010 10:58 pm
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 11008
Location: Here
Reply with quote
Post Re: Detached attachables being deleted
Oh, I thought you were trying to simulate thrust via Lua.


Fri Jun 11, 2010 10:59 pm
Profile
User avatar

Joined: Wed Nov 22, 2006 3:19 pm
Posts: 2070
Reply with quote
Post 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.


Fri Jun 11, 2010 11:25 pm
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 11008
Location: Here
Reply with quote
Post Re: Detached attachables being deleted
Post/pastebin your script.


Fri Jun 11, 2010 11:56 pm
Profile
User avatar

Joined: Wed Nov 22, 2006 3:19 pm
Posts: 2070
Reply with quote
Post 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 ♥♥♥♥♥.


Sat Jun 12, 2010 1:02 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 49 posts ]  Go to page 1, 2, 3, 4  Next

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.019s | 13 Queries | GZIP : Off ]