Data Realms Fan Forums
http://45.55.195.193/

Error regarding AEmitters being spawned
http://45.55.195.193/viewtopic.php?f=73&t=16368
Page 1 of 1

Author:  Shook [ Thu Aug 27, 2009 2:30 pm ]
Post subject:  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)

Author:  MaximDude [ Thu Aug 27, 2009 2:38 pm ]
Post subject:  Re: Error regarding AEmitters being spawned

Try

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

Author:  piipu [ Thu Aug 27, 2009 2:49 pm ]
Post subject:  Re: Error regarding AEmitters being spawned

Or rather add emitter = nil before the emitter = CreateAEmitter("Bullet Effects"); line.

Author:  Shook [ Thu Aug 27, 2009 4:11 pm ]
Post subject:  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. :)

Author:  Areku [ Thu Aug 27, 2009 9:51 pm ]
Post subject:  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.

Author:  Shook [ Fri Aug 28, 2009 1:38 pm ]
Post subject:  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.

Author:  Grif [ Fri Aug 28, 2009 2:45 pm ]
Post subject:  Re: Error regarding AEmitters being spawned

Alternately, just use locals for spawning, it's more efficient.

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