View unanswered posts | View active topics It is currently Fri Dec 27, 2024 10:48 pm



Reply to topic  [ 16 posts ]  Go to page 1, 2  Next
 Help with code: Not creating AEmitter/Gibbing Object 
Author Message
User avatar

Joined: Sat Jan 31, 2009 11:34 pm
Posts: 88
Location: The U S of A's
Reply with quote
Post 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.


Last edited by Cooljoesmith on Sat Oct 03, 2009 2:31 am, edited 1 time in total.



Fri Oct 02, 2009 11:39 pm
Profile
happy carebear mom
User avatar

Joined: Tue Mar 04, 2008 1:40 am
Posts: 7096
Location: b8bbd5
Reply with quote
Post Re: Help with code: Not creating AEmitter
You forgot to set the position of your emitter.


Fri Oct 02, 2009 11:53 pm
Profile
User avatar

Joined: Sat Jan 31, 2009 11:34 pm
Posts: 88
Location: The U S of A's
Reply with quote
Post Re: Help with code: Not creating AEmitter
*Massive head smack* thank you...


Sat Oct 03, 2009 12:00 am
Profile
User avatar

Joined: Sat Jan 31, 2009 11:34 pm
Posts: 88
Location: The U S of A's
Reply with quote
Post Re: Help with code: Not creating AEmitter/Gibbing Object
need more help.


Sat Oct 03, 2009 2:31 am
Profile
User avatar

Joined: Fri Dec 28, 2007 4:19 am
Posts: 1119
Reply with quote
Post Re: Help with code: Not creating AEmitter/Gibbing Object
Cooljoesmith wrote:
need more help.


Help with what.


Sat Oct 03, 2009 2:32 am
Profile
happy carebear mom
User avatar

Joined: Tue Mar 04, 2008 1:40 am
Posts: 7096
Location: b8bbd5
Reply with quote
Post 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
Profile
User avatar

Joined: Sat Jan 31, 2009 11:34 pm
Posts: 88
Location: The U S of A's
Reply with quote
Post Re: Help with code: Not creating AEmitter/Gibbing Object
i did, but it still did not work.


Sat Oct 03, 2009 2:58 am
Profile
User avatar

Joined: Fri Dec 28, 2007 4:19 am
Posts: 1119
Reply with quote
Post 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
Profile
User avatar

Joined: Sat Jan 31, 2009 11:34 pm
Posts: 88
Location: The U S of A's
Reply with quote
Post 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
Profile
User avatar

Joined: Fri Dec 28, 2007 4:19 am
Posts: 1119
Reply with quote
Post 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
Profile
User avatar

Joined: Sat Jan 31, 2009 11:34 pm
Posts: 88
Location: The U S of A's
Reply with quote
Post Re: Help with code: Not creating AEmitter/Gibbing Object
did that


Sat Oct 03, 2009 3:37 am
Profile
User avatar

Joined: Fri Dec 28, 2007 4:19 am
Posts: 1119
Reply with quote
Post 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
Profile
User avatar

Joined: Sat Jan 31, 2009 11:34 pm
Posts: 88
Location: The U S of A's
Reply with quote
Post 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
Profile
User avatar

Joined: Fri Dec 28, 2007 4:19 am
Posts: 1119
Reply with quote
Post 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
Profile
User avatar

Joined: Sat Jan 31, 2009 11:34 pm
Posts: 88
Location: The U S of A's
Reply with quote
Post 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
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 16 posts ]  Go to page 1, 2  Next

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.020s | 14 Queries | GZIP : Off ]