Basic lua: Tables: Difference between revisions
From The Official Visionaire Studio: Adventure Game Engine Wiki
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
{| class="in" | {| class="in" | ||
|- | |- | ||
| Line 6: | Line 5: | ||
| class="i_arrow clickablecell" | [[basic_lua:_Functions|>]] | | class="i_arrow clickablecell" | [[basic_lua:_Functions|>]] | ||
|} | |} | ||
<hr> | |||
Tables are one of the features of Lua script, that make the scripting language so dynamic & easy to use, as they allow us to easily create tables, insert, remove & sort data. Tables are often comprised of arrays that usually involve keywords - or an index number - & a value. Tables can be accessed using multiple different methods. | |||
== Creating Tables == | == Creating Tables == | ||
Below I am going to show you how to create various different types of tables/arrays. | Below I am going to show you how to create various different types of tables/arrays. | ||
| Line 121: | Line 123: | ||
</syntaxhighlight> || width="180px" style="vertical-align:middle;" | [[File:Basic_lua_(tables)_5.png|frameless|center|180px]] | </syntaxhighlight> || width="180px" style="vertical-align:middle;" | [[File:Basic_lua_(tables)_5.png|frameless|center|180px]] | ||
|} | |} | ||
<hr> | |||
{| class="in" | {| class="in" | ||
|- | |- | ||
Revision as of 02:16, 3 September 2022
| < | Index | > |
Tables are one of the features of Lua script, that make the scripting language so dynamic & easy to use, as they allow us to easily create tables, insert, remove & sort data. Tables are often comprised of arrays that usually involve keywords - or an index number - & a value. Tables can be accessed using multiple different methods.
Creating Tables
Below I am going to show you how to create various different types of tables/arrays.
Index Tables
Keyword Tables
Index Values and Sub-Arrays
| auto generated index entries with sub-arrays containing keywords | |
|---|---|
local t = {
{x = 100, y = 300},
{x = 200, y = 111}
}
print("x = " .. t[1].x .. ", y = " .. t[1].y)
|
Keywords and Sub-Arrays
| < | Index | > |




