A Roblox Community

A community of Robloxians who want to learn to script and build on Roblox Studio.
 
HomeFAQRegisterLog 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
 
naknak
 
Supernapalm
 
m27frogy
 
slayer9365
 
myrco919
 
branefreez
 
ninga95
 
CloneTrooper787
 
raboy117
 
Top posting users this month
Latest topics
» Send me an Email
January 8th 2016, 10:14 am by naknak

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

» New Site Possibly
July 6th 2015, 4:16 pm by m27frogy

» Ambassador!
April 15th 2015, 11:40 pm by naknak

» Boop - Tag
April 13th 2015, 9:46 pm by naknak

» Vip Class Script
April 13th 2015, 4:54 pm by naknak

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

» Where to go from here.
April 13th 2015, 4:51 pm by naknak

» Genesis Point
July 17th 2014, 7:04 pm by branefreez

» Reward System
July 17th 2014, 5:41 am by m27frogy

» Script Request
July 10th 2014, 11:43 am by naknak

» local scripts?
July 10th 2014, 11:39 am by naknak

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

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

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

» FlashLight Script
January 1st 2014, 2:11 pm by m27frogy

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

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

» Improve Coding
October 26th 2013, 1:12 pm by pook03

» Simple Button
September 1st 2013, 6:19 pm by branefreez


Share | 
 

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

Go down 
AuthorMessage
myrco919
Intermediate Scripter
Intermediate Scripter
avatar

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

PostSubject: Tables..............   January 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
avatar

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

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

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

Posts : 878
Join date : 2010-07-30

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

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


Posts : 393
Join date : 2011-01-17

PostSubject: Re: Tables..............   January 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



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

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

Posts : 878
Join date : 2010-07-30

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

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


Posts : 393
Join date : 2011-01-17

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

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

Posts : 878
Join date : 2010-07-30

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

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

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

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

Back to top Go down
myrco919
Intermediate Scripter
Intermediate Scripter
avatar

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

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

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



PostSubject: Re: Tables..............   February 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
avatar

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

PostSubject: Re: Tables..............   March 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
avatar

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

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

isn't it table.insert(tab,k,"Hello World")???

_________________
blueymaddog
Administrator • Moderator • Expert Scripter
PM: blueymaddog
<+1 post. ujelly?>
Back to top Go down
myrco919
Intermediate Scripter
Intermediate Scripter
avatar

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

PostSubject: Re: Tables..............   March 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
avatar

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

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

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

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

PostSubject: Re: Tables..............   March 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

_________________
blueymaddog
Administrator • Moderator • Expert Scripter
PM: blueymaddog
<+1 post. ujelly?>
Back to top Go down
Sponsored content




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

Back to top Go down
 
Tables..............
Back to top 
Page 1 of 1
 Similar topics
-
» Setting Correct Hashtable Size????
» Gaviota
» Stars tournament table after 385 games ( 385 / 550 )
» Stockfish + syzygy tables rules
» Stockfish syzygy tables ???

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