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


Author Topic: Menu and Tables dicussion  (Read 2746 times)

0 Members and 1 Guest are viewing this topic.

Offline AlphaTech

  • LostInSpace
  • Sr. Member
  • ***
  • Posts: 758
  • Gender: Male
  • The name's AlphaTECH, whatca need help with?! :)
    • View Profile
Menu and Tables dicussion
« on: September 26, 2015, 06:39:17 AM »
I am about to get a new pc and my original hard drives files are corrupted I don't know how this happened though but I think I downloaded to many games,movies,music etc and exceeded my 500GB'S. I am moving on to 2TB's now onw external drive and one built in typical drive but enough about my hunk of junk.  :ffvsielj3:

I just wanted a step by step tutoriala on menu's and how to do table's I had files explaining this but their lost to corruption. I never really got the whole Table or Menu thing anyway seems like my brain is always like this.



I need a complete step by step so of course DabossPonyBoy get your lazy ass here n help wit dis shiat and you to UnknownFaggit IE mean UnknownBrilliance  :D. Just joking but please help  :blank:

Offline Unknownsoldier

  • Hero Member
  • ****
  • Posts: 2,773
    • View Profile
Re: Menu and Tables dicussion
« Reply #1 on: September 26, 2015, 08:05:42 PM »
...UnknownFaggit IE mean UnknownBrilliance  :D. Just joking but please help  :blank:
t's what i thought fucking fgt

Offline MadmaN

  • Bully-Board Admin Team
  • Newbie
  • *
  • Posts: 0
  • Gender: Male
  • Biblio-Techa Mods (retired)
    • View Profile
Re: Menu and Tables dicussion
« Reply #2 on: September 26, 2015, 08:15:16 PM »
Give me a day or two and I will see about making a tutorial for you.

DaBOSS and I both have our own unique ways to do tables and menus.

There are several ways you can do a table and I will teach you DaBOSS's way as his way is just a bit more efficient then my own.

Far as Menus go, Both my way and his are pretty much the same on efficiency.

The thing you need to remember when working with tables, you cannot have a table go past a certain size...if it goes beyond that size then you will get crashes and other problems in the game...this is due to the limited address space in memory that Bully has. The easy way to get around this limitation is to split things up into multiple tables.

The easiest way to do all of this is to just use the built in index system...but the index system is really only good for testing and not something I reccomend for use on a release due to the fact that indexes cause you to use more code to get it looking just like as if tables were used.

Anything can be placed into a table. you can even place an entire lua code into a table all on its own in order to make it easier to access certain functions.

A typical table....this is how DaBOSS does his....will start much like the following:


Code: [Select]
function main()
  Wait(500)
  sensitivity = 0.1
  SetupThisTable()
  table = {
    --  Table Start
    {name","vehicle","stats"},
    {name","vehicle","stats"}
  }


To call from a table like this one you would use the following code. Please keep in mind that this is just a real quick and dirty example and not intended to be used directly.

 
Code: [Select]
  if IsButtonBeingPressed(2,0) then
                  s = s - 1
                  if s < 1 then s = table.getn(name) end
                elseif IsButtonBeingPressed(3,0) then
                  s = s + 1
                  if s > table.getn(name) then s = 1 end

This is just a loose and quick example to give you a basic idea. I know several ways to create tables and several ways to call from them.

If I know DaBOSS...he may try to help out here as well since he has pretty much developed tables into a literal artform all on his own and his style of doing tables is a very good one. Much better then my own personal style (if I do say so myself...and I DO!) and I have moved to using his method since it is very efficient.


I will try to help out more with this IF I get the time since I have been extremely busy the past couple weeks due to outdoor projects I need to get finished before winter gets here....almost done too... :biggrin:

Offline UltimateGamer9

  • Full Member
  • ***
  • Posts: 190
  • Gender: Male
    • View Profile
Re: Menu and Tables dicussion
« Reply #3 on: September 27, 2015, 12:42:41 AM »
Tables? Well is it like this you want?
 
Code: [Select]
local Select = 1
local Peds = {}

function main()
PedsSelector()
repeat
SetupPeds()
Wait(0)
until not Alive
end

function PedsSelector()
   while true do
   if IsButtonBeingPressed(0,0) and Select > 1 then
   Select = Select - 1
   TextPrintString("Peds Selector: " Peds[Select].Name,3,1)
   elseif IsButtonBeingPressed(1,0) and table.getn(Select) < 1 then
   Select = Select + 1
   TextPrintString("Peds Selector: " Peds[Select].Name,3,1)
   elseif IsButtonBeingPressed(3,0) then
   PlayerSwapModel(Peds[Select].Model)
end
Wait(0)
end
end

function SetupPeds()
  table.insert(Peds,Model = "player",Name = "Jimmy")
  table.insert(Peds,Model = "Nemesis_Gary",Name  = "Gary")
  table.insert(Peds,Model = "Peter",Name = "Pete")
end

Did you mean this? And credits to DaBOSS54320 for this one.

Offline Unknownsoldier

  • Hero Member
  • ****
  • Posts: 2,773
    • View Profile
Re: Menu and Tables dicussion
« Reply #4 on: September 27, 2015, 01:31:47 AM »
There are 3 ways that I have used in the past for tables. I will show you 2 of them because the one with "table.insert" is useless.



SECTION 1

Here is the way used for inserting SINGLE contents such as ped names:
tableName = {
  "my",
  "dogg",
  "died",
  "yesterday",
}


To return an option from this table, use this: tableName[2] -- That will return the "dogg" part.

So to print the word "dogg", we would do this:
TextPrintString(tableName[2], 3, 2)

Note that the number 2 in there can be replaced with any variable, for example if you were to make a menu out of it...



SECTION 2

The same method used for storing multiple items:
tableName = {
  {name = "tony", surname = "hawk"},
  {name = "per", surname = "son"},
  {name = "hel", surname = "lo"},
}

The return method in this part is really similar(if  not same) to the inserting method.

To return it, use: tableName[2].name -- This will return the "per" option in this table.

So if we were using it in a TextPrintString(), we would do this:
TextPrintString("Hello, my name is "..tableName[1].name.." "..tableName[1].surname, 3, 1) -- The "" "" part is for a space

Also, the ".." between all the texts separates them. Meaning, if you wanted to put "my" and "name" in a text, you could do this: TextPrintString("my ".."name", 3, 1)
That would print "my name" for 3 seconds as the large text on the top of the screen.



if u would add me on steam, i could send u shit bruh. add me: tha virgo

Offline DaBOSS54320

  • Hero Member
  • ****
  • Posts: 3,398
  • Gender: Female
    • View Profile
Re: Menu and Tables dicussion
« Reply #5 on: September 27, 2015, 09:20:55 AM »
I made a pretty lengthy tutorial here about tables/menus using a lot of images to guide you through how to do it using examples and explaining the code in each image.

Also... thanks mad, hehe.

Offline AlphaTech

  • LostInSpace
  • Sr. Member
  • ***
  • Posts: 758
  • Gender: Male
  • The name's AlphaTECH, whatca need help with?! :)
    • View Profile
Re: Menu and Tables dicussion
« Reply #6 on: September 27, 2015, 05:20:52 PM »
@Daboss Thanks Daboss I had your original tutorials down in my notes of such but my cpu is still down right now because of the crash so i'll have to wait till I get a new one. The hard drive is done tried changing it to a 1TB but it's completey fucked. I am just going to buy a new one all in all. So all my files are saved of course accept many of my notes as I forgot to put them in an external folder.

I am going to use the drop menu soon enough though when i'm able to. I plan to work on my zombie mod when I get my cpu. Can you give me a step by step tutorial on how you created a chapter skip in The Cure Two. I will try using your camera area code to setup up my cameras for Petes Missing I plan on releasing a full mission mod once I can create the chapter skip and use the cameras.

@Unknown and Madmam Thanks for your help also I am planning on releasing tons of mods this winter and now I understand tables completey. Thanks again hope everyone enjoys my mods when its released.

Offline DaBOSS54320

  • Hero Member
  • ****
  • Posts: 3,398
  • Gender: Female
    • View Profile
Re: Menu and Tables dicussion
« Reply #7 on: September 27, 2015, 07:07:24 PM »
Well basically I divide each part of my missions into separate functions. Usually I just name them like M1, M2, M3, and so on for each part of the mission (of course you can do it how you want and possibly more descriptive names, up to you). M1 would be called first after the initial setup (like after the starting menu runs), then at the end of that M1 function I'd call M2. At the end of M2 I'd call M3, and so on. Now here's the important part: for each part of the mission I want to be available to start on, I'd have a function for skipping to it that would setup everything the mission needs. For example, if on the menu you selected to skip to part 3 (M3) then a function called C_M3 would be called (C standing for checkpoint). C_M3 would setup everything that would of normally happened in parts 1 and 2 (M1 % M2) and then it would call the normal M3. For example if in part 2 or something Gary was spawned and recruited, then since M2 won't run (since we're skipping past it and going straight to part 3) we'll have to make C_M3 spawn and recruit Gary before calling M3 so that M3 can run properly.

Offline AlphaTech

  • LostInSpace
  • Sr. Member
  • ***
  • Posts: 758
  • Gender: Male
  • The name's AlphaTECH, whatca need help with?! :)
    • View Profile
Re: Menu and Tables dicussion
« Reply #8 on: September 27, 2015, 07:23:17 PM »
Okay I will need a lua setup of sorts lol you just explaining it is fine but I need a visual of how its being done. I also am adding an unlock function which will only run the next part of the mission only if you that certain part of the mission so if pedisdead then you can skip but if the pedisalive then it wont allow you skip. Their will be no way around it either. I'll set it to run a true or false to get the ped's values. So when you run the menu first part of the mission the first part will run fine but if you try to skip before that certain ped is dead then it doesn't allow it.