Data Realms Fan Forums http://45.55.195.193/ |
|
Creating a blast when certain pair of buttons is pressed. http://45.55.195.193/viewtopic.php?f=73&t=21439 |
Page 1 of 1 |
Author: | none [ Wed Feb 09, 2011 12:39 am ] |
Post subject: | 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. |
Author: | Petethegoat [ Wed Feb 09, 2011 11:29 pm ] |
Post subject: | 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. |
Author: | none [ Thu Feb 10, 2011 1:05 am ] |
Post subject: | 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 |
Author: | none [ Fri Feb 11, 2011 4:42 pm ] |
Post subject: | 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 |
Author: | none [ Sat Feb 12, 2011 12:12 am ] |
Post subject: | 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 |
Author: | none [ Sat Feb 12, 2011 5:00 pm ] |
Post subject: | 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? |
Author: | none [ Sat Feb 12, 2011 5:33 pm ] | ||
Post subject: | 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.
|
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |