Module global
Lua global variables.
The basic library provides core functions to Lua. If you do not include this library in your application, you should check carefully whether you need to provide implementations for some of its facilities.
Global(s)
StringBuilder |
StringBuilder. |
_G |
A global variable (not a function) that holds the global environment
(that is, |
_VERSION |
A global variable (not a function) that holds a string containing the current interpreter version. |
assert(v, message) |
Issues an error when the value of its argument |
bit32 |
This library provides generic functions for bitwise manipulation. |
error(message, level) |
Terminates the last protected function called and returns |
getmetatable(object) |
If |
ipairs(t) |
If t has a metamethod __ipairs, calls it with t as argument and returns the first three results from the call. |
math |
This library is an interface to the standard C math library. |
next(table, index) |
Allows a program to traverse all fields of a table. |
nwcFile |
nwcFile. |
nwcItem |
nwcItem. |
nwcNotePos |
nwcNotePos. |
nwcNotePosList |
nwcNotePosList. |
nwcOptGroup |
nwcOptGroup. |
nwcOptList |
nwcOptList. |
nwcPlayContext |
nwcPlayContext. |
nwcStaff |
nwcStaff. |
nwcut |
NWC User Tool Execution Environment. |
pairs(t) |
If t has a metamethod |
pcall(f, ...) |
Calls function |
print(...) |
Receives any number of arguments and prints their values to |
select(index, ...) |
If |
setmetatable(table, metatable) |
Sets the metatable for the given table. |
string |
This library provides generic functions for string manipulation. |
table |
This library provides generic functions for table manipulation. |
tonumber(e, base) |
When called with no base, tonumber tries to convert its argument to a number. |
tostring(v) |
Receives an argument of any type and converts it to a string in a reasonable format. |
type(v) |
Returns the type of its only argument, coded as a string. |
Global(s)
- StringBuilder#StringBuilder StringBuilder
-
StringBuilder.
This is the StringBuilder class.
- #table _G
-
A global variable (not a function) that holds the global environment (that is,
_G._G = _G
).Lua itself does not use this variable; changing its value does not affect any environment, nor vice-versa.
- #string _VERSION
-
A global variable (not a function) that holds a string containing the current interpreter version.
The current contents of this variable is "
Lua 5.2
".
- assert(v, message)
-
Issues an error when the value of its argument
v
is false (i.e., nil or false); otherwise, returns all its arguments.message
is an error message; when absent, it defaults to "assertion failed!".Parameters
-
v
: if this argument is false an error is issued. -
#string message
: an error message (optional, "assertion failed" by default)
Return value
All its arguments.
-
- bit32#bit32 bit32
-
This library provides generic functions for bitwise manipulation.
This is a global variable which hold the preloaded bit32 module.
- error(message, level)
-
Terminates the last protected function called and returns
message
as the error message.Function
error
never returns.Usually,
error
adds some information about the error position at the beginning of the message. Thelevel
argument specifies how to get the error position.
With level 1 (the default), the error position is where theerror
function was called.
Level 2 points the error to where the function that callederror
was called; and so on.
Passing a level 0 avoids the addition of error position information to the message.Parameters
-
#string message
: an error message. -
#number level
: specifies how to get the error position (optional,1
by default).
-
- getmetatable(object)
-
If
object
does not have a metatable, returns nil.Otherwise, if the object's metatable has a
"__metatable"
field, returns the associated value. Otherwise, returns the metatable of the given object.Parameter
-
object
:
Return values
-
#table: the metatable of object.
-
#nil: if no metatable was found
-
- ipairs(t)
-
If t has a metamethod __ipairs, calls it with t as argument and returns the first three results from the call.
Otherwise, returns three values: an iterator function, the table
t
, and0
, so that the constructionfor i,v in ipairs(t) do body end
will iterate over the pairs
(1,t[1]), (2,t[2]), ...,
up to the first integer key absent from the table.Parameter
-
#table t
: a table by index.
Return value
iterator function, table
t
, the value0
-
- math#math math
-
This library is an interface to the standard C math library.
This is a global variable which hold the preloaded math module.
- next(table, index)
-
Allows a program to traverse all fields of a table.
Its first argument is a table and its second argument is an index in this table.
next
returns the next index of the table and its associated value.When called with nil as its second argument,
next
returns an initial index and its associated value. When called with the last index, or with nil in an empty table,next
returns nil.If the second argument is absent, then it is interpreted as nil. In particular, you can use
next(t)
to check whether a table is empty. The order in which the indices are enumerated is not specified, even for numeric indices. (To traverse a table in numeric order, use a numerical for.)The behavior of
next
is undefined if, during the traversal, you assign any value to a non-existent field in the table. You may however modify existing fields. In particular, you may clear existing fields.Parameters
-
#table table
: table to traverse. -
index
: initial index (optional).
Return values
-
index, value
-
#nil: if called on the last index or on an empty table
-
- nwcFile#nwcFile nwcFile
-
nwcFile.
This is the nwcFile class.
- nwcItem#nwcItem nwcItem
-
nwcItem.
This is the nwcItem class.
- nwcNotePos#nwcNotePos nwcNotePos
-
nwcNotePos.
This is the nwcNotePos class.
- nwcNotePosList#nwcNotePosList nwcNotePosList
-
nwcNotePosList.
This is the nwcNotePosList class.
- nwcOptGroup#nwcOptGroup nwcOptGroup
-
nwcOptGroup.
This is the nwcOptGroup class.
- nwcOptList#nwcOptList nwcOptList
-
nwcOptList.
This is the nwcOptList class.
- nwcPlayContext#nwcPlayContext nwcPlayContext
-
nwcPlayContext.
This is the nwcPlayContext class.
- nwcStaff#nwcStaff nwcStaff
-
nwcStaff.
This is the nwcStaff class.
- nwcut#nwcut nwcut
-
NWC User Tool Execution Environment.
This is the main nwcut module.
- pairs(t)
-
If t has a metamethod
__pairs
, calls it with t as argument and returns the first three results from the call.Otherwise, returns three values: the
next
function, the table t, and nil, so that the constructionfor k,v in pairs(t) do body end
will iterate over all key–value pairs of table
t
. See function next for the caveats of modifying the table during its traversal.Parameter
-
#table t
: table to traverse.
Return value
iterator function, table
t
, the value0
-
- pcall(f, ...)
-
Calls function
f
with the given arguments in protected mode.This means that any error inside
f
is not propagated; instead,pcall
catches the error and returns a status code. Its first result is the status code (a boolean), which is true if the call succeeds without errors. In such case,pcall
also returns all results from the call, after this first result. In case of any error,pcall
returns false plus the error message.Parameters
-
f
: function to be call in protected mode. -
...
: function arguments.
Return values
-
#boolean: true plus the result of
f
function if its call succeeds without errors. -
#boolean, #string: false plus the error message in case of any error.
-
- print(...)
-
Receives any number of arguments and prints their values to
stdout
, using thetostring
function to convert each argument to a string.print is not intended for formatted output, but only as a quick way to show a value, for instance for debugging. For complete control over the output, use
string.format
andnwcut.write
.Parameter
-
...
: values to print tostdout
.
-
- select(index, ...)
-
If
index
is a number, returns all arguments after argument numberindex
.Otherwise,
index
must be the string"#"
, andselect
returns the total number of extra arguments it received.Parameters
-
index
: a number or the string"#"
-
...
:
Return values
-
all arguments after argument number
index
-
total number of extra arguments
-
- setmetatable(table, metatable)
-
Sets the metatable for the given table.
(You cannot change the metatable of other types from Lua, only from C.) If
metatable
is nil, removes the metatable of the given table. If the original metatable has a"__metatable"
field, raises an error.
This function returnstable
.Parameters
-
#table table
: -
#table metatable
:
Return value
#table: The first argument
table
. -
- string#string string
-
This library provides generic functions for string manipulation.
This is a global variable which hold the preloaded string module.
- table#table table
-
This library provides generic functions for table manipulation.
This is a global variable which hold the preloaded table module.
- tonumber(e, base)
-
When called with no base, tonumber tries to convert its argument to a number.
If the argument is already a number or a string convertible to a number, then tonumber returns this number; otherwise, it returns nil.
When called with base, then e should be a string to be interpreted as an integer numeral in that base. The base may be any integer between
2
and36
, inclusive. In bases above10
, the letter 'A' (in either upper or lower case) represents10
, 'B' represents11
, and so forth, with 'Z' representing35
. If the stringe
is not a valid numeral in the given base, the function returns nil.Parameters
-
e
: a number or string to convert to a number. -
#number base
: the base to interpret the numeral, any integer between2
and36
(optional,10
by default).
Return values
-
#number: converted number
-
#nil: if convertion fail.
-
- tostring(v)
-
Receives an argument of any type and converts it to a string in a reasonable format.
(For complete control of how numbers are converted, use
string.format
.)If the metatable of
v
has a"__tostring"
field, thentostring
calls the corresponding value withv
as argument, and uses the result of the call as its result.Parameter
-
v
: an argument of any type.
Return value
#string: a string in a reasonable format.
-
- type(v)
-
Returns the type of its only argument, coded as a string.
The possible results of this function are "
nil
" (a string, not the value nil), "number
", "string
", "boolean
", "table
", "function
", "thread
", and "userdata
".Parameter
-
v
: any value.
Return value
#string: the type of
v
. -