|
| 19 Feb 2015 09:43 PM |
| Are there any tutorials on accessing tables and using them. People seem like Geniuses at tables. The wiki article isn't helping. |
|
|
| Report Abuse |
|
|
gerov
|
  |
| Joined: 05 Feb 2011 |
| Total Posts: 5504 |
|
|
| 19 Feb 2015 09:53 PM |
lua.org has some good tutorials.
Why don't you take a seat over there? |
|
|
| Report Abuse |
|
|
|
| 19 Feb 2015 10:15 PM |
Think of tables as storage containers, here's a few examples of how to use them.
Example A: ---------------------------------------------------------------------------------------------- local t = {"Hi, ","table!","this ","is ","a "} print(t[1]..t[3]..t[4]..t[5]..t[2])
--Output: Hi, this is a table! ----------------------------------------------------------------------------------------------
Example B: ---------------------------------------------------------------------------------------------- local c = part:GetChildren() --returns a table containing all of the part's children
for i = 1,#c do
if c[i]:IsA("Decal") then --checks if the child is a decal c[i]:destroy() -- removes the decal end
end ----------------------------------------------------------------------------------------------
( ͡ಠ ͜ʖಠ) |
|
|
| Report Abuse |
|
|
| |
|
| |
|
|
| 20 Feb 2015 05:27 PM |
Could you go more in depth?
"I like to program." - Bosswalrus |
|
|
| Report Abuse |
|
|
|
| 20 Feb 2015 05:38 PM |
Let's say you were making an admin script. You would put all of the admin's names in a table, then check the player's name based on it. I will provide comments throughout this script to give examples.
local admins = {"LeitrisArcade","bosswalrus","Shedletsky"} -- table containing admin names
for i = 1,#admins do -- #admins stands for how many items are in the table(in this case 3) if ply.Name == admins[i] then
-- admins[i] means that you are going into the table, and finding the item in the table based on i. If you were to say "admins[1]", then it would see if the player's name was "LeitrisArcade", as LeitrisArcade is the first item in the table.
-- Code to make something happen if the player is an admin
end end
( ͡ಠ ͜ʖಠ) |
|
|
| Report Abuse |
|
|
Seranok
|
  |
| Joined: 12 Dec 2009 |
| Total Posts: 11083 |
|
|
| 20 Feb 2015 05:40 PM |
| Google "programming in lua 2.5" to learn about tables |
|
|
| Report Abuse |
|
|
|
| 20 Feb 2015 05:43 PM |
@LeitrisArcade Thank you. @Seranok Alright, thanks.
"I like to program." - Bosswalrus |
|
|
| Report Abuse |
|
|