News: Welcome back to Bullworth! If you haven't already, you will need to reset your password..


Author Topic: Lua help!!!  (Read 4590 times)

0 Members and 1 Guest are viewing this topic.

Offline The CeSSaRR

  • Don't messing me!
  • Jr. Member
  • **
  • Posts: 59
  • Gender: Male
  • You're messing with the wrong mascot!
    • View Profile
Lua help!!!
« on: December 22, 2013, 12:31:05 AM »
how we can do control which key for which action fighting style for lua?

I'm really sorry my english is bad...
İ mean how you can adjustment which animation which key in lua

Offline MadmaN

  • Bully-Board Admin Team
  • Newbie
  • *
  • Posts: 0
  • Gender: Male
  • Biblio-Techa Mods (retired)
    • View Profile
Re: Lua help!!!
« Reply #1 on: December 22, 2013, 04:41:16 PM »
If I understand you correctly, you want to know how to remap controls for specific actions?

VERY simple to do m8.

here is a example:

Code: [Select]
TL_Buttons = function()
        if IsButtonPressed(15, 1) and IsButtonPressed(2, 1) then
          px,py,pz = PlayerGetPosXYZ()
        TextPrintString("Player Pos: "..px..",  "..py..",  "..pz.."Area:"..AreaGetVisible(), 4, 2)
         Wait(1000)
        elseif IsButtonPressed(7, 0) and IsButtonPressed(12, 0) then
          PedSetActionNode(gPlayer, "/Global/Actions/Offense/RunningAttacks/RunningAttacksDirect", "Act/Globals/GlobalActions.act")
                 Wait(1000)
    end
end

What you do essentially is create a custom function which in this case I use a custom function named TL_Buttons which is easy to remember for setting up custom controls.

You have to make the first line after the custom function an IF statement and after that the rest are ELSEIF statements which all go in order basicly.

The button code in lua is pretty simple to understand if you break it down somewhat. IsButtonPressed(15, 1) translates to Button 15 on controller number 1.

Now...here is the tricky part. Every system will be different with this since bully does not detect controllers in the same way on every system. On most systems if you use a xbox 360 wired controller (reccomended over wireless) that controller will be controller 1 or 0. 0 is basicly the default controller being used for your current controller setup in the game where 1 is the very first active controller. You can set as many controllers as you want but you will need to create a button test script to figure out which controller(s) are what number. On my setup I use two xbox 360 afterglow controllers (1 currently due to one controller going bad on me) and my setup is the following: first xbox controller is controller 0, second xbox controller is controller 1, keyboard is controller 2, mouse is controller 3.

You are not required to use multiple controllers but due to teh 15 button limit on any controller in bully which I have not figured a way past, you may need to use more then one controller for testing or if you create a lot of custom actions you want mapped.

You CAN combine buttons which extends your capabilities quite a lot but could make for a bit of getting used to depending on what setup you use...You can combine two buttons for one action by doing the following code in lua: if IsButtonPressed(15, 1) and IsButtonPressed(2, 1) then

The first number in the () brackets is the button you want to map and the second number is the controller number.

Here is the basic rundown of what each button number is in lua:

D-PAD

  • UP = 2
  • DOWN = 3
  • LEFT = 0
  • RIGHT = 1
BUTTONS

  • X = 6
  • Y = 9
  • A = 7
  • B = 8
  • LEFT BUTTON = 11
  • RIGHT BUTTON = 13
  • LEFT TRIGGER = 10
  • RIGHT TRIGGER = 12
  • START = 4
  • SEELECT = 5
STICKS (when pressing them down)

  • LEFT STICK = 14
  • RIGHT STICK = 15
Please note that I only have put the normal xbox controller buttons since the keyboard buttons are a bit difficult to map out due to a LOT of duplicate buttons due to keyboards not being detected properly so you will get a lot of ghosting of the buttons when trying to run a button test script to map them out. This is why I no longer support keyboard users in my mods and why I highly reccomend getting hold of a new or used xbox 360 wired controller since those are normal usb that you can plug directly into your pc and all you have to do then is just go to microsoft's site and search for the drivers to download and install. You can use the same controller for other pc games too which is why I like using one.

Don't forget to call your custom function in your script's main function like I have here:

Code: [Select]
main = function()
  WeaponRequestModel(396)
  PickupRequestModel(396)
  ClothingGivePlayerOutfit("Boxing")
  Load("Act/Dialog.act")
  Load("Act/Debug.act")
  PlayerAddMoney(9999999, true)
  F_TableInit()
  ClockSetTickRate(0.0060000000521541)
  CreateThread("TL_Buttons")
  gMissionRunning = true
  while gMissionRunning do
    UpdateTextQueue()
    TL_Buttons()
      Wait(0)
   end
end

Hopefully this little impromptu guide helps you out with this.

Any further questions just post here and I or another modder will try to assist you further.

Have fun!

« Last Edit: December 22, 2013, 04:43:52 PM by |XF|-MadmaN[AR] »

Offline The CeSSaRR

  • Don't messing me!
  • Jr. Member
  • **
  • Posts: 59
  • Gender: Male
  • You're messing with the wrong mascot!
    • View Profile
Re: Lua help!!!
« Reply #2 on: December 23, 2013, 06:14:41 AM »
If I understand you correctly, you want to know how to remap controls for specific actions?

VERY simple to do m8.

here is a example:

Code: [Select]
TL_Buttons = function()
        if IsButtonPressed(15, 1) and IsButtonPressed(2, 1) then
          px,py,pz = PlayerGetPosXYZ()
        TextPrintString("Player Pos: "..px..",  "..py..",  "..pz.."Area:"..AreaGetVisible(), 4, 2)
         Wait(1000)
        elseif IsButtonPressed(7, 0) and IsButtonPressed(12, 0) then
          PedSetActionNode(gPlayer, "/Global/Actions/Offense/RunningAttacks/RunningAttacksDirect", "Act/Globals/GlobalActions.act")
                 Wait(1000)
    end
end

What you do essentially is create a custom function which in this case I use a custom function named TL_Buttons which is easy to remember for setting up custom controls.

You have to make the first line after the custom function an IF statement and after that the rest are ELSEIF statements which all go in order basicly.

The button code in lua is pretty simple to understand if you break it down somewhat. IsButtonPressed(15, 1) translates to Button 15 on controller number 1.

Now...here is the tricky part. Every system will be different with this since bully does not detect controllers in the same way on every system. On most systems if you use a xbox 360 wired controller (reccomended over wireless) that controller will be controller 1 or 0. 0 is basicly the default controller being used for your current controller setup in the game where 1 is the very first active controller. You can set as many controllers as you want but you will need to create a button test script to figure out which controller(s) are what number. On my setup I use two xbox 360 afterglow controllers (1 currently due to one controller going bad on me) and my setup is the following: first xbox controller is controller 0, second xbox controller is controller 1, keyboard is controller 2, mouse is controller 3.

You are not required to use multiple controllers but due to teh 15 button limit on any controller in bully which I have not figured a way past, you may need to use more then one controller for testing or if you create a lot of custom actions you want mapped.

You CAN combine buttons which extends your capabilities quite a lot but could make for a bit of getting used to depending on what setup you use...You can combine two buttons for one action by doing the following code in lua: if IsButtonPressed(15, 1) and IsButtonPressed(2, 1) then

The first number in the () brackets is the button you want to map and the second number is the controller number.

Here is the basic rundown of what each button number is in lua:

D-PAD

  • UP = 2
  • DOWN = 3
  • LEFT = 0
  • RIGHT = 1
BUTTONS

  • X = 6
  • Y = 9
  • A = 7
  • B = 8
  • LEFT BUTTON = 11
  • RIGHT BUTTON = 13
  • LEFT TRIGGER = 10
  • RIGHT TRIGGER = 12
  • START = 4
  • SEELECT = 5
STICKS (when pressing them down)

  • LEFT STICK = 14
  • RIGHT STICK = 15
Please note that I only have put the normal xbox controller buttons since the keyboard buttons are a bit difficult to map out due to a LOT of duplicate buttons due to keyboards not being detected properly so you will get a lot of ghosting of the buttons when trying to run a button test script to map them out. This is why I no longer support keyboard users in my mods and why I highly reccomend getting hold of a new or used xbox 360 wired controller since those are normal usb that you can plug directly into your pc and all you have to do then is just go to microsoft's site and search for the drivers to download and install. You can use the same controller for other pc games too which is why I like using one.

Don't forget to call your custom function in your script's main function like I have here:

Code: [Select]
main = function()
  WeaponRequestModel(396)
  PickupRequestModel(396)
  ClothingGivePlayerOutfit("Boxing")
  Load("Act/Dialog.act")
  Load("Act/Debug.act")
  PlayerAddMoney(9999999, true)
  F_TableInit()
  ClockSetTickRate(0.0060000000521541)
  CreateThread("TL_Buttons")
  gMissionRunning = true
  while gMissionRunning do
    UpdateTextQueue()
    TL_Buttons()
      Wait(0)
   end
end

Hopefully this little impromptu guide helps you out with this.

Any further questions just post here and I or another modder will try to assist you further.

Have fun!
Thanks a lot madman you are great

Offline MadmaN

  • Bully-Board Admin Team
  • Newbie
  • *
  • Posts: 0
  • Gender: Male
  • Biblio-Techa Mods (retired)
    • View Profile
Re: Lua help!!!
« Reply #3 on: December 23, 2013, 03:43:13 PM »
No Problem m8.

I and my team have a LOT of held back info on lua coding for bully that we have been holding back. Most of this will be taught to everyone as we get the time to make sure things are bug free and time allows the creation of proper tutorials for everything.

Offline The CeSSaRR

  • Don't messing me!
  • Jr. Member
  • **
  • Posts: 59
  • Gender: Male
  • You're messing with the wrong mascot!
    • View Profile
Re: Lua help!!!
« Reply #4 on: December 24, 2013, 06:09:53 AM »
No Problem m8.

I and my team have a LOT of held back info on lua coding for bully that we have been holding back. Most of this will be taught to everyone as we get the time to make sure things are bug free and time allows the creation of proper tutorials for everything.
All right mad,
my last question you release psf in christmas