Compare commits
2 Commits
cf00c7c212
...
57594aebbd
| Author | SHA1 | Date | |
|---|---|---|---|
| 57594aebbd | |||
| df29e4d0ef |
17
test.lua
17
test.lua
@@ -1,7 +1,22 @@
|
|||||||
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
||||||
|
fps = 60
|
||||||
|
duration = 5
|
||||||
menu.add_feature(
|
menu.add_feature(
|
||||||
"test",
|
"test",
|
||||||
"action",
|
"action",
|
||||||
0,
|
0,
|
||||||
function() return ui.notify_above_map("Hello from TypeScript", "", 140) end
|
function()
|
||||||
|
do
|
||||||
|
local i = 0
|
||||||
|
while i < (fps * duration) do
|
||||||
|
scriptdraw.draw_rect(
|
||||||
|
v2(0, 0),
|
||||||
|
v2(1, 1),
|
||||||
|
4294967295
|
||||||
|
)
|
||||||
|
system.wait(0)
|
||||||
|
i = i + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
)
|
)
|
||||||
|
|||||||
17
ts-lua/dist/test.lua
vendored
17
ts-lua/dist/test.lua
vendored
@@ -1,7 +1,22 @@
|
|||||||
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
||||||
|
fps = 60
|
||||||
|
duration = 5
|
||||||
menu.add_feature(
|
menu.add_feature(
|
||||||
"test",
|
"test",
|
||||||
"action",
|
"action",
|
||||||
0,
|
0,
|
||||||
function() return ui.notify_above_map("Hello from TypeScript", "", 140) end
|
function()
|
||||||
|
do
|
||||||
|
local i = 0
|
||||||
|
while i < (fps * duration) do
|
||||||
|
scriptdraw.draw_rect(
|
||||||
|
v2(0, 0),
|
||||||
|
v2(1, 1),
|
||||||
|
4294967295
|
||||||
|
)
|
||||||
|
system.wait(0)
|
||||||
|
i = i + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tstl && npm run post-build",
|
"build": "tstl && $npm_package_scripts_postbuild",
|
||||||
"post-build": "cp dist/test.lua ../test.lua",
|
"postbuild": "cp dist/test.lua ../test.lua",
|
||||||
"dev": "tstl --watch"
|
"dev": "tstl --watch"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"lua-types": "^2.10.1",
|
"lua-types": "^2.10.1",
|
||||||
"typescript-to-lua": "^0.40.1"
|
"typescript-to-lua": "^0.40.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,2 +1,13 @@
|
|||||||
menu.add_feature('test', 'action', 0, () =>
|
const fps = 60,
|
||||||
ui.notify_above_map('Hello from TypeScript', '', 140))
|
duration = 5 //seconds
|
||||||
|
|
||||||
|
menu.add_feature('test', 'action', 0, () => {
|
||||||
|
|
||||||
|
for (let i = 0; i < fps * duration; i++) {
|
||||||
|
|
||||||
|
scriptdraw.draw_rect(v2(0, 0), v2(1, 1), 0xffffffff)
|
||||||
|
system.wait(0)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
|||||||
14
ts-lua/types/D3D.d.ts
vendored
14
ts-lua/types/D3D.d.ts
vendored
@@ -1,10 +1,22 @@
|
|||||||
/**
|
/**
|
||||||
* D3D Functions
|
* D3D Functions
|
||||||
|
*
|
||||||
|
* These functions should only be used from renderers: feature, which can be set through the renderer property
|
||||||
|
*
|
||||||
|
* Renderer callbacks are executed from the d3d thread
|
||||||
|
* @example
|
||||||
|
* menu.add_feature("d3d renderer", "toggle", 0, nil).renderer = d3d_draw
|
||||||
* @public
|
* @public
|
||||||
* @noSelf
|
* @noSelf
|
||||||
*/
|
*/
|
||||||
declare namespace d3d {
|
declare namespace d3d {
|
||||||
|
|
||||||
|
function draw_text(text: string, pos: v2, size: v2, scale: float, color: int, flags: int): void;
|
||||||
|
function register_sprite(path: string): int;
|
||||||
|
function draw_sprite(id: int, pos: v2, scale: float, rot: float, color: int): void;
|
||||||
|
function get_sprite_origin(id: int): v2;
|
||||||
|
function get_sprite_size(id: int): v2;
|
||||||
|
function draw_line(start: v2, end: v2, size: int, color: int): void;
|
||||||
|
function draw_rect(pos: v2, size: v2, color: int): void;
|
||||||
|
|
||||||
}
|
}
|
||||||
18
ts-lua/types/Events.d.ts
vendored
Normal file
18
ts-lua/types/Events.d.ts
vendored
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
/**
|
||||||
|
* Hook Functions
|
||||||
|
* @public
|
||||||
|
* @noSelf
|
||||||
|
*/
|
||||||
|
declare namespace hook {
|
||||||
|
|
||||||
|
type eventNames = "exit"|"chat"|"player_join"|"player_leave"|"script";
|
||||||
|
|
||||||
|
function add_event_listener(eventName: "exit", callback: (code: integer) => void|never): int;
|
||||||
|
function add_event_listener(eventName: "chat", callback: (player: integer, body: string) => void|never): int;
|
||||||
|
function add_event_listener(eventName: "player_join", callback: (player: integer) => void|never): int;
|
||||||
|
function add_event_listener(eventName: "player_leave", callback: (player: integer) => void|never): int;
|
||||||
|
function add_event_listener(eventName: "script", callback: (id: integer, params: vector<int>) => void|never): int;
|
||||||
|
|
||||||
|
function remove_event_listener(eventName: eventNames, id: int): boolean;
|
||||||
|
|
||||||
|
}
|
||||||
6
ts-lua/types/Hooks.d.ts
vendored
6
ts-lua/types/Hooks.d.ts
vendored
@@ -5,6 +5,12 @@
|
|||||||
*/
|
*/
|
||||||
declare namespace hook {
|
declare namespace hook {
|
||||||
|
|
||||||
|
type script_event_hook = (source: Player, target: Player, params: int[], count: int) => false|null;
|
||||||
|
type net_event_hook = (source: Player, target: Player, eventId: int) => false|null;
|
||||||
|
|
||||||
|
function register_script_event_hook(callback: script_event_hook): int
|
||||||
|
function remove_script_event_hook(id: int): boolean
|
||||||
|
function register_net_event_hook(callback: net_event_hook): int
|
||||||
|
function remove_net_event_hook(id: int): boolean
|
||||||
|
|
||||||
}
|
}
|
||||||
16
ts-lua/types/Input.d.ts
vendored
16
ts-lua/types/Input.d.ts
vendored
@@ -5,6 +5,22 @@
|
|||||||
*/
|
*/
|
||||||
declare namespace input {
|
declare namespace input {
|
||||||
|
|
||||||
|
enum resonse {
|
||||||
|
SUCCESS = 0,
|
||||||
|
PENDING,
|
||||||
|
FAILED
|
||||||
|
}
|
||||||
|
|
||||||
|
enum types {
|
||||||
|
ASCII = 0,
|
||||||
|
ALPHA,
|
||||||
|
ALPHA_NUM,
|
||||||
|
NUM,
|
||||||
|
NUM_DOT,
|
||||||
|
FLOAT
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function get(title: string, default_value: string, len: int, type: int): [int, string];
|
||||||
|
|
||||||
}
|
}
|
||||||
29
ts-lua/types/Menu.d.ts
vendored
29
ts-lua/types/Menu.d.ts
vendored
@@ -9,27 +9,18 @@ declare namespace menu {
|
|||||||
|
|
||||||
type featureTypes = "parent"|"toggle"|"action"|"value_i"|"action_value_i"|"autoaction_value_i";
|
type featureTypes = "parent"|"toggle"|"action"|"value_i"|"action_value_i"|"autoaction_value_i";
|
||||||
|
|
||||||
export function add_feature(name: string, type: featureTypes, parent: Feature, script_handler: (feat: Feat) => void): Feat;
|
function add_feature(name: string, type: featureTypes, parent: Feature, script_handler: (feat: Feat) => void|never): Feat;
|
||||||
|
function delete_feature(id: int): boolean;
|
||||||
export function delete_feature(id: int): boolean;
|
function set_menu_can_navigate(): void;
|
||||||
|
function get_version(): void;
|
||||||
export function set_menu_can_navigate(): void;
|
function add_player_feature(name: string, type: string, parent: integer, script_handler: (feat: Feat) => void|never): PlayerFeat
|
||||||
|
function get_player_feature(i: uint32_t): PlayerFeat
|
||||||
export function get_version(): void;
|
function is_threading_mode(mode: int): boolean
|
||||||
|
|
||||||
export function add_player_feature(name: string, type: string, parent: integer, script_handler: (feat: Feat) => void): PlayerFeat
|
|
||||||
|
|
||||||
export function get_player_feature(i: uint32_t): PlayerFeat
|
|
||||||
|
|
||||||
export function is_threading_mode(mode: int): boolean
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @privateRemarks callback declaration may be wrong
|
* @privateRemarks callback declaration may be wrong
|
||||||
*/
|
*/
|
||||||
export function create_thread(callback: () => void, context: any): Thread
|
function create_thread(callback: (() => void|never), context: any): Thread
|
||||||
|
function has_thread_finished(id: Thread): boolean
|
||||||
export function has_thread_finished(id: Thread): boolean
|
function delete_thread(id: Thread): boolean
|
||||||
|
|
||||||
export function delete_thread(id: Thread): boolean
|
|
||||||
|
|
||||||
}
|
}
|
||||||
63
ts-lua/types/structs/v2.d.ts
vendored
63
ts-lua/types/structs/v2.d.ts
vendored
@@ -1,66 +1,33 @@
|
|||||||
/**
|
/**
|
||||||
* a 2x1 matrix
|
* a 2x1 matrix
|
||||||
* @public
|
* @public
|
||||||
|
* @noSelf
|
||||||
*/
|
*/
|
||||||
declare class v2 {
|
declare class v2 {
|
||||||
|
|
||||||
/**
|
readonly x: float;
|
||||||
*
|
readonly y: float;
|
||||||
* @remarks float
|
|
||||||
*/
|
|
||||||
readonly x: number;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* **instanciating this class with `new` will break the lua**
|
||||||
* @remarks float
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
readonly y: number;
|
constructor(x: float, y: float);
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param x float
|
|
||||||
* @param y float
|
|
||||||
*/
|
|
||||||
constructor(x?: number, y?: number);
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param val float
|
|
||||||
*/
|
|
||||||
public __add(val: v2|v3|number): v2;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param val float
|
|
||||||
*/
|
|
||||||
public __sub(val: v2|v3|number): v2;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param val float
|
|
||||||
*/
|
|
||||||
public __mul(val: v2|v3|number): v2;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param val float
|
|
||||||
*/
|
|
||||||
public __div(val: v2|v3|number): v2;
|
|
||||||
|
|
||||||
|
public __add(val: v2|v3|float): v2;
|
||||||
|
public __sub(val: v2|v3|float): v2;
|
||||||
|
public __mul(val: v2|v3|float): v2;
|
||||||
|
public __div(val: v2|v3|float): v2;
|
||||||
public __eq(val: v2): boolean;
|
public __eq(val: v2): boolean;
|
||||||
|
|
||||||
public __lt(val: v2): boolean;
|
public __lt(val: v2): boolean;
|
||||||
|
|
||||||
public __le(val: v2): boolean;
|
public __le(val: v2): boolean;
|
||||||
|
|
||||||
public __tostring(): string
|
public __tostring(): string
|
||||||
|
|
||||||
/**
|
public magnitude(val: v2|null): float;
|
||||||
*
|
|
||||||
* @returns float
|
|
||||||
*/
|
|
||||||
public magnitude(val: v2|null): number;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
declare function v2(x?: number, y?: number): v2
|
/**
|
||||||
|
* @noSelf
|
||||||
|
*/
|
||||||
|
declare function v2(x: float, y: float): v2
|
||||||
81
ts-lua/types/structs/v3.d.ts
vendored
81
ts-lua/types/structs/v3.d.ts
vendored
@@ -18,86 +18,37 @@
|
|||||||
* pos += dir
|
* pos += dir
|
||||||
*
|
*
|
||||||
* @public
|
* @public
|
||||||
|
* @noSelf
|
||||||
*/
|
*/
|
||||||
declare class v3 {
|
declare class v3 {
|
||||||
|
|
||||||
/**
|
readonly x: float;
|
||||||
*
|
readonly y: float;
|
||||||
* @remarks float
|
readonly z: float;
|
||||||
*/
|
|
||||||
readonly x: number;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* **instanciating this class with `new` will break the lua**
|
||||||
* @remarks float
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
readonly y: number;
|
constructor(x: float, y: float, z: float);
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @remarks float
|
|
||||||
*/
|
|
||||||
readonly z: number;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param x float
|
|
||||||
* @param y float
|
|
||||||
* @param z float
|
|
||||||
*/
|
|
||||||
constructor(x?: number, y?: number, z?: number);
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param val float
|
|
||||||
*/
|
|
||||||
public __add(val: v2|v3|number): v3;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param val float
|
|
||||||
*/
|
|
||||||
public __sub(val: v2|v3|number): v3;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param val float
|
|
||||||
*/
|
|
||||||
public __mul(val: v2|v3|number): v3;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param val float
|
|
||||||
*/
|
|
||||||
public __div(val: v2|v3|number): v3;
|
|
||||||
|
|
||||||
|
public __add(val: v2|v3|float): v3;
|
||||||
|
public __sub(val: v2|v3|float): v3;
|
||||||
|
public __mul(val: v2|v3|float): v3;
|
||||||
|
public __div(val: v2|v3|float): v3;
|
||||||
public __eq(val: v2): boolean;
|
public __eq(val: v2): boolean;
|
||||||
|
|
||||||
public __lt(val: v2): boolean;
|
public __lt(val: v2): boolean;
|
||||||
|
|
||||||
public __le(val: v2): boolean;
|
public __le(val: v2): boolean;
|
||||||
|
|
||||||
public __tostring(): string
|
public __tostring(): string
|
||||||
|
|
||||||
/**
|
public magnitude(val: v3|null): float;
|
||||||
*
|
|
||||||
* @returns float
|
|
||||||
*/
|
|
||||||
public magnitude(val: v3|null): number;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @privateRemarks
|
|
||||||
*
|
|
||||||
* I don't understand this methough function enough to even try to test this in typescript
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public transformRotToDir(): void;
|
public transformRotToDir(): void;
|
||||||
|
|
||||||
public radToDeg(): void;
|
public radToDeg(): void;
|
||||||
|
|
||||||
public degToRad(): void;
|
public degToRad(): void;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
declare function v3(x?: number, y?: number, z?: number): v3
|
/**
|
||||||
|
* @noSelf
|
||||||
|
*/
|
||||||
|
declare function v3(x: float, y: float, z: float): v3
|
||||||
|
|||||||
Reference in New Issue
Block a user