View unanswered posts | View active topics It is currently Wed Jul 03, 2024 6:45 am



Reply to topic  [ 8 posts ] 
 A small lua-related request 
Author Message
User avatar

Joined: Mon Sep 28, 2009 2:15 am
Posts: 720
Location: A fucking desert.
Reply with quote
Post A small lua-related request
This is, hopefully, not a very complex script that I'm asking for. I would like a script that creates a trail of MOSParticles on an object very often, so that the trail isn't all separated like it would be if i tried to make this with INI code.


Sun Aug 22, 2010 10:13 pm
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13143
Location: Here
Reply with quote
Post Re: A small lua-related request
Code:
function Create(self)
self.parspacing = 10; -- spacing betwen trail particles
self.lastpos = self.Pos;
end

function Update(self)
self.distcheck = SceneMan:ShortestDistance(self.lastpos,self.Pos,true)
if self.distcheck.Magnitude >= self.parspacing then
self.repnum = math.floor(self.distcheck.Magnitude/self.parspacing)
for i = 1, self.repnum do
self.tpar = CreateMOSParticle("trail particle");
self.tpar.Pos = self.lastpos + self.distcheck:SetMagnitude(i*self.parspacing);
MovableMan:AddParticle(self.tpar);
self.tpar = nil;
end
end
self.lastpos = self.Pos;
end

Did that on a DSI, so no tabz 4 u.


Sun Aug 22, 2010 11:43 pm
Profile
User avatar

Joined: Mon Sep 28, 2009 2:15 am
Posts: 720
Location: A fucking desert.
Reply with quote
Post Re: A small lua-related request
CaveCricket48 wrote:
Code:
snip

Did that on a DSI, so no tabz 4 u.



Thank-you very much, i've tried tabbing it on my own, and i want to know if this is correct:

Code:
function Create(self)
self.parspacing = 6; -- spacing betwen trail particles
self.lastpos = self.Pos;
end

function Update(self)
self.distcheck = SceneMan:ShortestDistance(self.lastpos,self.Pos,true)
   if self.distcheck.Magnitude >= self.parspacing then
   self.repnum = math.floor(self.distcheck.Magnitude/self.parspacing)
      for i = 1, self.repnum do
      self.tpar = CreateMOSParticle("trail particle");
      self.tpar.Pos = self.lastpos + self.distcheck:SetMagnitude(i*self.parspacing);
      MovableMan:AddParticle(self.tpar);
      self.tpar = nil;
      end
   end
self.lastpos = self.Pos;
end


Mon Aug 23, 2010 5:12 am
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: A small lua-related request
tabbing doesn't matter; lua ignores whitespace


Mon Aug 23, 2010 6:07 am
Profile
User avatar

Joined: Mon Sep 28, 2009 2:15 am
Posts: 720
Location: A fucking desert.
Reply with quote
Post Re: A small lua-related request
Then i'm confused; why doesn't this work?


Mon Aug 23, 2010 6:28 am
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13143
Location: Here
Reply with quote
Post Re: A small lua-related request
Probably because I typed something wrong. Open up the console after creating/using whatever had the script and check for errors.

Or you might've forgoten to change the particle PresetName in the script...


Mon Aug 23, 2010 4:12 pm
Profile
User avatar

Joined: Mon Sep 28, 2009 2:15 am
Posts: 720
Location: A fucking desert.
Reply with quote
Post Re: A small lua-related request
CaveCricket48 wrote:
Probably because I typed something wrong. Open up the console after creating/using whatever had the script and check for errors.

Or you might've forgoten to change the particle PresetName in the script...


the console doesn't display any errors, in fact i changed the ScriptPath to a non-existent script and it still didn't display an error. what's going on here?

but yes, to test it i changed the PresetName to Small Smoke Ball 1


Mon Aug 23, 2010 11:50 pm
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13143
Location: Here
Reply with quote
Post Re: A small lua-related request
Code:
function Create(self)
self.parspacing = 10; -- spacing betwen trail particles
self.lastpos = self.Pos;
end

function Update(self)
self.distcheck = SceneMan:ShortestDistance(self.lastpos,self.Pos,true)
if self.distcheck.Magnitude >= self.parspacing then
self.repnum = math.floor(self.distcheck.Magnitude/self.parspacing)
for i = 1, self.repnum do
self.tpar = CreateMOSParticle("trail particle");
self.tpar.Pos = self.lastpos + self.distcheck:SetMagnitude(i*self.parspacing);
MovableMan:AddParticle(self.tpar);
self.tpar = nil;
end
self.lastpos = self.Pos;
end
end

Try that.


Tue Aug 24, 2010 3:28 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 8 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.044s | 13 Queries | GZIP : Off ]