View unanswered posts | View active topics It is currently Thu Dec 26, 2024 5:03 pm



Reply to topic  [ 6 posts ] 
 Making AEmitters emit? -still not working- 
Author Message
User avatar

Joined: Fri Oct 17, 2008 9:46 pm
Posts: 5212
Location: The Grills Locker.
Reply with quote
Post Making AEmitters emit? -still not working-
So yeah, I decided to start learning lua. I made a simple script attached to an AHuman, to turn on a emitter if the "R" key was pressed. Here's it:
Code:
function Create(self)
-- Defining the variables:
   self.ChainPower = 0;
   self.Chain1 = CreateAEmitter("Chainz Cut");
   self.Chain2 = CreateAEmitter("Chainz Smoke");
end

function Update(self)
-- Now it checks if the chainbot is selected, if the chains are off and if the ignition is activated:
   if self:ChainPower == 0 and MovableMan:IsActor (self) and UInputMan:KeyPressed == ("R") then
-- If all of the above conditions are true, enable the chains and smoke:
      self.ChainPower = 1;
           self.Chain1:EnableEmission(ChainsEnabled);
      self.Chain2:EnableEmission(SmokeEnabled);
-- The else case is not here because it is not needed.
       end

-- Now it checks again for the above conditions again, but to see if the chains are already activated:
   if self:ChainPower == 1 and MovableMan:IsActor (self) and UInputMan:KeyPressed == ("R") then
-- If the conditions are fulfilled, turn the chains and smoke off:
      self.ChainPower = 0;
           self.Chain1:EnableEmission(false);
      self.Chain2:EnableEmission(false);
-- Again, the else case is not needed.
       end

end


And when I press the R key... Nothing happens. Nothing appears on the console, the emitters are not activated, absolutely nothing. The game doesn't even crash or show an error message.
If anyone could point out the problem, I would be most grateful.


Last edited by Areku on Sat May 16, 2009 10:55 pm, edited 1 time in total.



Sat May 16, 2009 10:14 pm
Profile WWW
User avatar

Joined: Mon Jun 30, 2008 9:13 pm
Posts: 499
Location: Finland
Reply with quote
Post Re: Making AEmitters emit?
You have to place the emitters and add them to the scene:
Code:
function Create(self)
-- Defining the variables:
   self.ChainPower = 0;
   self.Chain1 = CreateAEmitter("Chainz Cut");
   self.Chain2 = CreateAEmitter("Chainz Smoke");
   self.Chain1.Pos = self.Pos
   self.Chain2.Pos = self.Pos
   MovableMan:AddParticle(self.Chain1)
   MovableMan:AddParticle(self.Chain2)
end

function Update(self)
-- Now it checks if the chainbot is selected, if the chains are off and if the ignition is activated:
   if self:ChainPower == 0 and MovableMan:IsActor (self) and UInputMan:KeyPressed == ("R") then
-- If all of the above conditions are true, enable the chains and smoke:
      self.ChainPower = 1;
           self.Chain1:EnableEmission(ChainsEnabled);
      self.Chain2:EnableEmission(SmokeEnabled);
-- The else case is not here because it is not needed.
       end

-- Now it checks again for the above conditions again, but to see if the chains are already activated:
   if self:ChainPower == 1 and MovableMan:IsActor (self) and UInputMan:KeyPressed == ("R") then
-- If the conditions are fulfilled, turn the chains and smoke off:
      self.ChainPower = 0;
           self.Chain1:EnableEmission(false);
      self.Chain2:EnableEmission(false);
-- Again, the else case is not needed.
       end

end

That should work. Also, you'll have to hold R down.


Sat May 16, 2009 10:23 pm
Profile
User avatar

Joined: Fri Oct 17, 2008 9:46 pm
Posts: 5212
Location: The Grills Locker.
Reply with quote
Post Re: Making AEmitters emit?
Uh, sorry, but it doesn't work. Again, nothing happens at all. I create the actor, place some emitters, press R and then... Nothing. Once again.


Sat May 16, 2009 10:34 pm
Profile WWW
User avatar

Joined: Mon Jun 30, 2008 9:13 pm
Posts: 499
Location: Finland
Reply with quote
Post Re: Making AEmitters emit?
self.ChainPower not self:ChainPower


Sat May 16, 2009 10:38 pm
Profile
User avatar

Joined: Fri Oct 17, 2008 9:46 pm
Posts: 5212
Location: The Grills Locker.
Reply with quote
Post Re: Making AEmitters emit?
Thanks! Gonna test now.



EDIT: Nope, still doesn't work. I'm starting to get desperate. :P


Sat May 16, 2009 10:39 pm
Profile WWW

Joined: Sat Feb 03, 2007 7:11 pm
Posts: 1496
Reply with quote
Post Re: Making AEmitters emit? -still not working-
Of course it doesn't work when you press "R". You're using the function wrong.

Each letter is assigned a number. For example, "h" is "8". You can use this code
to find the numbers for the keys:

Code:
if(UInputMan:AnyPress()) then
print(UInputMan:WhichKeyHeld())
end


Add that to the end of your existing code, and press "R" and then check the console.


Sun May 17, 2009 6:00 am
Profile WWW
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.055s | 14 Queries | GZIP : Off ]