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



Reply to topic  [ 3 posts ] 
 LUA: Using JoyButtonReleased for burst mode 
Author Message

Joined: Sun Oct 07, 2012 3:24 am
Posts: 28
Reply with quote
Post LUA: Using JoyButtonReleased for burst mode
I am trying to create a burst mode pistol that is not fully automatic. This means when you hold the trigger it will only fire one burst (3 rounds). I am using UInputMan:JoyButtonReleased in a modified version of the Burst.lua from the coalition autopistol.

The problem is getting it to work with the current player's controller instead of only player 1's controller.

Code:
if self.canBurst == false then
   self:Deactivate();
   if UInputMan:JoyButtonReleased(0,5) then
      self.canBurst = true;


Fri Jan 17, 2014 8:50 am
Profile
User avatar

Joined: Mon Jun 17, 2013 2:55 pm
Posts: 434
Location: Somewhere
Reply with quote
Post Re: LUA: Using JoyButtonReleased for burst mode
Umm....Isn't there's already a burst-fire script for the Coalition auto pistol?


Fri Jan 17, 2014 12:45 pm
Profile

Joined: Fri Sep 10, 2010 1:48 am
Posts: 666
Location: Halifax, Canada
Reply with quote
Post Re: LUA: Using JoyButtonReleased for burst mode
This seems like a very silly way of doing it, using only the joybutton means it'll only work for controllers, whereas if you use the actor's lua controller (the lua interface rather not the physical controller) you can probably make it work with any control scheme.
Either way, you'd need to get the actor holding the gun and get his player or controller. So something like the following would probably help:
Code:
function Create(self)
self.Parent = nil;
self.ParentPlayer = nil;
function Update(self)
  --If it's not being held by an actor, set its parent and parent player to nil
  if self.ID == self.RootID then
    self.Parent = nil;
    self.ParentPlayer = nil;
  --If it is being held, give it a parent and find the parent's player
  else
    if self.Parent == nil or self.ParentPlayer == nil then
    self.Parent = MovableMan:GetMOFromID(self.ID);
    self.ParentPlayer = self.Parent:GetController().Player;
  end
  --Your stuff follows, except the 0 in joybuttonreleased is changed to self.ParentPlayer
  --Also, you should consider using self.Parent:GetController():IsState(Controller.RELEASE_PRIMARY) instead of uinputman stuff
end

By the way, this should probably have been in the lua scripting subforum.


Fri Jan 17, 2014 4:18 pm
Profile
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 ]