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



Reply to topic  [ 6 posts ] 
 Making 2 Timers - HELP! 
Author Message
User avatar

Joined: Thu May 27, 2010 10:25 am
Posts: 18
Location: Longbeach (not California), Australia
Reply with quote
Post 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


Sun Jun 06, 2010 3:05 am
Profile
User avatar

Joined: Mon Jun 15, 2009 4:02 pm
Posts: 905
Reply with quote
Post 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.


Sun Jun 06, 2010 10:28 am
Profile WWW
User avatar

Joined: Thu May 27, 2010 10:25 am
Posts: 18
Location: Longbeach (not California), Australia
Reply with quote
Post Re: Making 2 Timers - HELP!
nope.
still says there is an error with it calling a nil timer.
thanks for the help though


Sun Jun 06, 2010 11:47 am
Profile
User avatar

Joined: Sun Jul 13, 2008 9:57 am
Posts: 4886
Location: some compy
Reply with quote
Post 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.
Yo dawg lua doesn't need semicolons syntactically unless you're doing many things on the same line.

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
StartTimeMS() doesn't do anything to the value what are you smoking. Use Reset(), fixed for you, didn't touch anything else don't know if they're broken either learn to print values to debug.


Sun Jun 06, 2010 12:15 pm
Profile WWW
User avatar

Joined: Mon Jun 15, 2009 4:02 pm
Posts: 905
Reply with quote
Post 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.


Sun Jun 06, 2010 12:21 pm
Profile WWW
User avatar

Joined: Fri Jan 26, 2007 3:22 am
Posts: 1451
Reply with quote
Post Re: Making 2 Timers - HELP!
Nope, it doesn't but it sure makes your crap look better.


Sun Jun 06, 2010 5:34 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 6 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.063s | 13 Queries | GZIP : Off ]