Skip to content

Commit d29f363

Browse files
committed
update docs
1 parent 3779189 commit d29f363

File tree

193 files changed

+8363
-1695
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

193 files changed

+8363
-1695
lines changed

definitions/feature/manager/commandmgr.d.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,5 @@ declare class CommandManager {
1010
*/
1111
registerCommand(cmd: Command): void;
1212

13-
/**
14-
* Removes a command from the client.
15-
* @param mod The command to deregister. Must be a script command.
16-
*/
17-
deregisterCommand(cmd: Command): void;
13+
//deregisterCommand(cmd: Command): void;
1814
}

definitions/feature/manager/mmgr.d.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@ interface ModuleManager {
55
*/
66
registerModule(mod: Module): void;
77

8-
/**
9-
* Removes a module from the client.
10-
* @param mod The module to unregister. Must be a script module.
11-
*/
12-
deregisterModule(mod: Module): void;
8+
//deregisterModule(mod: Module): void;
139

1410
/**
1511
* Gets a module by the specified InternalName.

definitions/game.d.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ interface Game {
4141
*/
4242
getWorld() : World | null;
4343

44+
/**
45+
* Get whether you are in a UI screen
46+
*/
4447
isInUI(): boolean;
4548

4649
/**
@@ -52,6 +55,49 @@ interface Game {
5255
* Get the mouse position.
5356
*/
5457
getMousePos(): Vector2;
58+
59+
/**
60+
* Gets the user's input setting. Usually a key code; for example, `"forward"` returns `KeyCode.W` by default.
61+
*
62+
* If this function returns 0, either the key is set to nothing or the specified name was not found.
63+
*/
64+
getInputBinding(name: InputBinding): number;
5565
}
5666

67+
type InputBinding =
68+
"attack" |
69+
"pickItem" |
70+
"use" |
71+
"drop" |
72+
"hotbar.1" |
73+
"hotbar.2" |
74+
"hotbar.3" |
75+
"hotbar.4" |
76+
"hotbar.5" |
77+
"hotbar.6" |
78+
"hotbar.7" |
79+
"hotbar.8" |
80+
"hotbar.9" |
81+
"inventory" |
82+
"togglePerspective" |
83+
"jump" |
84+
"sneak" |
85+
"sprint" |
86+
"left" |
87+
"right" |
88+
"back" |
89+
"forward" |
90+
"mobEffects" |
91+
"chat" |
92+
"command" |
93+
"copyCoordinates" |
94+
"copyFacingCoordinates" |
95+
"toggleControlTips" |
96+
"codeBuilder" |
97+
"immersivereader" |
98+
"emote" |
99+
"menuTabLeft" |
100+
"menuTabRight" |
101+
"menuCancel";
102+
57103
declare const game: Game;

definitions/index.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/// <reference path="./script.d.ts" />
2+
/// <reference path="./plugin.d.ts" />
23
/// <reference path="./game.d.ts" />
34
/// <reference path="./latite.d.ts" />
45

@@ -17,6 +18,10 @@
1718
/// <reference path="./gfx/graphics3.d.ts" />
1819
/// <reference path="./gfx/Texture.d.ts" />
1920

21+
/// <reference path="./molang/Variable.d.ts" />
22+
/// <reference path="./molang/Variables.d.ts" />
23+
24+
/// <reference path="./native/NativeModule.d.ts" />
2025

2126
/// <reference path="./feature/command.d.ts" />
2227
/// <reference path="./feature/module.d.ts" />

definitions/latite.d.ts

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ interface CancellableEvent extends LatiteEvent {
66
}
77

88
interface SendChatEvent extends CancellableEvent {
9-
message: string;
9+
readonly message: string;
1010
}
1111

1212
type MessageType =
@@ -23,21 +23,21 @@ type MessageType =
2323
"object_whisper";
2424

2525
interface MessageEvent extends CancellableEvent {
26-
type: MessageType;
26+
readonly type: MessageType;
2727
/**
2828
* Whether or not the message type is a chat message.
2929
*/
30-
isChat: boolean;
31-
message: string;
30+
readonly isChat: boolean;
31+
readonly message: string;
3232

3333
/**
3434
* The sender of the message (if applicable)
3535
*/
36-
sender: string;
36+
readonly sender: string;
3737
/**
3838
* The Xbox User ID of the sender (if applicable)
3939
*/
40-
xuid: string;
40+
readonly xuid: string;
4141
}
4242

4343
declare const enum MouseButton {
@@ -48,22 +48,22 @@ declare const enum MouseButton {
4848
}
4949

5050
interface ClickEvent extends CancellableEvent {
51-
button: MouseButton;
52-
isDown: boolean;
53-
mouseX: number;
54-
mouseY: number;
51+
readonly button: MouseButton;
52+
readonly isDown: boolean;
53+
readonly mouseX: number;
54+
readonly mouseY: number;
5555
}
5656

5757
interface KeyEvent extends CancellableEvent {
58-
isDown: boolean;
59-
keyCode: KeyCode; // like 0x43
60-
keyAsChar: string; // like 'C'
58+
readonly isDown: boolean;
59+
readonly keyCode: KeyCode; // like 0x43
60+
readonly keyAsChar: string; // like 'C'
6161
}
6262

6363
interface ScriptEvent extends LatiteEvent {
64-
scriptName: string,
65-
scriptVersion: string,
66-
scriptAuthor: string
64+
readonly scriptName: string,
65+
readonly scriptVersion: string,
66+
readonly scriptAuthor: string
6767
}
6868

6969
type TitleType =
@@ -78,8 +78,12 @@ type TitleType =
7878
"times";
7979

8080
interface TitleEvent extends CancellableEvent {
81-
type: TitleType;
82-
text: string;
81+
readonly type: TitleType;
82+
readonly text: string;
83+
}
84+
85+
interface TextInputEvent extends CancellableEvent {
86+
readonly characters: string;
8387
}
8488

8589
interface ClientEvents {
@@ -207,6 +211,18 @@ interface ClientEvents {
207211
* ```
208212
*/
209213
"title": TitleEvent;
214+
215+
/**
216+
* Called whenever text input is received.
217+
*
218+
* ```ts
219+
* Listener:
220+
* {
221+
* characters: string
222+
* }
223+
* ```
224+
*/
225+
"text-input": TextInputEvent;
210226
}
211227

212228
interface Latite {

definitions/lib/filesystem.d.ts

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,47 @@ declare namespace include {
33
/**
44
* Reads a file asynchronously.
55
* @param path The path to read from.
6-
* @param callback
6+
* @param callback This will get called when the operation is finished
77
*/
8-
read(path: string, callback: (err: number, content: Buffer) => void): void;
8+
readAsync(path: string, callback: (err: number, content: Buffer) => void): void;
99

1010
/**
1111
*
1212
* @param path The path to write to
1313
* @param data The data to write (see util.stringToBuffer to convert a string to a buffer)
14-
* @param callback
14+
* @param callback This will get called when the operation is finished
1515
*/
16-
write(path: string, data: Buffer, callback: (err: number) => void): void;
16+
writeAsync(path: string, data: Buffer, callback: (err: number) => void): void;
1717

1818
/**
1919
* Reads a file from the path specified.
2020
* @param path The relative path from the script.
2121
*/
22-
readSync(path: string): Buffer;
22+
read(path: string): Buffer;
2323
/**
2424
* Writes a file to the path specified.
2525
* @param path The relative path from the script.
26-
* @param data The data to write.
26+
* @param data The data to write. For example, `util.stringToBuffer("hello")`
2727
*/
28-
writeSync(path: string, data: Buffer): void;
28+
write(path: string, data: Buffer): void;
2929

3030
/**
3131
* Checks if a file or a directory exists
3232
* @param path The path to check if a file or directory exists
3333
*/
34-
existsSync(path: string): boolean;
34+
exists(path: string): boolean;
3535

3636
/**
3737
* Creates a folder/directory.
3838
* @param path The path to create a directory.
3939
*/
40-
createDirectorySync(path: string): void;
40+
createDirectory(path: string): void;
41+
42+
/**
43+
*
44+
* @param path The path to append to the file.
45+
* @param data The data to append, for example, `util.bufferToString("hello")`
46+
*/
47+
append(path: string, data: Buffer): void;
4148
}
4249
}

definitions/lib/network.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,29 +28,29 @@ declare namespace include {
2828
* @param url The URL to send the request.
2929
* @param data
3030
*/
31-
getSync(url: string, data?: GetData): HttpResponse;
31+
get(url: string, data?: GetData): HttpResponse;
3232

3333
/**
3434
* Sends an async GET request to a URL.
3535
* @param url The URL to send the request.
3636
* @param data
3737
* @param callback
3838
*/
39-
get(url: string, data: GetData, callback: (resp: HttpResponse) => void): void;
39+
getAsync(url: string, data: GetData, callback: (resp: HttpResponse) => void): void;
4040

4141
/**
4242
* Sends a basic POST request to a URL.
4343
* @param url The URL to send a POST request.
4444
* @param data
4545
*/
46-
postSync(url: string, data?: PostData): HttpResponse;
46+
post(url: string, data?: PostData): HttpResponse;
4747

4848
/**
4949
* Sends an async POST request to a URL.
5050
* @param url The URL to send the request.
5151
* @param data
5252
* @param callback
5353
*/
54-
//post(url: string, data: GetData, callback: (err: number, resp: HttpResponse) => void): void;
54+
//postAsync(url: string, data: GetData, callback: (err: number, resp: HttpResponse) => void): void;
5555
}
5656
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
type NativeType = "void" | "float32" | "float64" | "int32" | "int64";
2+
3+
/**
4+
* A class representing a native DLL.
5+
*/
6+
declare class NativeModule {
7+
/**
8+
* Gets a module that's currently loaded.
9+
*
10+
* The plugin needs the permission `Permission.SystemAccess` to use this.
11+
*
12+
* This method is restricted to prevent cheating.
13+
* @param moduleName The module name, e.g. `"User32.dll"`
14+
*/
15+
static get(moduleName: string): NativeModule | null;
16+
17+
/**
18+
* The current handle of the module. Warning: will be truncated to Float64
19+
*/
20+
readonly handle: number;
21+
22+
/**
23+
* Calls a function.
24+
*
25+
* This method is restricted to prevent cheating.
26+
* @param functionName The procedure name.
27+
* @param returnType The return type that is expected.
28+
* @param args Arguments to pass to the function. The maximum arguments is 10.
29+
*/
30+
public call(functionName: string, returnType: NativeType, ...args: any[]): number | undefined;
31+
}

definitions/plugin.d.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
declare const enum Permission {
2+
SystemAccess = "permission.system_access",
3+
}
4+
5+
interface IPlugin {
6+
readonly name: string;
7+
readonly author: string;
8+
readonly version: string;
9+
readonly description: string;
10+
11+
/**
12+
* Requests a permission.
13+
* @param permission The permissions to request.
14+
* @returns Whether or not the permission was requested.
15+
*/
16+
requestPermission(permission: Permission): boolean;
17+
}
18+
19+
declare const plugin: IPlugin;

definitions/script.d.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,28 @@ interface ScriptModule {
5454
exports: {}
5555
}
5656

57-
declare const module: ScriptModule;
57+
interface IScript {
58+
/**
59+
* @deprecated
60+
*/
61+
name: string;
62+
63+
/**
64+
* @deprecated
65+
*/
66+
author: string;
67+
68+
/**
69+
* @deprecated
70+
*/
71+
description: string;
72+
73+
/**
74+
* @deprecated
75+
* @param values
76+
* @returns
77+
*/
78+
log: (... values: any[]) => void
79+
}
80+
81+
declare var script: IScript;

0 commit comments

Comments
 (0)