Data Realms Fan Forums http://45.55.195.193/ |
|
Making AEmitters emit? -still not working- http://45.55.195.193/viewtopic.php?f=73&t=14693 |
Page 1 of 1 |
Author: | Areku [ Sat May 16, 2009 10:14 pm ] |
Post subject: | 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. |
Author: | piipu [ Sat May 16, 2009 10:23 pm ] |
Post subject: | 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. |
Author: | Areku [ Sat May 16, 2009 10:34 pm ] |
Post subject: | 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. |
Author: | piipu [ Sat May 16, 2009 10:38 pm ] |
Post subject: | Re: Making AEmitters emit? |
self.ChainPower not self:ChainPower |
Author: | Areku [ Sat May 16, 2009 10:39 pm ] |
Post subject: | Re: Making AEmitters emit? |
Thanks! Gonna test now. EDIT: Nope, still doesn't work. I'm starting to get desperate. |
Author: | zalo [ Sun May 17, 2009 6:00 am ] |
Post subject: | 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. |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |