mirror of https://github.com/OpenMW/openmw.git
Update OpenMW Lua documentation
parent
cc7dbabd19
commit
4eb5841c60
@ -0,0 +1,21 @@
|
||||
set(LUA_API_FILES
|
||||
README.md
|
||||
coroutine.doclua
|
||||
global.doclua
|
||||
math.doclua
|
||||
string.doclua
|
||||
table.doclua
|
||||
openmw/async.lua
|
||||
openmw/core.lua
|
||||
openmw/nearby.lua
|
||||
openmw/query.lua
|
||||
openmw/self.lua
|
||||
openmw/ui.lua
|
||||
openmw/util.lua
|
||||
openmw/world.lua
|
||||
)
|
||||
|
||||
foreach (f ${LUA_API_FILES})
|
||||
copy_resource_file("${CMAKE_CURRENT_SOURCE_DIR}/${f}" "${OpenMW_BINARY_DIR}" "resources/lua_api/${f}")
|
||||
endforeach (f)
|
||||
|
@ -0,0 +1,13 @@
|
||||
Files in this directory describe OpenMW API for [Lua Development Tools](https://www.eclipse.org/ldt/) (LDT).
|
||||
|
||||
`*.doclua` files are taken (with some modifications) from LDT distribution and are distributed under `MIT` license.
|
||||
Openmw-specific docs (`openmw/*.lua`) are under `GPLv3` license.
|
||||
|
||||
To get a Lua IDE with integrated OpenMW documentation and code autocompletion do the following:
|
||||
|
||||
1. Install and run [LDT](https://www.eclipse.org/ldt/#installation).
|
||||
2. Press `File` / `New` / `Lua Project` in menu.
|
||||
3. Specify project name (for example the title of your omwaddon)
|
||||
4. Set `Targeted Execution Environment` to `No Execution Environment`, and `Target Grammar` to `lua-5.1`.
|
||||
5. Press `Next`, choose the `Libraries` tab, and click `Add External Source Folder`. Then specify there the path to this directory.
|
||||
6. Press `Finish`.
|
@ -0,0 +1,71 @@
|
||||
-------------------------------------------------------------------------------
|
||||
-- Coroutine Manipulation.
|
||||
-- The operations related to coroutines comprise a sub-library of the basic library
|
||||
-- and come inside the table coroutine.
|
||||
-- See http://www.lua.org/manual/5.1/manual.html#2.11 for a general description of coroutines.
|
||||
-- @module coroutine
|
||||
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Creates a new coroutine, with body `f`. `f` must be a Lua
|
||||
-- function. Returns this new coroutine, an object with type `"thread"`.
|
||||
-- @function [parent=#coroutine] create
|
||||
-- @param f a function used as coroutine body.
|
||||
-- @return #thread a new coroutine.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Starts or continues the execution of coroutine `co`. The first time
|
||||
-- you resume a coroutine, it starts running its body. The values `val1`,
|
||||
-- ... are passed as the arguments to the body function. If the coroutine
|
||||
-- has yielded, `resume` restarts it; the values `val1`, ... are passed
|
||||
-- as the results from the yield.
|
||||
--
|
||||
-- If the coroutine runs without any errors, `resume` returns true plus any
|
||||
-- values passed to `yield` (if the coroutine yields) or any values returned
|
||||
-- by the body function (if the coroutine terminates). If there is any error,
|
||||
-- `resume` returns false plus the error message.
|
||||
-- @function [parent=#coroutine] resume
|
||||
-- @param #thread co coroutine to start or resume.
|
||||
-- @param ... arguments passed to the body function or as result of yield call.
|
||||
-- @return #boolean true plus any values passed to `yield` (if the coroutine yields) or any values returned
|
||||
-- by the body function (if the coroutine terminates)
|
||||
-- @return #boolean false plus an error message.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Returns the running coroutine, or nil when called by the main thread.
|
||||
-- @function [parent=#coroutine] running
|
||||
-- @return #thread the running coroutine, or nil when called by the main thread.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Returns the status of coroutine `co`, as a string: `"running"`, if
|
||||
-- the coroutine is running (that is, it called `status`); `"suspended"`, if
|
||||
-- the coroutine is suspended in a call to `yield`, or if it has not started
|
||||
-- running yet; `"normal"` if the coroutine is active but not running (that
|
||||
-- is, it has resumed another coroutine); and `"dead"` if the coroutine has
|
||||
-- finished its body function, or if it has stopped with an error.
|
||||
-- @function [parent=#coroutine] status
|
||||
-- @param #thread co a coroutine
|
||||
-- @return #string the status : `"running"`, `"suspended"`, `"normal"` or `"dead"`.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Creates a new coroutine, with body `f`. `f` must be a Lua
|
||||
-- function. Returns a function that resumes the coroutine each time it is
|
||||
-- called. Any arguments passed to the function behave as the extra arguments to
|
||||
-- `resume`. Returns the same values returned by `resume`, except the first
|
||||
-- boolean. In case of error, propagates the error.
|
||||
-- @function [parent=#coroutine] wrap
|
||||
-- @param f a function used as coroutine body.
|
||||
-- @param ... arguments passed to the body function or as result of yield call.
|
||||
-- @return Any values passed to `yield` (if the coroutine yields) or any values returned
|
||||
-- by the body function (if the coroutine terminates).
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Suspends the execution of the calling coroutine. The coroutine cannot
|
||||
-- be running a C function, a metamethod, or an iterator. Any arguments to
|
||||
-- `yield` are passed as extra results to `resume`.
|
||||
-- @function [parent=#coroutine] yield
|
||||
-- @param ... arguments passed as extra results to `resume` function.
|
||||
-- @return Any values passed to the `resume` function.
|
||||
|
||||
return nil
|
@ -0,0 +1,269 @@
|
||||
-------------------------------------------------------------------------------
|
||||
-- Lua global variables.
|
||||
-- The basic library provides some core functions to Lua.
|
||||
-- All the preloaded module of Lua are declared here.
|
||||
-- @module global
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- This library provides generic functions for coroutine manipulation.
|
||||
-- This is a global variable which hold the preloaded @{coroutine} module.
|
||||
-- @field[parent = #global] coroutine#coroutine coroutine preloaded module
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- This library provides generic functions for string manipulation.
|
||||
-- This is a global variable which hold the preloaded @{string} module.
|
||||
-- @field[parent = #global] string#string string preloaded module
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- This library provides generic functions for table manipulation.
|
||||
-- This is a global variable which hold the preloaded @{table} module.
|
||||
-- @field[parent = #global] table#table table preloaded module
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- This library is an interface to the standard C math library.
|
||||
-- This is a global variable which hold the preloaded @{math} module.
|
||||
-- @field[parent = #global] math#math math preloaded module
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- This library is an interface to the standard C math library.
|
||||
-- This is a global variable which hold the preloaded @{omwutil} module.
|
||||
-- @field[parent = #global] omwutil#omwutil ou preloaded module
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- 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!"*.
|
||||
-- @function [parent=#global] assert
|
||||
-- @param v if this argument is false an error is issued.
|
||||
-- @param #string message an error message. defaults value is *"assertion failed"*.
|
||||
-- @return All its arguments.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- 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. The `level` argument specifies how to get the
|
||||
-- error position.
|
||||
-- With level 1 (the default), the error position is where the
|
||||
-- `error` function was called.
|
||||
-- Level 2 points the error to where the function
|
||||
-- that called `error` was called; and so on.
|
||||
-- Passing a level 0 avoids the addition of error position information to the message.
|
||||
-- @function [parent=#global] error
|
||||
-- @param #string message an error message.
|
||||
-- @param #number level specifies how to get the error position, default value is `1`.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- 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.
|
||||
-- @function [parent=#global] getmetatable
|
||||
-- @param object
|
||||
-- @return #table the metatable of object.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Use to iterate over a table by index.
|
||||
-- Returns three values: an iterator function, the table `t`, and 0,
|
||||
-- so that the construction :
|
||||
--
|
||||
-- for 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.
|
||||
-- @function [parent=#global] ipairs
|
||||
-- @param #table t a table by 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 or the `ipairs` function.)
|
||||
--
|
||||
-- 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.
|
||||
-- @function [parent=#global] next
|
||||
-- @param #table table table to traverse.
|
||||
-- @param index initial index.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Use to iterate over a table.
|
||||
-- Returns three values: the `next` function, the table `t`, and nil,
|
||||
-- so that the construction :
|
||||
--
|
||||
-- for 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.
|
||||
-- @function [parent=#global] pairs
|
||||
-- @param #table t table to traverse.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- 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.
|
||||
-- @function [parent=#global] pcall
|
||||
-- @param f function to be call in *protected mode*.
|
||||
-- @param ... function arguments.
|
||||
-- @return #boolean true plus the result of `f` function if its call succeeds without errors.
|
||||
-- @return #boolean,#string false plus the error message in case of any error.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Receives any number of arguments, and prints their values to OpenMW log,
|
||||
-- using the `tostring` function to convert them to strings. `print` is not
|
||||
-- intended for formatted output, but only as a quick way to show a value,
|
||||
-- typically for debugging. For formatted output, use `string.format`.
|
||||
--
|
||||
-- @function [parent=#global] print
|
||||
-- @param ... values to print to `stdout`.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Checks whether `v1` is equal to `v2`, without invoking any
|
||||
-- metamethod. Returns a boolean.
|
||||
-- @function [parent=#global] rawequal
|
||||
-- @param v1
|
||||
-- @param v2
|
||||
-- @return #boolean true if `v1` is equal to `v2`.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Gets the real value of `table[index]`, without invoking any
|
||||
-- metamethod. `table` must be a table; `index` may be any value.
|
||||
-- @function [parent=#global] rawget
|
||||
-- @param #table table
|
||||
-- @param index may be any value.
|
||||
-- @return The real value of `table[index]`, without invoking any
|
||||
-- metamethod.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Sets the real value of `table[index]` to `value`, without invoking any
|
||||
-- metamethod. `table` must be a table, `index` any value different from nil,
|
||||
-- and `value` any Lua value.
|
||||
-- This function returns `table`.
|
||||
-- @function [parent=#global] rawset
|
||||
-- @param #table table
|
||||
-- @param index any value different from nil.
|
||||
-- @param value any Lua value.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- If `index` is a number, returns all arguments after argument number
|
||||
-- `index`. Otherwise, `index` must be the string `"#"`, and `select` returns
|
||||
-- the total number of extra arguments it received.
|
||||
-- @function [parent=#global] select
|
||||
-- @param index a number or the string `"#"`
|
||||
-- @param ...
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- 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 returns `table`.
|
||||
-- @function [parent=#global] setmetatable
|
||||
-- @param #table table
|
||||
-- @param #table metatable
|
||||
-- @return The first argument `table`.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- 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.**
|
||||
--
|
||||
-- An optional argument specifies the base to interpret the numeral. The base
|
||||
-- may be any integer between 2 and 36, inclusive. In bases above 10, the
|
||||
-- letter '`A`' (in either upper or lower case) represents 10, '`B`' represents
|
||||
-- 11, and so forth, with '`Z`' representing 35. In base 10 (the default),
|
||||
-- the number can have a decimal part, as well as an optional exponent part.
|
||||
-- In other bases, only unsigned integers are accepted.
|
||||
-- @function [parent=#global] tonumber
|
||||
-- @param e a number or string to convert to a number.
|
||||
-- @param #number base the base to interpret the numeral, any integer between 2 and 36.(default is 10).
|
||||
-- @return #number a number if conversion succeeds else **nil**.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- 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 `e` has a `"__tostring"` field, then `tostring` calls
|
||||
-- the corresponding value with `e` as argument, and uses the result of the
|
||||
-- call as its result.
|
||||
-- @function [parent=#global] tostring
|
||||
-- @param e an argument of any type.
|
||||
-- @return #string a string in a reasonable format.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- 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`".
|
||||
-- @function [parent=#global] type
|
||||
-- @param v any value.
|
||||
-- @return #string the type of `v`.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Returns the elements from the given table. This function is equivalent to
|
||||
--
|
||||
-- return list[i], list[i+1], ..., list[j]
|
||||
-- except that the above code can be written only for a fixed number of
|
||||
-- elements. By default, `i` is 1 and `j` is the length of the list, as
|
||||
-- defined by the length operator.
|
||||
-- @function [parent=#global] unpack
|
||||
-- @param #table list a table by index
|
||||
-- @param i index of first value.
|
||||
-- @param j index of last value.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- A global variable (not a function) that holds a string containing the
|
||||
-- current interpreter version. The current contents of this variable is
|
||||
-- "`Lua 5.1`".
|
||||
-- @field [parent = #global] #string _VERSION
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- This function is similar to `pcall`, except that you can set a new
|
||||
-- error handler.
|
||||
--
|
||||
-- `xpcall` calls function `f` in protected mode, using `err` as the error
|
||||
-- handler. Any error inside `f` is not propagated; instead, `xpcall` catches
|
||||
-- the error, calls the `err` function with the original error object, and
|
||||
-- returns a status code. Its first result is the status code (a boolean),
|
||||
-- which is true if the call succeeds without errors. In this case, `xpcall`
|
||||
-- also returns all results from the call, after this first result. In case
|
||||
-- of any error, `xpcall` returns false plus the result from `err`.
|
||||
-- @function [parent=#global] xpcall
|
||||
-- @param f function to be call in *protected mode*.
|
||||
-- @param err function used as error handler.
|
||||
-- @return #boolean true plus the result of `f` function if its call succeeds without errors.
|
||||
-- @return #boolean,#string false plus the result of `err` function.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Loads the given module.
|
||||
-- If the requested module is one of the allowed standard libraries
|
||||
-- (`coroutine`, `math`, `string`, `table`), then returns the library.
|
||||
-- If it is one of the built-in OpenMW API packages, then returns the package.
|
||||
-- Otherwise it searches for a Lua source file with such name in OpenMW data folders.
|
||||
-- For example `require('my_lua_library.something')` will try to open the file
|
||||
-- `my_lua_library/something.lua`.
|
||||
--
|
||||
-- Loading DLLs and precompiled Lua files is intentionally prohibited for reasons
|
||||
-- of safety and compatibility between different platforms.
|
||||
--
|
||||
-- If there is any error loading or running the module, or if it cannot find
|
||||
-- any loader for the module, then `require` signals an error.
|
||||
-- @function [parent=#global] require
|
||||
-- @param #string modname name of module to load.
|
||||
|
||||
return nil
|
@ -0,0 +1,200 @@
|
||||
-------------------------------------------------------------------------------
|
||||
-- Mathematical Functions.
|
||||
-- This library is an interface to the standard C math library.
|
||||
-- It provides all its functions inside the table math.
|
||||
-- @module math
|
||||
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Returns the absolute value of `x`.
|
||||
-- @function [parent=#math] abs
|
||||
-- @param #number x
|
||||
-- @return #number
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Returns the arc cosine of `x` (in radians).
|
||||
-- @function [parent=#math] acos
|
||||
-- @param #number x
|
||||
-- @return #number
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Returns the arc sine of `x` (in radians).
|
||||
-- @function [parent=#math] asin
|
||||
-- @param #number x
|
||||
-- @return #number
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Returns the arc tangent of `x` (in radians).
|
||||
-- @function [parent=#math] atan
|
||||
-- @param #number x
|
||||
-- @return #number
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Returns the arc tangent of `y/x` (in radians), but uses the signs
|
||||
-- of both parameters to find the quadrant of the result. (It also handles
|
||||
-- correctly the case of `x` being zero.)
|
||||
-- @function [parent=#math] atan2
|
||||
-- @param #number y
|
||||
-- @param #number x
|
||||
-- @return #number
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Returns the smallest integer larger than or equal to `x`.
|
||||
-- @function [parent=#math] ceil
|
||||
-- @param #number x
|
||||
-- @return #number
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Returns the cosine of `x` (assumed to be in radians).
|
||||
-- @function [parent=#math] cos
|
||||
-- @param #number x
|
||||
-- @return #number
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Returns the hyperbolic cosine of `x`.
|
||||
-- @function [parent=#math] cosh
|
||||
-- @param #number x
|
||||
-- @return #number
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Returns the angle `x` (given in radians) in degrees.
|
||||
-- @function [parent=#math] deg
|
||||
-- @param #number x
|
||||
-- @return #number
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Returns the value *e^x*.
|
||||
-- @function [parent=#math] exp
|
||||
-- @param #number x
|
||||
-- @return #number
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Returns the largest integer smaller than or equal to `x`.
|
||||
-- @function [parent=#math] floor
|
||||
-- @param #number x
|
||||
-- @return #number
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Returns the remainder of the division of `x` by `y` that rounds the
|
||||
-- quotient towards zero.
|
||||
-- @function [parent=#math] fmod
|
||||
-- @param #number x
|
||||
-- @param #number y
|
||||
-- @return #number
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Returns `m` and `e` such that *x = m2^e*, `e` is an integer and the
|
||||
-- absolute value of `m` is in the range *[0.5, 1)* (or zero when `x` is zero).
|
||||
-- @function [parent=#math] frexp
|
||||
-- @param #number x
|
||||
-- @return #number
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- The value `HUGE_VAL`, a value larger than or equal to any other
|
||||
-- numerical value.
|
||||
-- @field [parent=#math] #number huge
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Returns *m2^e* (`e` should be an integer).
|
||||
-- @function [parent=#math] ldexp
|
||||
-- @param #number m
|
||||
-- @param #number e
|
||||
-- @return #number
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Returns the natural logarithm of `x`.
|
||||
-- @function [parent=#math] log
|
||||
-- @param #number x
|
||||
-- @return #number
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Returns the base-10 logarithm of `x`.
|
||||
-- @function [parent=#math] log10
|
||||
-- @param #number x
|
||||
-- @return #number
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Returns the maximum value among its arguments.
|
||||
-- @function [parent=#math] max
|
||||
-- @param #number x
|
||||
-- @return #number
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Returns the minimum value among its arguments.
|
||||
-- @function [parent=#math] min
|
||||
-- @param #number x
|
||||
-- @return #number
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Returns two numbers, the integral part of `x` and the fractional part of
|
||||
-- `x`.
|
||||
-- @function [parent=#math] modf
|
||||
-- @param #number x
|
||||
-- @return #number
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- The value of *pi*.
|
||||
-- @field [parent=#math] #number pi
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Returns *x^y*. (You can also use the expression `x^y` to compute this
|
||||
-- value.)
|
||||
-- @function [parent=#math] pow
|
||||
-- @param #number x
|
||||
-- @param #number y
|
||||
-- @return #number
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Returns the angle `x` (given in degrees) in radians.
|
||||
-- @function [parent=#math] rad
|
||||
-- @param #number x
|
||||
-- @return #number
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- This function is an interface to the simple pseudo-random generator
|
||||
-- function `rand` provided by ANSI C. (No guarantees can be given for its
|
||||
-- statistical properties.)
|
||||
--
|
||||
-- When called without arguments, returns a uniform pseudo-random real
|
||||
-- number in the range *[0,1)*. When called with an integer number `m`,
|
||||
-- `math.random` returns a uniform pseudo-random integer in the range *[1,
|
||||
-- m]*. When called with two integer numbers `m` and `n`, `math.random`
|
||||
-- returns a uniform pseudo-random integer in the range *[m, n]*.
|
||||
-- @function [parent=#math] random
|
||||
-- @param #number m
|
||||
-- @param #number n
|
||||
-- @return #number
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Returns the sine of `x` (assumed to be in radians).
|
||||
-- @function [parent=#math] sin
|
||||
-- @param #number x
|
||||
-- @return #number
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Returns the hyperbolic sine of `x`.
|
||||
-- @function [parent=#math] sinh
|
||||
-- @param #number x
|
||||
-- @return #number
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Returns the square root of `x`. (You can also use the expression `x^0.5`
|
||||
-- to compute this value.)
|
||||
-- @function [parent=#math] sqrt
|
||||
-- @param #number x
|
||||
-- @return #number
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Returns the tangent of `x` (assumed to be in radians).
|
||||
-- @function [parent=#math] tan
|
||||
-- @param #number x
|
||||
-- @return #number
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Returns the hyperbolic tangent of `x`.
|
||||
-- @function [parent=#math] tanh
|
||||
-- @param #number x
|
||||
-- @return #number
|
||||
|
||||
return nil
|
@ -0,0 +1,14 @@
|
||||
`*.lua` files from this dir are also used to generate html documentation.
|
||||
|
||||
After every change run the following commands to update it:
|
||||
|
||||
```
|
||||
luadocumentor -f doc -d ../../../docs/source/generated-luadoc/lua-api-reference *.lua
|
||||
sed -i 's/openmw\.\(\w*\)\(\#\|\.html\)/\1\2/g' ../../../docs/source/generated-luadoc/lua-api-reference/*.html
|
||||
```
|
||||
|
||||
`luadocumentor` can be installed via `luarocks`:
|
||||
|
||||
```
|
||||
luarocks install luadocumentor
|
||||
```
|
@ -0,0 +1,52 @@
|
||||
-------------------------------------------------------------------------------
|
||||
-- `openmw.async` contains timers and coroutine utils. All functions require
|
||||
-- the package itself as a first argument.
|
||||
-- @module async
|
||||
-- @usage local async = require('openmw.async')
|
||||
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Register a function as a timer callback.
|
||||
-- @function [parent=#async] registerTimerCallback
|
||||
-- @param self
|
||||
-- @param #string name
|
||||
-- @param #function func
|
||||
-- @return #TimerCallback
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Calls callback(arg) in `delay` seconds.
|
||||
-- Callback must be registered in advance.
|
||||
-- @function [parent=#async] newTimerInSeconds
|
||||
-- @param self
|
||||
-- @param #number delay
|
||||
-- @param #TimerCallback callback A callback returned by `registerTimerCallback`
|
||||
-- @param arg An argument for `callback`; can be `nil`.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Calls callback(arg) in `delay` game hours.
|
||||
-- Callback must be registered in advance.
|
||||
-- @function [parent=#async] newTimerInHours
|
||||
-- @param self
|
||||
-- @param #number delay
|
||||
-- @param #TimerCallback callback A callback returned by `registerTimerCallback`
|
||||
-- @param arg An argument for `callback`; can be `nil`.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Calls `func()` in `delay` seconds.
|
||||
-- The timer will be lost if the game is saved and loaded.
|
||||
-- @function [parent=#async] newUnsavableTimerInSeconds
|
||||
-- @param self
|
||||
-- @param #number delay
|
||||
-- @param #function func
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Calls `func()` in `delay` game hours.
|
||||
-- The timer will be lost if the game is saved and loaded.
|
||||
-- @function [parent=#async] newUnsavableTimerInHours
|
||||
-- @param self
|
||||
-- @param #number delay
|
||||
-- @param #function func
|
||||
|
||||
return nil
|
||||
|
@ -0,0 +1,328 @@
|
||||
-------------------------------------------------------------------------------
|
||||
-- `openmw.core` defines functions and types that are available in both local
|
||||
-- and global scripts.
|
||||
-- @module core
|
||||
-- @usage local core = require('openmw.core')
|
||||
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- The version of OpenMW Lua API. It is an integer that is incremented every time the API is changed.
|
||||
-- @field [parent=#core] #number API_VERSION
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Send an event to global scripts.
|
||||
-- @function [parent=#core] sendGlobalEvent
|
||||
-- @param #string eventName
|
||||
-- @param eventData
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Game time in seconds.
|
||||
-- The number of seconds in the game world, passed from starting a new game.
|
||||
-- @function [parent=#core] getGameTimeInSeconds
|
||||
-- @return #number
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Current time of the game world in hours.
|
||||
-- Note that the number of game seconds in a game hour is not guaranteed to be fixed.
|
||||
-- @function [parent=#core] getGameTimeInHours
|
||||
-- @return #number
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- @type OBJECT_TYPE
|
||||
-- @field [parent=#OBJECT_TYPE] #string Activator "Activator"
|
||||
-- @field [parent=#OBJECT_TYPE] #string Armor "Armor"
|
||||
-- @field [parent=#OBJECT_TYPE] #string Book "Book"
|
||||
-- @field [parent=#OBJECT_TYPE] #string Clothing "Clothing"
|
||||
-- @field [parent=#OBJECT_TYPE] #string Container "Container"
|
||||
-- @field [parent=#OBJECT_TYPE] #string Creature "Creature"
|
||||
-- @field [parent=#OBJECT_TYPE] #string Door "Door"
|
||||
-- @field [parent=#OBJECT_TYPE] #string Ingredient "Ingredient"
|
||||
-- @field [parent=#OBJECT_TYPE] #string Light "Light"
|
||||
-- @field [parent=#OBJECT_TYPE] #string Miscellaneous "Miscellaneous"
|
||||
-- @field [parent=#OBJECT_TYPE] #string NPC "NPC"
|
||||
-- @field [parent=#OBJECT_TYPE] #string Player "Player"
|
||||
-- @field [parent=#OBJECT_TYPE] #string Potion "Potion"
|
||||
-- @field [parent=#OBJECT_TYPE] #string Static "Static"
|
||||
-- @field [parent=#OBJECT_TYPE] #string Weapon "Weapon"
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Possible `object.type` values.
|
||||
-- @field [parent=#core] #OBJECT_TYPE OBJECT_TYPE
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- @type EQUIPMENT_SLOT
|
||||
-- @field [parent=#EQUIPMENT_SLOT] #number Helmet
|
||||
-- @field [parent=#EQUIPMENT_SLOT] #number Cuirass
|
||||
-- @field [parent=#EQUIPMENT_SLOT] #number Greaves
|
||||
-- @field [parent=#EQUIPMENT_SLOT] #number LeftPauldron
|
||||
-- @field [parent=#EQUIPMENT_SLOT] #number RightPauldron
|
||||
-- @field [parent=#EQUIPMENT_SLOT] #number LeftGauntlet
|
||||
-- @field [parent=#EQUIPMENT_SLOT] #number RightGauntlet
|
||||
-- @field [parent=#EQUIPMENT_SLOT] #number Boots
|
||||
-- @field [parent=#EQUIPMENT_SLOT] #number Shirt
|
||||
-- @field [parent=#EQUIPMENT_SLOT] #number Pants
|
||||
-- @field [parent=#EQUIPMENT_SLOT] #number Skirt
|
||||
-- @field [parent=#EQUIPMENT_SLOT] #number Robe
|
||||
-- @field [parent=#EQUIPMENT_SLOT] #number LeftRing
|
||||
-- @field [parent=#EQUIPMENT_SLOT] #number RightRing
|
||||
-- @field [parent=#EQUIPMENT_SLOT] #number Amulet
|
||||
-- @field [parent=#EQUIPMENT_SLOT] #number Belt
|
||||
-- @field [parent=#EQUIPMENT_SLOT] #number CarriedRight
|
||||
-- @field [parent=#EQUIPMENT_SLOT] #number CarriedLeft
|
||||
-- @field [parent=#EQUIPMENT_SLOT] #number Ammunition
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Available equipment slots. Used in `object:getEquipment` and `object:setEquipment`.
|
||||
-- @field [parent=#core] #EQUIPMENT_SLOT EQUIPMENT_SLOT
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Any object that exists in the game world and has a specific location.
|
||||
-- Player, actors, items, and statics are game objects.
|
||||
-- @type GameObject
|
||||
-- @field [parent=#GameObject] openmw.util#Vector3 position Object position.
|
||||
-- @field [parent=#GameObject] openmw.util#Vector3 rotation Object rotation (ZXY order).
|
||||
-- @field [parent=#GameObject] #Cell cell The cell where the object currently is. During loading a game and for objects in an inventory or a container `cell` is nil.
|
||||
-- @field [parent=#GameObject] #string type Type of the object (see @{openmw.core#OBJECT_TYPE}).
|
||||
-- @field [parent=#GameObject] #number count Count (makes sense if holded in a container).
|
||||
-- @field [parent=#GameObject] #string recordId Record ID.
|
||||
-- @field [parent=#GameObject] #Inventory inventory Inventory of an Player/NPC or content of an container.
|
||||
-- @field [parent=#GameObject] #boolean isTeleport `True` if it is a teleport door (only if `object.type` == "Door").
|
||||
-- @field [parent=#GameObject] openmw.util#Vector3 destPosition Destination (only if a teleport door).
|
||||
-- @field [parent=#GameObject] openmw.util#Vector3 destRotation Destination rotation (only if a teleport door).
|
||||
-- @field [parent=#GameObject] #string destCell Destination cell (only if a teleport door).
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Is the object still exists/available.
|
||||
-- Returns true if the object exists and loaded, and false otherwise. If false, then every
|
||||
-- access to the object will raise an error.
|
||||
-- @function [parent=#GameObject] isValid
|
||||
-- @param self
|
||||
-- @return #boolean
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Returns true if the object is an actor and is able to move. For dead, paralized,
|
||||
-- or knocked down actors in returns false.
|
||||
-- access to the object will raise an error.
|
||||
-- @function [parent=#GameObject] canMove
|
||||
-- @param self
|
||||
-- @return #boolean
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Speed of running. Returns 0 if not an actor, but for dead actors it still returns a positive value.
|
||||
-- @function [parent=#GameObject] getRunSpeed
|
||||
-- @param self
|
||||
-- @return #number
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Speed of walking. Returns 0 if not an actor, but for dead actors it still returns a positive value.
|
||||
-- @function [parent=#GameObject] getWalkSpeed
|
||||
-- @param self
|
||||
-- @return #number
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Send local event to the object.
|
||||
-- @function [parent=#GameObject] sendEvent
|
||||
-- @param self
|
||||
-- @param #string eventName
|
||||
-- @param eventData
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Returns `true` if the item is equipped on the object.
|
||||
-- @function [parent=#GameObject] isEquipped
|
||||
-- @param self
|
||||
-- @param #GameObject item
|
||||
-- @return #boolean
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Get equipment.
|
||||
-- Returns a table `slot` -> `GameObject` of currently equipped items.
|
||||
-- See @{openmw.core#EQUIPMENT_SLOT}. Returns empty table if the object doesn't have
|
||||
-- equipment slots.
|
||||
-- @function [parent=#GameObject] getEquipment
|
||||
-- @param self
|
||||
-- @return #map<#number,#GameObject>
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Set equipment.
|
||||
-- Keys in the table are equipment slots (see @{openmw.core#EQUIPMENT_SLOT}). Each
|
||||
-- value can be either a `GameObject` or recordId. Raises an error if
|
||||
-- the object doesn't have equipment slots and table is not empty. Can be
|
||||
-- called only on self or from a global script.
|
||||
-- @function [parent=#GameObject] setEquipment
|
||||
-- @param self
|
||||
-- @param equipment
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Add new local script to the object.
|
||||
-- Can be called only from a global script.
|
||||
-- @function [parent=#GameObject] addScript
|
||||
-- @param self
|
||||
-- @param #string scriptPath Path to the script in OpenMW virtual filesystem
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Moves object to given cell and position.
|
||||
-- The effect is not immediate: the position will be updated only in the next
|
||||
-- frame. Can be called only from a global script.
|
||||
-- @function [parent=#GameObject] teleport
|
||||
-- @param self
|
||||
-- @param #string cellName Name of the cell to teleport into. For exteriors can be empty.
|
||||
-- @param openmw.util#Vector3 position New position
|
||||
-- @param openmw.util#Vector3 rotation New rotation. Optional argument. If missed, then the current rotation is used.
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- List of GameObjects.
|
||||
-- @type ObjectList
|
||||
-- @extends #list<#GameObject>
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Create iterator.
|
||||
-- @function [parent=#ObjectList] ipairs
|
||||
-- @param self
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Filter list with a Query.
|
||||
-- @function [parent=#ObjectList] select
|
||||
-- @param self
|
||||
-- @param openmw.query#Query query
|
||||
-- @return #ObjectList
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- A cell of the game world.
|
||||
-- @type Cell
|
||||
-- @field [parent=#Cell] #string name Name of the cell (can be empty string).
|
||||
-- @field [parent=#Cell] #string region Region of the cell.
|
||||
-- @field [parent=#Cell] #boolean isExterior Is it exterior or interior.
|
||||
-- @field [parent=#Cell] #number gridX Index of the cell by X (only for exteriors).
|
||||
-- @field [parent=#Cell] #number gridY Index of the cell by Y (only for exteriors).
|
||||
-- @field [parent=#Cell] #boolean hasWater True if the cell contains water.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Returns true either if the cell contains the object or if the cell is an exterior and the object is also in an exterior.
|
||||
-- @function [parent=#Cell] isInSameSpace
|
||||
-- @param self
|
||||
-- @param #GameObject object
|
||||
-- @return #boolean
|
||||
-- @usage
|
||||
-- if obj1.cell:isInSameSpace(obj2) then
|
||||
-- dist = (obj1.position - obj2.position):length()
|
||||
-- else
|
||||
-- -- the distance can't be calculated because the coordinates are in different spaces
|
||||
-- end
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Select objects from the cell with a Query (only in global scripts).
|
||||
-- Returns an empty list if the cell is not loaded.
|
||||
-- @function [parent=#Cell] selectObjects
|
||||
-- @param self
|
||||
-- @param openmw.query#Query query
|
||||
-- @return #ObjectList
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Inventory of a player/NPC or a content of a container.
|
||||
-- @type Inventory
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- The number of items with given recordId.
|
||||
-- @function [parent=#Inventory] countOf
|
||||
-- @param self
|
||||
-- @param #string recordId
|
||||
-- @return #number
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Get all content of the inventory.
|
||||
-- @function [parent=#Inventory] getAll
|
||||
-- @param self
|
||||
-- @return #ObjectList
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Get all potions.
|
||||
-- @function [parent=#Inventory] getPotions
|
||||
-- @param self
|
||||
-- @return #ObjectList
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Get all apparatuses.
|
||||
-- @function [parent=#Inventory] getApparatuses
|
||||
-- @param self
|
||||
-- @return #ObjectList
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Get all armor.
|
||||
-- @function [parent=#Inventory] getArmor
|
||||
-- @param self
|
||||
-- @return #ObjectList
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Get all books.
|
||||
-- @function [parent=#Inventory] getBooks
|
||||
-- @param self
|
||||
-- @return #ObjectList
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Get all clothing.
|
||||
-- @function [parent=#Inventory] getClothing
|
||||
-- @param self
|
||||
-- @return #ObjectList
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Get all ingredients.
|
||||
-- @function [parent=#Inventory] getIngredients
|
||||
-- @param self
|
||||
-- @return #ObjectList
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Get all lights.
|
||||
-- @function [parent=#Inventory] getLights
|
||||
-- @param self
|
||||
-- @return #ObjectList
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Get all lockpicks.
|
||||
-- @function [parent=#Inventory] getLockpicks
|
||||
-- @param self
|
||||
-- @return #ObjectList
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Get all miscellaneous items.
|
||||
-- @function [parent=#Inventory] getMiscellaneous
|
||||
-- @param self
|
||||
-- @return #ObjectList
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Get all probes.
|
||||
-- @function [parent=#Inventory] getProbes
|
||||
-- @param self
|
||||
-- @return #ObjectList
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Get all repair kits.
|
||||
-- @function [parent=#Inventory] getRepairKits
|
||||
-- @param self
|
||||
-- @return #ObjectList
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Get all weapon.
|
||||
-- @function [parent=#Inventory] getWeapons
|
||||
-- @param self
|
||||
-- @return #ObjectList
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Argument of `onKeyPress` engine handler
|
||||
-- @type KeyboardEvent
|
||||
-- @field [parent=#KeyboardEvent] #string symbol The pressed symbol (1-symbol string).
|
||||
-- @field [parent=#KeyboardEvent] #string code Key code.
|
||||
-- @field [parent=#KeyboardEvent] #boolean withShift Is `Shift` key pressed.
|
||||
-- @field [parent=#KeyboardEvent] #boolean withCtrl Is `Control` key pressed.
|
||||
-- @field [parent=#KeyboardEvent] #boolean withAlt Is `Alt` key pressed.
|
||||
-- @field [parent=#KeyboardEvent] #boolean withSuper Is `Super`/`Win` key pressed.
|
||||
|
||||
return nil
|
||||
|
@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
luadocumentor -f doc -d ../../../docs/source/generated-luadoc/lua-api-reference *.lua
|
||||
sed -i 's/openmw\.\(\w*\)\(\#\|\.html\)/\1\2/g' ../../../docs/source/generated-luadoc/lua-api-reference/*.html
|
@ -0,0 +1,36 @@
|
||||
-------------------------------------------------------------------------------
|
||||
-- `openmw.nearby` provides read-only access to the nearest area of the game world.
|
||||
-- Can be used only from local scripts.
|
||||
-- @module nearby
|
||||
-- @usage local nearby = require('openmw.nearby')
|
||||
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- List of nearby activators.
|
||||
-- @field [parent=#nearby] openmw.core#ObjectList activators
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- List of nearby actors.
|
||||
-- @field [parent=#nearby] openmw.core#ObjectList actors
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- List of nearby containers.
|
||||
-- @field [parent=#nearby] openmw.core#ObjectList containers
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- List of nearby doors.
|
||||
-- @field [parent=#nearby] openmw.core#ObjectList doors
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Everything that can be picked up in the nearby.
|
||||
-- @field [parent=#nearby] openmw.core#ObjectList items
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Evaluates a Query.
|
||||
-- @function [parent=#nearby] selectObjects
|
||||
-- @param openmw.query#Query query
|
||||
-- @return openmw.core#ObjectList
|
||||
|
||||
return nil
|
||||
|
@ -0,0 +1,116 @@
|
||||
-------------------------------------------------------------------------------
|
||||
-- `openmw.query` constructs queries that can be used in `world.selectObjects` and `nearby.selectObjects`.
|
||||
-- @module query
|
||||
-- @usage local query = require('openmw.query')
|
||||
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Query. A Query itself can no return objects. It only holds search conditions.
|
||||
-- @type Query
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Add condition.
|
||||
-- @function [parent=#Query] where
|
||||
-- @param self
|
||||
-- @param condition
|
||||
-- @return #Query
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Limit result size.
|
||||
-- @function [parent=#Query] limit
|
||||
-- @param self
|
||||
-- @param #number maxCount
|
||||
-- @return #Query
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- A field that can be used in a condition
|
||||
-- @type Field
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Equal
|
||||
-- @function [parent=#Field] eq
|
||||
-- @param self
|
||||
-- @param value
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Not equal
|
||||
-- @function [parent=#Field] neq
|
||||
-- @param self
|
||||
-- @param value
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Lesser
|
||||
-- @function [parent=#Field] lt
|
||||
-- @param self
|
||||
-- @param value
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Lesser or equal
|
||||
-- @function [parent=#Field] lte
|
||||
-- @param self
|
||||
-- @param value
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Greater
|
||||
-- @function [parent=#Field] gt
|
||||
-- @param self
|
||||
-- @param value
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Greater or equal
|
||||
-- @function [parent=#Field] gte
|
||||
-- @param self
|
||||
-- @param value
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- @type OBJECT
|
||||
-- @field [parent=#OBJECT] #Field type
|
||||
-- @field [parent=#OBJECT] #Field recordId
|
||||
-- @field [parent=#OBJECT] #Field count
|
||||
-- @field [parent=#OBJECT] #CellFields cell
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Fields that can be used with any object.
|
||||
-- @field [parent=#query] #OBJECT OBJECT
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- @type DOOR
|
||||
-- @field [parent=#DOOR] #Field isTeleport
|
||||
-- @field [parent=#DOOR] #CellFields destCell
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Fields that can be used only when search for doors.
|
||||
-- @field [parent=#query] #DOOR DOOR
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- @type CellFields
|
||||
-- @field [parent=#CellFields] #Field name
|
||||
-- @field [parent=#CellFields] #Field region
|
||||
-- @field [parent=#CellFields] #Field isExterior
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Base Query to select activators.
|
||||
-- @field [parent=#query] #Query activators
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Base Query to select actors.
|
||||
-- @field [parent=#query] #Query actors
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Base Query to select containers.
|
||||
-- @field [parent=#query] #Query containers
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Base Query to select doors.
|
||||
-- @field [parent=#query] #Query doors
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Base Query to select items.
|
||||
-- @field [parent=#query] #Query items
|
||||
|
||||
return nil
|
||||
|
@ -0,0 +1,68 @@
|
||||
-------------------------------------------------------------------------------
|
||||
-- `openmw.self` provides full access to the object the script is attached to.
|
||||
-- Can be used only from local scripts. All fields and function of `GameObject` are also available for `openmw.self`.
|
||||
-- @module self
|
||||
-- @extends openmw.core#GameObject
|
||||
-- @usage local self = require('openmw.self')
|
||||
-- if self.type == 'Player' then -- All fields and functions of `GameObject` are available.
|
||||
-- self:sendEvent("something", self.position)
|
||||
-- end
|
||||
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Returns true if the script isActive (the object it is attached to is in an active cell).
|
||||
-- If it is not active, then `openmw.nearby` can not be used.
|
||||
-- @function [parent=#self] isActive
|
||||
-- @param self
|
||||
-- @return #boolean
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- The object the script is attached to (readonly)
|
||||
-- @field [parent=#self] openmw.core#GameObject object
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Movement controls (only for actors)
|
||||
-- @field [parent=#self] #ActorControls controls
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Allows to view and/or modify controls of an actor. Makes an effect only if
|
||||
-- `setDirectControl(true)` was called. All fields are mutable.
|
||||
-- @type ActorControls
|
||||
-- @field [parent=#ActorControls] #number movement +1 - move forward, -1 - move backward
|
||||
-- @field [parent=#ActorControls] #number sideMovement +1 - move right, -1 - move left
|
||||
-- @field [parent=#ActorControls] #number turn Turn right (radians); if negative - turn left
|
||||
-- @field [parent=#ActorControls] #boolean run true - run, false - walk
|
||||
-- @field [parent=#ActorControls] #boolean jump If true - initiate a jump
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Enables or disables direct movement control (disabled by default).
|
||||
-- @function [parent=#self] setDirectControl
|
||||
-- @param self
|
||||
-- @param #boolean control
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Enables or disables standart AI (enabled by default).
|
||||
-- @function [parent=#self] enableAI
|
||||
-- @param self
|
||||
-- @param #boolean v
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Returns current target or nil if not in combat
|
||||
-- @function [parent=#self] getCombatTarget
|
||||
-- @param self
|
||||
-- @return openmw.core#GameObject
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Remove all combat packages from the actor.
|
||||
-- @function [parent=#self] stopCombat
|
||||
-- @param self
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Attack `target`.
|
||||
-- @function [parent=#self] startCombat
|
||||
-- @param self
|
||||
-- @param openmw.core#GameObject target
|
||||
|
||||
return nil
|
||||
|
@ -0,0 +1,15 @@
|
||||
-------------------------------------------------------------------------------
|
||||
-- `openmw.ui` controls user interface.
|
||||
-- Can be used only by local scripts, that are attached to a player.
|
||||
-- @module ui
|
||||
-- @usage local ui = require('openmw.ui')
|
||||
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Shows given message at the bottom of the screen.
|
||||
-- @function [parent=#ui] showMessage
|
||||
-- @param #string msg
|
||||
|
||||
return nil
|
||||
|
@ -0,0 +1,150 @@
|
||||
-------------------------------------------------------------------------------
|
||||
-- `openmw.util` defines utility functions and classes like 3D vectors, that don't depend on the game world.
|
||||
-- @module util
|
||||
-- @usage local util = require('openmw.util')
|
||||
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Limits given value to the interval [`from`, `to`]
|
||||
-- @function [parent=#util] clamp
|
||||
-- @param #number value
|
||||
-- @param #number from
|
||||
-- @param #number to
|
||||
-- @return #number min(max(value, from), to)
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Adds `2pi*k` and puts the angle in range `[-pi, pi]`
|
||||
-- @function [parent=#util] normalizeAngle
|
||||
-- @param #number angle Angle in radians
|
||||
-- @return #number Angle in range `[-pi, pi]`
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Immutable 2D vector
|
||||
-- @type Vector2
|
||||
-- @field #number x
|
||||
-- @field #number y
|
||||
-- @usage
|
||||
-- v = util.vector2(3, 4)
|
||||
-- v.x, v.y -- 3.0, 4.0
|
||||
-- str(v) -- "(3.0, 4.0)"
|
||||
-- v:length() -- 5.0 length
|
||||
-- v:length2() -- 25.0 square of the length
|
||||
-- v:normalize() -- vector2(3/5, 4/5)
|
||||
-- v:rotate(radians) -- rotate clockwise (returns rotated vector)
|
||||
-- v1:dot(v2) -- dot product (returns a number)
|
||||
-- v1 * v2 -- dot product
|
||||
-- v1 + v2 -- vector addition
|
||||
-- v1 - v2 -- vector subtraction
|
||||
-- v1 * x -- multiplication by a number
|
||||
-- v1 / x -- division by a number
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Creates a new 2D vector. Vectors are immutable and can not be changed after creation.
|
||||
-- @function [parent=#util] vector2
|
||||
-- @param #number x.
|
||||
-- @param #number y.
|
||||
-- @return #Vector2.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Length of the vector
|
||||
-- @function [parent=#Vector2] length
|
||||
-- @param self
|
||||
-- @return #number
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Square of the length of the vector
|
||||
-- @function [parent=#Vector2] length2
|
||||
-- @param self
|
||||
-- @return #number
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Normalizes vector.
|
||||
-- Returns two values: normalized vector and the length of the original vector.
|
||||
-- It doesn't change the original vector.
|
||||
-- @function [parent=#Vector2] normalize
|
||||
-- @param self
|
||||
-- @return #Vector2, #number
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Rotates 2D vector clockwise.
|
||||
-- @function [parent=#Vector2] rotate
|
||||
-- @param self
|
||||
-- @param #number angle Angle in radians
|
||||
-- @return #Vector2 Rotated vector.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Dot product.
|
||||
-- @function [parent=#Vector2] dot
|
||||
-- @param self
|
||||
-- @param #Vector2 v
|
||||
-- @return #number
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Immutable 3D vector
|
||||
-- @type Vector3
|
||||
-- @field #number x
|
||||
-- @field #number y
|
||||
-- @field #number z
|
||||
-- @usage
|
||||
-- v = util.vector3(3, 4, 5)
|
||||
-- v.x, v.y, v.z -- 3.0, 4.0, 5.0
|
||||
-- str(v) -- "(3.0, 4.0, 4.5)"
|
||||
-- v:length() -- length
|
||||
-- v:length2() -- square of the length
|
||||
-- v:normalize() -- normalized vector
|
||||
-- v1:dot(v2) -- dot product (returns a number)
|
||||
-- v1 * v2 -- dot product (returns a number)
|
||||
-- v1:cross(v2) -- cross product (returns a vector)
|
||||
-- v1 ^ v2 -- cross product (returns a vector)
|
||||
-- v1 + v2 -- vector addition
|
||||
-- v1 - v2 -- vector subtraction
|
||||
-- v1 * x -- multiplication by a number
|
||||
-- v1 / x -- division by a number
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Creates a new 3D vector. Vectors are immutable and can not be changed after creation.
|
||||
-- @function [parent=#util] vector3
|
||||
-- @param #number x.
|
||||
-- @param #number y.
|
||||
-- @param #number z.
|
||||
-- @return #Vector3.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Length of the vector
|
||||
-- @function [parent=#Vector3] length
|
||||
-- @param self
|
||||
-- @return #number
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Square of the length of the vector
|
||||
-- @function [parent=#Vector3] length2
|
||||
-- @param self
|
||||
-- @return #number
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Normalizes vector.
|
||||
-- Returns two values: normalized vector and the length of the original vector.
|
||||
-- It doesn't change the original vector.
|
||||
-- @function [parent=#Vector3] normalize
|
||||
-- @param self
|
||||
-- @return #Vector3, #number
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Dot product.
|
||||
-- @function [parent=#Vector3] dot
|
||||
-- @param self
|
||||
-- @param #Vector3 v
|
||||
-- @return #number
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Cross product.
|
||||
-- @function [parent=#Vector3] cross
|
||||
-- @param self
|
||||
-- @param #Vector3 v
|
||||
-- @return #Vector3
|
||||
|
||||
return nil
|
||||
|
@ -0,0 +1,34 @@
|
||||
-------------------------------------------------------------------------------
|
||||
-- `openmw.world` is an interface to the game world for global scripts.
|
||||
-- Can not be used from local scripts.
|
||||
-- @module world
|
||||
-- @usage local world = require('openmw.world')
|
||||
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- List of currently active actors.
|
||||
-- @field [parent=#world] openmw.core#ObjectList activeActors
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Evaluates a Query.
|
||||
-- @function [parent=#world] selectObjects
|
||||
-- @param openmw.query#Query query
|
||||
-- @return openmw.core#ObjectList
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Loads a named cell
|
||||
-- @function [parent=#world] getCellByName
|
||||
-- @param #string cellName
|
||||
-- @return openmw.core#Cell
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Loads an exterior cell by grid indices
|
||||
-- @function [parent=#world] getExteriorCell
|
||||
-- @param #number gridX
|
||||
-- @param #number gridY
|
||||
-- @return openmw.core#Cell
|
||||
|
||||
|
||||
return nil
|
||||
|
@ -0,0 +1,231 @@
|
||||
-------------------------------------------------------------------------------
|
||||
-- String Manipulation.
|
||||
-- This library provides generic functions for string manipulation,
|
||||
-- such as finding and extracting substrings, and pattern matching.
|
||||
-- When indexing a string in Lua, the first character is at position 1 (not at 0, as in C).
|
||||
-- Indices are allowed to be negative and are interpreted as indexing backwards, from the end of the string.
|
||||
-- Thus, the last character is at position -1, and so on.
|
||||
--
|
||||
-- The string library provides all its functions inside the table string. It also sets a metatable for strings where the __index field points to the string table. Therefore, you can use the string functions in object-oriented style.
|
||||
-- For instance, string.byte(s, i) can be written as s:byte(i).
|
||||
--
|
||||
-- The string library assumes one-byte character encodings.
|
||||
-- @module string
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Returns the internal numerical codes of the characters `s[i]`, `s[i+1]`,
|
||||
-- ..., `s[j]`. The default value for `i` is 1; the default value for `j`
|
||||
-- is `i`.
|
||||
-- Note that numerical codes are not necessarily portable across platforms.
|
||||
-- @function [parent=#string] byte
|
||||
-- @param #string s string to handle.
|
||||
-- @param #number i start index, default value is 1.
|
||||
-- @param #number j end index, default value is `i`.
|
||||
-- @return the internal numerical codes of the characters `s[i]`, `s[i+1]`,..., `s[j]`
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Receives zero or more integers. Returns a string with length equal to
|
||||
-- the number of arguments, in which each character has the internal numerical
|
||||
-- code equal to its corresponding argument.
|
||||
--
|
||||
-- Note that numerical codes are not necessarily portable across platforms.
|
||||
-- @function [parent=#string] char
|
||||
-- @param ... zero or more integers.
|
||||
-- @return #string a string with length equal to
|
||||
-- the number of arguments, in which each character has the internal numerical
|
||||
-- code equal to its corresponding argument.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Returns a string containing a binary representation of the given
|
||||
-- function, so that a later `loadstring` on this string returns a copy of
|
||||
-- the function. `function` must be a Lua function without upvalues.
|
||||
-- @function [parent=#string] dump
|
||||
-- @param f the function to dump.
|
||||
-- @return #string a string representation of the given function.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Looks for the first match of `pattern` in the string `s`. If it finds a
|
||||
-- match, then `find` returns the indices of `s` where this occurrence starts
|
||||
-- and ends; otherwise, it returns nil.A third, optional numerical argument
|
||||
-- `init` specifies where to start the search; its default value is 1 and
|
||||
-- can be negative. A value of true as a fourth, optional argument `plain`
|
||||
-- turns off the pattern matching facilities, so the function does a plain
|
||||
-- "find substring" operation, with no characters in `pattern` being considered
|
||||
-- "magic".
|
||||
--
|
||||
-- Note that if `plain` is given, then `init` must be given as well.
|
||||
-- If the pattern has captures, then in a successful match the captured values
|
||||
-- are also returned, after the two indices.
|
||||
-- @function [parent=#string] find
|
||||
-- @param #string s string to handle.
|
||||
-- @param #string pattern pattern to search.
|
||||
-- @param #number init index where to start the search. (default value is 1)
|
||||
-- @param #boolean plain set to true to search without pattern matching. (default value is false)
|
||||
-- @return #number, #number start and end indices of first occurence.
|
||||
-- @return #nil if pattern not found.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Returns a formatted version of its variable number of arguments following
|
||||
-- the description given in its first argument (which must be a string). The
|
||||
-- format string follows the same rules as the `printf` family of standard C
|
||||
-- functions. The only differences are that the options/modifiers `*`, `l`,
|
||||
-- `L`, `n`, `p`, and `h` are not supported and that there is an extra option,
|
||||
-- `q`. The `q` option formats a string in a form suitable to be safely read
|
||||
-- back by the Lua interpreter: the string is written between double quotes,
|
||||
-- and all double quotes, newlines, embedded zeros, and backslashes in the
|
||||
-- string are correctly escaped when written. For instance, the call
|
||||
--
|
||||
-- string.format('%q', 'a string with "quotes" and \n new line')
|
||||
--
|
||||
-- will produce the string:
|
||||
--
|
||||
-- "a string with \"quotes\" and \
|
||||
-- new line"
|
||||
--
|
||||
-- The options `c`, `d`, `E`, `e`, `f`, `g`, `G`, `i`, `o`, `u`, `X`, and
|
||||
-- `x` all expect a number as argument, whereas `q` and `s` expect a string.
|
||||
-- This function does not accept string values containing embedded zeros,
|
||||
-- except as arguments to the `q` option.
|
||||
-- @function [parent=#string] format
|
||||
-- @param #string formatstring the string template.
|
||||
-- @param ... arguments could be strings or numbers.
|
||||
-- @return #string the formatted string.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Returns an iterator function that, each time it is called, returns the
|
||||
-- next captures from `pattern` over string `s`. If `pattern` specifies no
|
||||
-- captures, then the whole match is produced in each call.
|
||||
-- As an example, the following loop
|
||||
--
|
||||
-- s = "hello world from Lua"
|
||||
-- for w in string.gmatch(s, "%a+") do
|
||||
-- print(w)
|
||||
-- end
|
||||
--
|
||||
-- will iterate over all the words from string `s`, printing one per line. The
|
||||
-- next example collects all pairs `key=value` from the given string into
|
||||
-- a table:
|
||||
--
|
||||
-- t = {}
|
||||
-- s = "from=world, to=Lua"
|
||||
-- for k, v in string.gmatch(s, "(%w+)=(%w+)") do
|
||||
-- t[k] = v
|
||||
-- end
|
||||
--
|
||||
-- For this function, a '`^`' at the start of a pattern does not work as an
|
||||
-- anchor, as this would prevent the iteration.
|
||||
-- @function [parent=#string] gmatch
|
||||
-- @param #string s string to handle.
|
||||
-- @param #string pattern pattern to search.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Returns a copy of `s` in which all (or the first `n`, if given)
|
||||
-- occurrences of the `pattern` have been replaced by a replacement string
|
||||
-- specified by `repl`, which can be a string, a table, or a function. `gsub`
|
||||
-- also returns, as its second value, the total number of matches that occurred.
|
||||
--
|
||||
-- If `repl` is a string, then its value is used for replacement. The character
|
||||
-- `%` works as an escape character: any sequence in `repl` of the form `%n`,
|
||||
-- with *n* between 1 and 9, stands for the value of the *n*-th captured
|
||||
-- substring (see below). The sequence `%0` stands for the whole match. The
|
||||
-- sequence `%%` stands for a single `%`.
|
||||
--
|
||||
-- If `repl` is a table, then the table is queried for every match, using
|
||||
-- the first capture as the key; if the pattern specifies no captures, then
|
||||
-- the whole match is used as the key.
|
||||
--
|
||||
-- If `repl` is a function, then this function is called every time a match
|
||||
-- occurs, with all captured substrings passed as arguments, in order; if
|
||||
-- the pattern specifies no captures, then the whole match is passed as a
|
||||
-- sole argument.
|
||||
--
|
||||
-- If the value returned by the table query or by the function call is a
|
||||
-- string or a number, then it is used as the replacement string; otherwise,
|
||||
-- if it is false or nil, then there is no replacement (that is, the original
|
||||
-- match is kept in the string).
|
||||
--
|
||||
-- Here are some examples:
|
||||
--
|
||||
-- x = string.gsub("hello world", "(%w+)", "%1 %1")
|
||||
-- --> x="hello hello world world"
|
||||
-- x = string.gsub("hello world", "%w+", "%0 %0", 1)
|
||||
-- --> x="hello hello world"
|
||||
-- x = string.gsub("hello world from Lua", "(%w+)%s*(%w+)", "%2 %1")
|
||||
-- --> x="world hello Lua from"
|
||||
-- x = string.gsub("home = $HOME, user = $USER", "%$(%w+)", os.getenv)
|
||||
-- --> x="home = /home/roberto, user = roberto"
|
||||
-- x = string.gsub("4+5 = $return 4+5$", "%$(.-)%$", function (s)
|
||||
-- return loadstring(s)()
|
||||
-- end)
|
||||
-- --> x="4+5 = 9"
|
||||
-- local t = {name="lua", version="5.1"}
|
||||
-- x = string.gsub("$name-$version.tar.gz", "%$(%w+)", t)
|
||||
-- --> x="lua-5.1.tar.gz"
|
||||
-- @function [parent=#string] gsub
|
||||
-- @param #string s string to handle.
|
||||
-- @param #string pattern pattern to search.
|
||||
-- @param repl replacement could be a string, a table or a function.
|
||||
-- @param #number n number of occurences to replace, default is nil which means all occurences.
|
||||
-- @return #string a modified copy of `s`.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Receives a string and returns its length. The empty string `""` has
|
||||
-- length 0. Embedded zeros are counted, so `"a\000bc\000"` has length 5.
|
||||
-- @function [parent=#string] len
|
||||
-- @param #string s string to handle.
|
||||
-- @return #number the lenght of `s`.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Receives a string and returns a copy of this string with all uppercase
|
||||
-- letters changed to lowercase. All other characters are left unchanged. The
|
||||
-- definition of what an uppercase letter is depends on the current locale.
|
||||
-- @function [parent=#string] lower
|
||||
-- @param #string s string to handle.
|
||||
-- @return #string a lower case version of `s`.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Looks for the first *match* of `pattern` in the string `s`. If it
|
||||
-- finds one, then `match` returns the captures from the pattern; otherwise
|
||||
-- it returns nil. If `pattern` specifies no captures, then the whole match
|
||||
-- is returned. A third, optional numerical argument `init` specifies where
|
||||
-- to start the search; its default value is 1 and can be negative.
|
||||
-- @function [parent=#string] match
|
||||
-- @param #string s string to handle.
|
||||
-- @param #string pattern pattern to search.
|
||||
-- @param #number init index where to start the search. (default value is 1)
|
||||
-- @return #string the captures from the pattern; otherwise it returns nil. If pattern specifies no captures, then the whole match is returned.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Returns a string that is the concatenation of `n` copies of the string `s`.
|
||||
-- @function [parent=#string] rep
|
||||
-- @param #string s string to handle.
|
||||
-- @param #number n number of repetition.
|
||||
-- @return #string the concatenation of `n` copies of the string `s`.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Returns a string that is the string `s` reversed.
|
||||
-- @function [parent=#string] reverse
|
||||
-- @param #string s string to handle.
|
||||
-- @return #string the string `s` reversed.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Returns the substring of `s` that starts at `i` and continues until
|
||||
-- `j`; `i` and `j` can be negative. If `j` is absent, then it is assumed to
|
||||
-- be equal to -1 (which is the same as the string length). In particular,
|
||||
-- the call `string.sub(s,1,j)` returns a prefix of `s` with length `j`, and
|
||||
-- `string.sub(s, -i)` returns a suffix of `s` with length `i`.
|
||||
-- @function [parent=#string] sub
|
||||
-- @param #string s string to handle.
|
||||
-- @param #number i start index.
|
||||
-- @param #number j end index. (default value is -1, which is the same as the string lenght)
|
||||
-- @return #string the substring of `s` that starts at `i` and continues until `j`.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Receives a string and returns a copy of this string with all lowercase
|
||||
-- letters changed to uppercase. All other characters are left unchanged. The
|
||||
-- definition of what a lowercase letter is depends on the current locale.
|
||||
-- @function [parent=#string] upper
|
||||
-- @param #string s string to handle.
|
||||
-- @return #string a upper case version of `s`.
|
||||
|
||||
return nil
|
@ -0,0 +1,66 @@
|
||||
-------------------------------------------------------------------------------
|
||||
-- Table Manipulation
|
||||
-- This library provides generic functions for table manipulation.
|
||||
-- It provides all its functions inside the table table.
|
||||
--
|
||||
-- Most functions in the table library assume that the table represents an array or a list.
|
||||
-- For these functions, when we talk about the "length" of a table we mean the result of the length operator.
|
||||
-- @module table
|
||||
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Given an array where all elements are strings or numbers, returns
|
||||
-- `table[i]..sep..table[i+1]...sep..table[j]`. The default value for
|
||||
-- `sep` is the empty string, the default for `i` is 1, and the default for
|
||||
-- `j` is the length of the table. If `i` is greater than `j`, returns the
|
||||
-- empty string.
|
||||
-- @function [parent=#table] concat
|
||||
-- @param #table table table to handle.
|
||||
-- @param #string sep the separator, default value is an empty string.
|
||||
-- @param #number i start index, default value is 1.
|
||||
-- @param #number j end index, default value is lenght of the table.
|
||||
-- @return #string the concatenated table.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Inserts element `value` at position `pos` in `table`, shifting up
|
||||
-- other elements to open space, if necessary. The default value for `pos` is
|
||||
-- `n+1`, where `n` is the length of the table, so that a call
|
||||
-- `table.insert(t,x)` inserts `x` at the end of table `t`.
|
||||
-- @function [parent=#table] insert
|
||||
-- @param #table table table to modify.
|
||||
-- @param #number pos index of insertion.
|
||||
-- @param value value to insert.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Returns the largest positive numerical index of the given table, or
|
||||
-- zero if the table has no positive numerical indices. (To do its job this
|
||||
-- function does a linear traversal of the whole table.)
|
||||
-- @function [parent=#table] maxn
|
||||
-- @param #table table table to traverse.
|
||||
-- @return #number the largest positive numerical index of the given table, or
|
||||
-- zero if the table has no positive numerical indices.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Removes from `table` the element at position `pos`, shifting down other
|
||||
-- elements to close the space, if necessary. Returns the value of the removed
|
||||
-- element. The default value for `pos` is `n`, where `n` is the length of the
|
||||
-- table, so that a call `table.remove(t)` removes the last element of table
|
||||
-- `t`.
|
||||
-- @function [parent=#table] remove
|
||||
-- @param #table table table to modify.
|
||||
-- @param #number pos index of deletion. (default value is the lenght of the table)
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Sorts table elements in a given order,
|
||||
-- *in-place*, from `table[1]` to `table[n]`, where `n` is the length of the
|
||||
-- table. If `comp` is given, then it must be a function that receives two
|
||||
-- table elements, and returns true when the first is less than the second
|
||||
-- (so that `not comp(a[i+1],a[i])` will be true after the sort). Lua operator < is used instead.
|
||||
--
|
||||
-- The sort algorithm is not stable; that is, elements considered equal by the given order may have their relative positions changed by the sort.
|
||||
-- @function [parent=#table] sort
|
||||
-- @param #table table table to sort.
|
||||
-- @param comp a function which take to table and returns true when the first is less than the second.
|
||||
|
||||
return nil
|
Loading…
Reference in New Issue