View unanswered posts | View active topics It is currently Fri Dec 27, 2024 11:06 pm



Reply to topic  [ 7 posts ] 
 Error regarding AEmitters being spawned 
Author Message
User avatar

Joined: Fri Feb 16, 2007 8:43 pm
Posts: 1695
Location: AH SHIT FUCK AUGH
Reply with quote
Post Error regarding AEmitters being spawned
Well, the error message looks like this:

Image

And the code that causes it looks like this:

Code:
function Create(self)
   self.lifeTimer = Timer();
end

function Destroy(self)
   if self.lifeTimer:IsPastSimMS(950) == false then
      emitter = CreateAEmitter("Bullet Effects");
      emitter.Pos.X = self.Pos.X;
      emitter.Pos.Y = self.Pos.Y;
      local totalVelocity = math.sqrt(self.Vel.X^2 + self.Vel.Y^2);
      local flightAngle = math.asin(self.Vel.Y / totalVelocity);
      emitter.RotAngle = flightAngle + math.pi;
      MovableMan:AddParticle(emitter);
   end
end

Also worth noting is that there are up to 24 instances of that code being run at the same time. The error doesn't seem to make the code malfunction, but i'm pretty sure it could end up lagging the game, as well as clogging up the Lua console.

Any idea on how to fix? (I guess it'd have something to do with making each emitter unique or something)


Thu Aug 27, 2009 2:30 pm
Profile WWW
User avatar

Joined: Wed Nov 22, 2006 3:19 pm
Posts: 2073
Reply with quote
Post Re: Error regarding AEmitters being spawned
Try

Code:
emitter = CreateAEmitter("Bullet Effects","yourRTEname.rte");


Thu Aug 27, 2009 2:38 pm
Profile
User avatar

Joined: Mon Jun 30, 2008 9:13 pm
Posts: 499
Location: Finland
Reply with quote
Post Re: Error regarding AEmitters being spawned
Or rather add emitter = nil before the emitter = CreateAEmitter("Bullet Effects"); line.


Thu Aug 27, 2009 2:49 pm
Profile
User avatar

Joined: Fri Feb 16, 2007 8:43 pm
Posts: 1695
Location: AH SHIT FUCK AUGH
Reply with quote
Post Re: Error regarding AEmitters being spawned
None of them works on their own, but i fixed it partly with Piipu's solution, so now the code looks like this:

Code:
function Create(self)
   self.lifeTimer = Timer();
end

function Destroy(self)
   if self.lifeTimer:IsPastSimMS(350) == false then
      emitter2 = nil;
      if emitter2 ~= CreateAEmitter("Bullet Effects") then
         emitter2 = CreateAEmitter("Bullet Effects");
      end
      emitter2.Pos.X = self.Pos.X;
      emitter2.Pos.Y = self.Pos.Y;
      local totalVelocity = math.sqrt(self.Vel.X^2 + self.Vel.Y^2);
      local flightAngle = math.asin(self.Vel.Y / totalVelocity);
      emitter2.RotAngle = flightAngle + math.pi;
      MovableMan:AddParticle(emitter2);
   end
end

Thanks for your help, guys. :)


Thu Aug 27, 2009 4:11 pm
Profile WWW
User avatar

Joined: Fri Oct 17, 2008 9:46 pm
Posts: 5212
Location: The Grills Locker.
Reply with quote
Post Re: Error regarding AEmitters being spawned
I've run into that error a few times. Just replace "emitter2" with "self.emitter2", and it should work.


Thu Aug 27, 2009 9:51 pm
Profile WWW
User avatar

Joined: Fri Feb 16, 2007 8:43 pm
Posts: 1695
Location: AH SHIT FUCK AUGH
Reply with quote
Post Re: Error regarding AEmitters being spawned
Odd, that didn't work before, but it does now.

>.>

Thanks. I guess my coding must've been extra shoddy at the time i tried.


Fri Aug 28, 2009 1:38 pm
Profile WWW
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: Error regarding AEmitters being spawned
Alternately, just use locals for spawning, it's more efficient.


Fri Aug 28, 2009 2:45 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 7 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.032s | 17 Queries | GZIP : Off ]