A Roblox Community
Would you like to react to this message? Create an account in a few clicks or log in to continue.

A Roblox Community

A community of Robloxians who want to learn to script and build on Roblox Studio.
 
HomeLatest imagesRegisterLog in
If you're a experienced coder make some tutorials! It would really help the site grow.
Make sure you read the rules(Which can be found by clicking here)
If you're a beginner at coding, try some tutorials.
We have many Moderators/Admins watching this site. Contact them with Questions.
Let us know what your favorite sport is. By clicking here to vote (Click here)
This site is becoming inactive. Lets make it active.
Log in
Username:
Password:
Log in automatically: 
:: I forgot my password
Top posters
blueymaddog
Tables.............. Vote_lcapTables.............. Voting_barTables.............. Vote_rcap 
naknak
Tables.............. Vote_lcapTables.............. Voting_barTables.............. Vote_rcap 
Supernapalm
Tables.............. Vote_lcapTables.............. Voting_barTables.............. Vote_rcap 
m27frogy
Tables.............. Vote_lcapTables.............. Voting_barTables.............. Vote_rcap 
slayer9365
Tables.............. Vote_lcapTables.............. Voting_barTables.............. Vote_rcap 
myrco919
Tables.............. Vote_lcapTables.............. Voting_barTables.............. Vote_rcap 
branefreez
Tables.............. Vote_lcapTables.............. Voting_barTables.............. Vote_rcap 
ninga95
Tables.............. Vote_lcapTables.............. Voting_barTables.............. Vote_rcap 
CloneTrooper787
Tables.............. Vote_lcapTables.............. Voting_barTables.............. Vote_rcap 
raboy117
Tables.............. Vote_lcapTables.............. Voting_barTables.............. Vote_rcap 
Top posting users this month
No user
Latest topics
» Where to go from here.
Tables.............. EmptySeptember 14th 2020, 1:20 pm by MrNicNac

» Send me an Email
Tables.............. EmptySeptember 14th 2020, 1:16 pm by MrNicNac

» [v1.6.0.0] Lua Script Obfuscator [No Bytecode]
Tables.............. EmptyJuly 6th 2015, 7:38 pm by m27frogy

» New Site Possibly
Tables.............. EmptyJuly 6th 2015, 4:16 pm by m27frogy

» Ambassador!
Tables.............. EmptyApril 15th 2015, 11:40 pm by naknak

» Boop - Tag
Tables.............. EmptyApril 13th 2015, 9:46 pm by naknak

» Vip Class Script
Tables.............. EmptyApril 13th 2015, 4:54 pm by naknak

» Who's active?!
Tables.............. EmptyApril 13th 2015, 4:52 pm by naknak

» Genesis Point
Tables.............. EmptyJuly 17th 2014, 7:04 pm by branefreez

» Reward System
Tables.............. EmptyJuly 17th 2014, 5:41 am by m27frogy

» Script Request
Tables.............. EmptyJuly 10th 2014, 11:43 am by naknak

» local scripts?
Tables.............. EmptyJuly 10th 2014, 11:39 am by naknak

» Project: Reconstruction [Died]
Tables.............. EmptyJuly 10th 2014, 11:36 am by naknak

» Hi. I am new here
Tables.............. EmptyApril 26th 2014, 4:01 pm by altshiftkey

» What's your favorite sport?
Tables.............. EmptyJanuary 1st 2014, 2:13 pm by m27frogy

» FlashLight Script
Tables.............. EmptyJanuary 1st 2014, 2:11 pm by m27frogy

» Gun Making! [READ DESC]
Tables.............. EmptyJanuary 1st 2014, 2:10 pm by m27frogy

» Hi, I am new here!
Tables.............. EmptyNovember 26th 2013, 3:33 pm by Keanu73

» Improve Coding
Tables.............. EmptyOctober 26th 2013, 1:12 pm by pook03

» Simple Button
Tables.............. EmptySeptember 1st 2013, 6:19 pm by branefreez


 

 Tables..............

Go down 
4 posters
AuthorMessage
myrco919
Intermediate Scripter
Intermediate Scripter
myrco919


Posts : 190
Join date : 2011-01-21
Age : 26
Location : Holland

Tables.............. Empty
PostSubject: Tables..............   Tables.............. EmptyJanuary 29th 2011, 4:38 am

~-Replace this Thread when it's supposed to be somewhere else-~

Welcome to my second tutorial/guide wich is about Tables.

~-Indexing-~
Tables are good for storing data, you create a Table by using the '{}' symbols:

Code:
local tab = {}

Indexing a table is easy and can be done in around four ways:

Code:
local tab = {k = "Hello World"}

or

Code:
local tab = {}
table.insert(tab, k = "Hello World")

or

Code:
local tab = {}
table.insert(tab, k = "Hello World", 1)

Now example1 will create a table with k = "Hello World", so if I say print(k) it will result in "Hello World".

Example2 creates an empty Table and indexes it with k = "Hello World" so afther that the Table looks like example1.

Example3 creates an empty Table too, but the given value is indexed on key 1.

~WARNING: Don't call a Table 'table' or 'Table' also don't frogot that table.insert(table, value, key) might replace the key that's aleardy been setted:
local tab = {j = "Hello World"}
print(j) --> Hello World
table.insert(tab, j = "Oh my", 1)
print(j) --> Oh my ~
_________________________________________________________________________________________________

~- The use of for loops in a Table -~

For loops are very usefull at Tables:

Code:
local names = {}
script.Parent.Touched:connect(function(p)
local h = p.Parent:findFirstChild("Humanoid")
if h then
for _,v in pairs (names) do
if h.Parent.Name == v then
print("Aleardy touched")
elseif h.Parent.Name ~= v then
table.insert(names, h.Parent.Name)
end
end
end
end)

So that creates a Table called "names".
Line 2, 3 and 4 are obvious.
Line 5: A for loop is created with v == all values in the Table "names"
Line 6: Checks if h.Parent's Name is equal to all the values in the Table names.
Line 7: If the if statement returns true then it prints "Aleardy touched".
Line 8: Else h.Parent's Name ISN'T equal to all the values stored in the Table "names" then
Line 9: If the elseif statement returns true then it inserts h.Parent's Name into the Table "names"
Line 10-13 are all the ends.

________________________________________________________________________________________________
There are many Table functions, such ash table.insert, table.insert, table.concat etc read more about these functions in the Wiki:
http://wiki.roblox.com/index.php/Function_Dump/Table_Manipulation

Don't like this Thread? Well then read the Wiki:
http://wiki.roblox.com/index.php/Table
Back to top Go down
myrco919
Intermediate Scripter
Intermediate Scripter
myrco919


Posts : 190
Join date : 2011-01-21
Age : 26
Location : Holland

Tables.............. Empty
PostSubject: Re: Tables..............   Tables.............. EmptyJanuary 29th 2011, 12:47 pm

Someone rate please?
Back to top Go down
naknak
Administrator
Administrator
naknak


Posts : 878
Join date : 2010-07-30

Tables.............. Empty
PostSubject: Re: Tables..............   Tables.............. EmptyJanuary 29th 2011, 1:27 pm

Pretty good.
Back to top Go down
Supernapalm
Expert Scripter
Expert Scripter
avatar


Posts : 393
Join date : 2011-01-17

Tables.............. Empty
PostSubject: Re: Tables..............   Tables.............. EmptyJanuary 29th 2011, 2:32 pm

i think you should put more philosophical information in this
Back to top Go down
http://hackthissite.org
Guest
Guest
avatar



Tables.............. Empty
PostSubject: Re: Tables..............   Tables.............. EmptyJanuary 29th 2011, 5:06 pm

I think you should put more correct information in this :/
Back to top Go down
naknak
Administrator
Administrator
naknak


Posts : 878
Join date : 2010-07-30

Tables.............. Empty
PostSubject: Re: Tables..............   Tables.............. EmptyJanuary 29th 2011, 5:07 pm

Better way to say it ;)
Back to top Go down
Supernapalm
Expert Scripter
Expert Scripter
avatar


Posts : 393
Join date : 2011-01-17

Tables.............. Empty
PostSubject: Re: Tables..............   Tables.............. EmptyJanuary 29th 2011, 7:22 pm

i think correct and philosophical are different
Back to top Go down
http://hackthissite.org
naknak
Administrator
Administrator
naknak


Posts : 878
Join date : 2010-07-30

Tables.............. Empty
PostSubject: Re: Tables..............   Tables.............. EmptyJanuary 29th 2011, 8:04 pm

maybe so. Close enough to be the same.
Back to top Go down
myrco919
Intermediate Scripter
Intermediate Scripter
myrco919


Posts : 190
Join date : 2011-01-21
Age : 26
Location : Holland

Tables.............. Empty
PostSubject: Re: Tables..............   Tables.............. EmptyFebruary 6th 2011, 8:21 am

Back to top Go down
myrco919
Intermediate Scripter
Intermediate Scripter
myrco919


Posts : 190
Join date : 2011-01-21
Age : 26
Location : Holland

Tables.............. Empty
PostSubject: Re: Tables..............   Tables.............. EmptyFebruary 6th 2011, 8:22 am

Altough I wanted to make a quick tutorial.
Back to top Go down
Guest
Guest
avatar



Tables.............. Empty
PostSubject: Re: Tables..............   Tables.............. EmptyFebruary 13th 2011, 4:31 pm

uggg im very confused, can someone explain this to me i might have missed something or im just a noob idk can someone tell me what that script would do ^ -_-
Back to top Go down
myrco919
Intermediate Scripter
Intermediate Scripter
myrco919


Posts : 190
Join date : 2011-01-21
Age : 26
Location : Holland

Tables.............. Empty
PostSubject: Re: Tables..............   Tables.............. EmptyMarch 6th 2011, 4:18 pm

@cookie:
'
So that creates a Table called "names".
Line 2, 3 and 4 are obvious.
Line 5: A for loop is created with v == all values in the Table "names"
Line 6: Checks if h.Parent's Name is equal to all the values in the Table names.
Line 7: If the if statement returns true then it prints "Aleardy touched".
Line 8: Else h.Parent's Name ISN'T equal to all the values stored in the Table "names" then
Line 9: If the elseif statement returns true then it inserts h.Parent's Name into the Table "names"
Line 10-13 are all the ends.
'
Back to top Go down
blueymaddog
Administrator
Administrator
blueymaddog


Posts : 1081
Join date : 2010-12-09
Age : 26

Tables.............. Empty
PostSubject: Re: Tables..............   Tables.............. EmptyMarch 20th 2011, 6:18 am

isn't it table.insert(tab,k,"Hello World")???
Back to top Go down
myrco919
Intermediate Scripter
Intermediate Scripter
myrco919


Posts : 190
Join date : 2011-01-21
Age : 26
Location : Holland

Tables.............. Empty
PostSubject: Re: Tables..............   Tables.............. EmptyMarch 21st 2011, 9:26 am

No, cuz k isn't a number value and I want k being defined to "Hello World".
Back to top Go down
myrco919
Intermediate Scripter
Intermediate Scripter
myrco919


Posts : 190
Join date : 2011-01-21
Age : 26
Location : Holland

Tables.............. Empty
PostSubject: Re: Tables..............   Tables.............. EmptyMarch 21st 2011, 9:27 am

Bluey, did you lose your admin powers?
Back to top Go down
blueymaddog
Administrator
Administrator
blueymaddog


Posts : 1081
Join date : 2010-12-09
Age : 26

Tables.............. Empty
PostSubject: Re: Tables..............   Tables.............. EmptyMarch 27th 2011, 6:21 am

yup , and I got them back!

test this:
print(table.insert({},"k","Hello World!")["k"])

it should print 'Hello World!" in the output. correct me if I'm wrong
Back to top Go down
Sponsored content





Tables.............. Empty
PostSubject: Re: Tables..............   Tables.............. Empty

Back to top Go down
 
Tables..............
Back to top 
Page 1 of 1
 Similar topics
-
» TABLES!!!!

Permissions in this forum:You cannot reply to topics in this forum
A Roblox Community :: Tutorials and Resources :: Intermediate-
Jump to: