cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 21 Sep 2012 11:56 PM |
So, a table (it's called array in most other scripting languages) is a variable that holds multiple values, it can range from integers to strings and instances.
------------------------------------------------------------------------------- How you would start a table
TableName = {"Value1", 2.1234, game.Workspace:GetChildren()} That would make a table with the values of: Value1, 2.1234, and an array of all the objects in workspace
Multi tables
UserInfo = { {"Cnt", 12, 51, game.Players["CntKillMe"]}, {"Crus", 12, 51, game.Players["Crusada91"]} }
Even triple/quadruple/etc tables work: Lol = { { { { 1 }, {1}, 1 } , 1}, 1} |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 21 Sep 2012 11:57 PM |
To insert into a table
table.insert(TableName, Value)
Example:
Usrs = {"cnt", "crus"} table.insert(Usrs, "roblox"}
Then, Usrs will equal {"cnt", "crus", "roblox"} |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 21 Sep 2012 11:57 PM |
To remove from a table
table.remove(TableName, Location)
Examples:
Usrs = {"cnt", "crus", "roblox"} table.remove(Usrs, 2)
Then, Usrs will equal {"cnt", "roblox"}
Note: Roblox's tables start from 1, most other languages start from 0
Example:
Roblox Usrs = {"lol", "lol2", "lol3"} Index of lol = 1, lol2 = 2, lol3 = 3
JavaScript Usrs = ["lol", "lol2", "lol3"] Index of lol = 0, lol2 = 1, lol3 = 2
PHP $Usrs = Array("lol", "lol2", "lol3") Index of lol = 0, lol2 = 1, lol3 = 2
VisualStudios Dim Usrs = {"lol", "lol2", "lol3"} Index of lol = 0, lol2 = 1, lol3 = 2 |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 21 Sep 2012 11:58 PM |
To view a value from a table
TableName[Index]
Example: Usrs = {"lol", "lol2", "lol3"} print(TableName[1])
That would print "lol"
To see if a value is contained in a table
Usrs = {"lol", "lol2", "lol3"}
if #Usrs == 0 then return end --Hashtag indicates the length of the table, if the table is empty then it will just stop running a function for i = 1, #Usrs do --Start a for loop from 1 until amount of users [3 in this case] if Usrs[i] == "lolz" then --Checks if the table[index] equals lolz return true --It does! end end return false --Aww
Note for other languages
To get length of array from:
JavaScript ArrayName.length
PHP count($ArrayName)
VisualStudios UBound(ArrayName)
So, need help? Just comment and I will get to it asap |
|
|
| Report Abuse |
|
|
rayoma
|
  |
| Joined: 13 Nov 2009 |
| Total Posts: 1911 |
|
|
| 22 Sep 2012 12:59 AM |
tab={ a=3; b=tab; };
print(tab.a);--3 print(tab.b.b.b.b.b.b.b.b.b.b.b.a);--3
c={}; c[true]=function() print("Yes"); end c[false]=function() print("No"); end
c[ 1==1 ]();--Yes c[ 1==2 ]();--No
Forgot that stuff |
|
|
| Report Abuse |
|
|