Data Realms Fan Forums http://45.55.195.193/ |
|
Help negating an if argument http://45.55.195.193/viewtopic.php?f=73&t=15575 |
Page 1 of 1 |
Author: | Areku [ Fri Jun 26, 2009 2:13 pm ] |
Post subject: | Help negating an if argument |
A few days ago, I posted on this forum asking for a way to check if an actor was using a specific weapon. Now my problem is exactly the opposite: I want to check if that actor is NOT using that said weapon. Here's the code I'm using: (not all of it) Code: if self:IsPlayerControlled() and UInputMan:KeyPressed(24) then for mo in MovableMan.Particles do for i = 1, MovableMan:GetMOIDCount() - 1 do mo = MovableMan:GetMOFromID(i) if mo.RootID == self.ID and mo.PresetName == "Red's Saw" then if self.dashtimer1:IsPastRealMS(800) == true then self:GetController():SetState(Controller.BODY_CROUCH,true); self:GetController():SetState(Controller.WEAPON_FIRE,true); dash = CreateMOPixel("Dash Holder Pixel"); local sigma = ToActor(self):GetAimAngle(true); dash.Pos = self.Pos + Vector(math.cos(sigma)*300,math.sin(sigma)*-300); flashpoint = CreateAEmitter("Shiny Yellow Blast Long"); flashpoint.Pos = self.Pos; self.Vel.X = (self.Pos.X - dash.Pos.X) * -0.06; self.Vel.Y = (self.Pos.Y - dash.Pos.Y) * -0.06; MovableMan:AddParticle(flashpoint); flashpoint.Vel.X = (flashpoint.Pos.X - dash.Pos.X) * -0.06; flashpoint.Vel.Y = (flashpoint.Pos.Y - dash.Pos.Y) * -0.06; MovableMan:AddParticle(dash); self:ClearForces(); -- This is here to prevent actors from instagibbing after a couple of dashes. self.invictimer:Reset(); self.HitsMOs = false; self.GetsHitByMOs = false; self.dashtimer1:Reset(); end -- else -- if self.dashtimer1:IsPastRealMS(800) == true then -- self:GetController():SetState(Controller.BODY_CROUCH,true); -- dash = CreateMOPixel("Dash Holder Pixel"); -- local sigma = ToActor(self):GetAimAngle(true); -- dash.Pos = self.Pos + Vector(math.cos(sigma)*300,math.sin(sigma)*-300); -- self.Vel.X = (self.Pos.X - dash.Pos.X) * -0.06; -- self.Vel.Y = (self.Pos.Y - dash.Pos.Y) * -0.06; -- MovableMan:AddParticle(dash); -- self:ClearForces(); -- This is here to prevent actors from instagibbing after a couple of dashes. -- for soondeadguy in MovableMan.Actors do -- soondeadguy:SetWhichMOToNotHit(self,0.6); -- end -- self.dashtimer1:Reset(); -- end end end end end The commented out part is what I wanted to happen if the key was pressed and the actor wasn't holding the weapon. Before anyone asks, the else statement doesn't work, as it causes the second option to happen always, regardless of the weapon being held or not. Can anyone help with this? |
Author: | mail2345 [ Fri Jun 26, 2009 6:27 pm ] |
Post subject: | Re: Help negating an if argument |
Code: not(mo.PresetName == "Red's Saw") Does the trick. Oh, to make sure it does not react on other attachables, I would add: Code: and mo.ClassName == "HDFirearm" |
Author: | Areku [ Fri Jun 26, 2009 10:59 pm ] |
Post subject: | Re: Help negating an if argument |
Uh, nope. Still does nothing. No matter, though. I'll just give the actor a weapon called "bare hands" and check if it's wielding it. Not exactly what I first intended to make, but should do the trick. |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |