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



Reply to topic  [ 3 posts ] 
 Help negating an if argument 
Author Message
User avatar

Joined: Fri Oct 17, 2008 9:46 pm
Posts: 5212
Location: The Grills Locker.
Reply with quote
Post 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?


Fri Jun 26, 2009 2:13 pm
Profile WWW
User avatar

Joined: Tue Nov 06, 2007 6:58 am
Posts: 2054
Reply with quote
Post 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"


Fri Jun 26, 2009 6:27 pm
Profile
User avatar

Joined: Fri Oct 17, 2008 9:46 pm
Posts: 5212
Location: The Grills Locker.
Reply with quote
Post 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.


Fri Jun 26, 2009 10:59 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 3 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.056s | 13 Queries | GZIP : Off ]