-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy path5.1-only.d.ts
More file actions
103 lines (94 loc) · 3.51 KB
/
Copy path5.1-only.d.ts
File metadata and controls
103 lines (94 loc) · 3.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/** @noSelfInFile */
/**
* Loads a chunk using function func to get its pieces. Each call to func must
* return a string that concatenates with previous results. A return of an empty
* string, nil, or no value signals the end of the chunk.
*
* If there are no errors, returns the compiled chunk as a function; otherwise,
* returns nil plus the error message. The environment of the returned function
* is the global environment.
*
* chunkname is used as the chunk name for error messages and debug information.
* When absent, it defaults to "=(load)".
*/
declare function load(
func: () => string | null | undefined,
chunkname?: string
): LuaMultiReturn<[() => any] | [undefined, string]>;
/**
* Similar to load, but gets the chunk from file filename or from the standard
* input, if no file name is given.
*/
declare function loadfile(filename?: string): LuaMultiReturn<[() => any] | [undefined, string]>;
/**
* Similar to load, but gets the chunk from the given string.
*
* To load and run a given string, use the idiom
*
* `assert(loadstring(s))()`
*
* When absent, chunkname defaults to the given string.
*/
declare function loadstring(
string: string,
chunkname?: string
): LuaMultiReturn<[() => any] | [undefined, string]>;
/**
* This function is similar to pcall, except that it sets a new message handler
* msgh.
*
* 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.
*/
declare function xpcall<R, E>(
f: () => R,
err: (err: any) => E
): LuaMultiReturn<[true, R] | [false, E]>;
declare namespace math {
/**
* Returns the logarithm of x.
*/
function log(x: number): number;
}
declare namespace string {
/**
* Returns a string that is the concatenation of n copies of the string s.
*/
function rep(s: string, n: number): string;
}
declare namespace os {
/**
* Calls the C function exit, with an optional code, to terminate the host
* program. The default value for code is the success code.
*/
function exit(code?: number): never;
}
declare namespace debug {
/**
* This function returns the name and the value of the local variable with
* index local of the function at level level of the stack. (The first
* parameter or local variable has index 1, and so on, until the last active
* local variable.) The function returns nil if there is no local variable
* with the given index, and raises an error when called with a level out of
* range. (You can call debug.getinfo to check whether the level is valid.)
*
* Variable names starting with '(' (open parentheses) represent internal
* variables (loop control variables, temporaries, and C function locals).
*/
function getlocal(level: number, local: number): LuaMultiReturn<[string, any]>;
function getlocal(
thread: LuaThread,
level: number,
local: number
): LuaMultiReturn<[string, any]>;
}
declare namespace io {
type FileReadNumberFormat = '*n';
type FileReadLineFormat = '*l';
type FileReadFormat = FileReadNumberFormat | FileReadLineFormat | '*a' | number;
}