Author |
Message |
Urch
Joined: Mon Sep 28, 2009 2:15 am Posts: 720 Location: A fucking desert.
|
![Post Post](./styles/images/imageset/icon_topic_latest.gif) 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 |
|
![](./styles/acidtech_tiger/theme/images/spacer.gif) |
CaveCricket48
Joined: Tue Jun 12, 2007 11:52 pm Posts: 13143 Location: Here
|
![Post Post](./styles/images/imageset/icon_topic_latest.gif) 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 |
|
![](./styles/acidtech_tiger/theme/images/spacer.gif) |
Urch
Joined: Mon Sep 28, 2009 2:15 am Posts: 720 Location: A fucking desert.
|
![Post Post](./styles/images/imageset/icon_topic_latest.gif) Re: A small lua-related request
CaveCricket48 wrote: 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 |
|
![](./styles/acidtech_tiger/theme/images/spacer.gif) |
Grif
REAL AMERICAN HERO
Joined: Sat Jan 27, 2007 10:25 pm Posts: 5655
|
![Post Post](./styles/images/imageset/icon_topic_latest.gif) Re: A small lua-related request
tabbing doesn't matter; lua ignores whitespace
|
Mon Aug 23, 2010 6:07 am |
|
![](./styles/acidtech_tiger/theme/images/spacer.gif) |
Urch
Joined: Mon Sep 28, 2009 2:15 am Posts: 720 Location: A fucking desert.
|
![Post Post](./styles/images/imageset/icon_topic_latest.gif) Re: A small lua-related request
Then i'm confused; why doesn't this work?
|
Mon Aug 23, 2010 6:28 am |
|
![](./styles/acidtech_tiger/theme/images/spacer.gif) |
CaveCricket48
Joined: Tue Jun 12, 2007 11:52 pm Posts: 13143 Location: Here
|
![Post Post](./styles/images/imageset/icon_topic_latest.gif) 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 |
|
![](./styles/acidtech_tiger/theme/images/spacer.gif) |
Urch
Joined: Mon Sep 28, 2009 2:15 am Posts: 720 Location: A fucking desert.
|
![Post Post](./styles/images/imageset/icon_topic_latest.gif) 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 |
|
![](./styles/acidtech_tiger/theme/images/spacer.gif) |
CaveCricket48
Joined: Tue Jun 12, 2007 11:52 pm Posts: 13143 Location: Here
|
![Post Post](./styles/images/imageset/icon_topic_latest.gif) 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 |
|
![](./styles/acidtech_tiger/theme/images/spacer.gif) |
|