Data Realms Fan Forums http://45.55.195.193/ |
|
Making 2 Timers - HELP! http://45.55.195.193/viewtopic.php?f=73&t=18922 |
Page 1 of 1 |
Author: | Sam4578 [ Sun Jun 06, 2010 3:05 am ] |
Post subject: | Making 2 Timers - HELP! |
I've Been trying to make a round that explodes after a certain amount of time after hitting terrain so far I've gotten Quote: function Create(self) self.burst = CreateAMOSRotating("Attempt") self.hasburst = false self.Timer = Timer() self.rayhit = Vector(0,0) self.raymiss = Vector(0,0); self.LifeTimer = Timer() end function Destroy(self) end function Update(self) if self.Timer:IsPastSimMS(20) then SceneMan:CastObstacleRay(self.Pos,(self.Vel/self.Vel.Magnitude)*750,self.rayhit,self.raymiss,-1,0,2); if ((self.rayhit - self.Pos).Magnitude) < 7 and self.hasburst == false and not self.rayhit:IsZero() then self.LifeTimer:StartSimTimeMS() end end if self.LifeTimer:IsPastSimMS(500) then self:GibThis(); self.hasburst = true end if self.hasburst then self.burst.RotAngle = self.Vel.AbsRadAngle; self.burst.Vel = self.Vel*20; self.burst.Pos = self.Pos; MovableMan:AddParticle(self.burst); self:GibThis(); end end (P.S sorry for wall of code rape) Anyway it returns an error that line 14 has a nil value please tell me what I'm doing wrong. Cheers |
Author: | Petethegoat [ Sun Jun 06, 2010 10:28 am ] |
Post subject: | Re: Making 2 Timers - HELP! |
At a glance, i would suggest that you have missed a couple of semi colons, in function Create(self) especially. The function Destroy(self)/end can be removed entirely. Eh, just make sure you have a semi colon after every statement, and see if that fixes it. |
Author: | Sam4578 [ Sun Jun 06, 2010 11:47 am ] |
Post subject: | Re: Making 2 Timers - HELP! |
nope. still says there is an error with it calling a nil timer. thanks for the help though |
Author: | Geti [ Sun Jun 06, 2010 12:15 pm ] |
Post subject: | Re: Making 2 Timers - HELP! |
Petethegoat wrote: At a glance, i would suggest that you have missed a couple of semi colons, in function Create(self) especially. The function Destroy(self)/end can be removed entirely. Code: function Update(self) if self.Timer:IsPastSimMS(20) then SceneMan:CastObstacleRay(self.Pos,(self.Vel/self.Vel.Magnitude)*750,self.rayhit,self.raymiss,-1,0,2); if ((self.rayhit - self.Pos).Magnitude) < 7 and self.hasburst == false and not self.rayhit:IsZero() then self.LifeTimer:Reset() end end if self.LifeTimer:IsPastSimMS(500) then self:GibThis(); self.hasburst = true end if self.hasburst then self.burst.RotAngle = self.Vel.AbsRadAngle; self.burst.Vel = self.Vel*20; self.burst.Pos = self.Pos; MovableMan:AddParticle(self.burst); self:GibThis(); end end |
Author: | Petethegoat [ Sun Jun 06, 2010 12:21 pm ] |
Post subject: | Re: Making 2 Timers - HELP! |
Geti wrote: Yo dawg lua doesn't need semicolons syntactically unless you're doing many things on the same line. It doesn't? Too used to C I guess. |
Author: | Daman [ Sun Jun 06, 2010 5:34 pm ] |
Post subject: | Re: Making 2 Timers - HELP! |
Nope, it doesn't but it sure makes your crap look better. |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |