Mosr's Scripts

Tables are simple



Take your regular variable: target = "senoske"

and when you call on "target" it'll return with "senoske". 


Now, we can put target inside of another variable with it's current value. The variable name becomes a key, and "senoske" becomes the value of that key. The variable we put target into then becomes a table.


thisTable = { --table name and open the table
   ["target"] = "senoske"  --key/value pair
   } --close the table


So, now it's a table. "target" is the key and "senoske is the value".


Normally we'd use send("kill " to call "senoske" from the variable. This doesn't change much- we'd use


so, send("kill " would be used. The spot before the period says "Yeah, the street name we're looking for is "thisTable". The spot after says "The house number we're looking for is "target", who owns that house?"


So, it'll pull "senoske" out of and voila you have a table.

There are multiple kinds of tables. The two simplest and easiest to understand are numbered tables and libraries. 

Numbered tables have numbers for the keys, so like:


thisTable = {  --name and open
   [1] = "lala",     --key/value
   [2] = "hoho",     --key/value
   [3] = "meme",     --key/value
   }--make sure to always close your table.


And libraries look like this:

thisTable = { --name and open
   ["target"]  = "senoske"  --key/value
   ["ally"]    = "karai"    --key/value
   ["sensefor"]= "jalo"     --key/value



You call all of these the same way, only the syntax is a little different. For a library, you'd do or 


For a numbered table you'd do thisTable[1] or thisTable[2].


If you want to loop through a table and echo its contents, you'd use FOR. There are two kinds of FOR. There is one for libraries, and one for numbered tables. 


For libraries you'd use:

for k,v <--these two letters don't matter. They can be words or whatever. The easiest is to just use k for key and v for value.

for k,v in pairs(thisTable) do  <--pairs is for libraries. ipairs is for numbered tables. Think of it like "integer pairs)



for k,v in pairs(thisTable) do

That would echo the library like this: "senoskekaraijalo"


So you'd want to change the echo to:

echo(v.." ")

and it would turn out like this: "senoske karai jalo "

With tables, the possibilities are endless. I hope this helps.