Forum

> > CS2D > Scripts > What is Table?
Forums overviewCS2D overview Scripts overviewLog in to reply

English What is Table?

10 replies
To the start Previous 1 Next To the start

old What is Table?

Paulo49
User Off Offline

Quote
Example Script With Table please?
edited 1×, last 18.09.15 02:26:25 am

old Re: What is Table?

XoOt
Super User Off Offline

Quote
Quote
What is Table?


Answer:
This is a table.

IMG:https://www.mrrental.com.au/media/furniture/cobran-coffee-table.jpg?sfvrsn=2


You will see most tables in addition with something suspicious called 'chair'. Here's a image if you also dont know it.
IMG:https://cdn.mattblatt.com.au/productimages/The-Matt-Blatt-Replica-Emeco-US-Navy-Chair-Aluminium?w=440&h=460&id=15590&fullSize=True


Ps: no need to thank me, im glad that i could help.

old Re: What is Table?

TimeQuesT
User Off Offline

Quote
user XoOt: definitely one of the best answers I've ever seen

Well to make it short: A table is a variable that actually holds many other variables.

Here's a example:
1
2
3
4
pseudo_table = {5, 10, 15, 1, 3, 100};
for i = 1, #pseudo_table do
	print(pseudo_table[i]);
end

Imagine if there were no tables:
1
2
3
4
5
6
7
8
9
10
11
12
13
a = 5;
b = 10;
c = 15;
d = 1;
e = 3;
f = 100;

print(a);
print(b);
print(c);
print(d);
print(e);
print(f);

Something special in lua is that a table can store many variables of many types. Unlike in c++ or in many other programming languages.

LUA
1
pseudo_table = {100, 50, 20, "This is a string!", "hey another string :D", 5.0, 3.0};

C++
1
2
3
int pseudo_array_int[3] = {100, 50, 20};
std::string pseudo_array_string[2] = {"This is a string!", "hey another string :D"};
float pseudo_array_float[2] = {5.0f, 3.0f};
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview