Skip to content

Documentations

Jurian / Lucy edited this page Oct 16, 2020 · 8 revisions

Installation

Getting this module isn't really the most challenging. There are several ways you could do this.

  1. Copy and pasting the code from here
  2. Pulling the github repo (in case you work in Visual Studio Code) and using it as any other normal module
  3. Obtaining the freemodel which can be acquired here

Functionality Documentation

SmartTables.new(<Table> target, <string> reference name, <boolean> shared)

Description
creates a new smart table allowing for quick searching through it.

Parameters

Variable name Type Description
target table The template of which the smart table will take the base from to create a more easier to use table functionality
reference name string This is an optional variable, if left empty it will default to a randomly generated string. only really applies to when the table is shared
shared boolean this boolean defaults to false, if set to true other scripts of the same permission layer can access the storage to modify or read the table (server on itself or client on itself)

Returns

Variable name Type Description
Init_Metatable Metatable Can be used to have simplistic control over your table.

SmartTables.GetTable(<string> Name)

Description
Returns the shared smart table that's affiliated with the given name, if any.

Parameters

Variable name Type Description
Name string The name of one of the shared smart tables.

Returns

Variable name Type Description
Init_Metatable Metatable Can be used to have simplistic control over your table.

Init_Metatable:GetRaw()

Description
Returns the raw table from the point entry. In this case the full table without any metatables inserted.

Returns

Variable name Type
Raw_table table

Init_Metatable:getn()

Description
Returns the table count (not descendant count) of the table, regardless of if this table is a dictionary, array or a mix. similar to #Table

Returns

Variable name Type
Count int

Init_Metatable:Dispose()

Description
Disposes the full smart table. An empty table will remain on the initial smart table's variable, that variable would need to be manually disposed by setting it to nil (or simply by doing Init_Metatable = Init_Metatable:Dispose())

Init_Metatable["ValueName"]

Description
This is a special indexation, by indexing anything that's below the Init_Metatable it will return the value of the given ValueName. Examples can be found here. It's basically a recursive search.

Returns

Variable name Type Description
PostInit_Metatable Metatable similar to Init_Metatable but with some limitations

PostInit_Metatable:GetRaw()

Description
Returns the raw table from the point entry. In this case taking the table segment of this key

Returns

Variable name Type
Raw_table table

PostInit_Metatable:getn()

Description
Returns the table count (not descendant count) of the table, regardless of if this table is a dictionary, array or a mix. similar to #Table

Returns

Variable name Type
Count int

PostInit_Metatable["ValueName"]

Description
This is a special indexation, by indexing anything that's below the PostInit_Metatable it will return the value of the given ValueName. Examples can be found here. It's basically a recursive search.

Returns

Variable name Type
PostInit_Metatable Metatable

Creation & Instantiation

in order to require and create a smart table simply follow the next couple steps

local SmartTables = require("SmartTableLocation") -- replace "SmartTableLocation" with the hierarchy reference to the table
local Table = SmartTables.new({
    Table445 = {
        Table21 = {
            Table2 = {
                Table3 = {
                    Meh = {
                        TargetTable = {
                            Table5 = {
                                Secondary = {
                                    Value = 256
                                }
                            }
                        },
                    }
                }
            }
        };
        Table45 = {
            Value = 7;
        };
        {
            Value23 = 2;
        }
    }
})

That's all there is to creating it, you use it like a normal table but easier. to get to the variable Value you can easily just do

local ValueReference = Table.Value

But what about multiple variables with different parent tables BUT with the same name? it would just pick the wrong one right? well in the example above it would pick the first one it could find that matches the criteria. However you can go to the desired value in any way you'd like. for example;

local ValueReference = Table.Secondary.Value 

or

local ValueReference = Table.Table45.Value

Documentations
Base
Functionalities
Examples

Clone this wiki locally