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



Reply to topic  [ 7 posts ] 
 Creating a blast when certain pair of buttons is pressed. 
Author Message

Joined: Fri Dec 18, 2009 11:00 pm
Posts: 167
Reply with quote
Post Re: Creating a blast when certain pair of buttons is pressed.
Code:
function Update(self)
   if self.parent:GetController():IsState(Controller.PRESS_UP) and self.parent:GetController():IsState(Controller.PRESS_DOWN) then
      local Ge = CreateMOSRotating("Blast");
         Ge.pos = self.pos;
         Ge.vel = self.Vel;
         MovableMan:AddParticle(Ge);
         self.ToDelete = true;
      end
   end
end


you may need to use Controller.HOLD_UP and Controller.PRESS_DOWN (or vise versa), cause this requires to be pressed at the exact same time.


Wed Feb 09, 2011 12:39 am
Profile
User avatar

Joined: Mon Jun 15, 2009 4:02 pm
Posts: 905
Reply with quote
Post Re: Creating a blast when certain pair of buttons is pressed.
Needing to press both jump and crouch at the same time excludes gamepad users.
Makes me saaaad. :(


Wed Feb 09, 2011 11:29 pm
Profile WWW

Joined: Fri Dec 18, 2009 11:00 pm
Posts: 167
Reply with quote
Post Re: Creating a blast when certain pair of buttons is pressed.
so are you using something like this

Code:
function Create(self)
     for i = 1, MovableMan:GetMOIDCount() - 1 do
          local gun = MovableMan:GetMOFromID(i);
          if gun.PresetName == "name of gun" then
               local avgx = gun.Pos.X - self.Pos.X;
               local avgy = gun.Pos.Y - self.Pos.Y;
               local dist = math.sqrt(avgx ^ 2 + avgy ^ 2);
               if dist < 50 then
                    self.gun = gun;
               end
          end
     end
     if self.gun ~= nil then
          local root = MovableMan:GetRootMOID(self.gun.ID);
          if root.ClassName == "AHuman" then
               self.act = MovableMan:GetMOFromID(root);
          end
     end
end

function Update(self)
     if self.parent ~= nil then
          if self.parent:GetController():IsState(Controller.PIE_MENU_ACTIVE) then
               local Ge = CreateMOSRotating("Blast");
               MovableMan:AddMO(Ge);
               Ge.pos = self.pos;
               Ge.vel = self.Vel
               self.ToDelete = true;
          end
     end
end


Thu Feb 10, 2011 1:05 am
Profile

Joined: Fri Dec 18, 2009 11:00 pm
Posts: 167
Reply with quote
Post Re: Creating a blast when certain pair of buttons is pressed.
More meat? if there was any less meat I'd call it a bone; as in your scripts bone dead wrong :grin: :P


Fri Feb 11, 2011 4:42 pm
Profile

Joined: Fri Dec 18, 2009 11:00 pm
Posts: 167
Reply with quote
Post Re: Creating a blast when certain pair of buttons is pressed.
Quote:
"root" can't be used as a variable.


Since when??

I have been using root as a variable in all my scripts and haven't had any problems with it?

and yes, you only need to find the actor, to use the script it it still useful to find the gun to get gun position and rotangle if you are making lua bullets?

else this will suffice

Code:
function Create(self)
   for actor in MovableMan.Actors do
      local avgx = actor.Pos.X - self.Pos.X;
      local avgy = actor.Pos.Y - self.Pos.Y;
      local dist = math.sqrt(avgx ^ 2 + avgy ^ 2);
      if dist < 50 then
         self.parent = actor;
      end
   end
end

function Update(self)
     if self.parent ~= nil then
          if self.parent:GetController():IsState(Controller.PIE_MENU_ACTIVE) then
               local Ge = CreateMOSRotating("Blast");
               MovableMan:AddMO(Ge);
               Ge.pos = self.pos;
               Ge.vel = self.Vel
               self.ToDelete = true;
          end
     end
end


Sat Feb 12, 2011 12:12 am
Profile

Joined: Fri Dec 18, 2009 11:00 pm
Posts: 167
Reply with quote
Post Re: Creating a blast when certain pair of buttons is pressed.
Soo you want the gun to:

A. shoot a bullet and if you "right click" with your actor the bullet explodes?
B. or do you want the bullet to find an actor (not yourself) and blow up the actor?
C. or blow yourself up?


Sat Feb 12, 2011 5:00 pm
Profile

Joined: Fri Dec 18, 2009 11:00 pm
Posts: 167
Reply with quote
Post Re: Creating a blast when certain pair of buttons is pressed.
I made an example for you, when you fire the gun then right click it turns into pow.


Attachments:
boom.rte.rar [5.45 KiB]
Downloaded 209 times
Sat Feb 12, 2011 5:33 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 7 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.061s | 14 Queries | GZIP : Off ]