Data Realms Fan Forums
http://45.55.195.193/

Gibbing self after slowing down into a set speed
http://45.55.195.193/viewtopic.php?f=73&t=21646
Page 1 of 1

Author:  Asklar [ Fri Mar 04, 2011 9:34 pm ]
Post subject:  Gibbing self after slowing down into a set speed

I want to gib an object if it's speed gets reduced a lot, how could I do it?

Until now my code looks like this:

Code:
function Update(self)

 if self.Vel < (5,5) or self.Vel < (-5,-5) or self.Vel < (5,-5) or self.Vel < (-5,5) then
      self:GibThis();
 end
end


But it's not working.

Author:  Roast Veg [ Fri Mar 04, 2011 9:36 pm ]
Post subject:  Re: Gibbing self after slowing down into a set speed

Code:
function Update(self)
    if self.Vel.Magnitude <= 25 or self.Vel.Magnitude >= -25 then
        self:GibThis()
    end
end

Author:  Asklar [ Fri Mar 04, 2011 9:41 pm ]
Post subject:  Re: Gibbing self after slowing down into a set speed

Thanks, that worked perfectly.

Edit: Wait a second, not so perfectly.
The lua console give me this error:
Attempt to call method "GibThis" (a nil value)

What's wrong then?

Author:  Roast Veg [ Fri Mar 04, 2011 9:47 pm ]
Post subject:  Re: Gibbing self after slowing down into a set speed

Try putting a semicolon (;) after gibthis.

Author:  Asklar [ Fri Mar 04, 2011 9:47 pm ]
Post subject:  Re: Gibbing self after slowing down into a set speed

Still, same error.

Author:  Roast Veg [ Fri Mar 04, 2011 9:52 pm ]
Post subject:  Re: Gibbing self after slowing down into a set speed

Is the thing actually being destroyed? If so then it could be that it's calling an update or two before actually disappearing.

If not then try:
Code:
function Update(self)
    if self.Vel.Magnitude <= 25 and self.ToDelete ~= true then
        self:GibThis()
    end
end]


EDIT: DERP ME, try this instead. Thank you CaveCricket48.

Author:  Asklar [ Fri Mar 04, 2011 9:57 pm ]
Post subject:  Re: Gibbing self after slowing down into a set speed

I keep getting the same error.

I placed a function on it when it is destroyed, so I can recognize that the particle is actually gibbing, but after it's lifetime rather than after reducing its speed.

Author:  Roast Veg [ Fri Mar 04, 2011 10:07 pm ]
Post subject:  Re: Gibbing self after slowing down into a set speed

What is your object? It sounds like it cannot gib anyway. Set:
Code:
self.ToDelete = true;
instead.

Author:  Asklar [ Fri Mar 04, 2011 10:13 pm ]
Post subject:  Re: Gibbing self after slowing down into a set speed

A mo pixel.

Now I realized I'm an idiot =D MOPixels don't gib :cclol:

Thanks.
A lot.

Author:  Roast Veg [ Fri Mar 04, 2011 10:31 pm ]
Post subject:  Re: Gibbing self after slowing down into a set speed

You can make it look like they gibbed by creating object in the destroy function.

Author:  Asklar [ Fri Mar 04, 2011 10:35 pm ]
Post subject:  Re: Gibbing self after slowing down into a set speed

Yep, that was what I did.

You see, I've seen some explosive round codes, and they all looked fairly the same to me.

So I decided to create my own because of 2 reasons:
1) Learning, progresing, tried to make something "different" in my own way.
2) I didn't want to ask anyone for his code.

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