View unanswered posts | View active topics It is currently Fri Dec 27, 2024 7:54 am



Reply to topic  [ 67 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next
 Lua trails? 
Author Message
User avatar

Joined: Wed Nov 22, 2006 3:19 pm
Posts: 2073
Reply with quote
Post Re: Lua trails?
It still gets fired upright. But now the trail changes direction when the particle hits something.


Sat Aug 08, 2009 11:24 am
Profile
User avatar

Joined: Fri May 11, 2007 4:30 pm
Posts: 1040
Location: England
Reply with quote
Post Re: Lua trails?
Code:
function Create(self)
   lastposx = self.Pos.X; lastposy = self.Pos.Y;
   lastpos = vector(lastposx,lastposy);
   counter = 0;
   numparticles=6;
end
function Update(self)
   local temp = Vector(self.Pos - lastpos);
   dist = temp.Magnitude;
   angle = math.atan(self.Vel.Y/self.Vel.X);
   spread = dist / numparticles;
   while (counter < numparticles) do
      counter = counter + 1;
      trail = CreateMOPixel("yourparticle");
      trail.Pos.X = lastposx + (counter * (math.cos(angle) * spread));
      trail.Pos.Y = lastposy + (counter * (math.sin(angle) * spread));
      trail.Vel = self.Vel;
      MovableMan:AddParticle(trail);
   end
   if (counter == numparticles) then counter = 0; end
   --anything else you want to add
   lastposx = self.Pos.X; lastposy = self.Pos.Y;
   lastposx = vector(lastposx,lastposy);
end

okay I went through the code on a piece of paper and I'm pretty sure that it works and that the only thing that could be wrong is the distance which before was very wrong? also I got the angle wrong, it should be angle = math.atan(self.Vel.Y/self.Vel.X); got the x and y mixed up

this is roughly how it should work:
http://filesmelt.com/downloader/scan008.png


Sat Aug 08, 2009 4:17 pm
Profile
User avatar

Joined: Wed Nov 22, 2006 3:19 pm
Posts: 2073
Reply with quote
Post Re: Lua trails?
/ignore this post - Disregard this.

I get the following:
Image
What does it mean? I don't know... Something with the Vector...

Stupid lua GRAAHHHHH!!!!!! FFFFFFFFFFFF----!!!!!!
Image


Sat Aug 08, 2009 7:30 pm
Profile
User avatar

Joined: Fri May 11, 2007 4:30 pm
Posts: 1040
Location: England
Reply with quote
Post Re: Lua trails?
Code:
function Create(self)
   lastposx = self.Pos.X; lastposy = self.Pos.Y;
   lastpos = vector(lastposx,lastposy);
   counter = 0;
   numparticles=6;
end
function Update(self)
   local temp = self.Pos - lastpos;
   dist = temp.Magnitude;
   angle = math.atan(self.Vel.Y/self.Vel.X);
   spread = dist / numparticles;
   while (counter < numparticles) do
      counter = counter + 1;
      trail = CreateMOPixel("yourparticle");
      trail.Pos.X = lastposx + (counter * (math.cos(angle) * spread));
      trail.Pos.Y = lastposy + (counter * (math.sin(angle) * spread));
      trail.Vel = self.Vel;
      MovableMan:AddParticle(trail);
   end
   if (counter == numparticles) then counter = 0; end
   --anything else you want to add
   lastposx = self.Pos.X; lastposy = self.Pos.Y;
   lastposx = vector(lastposx,lastposy);
end


pfft, k that's fixed fo' sho'


Sat Aug 08, 2009 11:07 pm
Profile
User avatar

Joined: Wed Nov 22, 2006 3:19 pm
Posts: 2073
Reply with quote
Post Re: Lua trails?
Image

Image


Tue Aug 11, 2009 9:43 am
Profile
User avatar

Joined: Fri May 11, 2007 4:30 pm
Posts: 1040
Location: England
Reply with quote
Post Re: Lua trails?
hehehe
local temp = Vector(0,0);
temp = self.Pos - lastpos;

if that doesn't work
local tempx = self.Pos.X - lastposx;
local tempy = self.Pos.Y - lastposy;
local temp = Vector(tempx,tempy);

man vectors sure are stubborn


Tue Aug 11, 2009 3:28 pm
Profile
User avatar

Joined: Mon Oct 06, 2008 2:04 am
Posts: 1559
Reply with quote
Post Re: Lua trails?
If I was robolee, I'd be intentionally screwing up code just to see Maxim post more nerdrage pictures.


Tue Aug 11, 2009 3:30 pm
Profile
User avatar

Joined: Wed Nov 22, 2006 3:19 pm
Posts: 2073
Reply with quote
Post Re: Lua trails?
LowestFormOfWit wrote:
If I was robolee, I'd be intentionally screwing up code just to see Maxim post more nerdrage pictures.


Image

@ lee

Nope, sire, that doesn't work.
Are you even sure it has something to do with the 'temp' part?


Tue Aug 11, 2009 3:44 pm
Profile
User avatar

Joined: Fri May 11, 2007 4:30 pm
Posts: 1040
Location: England
Reply with quote
Post Re: Lua trails?
I'm not really sure where any of the errors are that you encounter, based on what you tell me I have to take my best guess, and you're tellin me it's a problem with vectors... hey wait a second I see what I done wrong:
in the create code I wrote:
lastpos = vector(lastposx,lastposy);
and at the end of the code:
lastposx = vector(lastposx,lastposy);

change both to:
lastpos = Vector(lastposx,lastposy);

stupid capitalism and hermit "x"'s. though I would expect you to notice that, you might want to check for silly errors like that yourself.


Wed Aug 12, 2009 1:11 am
Profile
User avatar

Joined: Wed Nov 22, 2006 3:19 pm
Posts: 2073
Reply with quote
Post Re: Lua trails?
robolee wrote:
I'm not really sure where any of the errors are that you encounter, based on what you tell me I have to take my best guess, and you're tellin me it's a problem with vectors... hey wait a second I see what I done wrong:
in the create code I wrote:
lastpos = vector(lastposx,lastposy);
and at the end of the code:
lastposx = vector(lastposx,lastposy);

change both to:
lastpos = Vector(lastposx,lastposy);

stupid capitalism and hermit "x"'s. though I would expect you to notice that, you might want to check for silly errors like that yourself.


Actually, I did notice it, and I capitilized it. I thought you would too. >__________>'

I'll see if that works.

Edit:

Well... It 'almost' works propely. (Hooray for it actually working :D)
I'll whoop a gif when I get back from work...


Wed Aug 12, 2009 3:46 am
Profile
User avatar

Joined: Wed Nov 22, 2006 3:19 pm
Posts: 2073
Reply with quote
Post Re: Lua trails?
Damnit! I totally forgot about this carp!

Yeah, here's what happens now... It sorta semi works, and yet, it doesn't...
Image


Do you think that there may be a simpler yet effective-er code?
Making something simple like a trail should not be so difficult >_____________________>'

Shame there is no way to add a dragging glow to a MOP trail. Like, doing all this crap directly from the .ini.


Sun Aug 16, 2009 7:44 pm
Profile
happy carebear mom
User avatar

Joined: Tue Mar 04, 2008 1:40 am
Posts: 7096
Location: b8bbd5
Reply with quote
Post Re: Lua trails?
Maybe what you can do is modify the current code to spawn a line of glows, instead of just the one. Something like
Code:
for i = 0 to AMT
 (spawn glow at) Vector(self.Pos.X - i * (currentPos - lastPos / AMT), self.Pos.Y - i * (currentPos - lastPos / AMT))
end


Sun Aug 16, 2009 7:51 pm
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: Lua trails?
Seriously this could all be done with sin and cos. Just spawn three particles per sim update, one at self pos, and then one each at 5 pixels forward and back along the velocity vector.


Sun Aug 16, 2009 10:26 pm
Profile
User avatar

Joined: Wed Nov 22, 2006 3:19 pm
Posts: 2073
Reply with quote
Post Re: Lua trails?
Grif wrote:
Seriously this could all be done with sin and cos. Just spawn three particles per sim update, one at self pos, and then one each at 5 pixels forward and back along the velocity vector.


I'd do it. Sadly though, I haven't quite mastered all the trig and ♥♥♥♥ yet. Actually, I can't understand how it even works. >_______________>'


Sun Aug 16, 2009 11:00 pm
Profile
happy carebear mom
User avatar

Joined: Tue Mar 04, 2008 1:40 am
Posts: 7096
Location: b8bbd5
Reply with quote
Post Re: Lua trails?
Grif wrote:
Seriously this could all be done with sin and cos.

Oooor, you could use the X and Y of a normalized copy of the velocity vector multiplied by some constant, and negate it for the one behind...


Sun Aug 16, 2009 11:09 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 67 posts ]  Go to page Previous  1, 2, 3, 4, 5  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.035s | 14 Queries | GZIP : Off ]