Data Realms Fan Forums http://45.55.195.193/ |
|
A small lua-related request http://45.55.195.193/viewtopic.php?f=75&t=19586 |
Page 1 of 1 |
Author: | Urch [ Sun Aug 22, 2010 10:13 pm ] |
Post subject: | 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. |
Author: | CaveCricket48 [ Sun Aug 22, 2010 11:43 pm ] |
Post subject: | 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. |
Author: | Urch [ Mon Aug 23, 2010 5:12 am ] |
Post subject: | 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 |
Author: | Grif [ Mon Aug 23, 2010 6:07 am ] |
Post subject: | Re: A small lua-related request |
tabbing doesn't matter; lua ignores whitespace |
Author: | Urch [ Mon Aug 23, 2010 6:28 am ] |
Post subject: | Re: A small lua-related request |
Then i'm confused; why doesn't this work? |
Author: | CaveCricket48 [ Mon Aug 23, 2010 4:12 pm ] |
Post subject: | 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... |
Author: | Urch [ Mon Aug 23, 2010 11:50 pm ] |
Post subject: | 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 |
Author: | CaveCricket48 [ Tue Aug 24, 2010 3:28 am ] |
Post subject: | 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. |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |