Data Realms Fan Forums
http://45.55.195.193/

Help with code: Not creating AEmitter/Gibbing Object
http://45.55.195.193/viewtopic.php?f=73&t=16728
Page 1 of 2

Author:  Cooljoesmith [ Fri Oct 02, 2009 11:39 pm ]
Post subject:  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

^^^
Fixed


need 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.

Author:  Duh102 [ Fri Oct 02, 2009 11:53 pm ]
Post subject:  Re: Help with code: Not creating AEmitter

You forgot to set the position of your emitter.

Author:  Cooljoesmith [ Sat Oct 03, 2009 12:00 am ]
Post subject:  Re: Help with code: Not creating AEmitter

*Massive head smack* thank you...

Author:  Cooljoesmith [ Sat Oct 03, 2009 2:31 am ]
Post subject:  Re: Help with code: Not creating AEmitter/Gibbing Object

need more help.

Author:  DSMK2 [ Sat Oct 03, 2009 2:32 am ]
Post subject:  Re: Help with code: Not creating AEmitter/Gibbing Object

Cooljoesmith wrote:
need more help.


Help with what.

Author:  Duh102 [ Sat Oct 03, 2009 2:34 am ]
Post subject:  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?

Author:  Cooljoesmith [ Sat Oct 03, 2009 2:58 am ]
Post subject:  Re: Help with code: Not creating AEmitter/Gibbing Object

i did, but it still did not work.

Author:  DSMK2 [ Sat Oct 03, 2009 3:00 am ]
Post subject:  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

Author:  Cooljoesmith [ Sat Oct 03, 2009 3:24 am ]
Post subject:  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)

Author:  DSMK2 [ Sat Oct 03, 2009 3:25 am ]
Post subject:  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

Author:  Cooljoesmith [ Sat Oct 03, 2009 3:37 am ]
Post subject:  Re: Help with code: Not creating AEmitter/Gibbing Object

did that

Author:  DSMK2 [ Sat Oct 03, 2009 3:42 am ]
Post subject:  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?

Author:  Cooljoesmith [ Sat Oct 03, 2009 3:47 am ]
Post subject:  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.

Author:  DSMK2 [ Sat Oct 03, 2009 4:03 am ]
Post subject:  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.

Author:  Cooljoesmith [ Sat Oct 03, 2009 4:11 am ]
Post subject:  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.

Page 1 of 2 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/