Author |
Message |
Cooljoesmith
Joined: Sat Jan 31, 2009 11:34 pm Posts: 88 Location: The U S of A's
|
Help with code: Not creating AEmitter/Gibbing Object
I need help with this code... It gibs the object, but wont create the Emitter.
Code: function Create(self) self.LTimer = Timer(); self.projectile = CreateAEmitter("Particle Sniper Bolt","EAF.rte"); end
function Update(self) if self.LTimer:IsPastSimMS(50) then MovableMan:AddParticle(self.projectile); self:GibThis(); end end ^^^ Fixedneed help with this code Code: function Create(self)
end
function Update(self) self.boltspeed = self.vel;
if self.boltspeed < 180 then self:GibThis(); end end it keeps saying it cant compare with a nill number or some thing thank you for any help.
Last edited by Cooljoesmith on Sat Oct 03, 2009 2:31 am, edited 1 time in total.
|
Fri Oct 02, 2009 11:39 pm |
|
|
Duh102
happy carebear mom
Joined: Tue Mar 04, 2008 1:40 am Posts: 7096 Location: b8bbd5
|
Re: Help with code: Not creating AEmitter
You forgot to set the position of your emitter.
|
Fri Oct 02, 2009 11:53 pm |
|
|
Cooljoesmith
Joined: Sat Jan 31, 2009 11:34 pm Posts: 88 Location: The U S of A's
|
Re: Help with code: Not creating AEmitter
*Massive head smack* thank you...
|
Sat Oct 03, 2009 12:00 am |
|
|
Cooljoesmith
Joined: Sat Jan 31, 2009 11:34 pm Posts: 88 Location: The U S of A's
|
Re: Help with code: Not creating AEmitter/Gibbing Object
need more help.
|
Sat Oct 03, 2009 2:31 am |
|
|
DSMK2
Joined: Fri Dec 28, 2007 4:19 am Posts: 1119
|
Re: Help with code: Not creating AEmitter/Gibbing Object
Cooljoesmith wrote: need more help. Help with what.
|
Sat Oct 03, 2009 2:32 am |
|
|
Duh102
happy carebear mom
Joined: Tue Mar 04, 2008 1:40 am Posts: 7096 Location: b8bbd5
|
Re: Help with code: Not creating AEmitter/Gibbing Object
He updated the OP.
@OP: I'm not sure why you're setting self.boltspeed, then promptly comparing it. Why not just use self.Vel?
|
Sat Oct 03, 2009 2:34 am |
|
|
Cooljoesmith
Joined: Sat Jan 31, 2009 11:34 pm Posts: 88 Location: The U S of A's
|
Re: Help with code: Not creating AEmitter/Gibbing Object
i did, but it still did not work.
|
Sat Oct 03, 2009 2:58 am |
|
|
DSMK2
Joined: Fri Dec 28, 2007 4:19 am Posts: 1119
|
Re: Help with code: Not creating AEmitter/Gibbing Object
Wait I think I know what he got wrong, he's trying to compare a vector with a number. And the variable for velocity is "Vel". So I'm assuming you'd need to find the velocity... Trig time(?) Code: self.Vel.X/cos(RotAngle) = Actual Vel self.Vel.Y/sin(RotAngle) = Actual Vel Since... Code: Horizontal Velocity = Velocity*cos(RotAngle) Vertical Velocity = Velocity*sin(RotAngle) Then from there... Code: If self.Vel.X/cos(RotAngle) == self.Vel.Y/sin(RotAngle) and self.Vel.X/cos(RotAngle) < 180 and self.Vel.Y/sin(RotAngle) < 180 then Should give you the idea... Hopefully my math is correct :S
|
Sat Oct 03, 2009 3:00 am |
|
|
Cooljoesmith
Joined: Sat Jan 31, 2009 11:34 pm Posts: 88 Location: The U S of A's
|
Re: Help with code: Not creating AEmitter/Gibbing Object
ok... i get it... but now it spams the console with
ERROR: blah blah... : attempt to call global 'cos'(a nill value)
|
Sat Oct 03, 2009 3:24 am |
|
|
DSMK2
Joined: Fri Dec 28, 2007 4:19 am Posts: 1119
|
Re: Help with code: Not creating AEmitter/Gibbing Object
Cooljoesmith wrote: ok... i get it... but now it spams the console with
ERROR: blah blah... : attempt to call global 'cos'(a nill value) replace RotAngle with self.RotAngle
|
Sat Oct 03, 2009 3:25 am |
|
|
Cooljoesmith
Joined: Sat Jan 31, 2009 11:34 pm Posts: 88 Location: The U S of A's
|
Re: Help with code: Not creating AEmitter/Gibbing Object
did that
|
Sat Oct 03, 2009 3:37 am |
|
|
DSMK2
Joined: Fri Dec 28, 2007 4:19 am Posts: 1119
|
Re: Help with code: Not creating AEmitter/Gibbing Object
Cooljoesmith wrote: did that May I see your code as of now? And what are you scripting this to?
|
Sat Oct 03, 2009 3:42 am |
|
|
Cooljoesmith
Joined: Sat Jan 31, 2009 11:34 pm Posts: 88 Location: The U S of A's
|
Re: Help with code: Not creating AEmitter/Gibbing Object
Code: function Create(self)
end
function Update(self) if self.Vel.X/cos(self.RotAngle) == self.Vel.Y/sin(self.RotAngle) and self.Vel.X/cos(self.RotAngle) < 180 and self.Vel.Y/sin(self.RotAngle) < 180 then self:GibThis(); end end and i am attaching this to a AEmitter that is acting like a projectile.
|
Sat Oct 03, 2009 3:47 am |
|
|
DSMK2
Joined: Fri Dec 28, 2007 4:19 am Posts: 1119
|
Re: Help with code: Not creating AEmitter/Gibbing Object
Cooljoesmith wrote: Code: function Create(self)
end
function Update(self) if self.Vel.X/cos(self.RotAngle) == self.Vel.Y/sin(self.RotAngle) and self.Vel.X/cos(self.RotAngle) < 180 and self.Vel.Y/sin(self.RotAngle) < 180 then self:GibThis(); end end and i am attaching this to a AEmitter that is acting like a projectile. Oh blah, in front of all the trig functions call "math." like math.cos, math.sin. Since we're calling functions from the math class.
|
Sat Oct 03, 2009 4:03 am |
|
|
Cooljoesmith
Joined: Sat Jan 31, 2009 11:34 pm Posts: 88 Location: The U S of A's
|
Re: Help with code: Not creating AEmitter/Gibbing Object
ok... it no longer spams with error messages... and i think it works but it still does not gib the object.
|
Sat Oct 03, 2009 4:11 am |
|
|
|