LUA Library
Basic functions
ASSERT (V,[,message])
When V is false, a message is returned
ASSERT (Money >0, "error-1001");
CollectGarbage ([Opt,[arg]]);//garbage collection related
Collet Stop Restart count step setpause Setstepmul
View memory is CollectGarbage ("count");
Error (Message,[,level]);
Error ("This operations is invalid");
_g global variables contain all of the global variables and functions
Getfenv ([f]) The current environment used by the current function f can be a function or a number
Getmetable (object) The current object has an associated metatable
Ipairs (t) output continuous array format
Load (Func[,chunkname]))???
LoadString (String, "Chunkname")???
Next (table, "index")
T = {"One", "Deux", "Drei", "Quarto"};
Print (Next (t,3));//Prints out key value//t[3] only prints out value
Pairs (t) Traversal object
Pcall (f,arg1,...) function protection situation Call
Rawget (table,index) equals table "index"
Rawset (Table,index,value) equals table[index] = value;
Select (Index,...) //???
Setfenv (f,table)//Setting the environment of the function
Setmetatable (table,metatable);
Tonumber (), ToString () type conversion
Type () view type//nil,number,string,boolean,table,thread,userdata
Unpack (List,[i,[j]]);//
MYT = {1,2,3,4,5,5,6,7,78,8,8,9};
Print (Unpack (myt,3,8))
System Library
Common libraries have table string math file os
Table functions
Table.concat (atable,start,end);//The value of the printed table
Table.insert (Atable,pos,value)
Table.remove (Atable,pos);
Table.sort (Atable,compare)//The second parameter is called after each comparison
OS functions
Os.clock ();//clock interval, CPU interval for executing instructions
Os.date ();//Date
Os.difftime ()//Time difference
Os.remove (filename);//removing files
Os.rename (oldname,newname);//Modify file name
Os.time ()//Time
Os.tmpname ();//Random name
Common Uses of table
As an array
As a hash table (Key,value)
. And: The difference
The colon includes itself.
Pure Lua under MAC (ii)