Advertisement
Guest User

lua5.api

a guest
Mar 5th, 2016
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.95 KB | None | 0 0
  1. _G () holds global environment, setfenv changes environments
  2. _VERSION current interpreter version "Lua 5.1"
  3. assert (v [, message]) error if v nil or false, otherwise returns v
  4. bit.arshift(x, n) arithmetic right-shift
  5. bit.band(x1 [,x2...]) bitwise 'and' of arguments
  6. bit.bnot(x) bitwise 'not' of argument
  7. bit.bor(x1 [,x2...]) bitwise 'or' of arguments
  8. bit.bswap(x) swaps the bytes of the argument (32-bit little-endian/big-endian)
  9. bit.bxor(x1 [,x2...]) bitwise 'xor' of arguments
  10. bit.lshift(x, n) logical left-shift
  11. bit.rol(x, n) bitwise left rotation
  12. bit.ror(x, n) bitwise right rotation
  13. bit.rshift(x, n) logical right-shift
  14. bit.tohex(x [,n]) Converts its first argument to a hex string
  15. collectgarbage ([limit]) set threshold to limit KBytes, default 0, may run GC
  16. coroutine.create (f) creates coroutine from function f, returns coroutine
  17. coroutine.resume (co, val1, ...) continues execution of co, returns bool status plus any values
  18. coroutine.status (co) returns co status: "running", "suspended" or "dead"
  19. coroutine.wrap (f) creates coroutine with body f, returns function that resumes co
  20. coroutine.yield (val1, ...) suspend execution of calling coroutine
  21. debug.debug () enters interactive debug mode, line with only "cont" terminates
  22. debug.gethook () returns current hook function, hook mask, hook count
  23. debug.getinfo (function [, what]) returns table with information about a function
  24. debug.getlocal (level, local) returns name and value of local variable with index local at stack level
  25. debug.getupvalue (func, up) returns name and value of upvalue with index up of function func
  26. debug.sethook (hook, mask [, count]) sets given function as a hook, mask="[crl]"
  27. debug.setlocal (level, local, value) sets local variable with index local at stack level with value
  28. debug.setupvalue (func, up, value) sets upvalue with index up of function func with value
  29. debug.traceback ([message]) returns a string with a traceback of the call stack
  30. dofile (filename) executes as Lua chunk, default stdin, returns value
  31. error (message [, level]) terminates protected func, never returns, level 1 (default), 2=parent
  32. file:close () closes file
  33. file:flush () saves any written data to file
  34. file:lines () returns iterator function to return lines, nil ends
  35. file:read (format1, ...) reads file according to given formats, returns read values or nil
  36. file:seek ([whence] [, offset]) sets file pos, whence="set"|"cur"|"end", defaults "curr",0, returns file pos
  37. file:write (value1, ...) writes strings or numbers to file
  38. gcinfo () returns dynamic mem in use (KB), and current GC threshold (KB)
  39. getfenv (f) gets env, f can be a function or number (stack level, default=1), 0=global env
  40. getmetatable (object) returns metatable of given object, otherwise nil
  41. io.close ([file]) closes file, or the default output file
  42. io.flush () flushes the default output file
  43. io.input ([file]) opens file in text mode, sets as default input file, or returns current default input file
  44. io.lines ([filename]) open file in read mode, returns iterator function to return lines, nil ends
  45. io.open (filename [, mode]) opens file in specified mode "[rawb+]", returns handle or nil
  46. io.output ([file]) opens file in text mode, sets as default output file, or returns current default output file
  47. io.read (format1, ...) reads file according to given formats, returns read values or nil
  48. io.stderr file descriptor for STDERR
  49. io.stdin file descriptor for STDIN
  50. io.stdout file descriptor for STDOUT
  51. io.tmpfile () returns a handle for a temporary file, opened in update mode
  52. io.type (obj) returns "file" if obj is an open file handle, "close file" if closed, or nil if not a file handle
  53. io.write (value1, ...) writes strings or numbers to file
  54. ipairs (t) returns an iterator function, table t and 0
  55. loadfile (filename) loads chunk without execution, returns chunk as function, else nil plus error
  56. loadlib (libname, funcname) links to dynamic library libname, returns funcname as a C function
  57. loadstring (string [, chunkname]) loads string as chunk, returns chunk as function, else nil plus error
  58. math.abs (v) returns absolute value of v
  59. math.acos (v) returns arc cosine value of v in radians
  60. math.asin (v) returns arc sine value of v in radians
  61. math.atan (v) returns arc tangent value of v in radians
  62. math.atan2 (v1, v2) returns arc tangent value of v1/v2 in radians
  63. math.ceil (v) returns smallest integer >= v
  64. math.cos (rad) returns cosine value of angle rad
  65. math.deg (rad) returns angle in degrees of radians rad
  66. math.exp (v) returns e^v
  67. math.floor (v) returns largest integer <= v
  68. math.frexp (v) returns mantissa [0.5,1) and exponent values of v
  69. math.ldexp (v1, v2) returns v1*2^v2
  70. math.log (v) returns natural logarithm of v
  71. math.log10 (v) returns logarithm 10 of v
  72. math.max (v1, ...) returns maximum in a list of one or more values
  73. math.min (v1, ...) returns minimum in a list of one or more values
  74. math.mod (v1, v2) returns remainder of v1/v2 which is v1 - iV2 for some integer i
  75. math.pow (v1, v2) returns v1 raised to the power of v2
  76. math.rad (deg) returns angle in radians of degrees deg
  77. math.random ([n [, u]]) returns random real [0,1), integer [1,n] or real [1,u] (with n=1)
  78. math.randomseed (seed) sets seed for pseudo-random number generator
  79. math.sin (rad) returns sine value of angle rad
  80. math.sqrt (v) returns square root of v
  81. math.tan (rad) returns tangent value of angle rad
  82. next (table [, index]) returns next index,value pair, if index=nil (default), returns first index
  83. os.clock () returns CPU time used by program in seconds
  84. os.date ([format [, time]]) returns a string or table containing date and time, "*t" returns a table
  85. os.difftime (t2, t1) returns number of seconds from time t1 to time t2
  86. os.execute (command) executes command using C function system, returns status code
  87. os.exit ([code]) terminates host program with optional code, default is success code
  88. os.getenv (varname) returns value of environment variable varname. nil if not defined
  89. os.remove (filename) deletes file with given name, nil if fails
  90. os.rename (oldname, newname) renames file oldname to newname, nil if fails
  91. os.setlocale (locale [, category]) set current locale of program, returns name of new locate or nil
  92. os.time ([table]) returns current time (usually seconds) or time as represented by table
  93. os.tmpname () returns a string with a filename for a temporary file (dangerous! tmpfile is better)
  94. pairs (t) returns the next function and table t plus a nil, iterates over all key-value pairs
  95. pcall (f, arg1, arg2, ...) protected mode call, catches errors, returns status code first (true=success)
  96. print (e1, e2, ...) prints values to stdout using tostring
  97. rawequal (v1, v2) non-metamethod v1==v2, returns boolean
  98. rawget (table, index) non-metamethod get value of table[index], index != nil
  99. rawset (table, index, value) non-metamethod set value of table[index], index != nil
  100. require (packagename) loads package, updates _LOADED, returns boolean
  101. setfenv (f, table) sets env, f can be a function or number (stack level, default=1), 0=global env
  102. setmetatable (table, metatable) sets metatable, nil to remove metatable
  103. string.byte (s [, i]) returns numerical code, nil if index out of range, default i=1
  104. string.char (i1, i2, ...) returns a string built from 0 or more integers
  105. string.dump (function) returns binary representation of function, used with loadstring
  106. string.find (s, pattern [, init [, plain]]) matches pattern in s, returns start,end indices, else nil
  107. string.format (formatstring, e1, e2, ...) returns formatted string, printf-style
  108. string.gfind (s, pat) returns iterator function that returns next captures from pattern pat on s
  109. string.gsub (s, pat, repl [, n]) returns copy of s with pat replaced by repl, and substitutions made
  110. string.len (s) returns string length
  111. string.lower (s) returns string with letters in lower case
  112. string.rep (s, n) returns string with n copies of string s
  113. string.sub (s, i [, j]) returns substring from index i to j of s, default j=-1 (string length)
  114. string.upper (s) returns string with letters in upper case
  115. table.concat (table [, sep [, i [, j]]]) returns concatenated table elements i to j separated by sep
  116. table.foreach (table, f) executes f(index,value) over all elements of table, returns first non-nil of f
  117. table.foreachi (table, f) executes f(index,value) in sequential order 1 to n, returns first non-nil of f
  118. table.getn (table) returns size of table, or n field, or table.setn value, or 1 less first index with nil value
  119. table.insert (table, [pos,] value) insert value at location pos in table, default pos=n+1
  120. table.remove (table [, pos]) removes element at pos from table, default pos=n
  121. table.setn (table, n) sets size of table, n field of table if it exists
  122. table.sort (table [, comp]) sorts in-place elements 1 to n, comp(v1,v2) true if v1<v2, default <
  123. tonumber (e [, base]) convert to number, returns number, nil if non-convertible, 2<=base<=36
  124. tostring (e) convert to string, returns string
  125. type (v) returns type of v as a string
  126. unpack (list) returns all elements from list
  127. xpcall (f, err) pcall function f with new error handler err
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement