Well, a table isn't the only thing you need for a menu to work (but it is an important part of an efficient one). Here's some images I just put together explaining everything from variables to tables to how to make a menu. (
It took over an hour so I hope you appreciate it you lil shit).
You'll probably need to enlarge the images to read them.
Before moving onto tables, we need to cover variables a bit and how they can only store one value at once. Variables can only have 1 value at once. This is shown in the following image...
Before moving onto tables, you should also get that there are different types of variables. Here's a few:
x = 2 --
x is a variable with a
number value.
text = "Here's some text" --
text is a variable with a
string value. a
string is text in between 2 quotes, the quotes distinguish it from code
missiongRunning = true --
missionRunning is a variable with a
boolean value, a
boolean is either true or false.
var = nil --
var is a variable with a
nil value, which actually means.... no value. This variable stores no value.
nil means
no value.
A table... is actually just another type of variable. Tables are what we will need to store multiple values in a single variable.
On line 22 I messed up, some of the text isn't showing. It's meant to say "as you can see, we can use the ped handles we stored in the table just like ped handles we'd store in regular variables"
You can set the initial values of a table by filling in the braces too.
A very useful trick that you can do with tables is use a variable to access certain elements of the table. (Ignore the friend who stole my username, didn't realize that got screenshotted)
Now that you get how tables work a bit, let's move onto a different topic for a moment... the basics of menus. This example just shows changing the value of a variable, but you'll need to get it before moving on. (Changed the color to stand out a bit more)
Now back to tables. I have 2 things to show... in one image (save the cyber trees). First the fact that tables, can store tables. Secondly that you can use strings as keys to tables.
Diverting from tables again. Here's another type of variable... one that refers to a function. So far the examples haven't had any functions in them (and thus couldn't be ran) because they haven't needed it to teach what I was trying to teach. This one since it deals with functions does however (but it's still not runnable without MissionSetup).
Using everything you've learned up to this point.... let's try to make a basic menu.
Here's what the style selector part of that could be.
Our menus so far have a few problems though... one, we used the sprint button as a selection button. That means if the player tries to run while using the menu, he'll be selecting things in the menu on accident. Also, the script ends after 1 selection is made and you can't go back in the menu and select another thing. Here, we'll fix all of that.
Topic talking about why the call to
Wait was used where it was in the last image:
http://www.bully-board.com/index.php?topic=22715.0The code for the example shown in the last image:
http://pastebin.com/pM9r2HL1I hope this has all helped you, if you have any questions feel free to ask.
Edit: Forgot to include a link to that LUA timing topic.... whoops.