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


Author Topic: How to create a menu  (Read 1413 times)

0 Members and 1 Guest are viewing this topic.

Offline Enderman

  • What i'm doing right now?
  • Full Member
  • ***
  • Posts: 293
  • Gender: Male
  • I'm no longer do mods for Bully ...
    • View Profile
    • bully-board.com
How to create a menu
« on: August 21, 2014, 01:34:56 AM »
Can i create a menu like boss style selector if anyone know please teach me :)

Offline Mick3Mouse

  • Obam3mouse
  • Bullworth Junkie
  • ****
  • Posts: 4,343
  • Gender: Male
  • Major Mick3Mouse Algie Hunter
    • View Profile
    • My youtube
Re: How to create a menu
« Reply #1 on: August 21, 2014, 05:42:58 AM »
Check out this topic:

http://www.bully-board.com/index.php?topic=18725.0


it teaches you how to make a menu. 

Offline DaBOSS54320

  • Hero Member
  • ****
  • Posts: 3,398
  • Gender: Female
    • View Profile
Re: How to create a menu
« Reply #2 on: August 21, 2014, 03:22:58 PM »
Important Edit: I don't know how to disable BB code, but because of using LUA code that looked like BB code it messed up this tutorial. Click the "quote this message" thing for this reply and copy all of it into notepad or something to view. That way you will see all the text as I intended it to be read.

Here is what we will need to do to make a menu:

1) Make a variable to keep track of where we are in the menu.
2) Make a table or list or my favorite a table of lists for all the parts of the menu to be.
3) A way to change the variable by pressing left/right.
4) Displaying the menu.
5) Confirming your selection on the menu.


1) Make a variable: We need to make a variable to track where we are in the table. So anywhere that is outside of a loop (Such as the top of the file or in MissionSetup) put something like "s = 1". That will make a variable named 's' that equals 1.

2) Make a table/list: We need to make a table for all the parts of the menu. We'll use a table for now because it is the simplest. I am making a new LUA tutorial soon though so that will cover the tables and stuff.
Styles = {"B_Striker_A","J_Striker_A","Nemesis","P_Bif","AN_DOG","N_Striker_B"}
This should be put right by the select variable we made earlier.
That will setup a table called "Styles" that has 6 styles in it. We access the certain parts of it by using Styles[x] where x is the part of the table we are trying to get. So Styles[3] for example would get Nemesis since it is the 3rd part of the Styles table.

3) A way to change the variable: In the main loop (Probably where it says 'repeat' in 'main') we should put a function called something like "F_Styles" that will have all the code for our style selector. Inside F_Styles we will make the variable change when you press the button 0 or 1 (In LUA that is left and right) by putting IsButtonBeingPressed(b,c) where b is the button number and c is the controller. As said before 0 and 1 are left/right for the button, and the controller is usually 0 because that is the player's controller. (Even if you are playing with a keyboard, it is counted as the controller so still put 0) The function returns true if the button was just pressed, and false if it was not. So we could do...
if IsButtonBeingPressed(0,0) and s > 1 then
  s = s - 1
end
For making it go left, and right is done in a similar way. (View the code at the bottom if you need to see it all as I'll write an example there) We did "and s > 1" to make sure that we are above 1 before going down so that 1 will be the lowest we can go. The function table.getn(Styles) gets the length of the table so we can use that for selecting right.

4) Displaying the menu: The simple way is to use TextPrintString. We could do like TextPrintString("Style: "..Styles,1,1) inside of our F_Styles function and then it would display what style we are currently on. If you want a menu system like Super Mod then wait until I release a new one, as the current one I have released is kinda glitched. Or figure it out yourself if you want but it is kind of complex.

5) Confirming your selection: This part is easy, very similar to changing the variable. I use the zoom out button because it doesn't really do too much in the game so it works nice. 3 is down. When we set action trees (Styles) we need it to be like "/Global/P_Striker_A","Act/Anim/P_Striker_A,act" so you may wonder how it will work with our Styles table. Simple, we can append the strings together using "..". Some people put the entire string "/Global/P_Striker_A" in their tables but that will actually just take up memory that could be saved by doing what we are doing. So, we could do...
if IsButtonBeingPressed(3,0) then
  PedSetActionTree(gPlayer,"/Global/"..Styles,"Act/Anim/"..Styles..".act")
end

Final Example:
Code: [Select]
MissionSetup = function()
  s = 1
  Styles = {"B_Striker_A","J_Striker_A","Nemesis","P_Bif","AN_DOG","N_Striker_B"}
end

MissionCleanup = function()
end

main = function()
  repeat
    F_Styles()
Wait(0) -- The repeat loop will crash without this
  until not Alive
end

F_Styles = function()
  if IsButtonBeingPressed(0,0) and s > 1 then
    s = s - 1
  elseif IsButtonBeingPressed(1,0) and s < table.getn(Styles) then
    s = s + 1
  elseif IsButtonBeingPressed(3,0) then
    PedSetActionTree(gPlayer,"/Global/"..Styles[s],"Act/Anim/"..Styles[s]..".act")
  end
end

Hope I didn't confuse you... xD
You probably want to use tables of lists for tables but I will be teaching how lists and tables work in my upcoming tutorial.
Also you can add more styles to the Styles = {} part in that script obviously if you want a full style selector.
« Last Edit: August 23, 2014, 02:40:04 AM by DaBOSS54320 »