Data Realms Fan Forums
http://45.55.195.193/

Lua trails?
http://45.55.195.193/viewtopic.php?f=73&t=16094
Page 1 of 5

Author:  MaximDude [ Mon Aug 03, 2009 6:32 pm ]
Post subject:  Lua trails?

So, i'm trying to add a trail to a MOPixel using lua, but, i'm failing. >_____>'

First, I tried directly creating the trail particle
Code:
   local trail = nil;
   trail = CreateMOPixel("trail name");
   trail.Pos.X = self.Pos.X;
   trail.Pos.Y = self.Pos.Y;
   MovableMan:AddParticle(trail);

No trail was seen and it lagged bigtime.

Then I tried attaching an AEmitter to the MOPixel to emit the trail particles
Code:
function Create(self)
   self.trail = CreateAEmitter("trail name","mod.rte");
   self.trail.Pos = Vector(self.Pos.X,self.Pos.Y);
   self.trail.Vel = self.Vel;
   MovableMan:AddParticle(self.trail);
end

function Update(self)
   if MovableMan:IsParticle(self.trail) == true then
      self.trail.Pos = Vector(self.Pos.X,self.Pos.Y);
      self.trail.Vel = self.Vel;
   end
end

Again, no trail was seen but it didn't lag

What am I doing wrong?

Author:  Mind [ Mon Aug 03, 2009 7:46 pm ]
Post subject:  Re: Lua trails?

Okay, MaximDude. I actually had this problem, but here's what you would do.

In Create
Code:
self.aemitter = CreateAEmitter("Blah");
self.aemitter.Pos = self.Pos
self.aemitter.Vel = self.Vel
MovableMan:AddParticle(self.aemitter);



In Update.
Code:
self.aemitter.Vel = self.Vel
self.aemitter.Pos = self.Pos


Really should work

Worked for me :3

Author:  MaximDude [ Mon Aug 03, 2009 8:31 pm ]
Post subject:  Re: Lua trails?

Still no go...
I suspect that it is me doing something wrong...

My AE was an AddAmmo AE, I changed it to an AddEffect AE, but it still doesn't show...

And my CC becaue really crashy for some reason... >_________>'
I'll have to look into this.

Thanks anyway.

Author:  robolee [ Mon Aug 03, 2009 8:53 pm ]
Post subject:  Re: Lua trails?

first of all you are adding it to the exact same place as the original particle, so it may actually be workin but it's just behind the other one, try adding this:

if (self.Vel.X > 0.1) then trail.Pos.X = trail.Pos.X + 1; end
if (self.Vel.X < -0.1) then trail.Pos.X = trail.Pos.X - 1; end
if (self.Vel.Y > 0.1) then trail.Pos.Y = trail.Pos.X + 1; end
if (self.Vel.Y < -0.1) then trail.Pos.Y = trail.Pos.X - 1; end
(note I don't use 0 because it's very unlikely it's ever going to be exactly 0)

Also, adding things to the scene with lua has been problematic with me so yeah, if that doesn't fix it it's a problem with how you are adding it

Author:  MaximDude [ Mon Aug 03, 2009 9:05 pm ]
Post subject:  Re: Lua trails?

robolee wrote:
first of all you are adding it to the exact same place as the original particle, so it may actually be workin but it's just behind the other one, try adding this:


The particle being created has PinStrength, so its supposed to stay behind the particle while it moves forwards.

In the 2nd code, I attached an AEmitter to the particle. Again, particles emitted from it would always stay behind.

Quote:
Also, adding things to the scene with lua has been problematic with me so yeah, if that doesn't fix it it's a problem with how you are adding it


It most likely is.

Emitters should be able to be attached to MOPixels. I see no reason why not.
It would make the proces of pretty glow trail creation alot easier.

I wonder if I can add sharpness to an AE... Then i'd use it directly.

Author:  MaximDude [ Mon Aug 03, 2009 9:37 pm ]
Post subject:  Re: Lua trails?

I, am a ♥♥♥♥ idiot.
All this time, the LifeTime on the glow particle was set to 10... It was meant to be 1000....
Everything worked just fine from the very beginning... I just couldn't see the result...

/doublefacepalm

Thread can be closed now. :roll:

Author:  robolee [ Mon Aug 03, 2009 9:53 pm ]
Post subject:  Re: Lua trails?

I see it's just that you were adding the velocity of the particle to the trail particle and in update you were updating the position of the trail particle to match with the leading particle, and I thought you were after some kind of trail flowing behind it rather than a static trail. You usually find the problem lies within the annoying little things like that :P

Author:  MaximDude [ Mon Aug 03, 2009 10:14 pm ]
Post subject:  Re: Lua trails?

robolee wrote:
I thought you were after some kind of trail flowing behind it rather than a static trail. You usually find the problem lies within the annoying little things like that :P


Actually, I am trying to do that.
A nice glowy trail behind it, but, it doesn't quite work because of the particle's speed is too high. So its just blobs at equal intervals.

Author:  Mind [ Mon Aug 03, 2009 10:17 pm ]
Post subject:  Re: Lua trails?

Uh can I see the glows and um aemitter's code? Just the part where it is emitting the glow and the whole glow code. :3

Author:  MaximDude [ Tue Aug 04, 2009 3:37 pm ]
Post subject:  Re: Lua trails?

Mind wrote:
Uh can I see the glows and um aemitter's code? Just the part where it is emitting the glow and the whole glow code. :3


Why would you need that?
Its a regular MOPixel with ScreenEffect and an AddEffect AEmitter emitting that pixel.
The script is attached to a round.

Author:  Areku [ Tue Aug 04, 2009 10:14 pm ]
Post subject:  Re: Lua trails?

Well, how about this:

Code:
function Create(self)
   self.timer = Timer();
   trail = CreateMOPixel("Plasma Cutter Trail","Apollocalipse.rte");
   
end


function Update(self)


   if self.timer:IsPastSimMS(10) == true then
      self.timer:Reset();   
      trail = CreateMOPixel("Plasma Cutter Trail","Apollocalipse.rte");
      trail.Pos = self.Pos;            
      MovableMan:AddParticle(trail);
   end      
end


It's what I used for a laser gun I made yesterday. Doesn't lag at all. Here's the effect it creates:

Attachments:
File comment: The effect.
lasergun.png
lasergun.png [ 179.65 KiB | Viewed 5340 times ]

Author:  MaximDude [ Wed Aug 05, 2009 3:31 am ]
Post subject:  Re: Lua trails?

My code works too, and the result is the same.
Though, I wanted it to be more like •••••• then • • • • • •, but that really depends on the speed of the round.

Author:  Mind [ Wed Aug 05, 2009 5:06 am ]
Post subject:  Re: Lua trails?

And how short you make the timer.

Author:  MaximDude [ Wed Aug 05, 2009 2:40 pm ]
Post subject:  Re: Lua trails?

Mind wrote:
And how short you make the timer.


0/1 sim MS.
And still, • • • • • • and not ••••••••.

Author:  Mind [ Wed Aug 05, 2009 9:51 pm ]
Post subject:  Re: Lua trails?

How fast are you shooting the bullet?

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