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 ]]
|
||||
fps = 60
|
||||
duration = 5
|
||||
menu.add_feature(
|
||||
"test",
|
||||
"action",
|
||||
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 ]]
|
||||
fps = 60
|
||||
duration = 5
|
||||
menu.add_feature(
|
||||
"test",
|
||||
"action",
|
||||
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,
|
||||
"scripts": {
|
||||
"build": "tstl && npm run post-build",
|
||||
"post-build": "cp dist/test.lua ../test.lua",
|
||||
"dev": "tstl --watch"
|
||||
},
|
||||
"devDependencies": {
|
||||
"lua-types": "^2.10.1",
|
||||
"typescript-to-lua": "^0.40.1"
|
||||
}
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"build": "tstl && $npm_package_scripts_postbuild",
|
||||
"postbuild": "cp dist/test.lua ../test.lua",
|
||||
"dev": "tstl --watch"
|
||||
},
|
||||
"devDependencies": {
|
||||
"lua-types": "^2.10.1",
|
||||
"typescript-to-lua": "^0.40.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,2 +1,13 @@
|
||||
menu.add_feature('test', 'action', 0, () =>
|
||||
ui.notify_above_map('Hello from TypeScript', '', 140))
|
||||
const fps = 60,
|
||||
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
|
||||
*
|
||||
* 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
|
||||
* @noSelf
|
||||
*/
|
||||
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;
|
||||
|
||||
}
|
||||
8
ts-lua/types/Hooks.d.ts
vendored
8
ts-lua/types/Hooks.d.ts
vendored
@@ -5,6 +5,12 @@
|
||||
*/
|
||||
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
|
||||
|
||||
}
|
||||
18
ts-lua/types/Input.d.ts
vendored
18
ts-lua/types/Input.d.ts
vendored
@@ -5,6 +5,22 @@
|
||||
*/
|
||||
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";
|
||||
|
||||
export function add_feature(name: string, type: featureTypes, parent: Feature, script_handler: (feat: Feat) => void): Feat;
|
||||
|
||||
export function delete_feature(id: int): boolean;
|
||||
|
||||
export function set_menu_can_navigate(): void;
|
||||
|
||||
export function get_version(): void;
|
||||
|
||||
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
|
||||
|
||||
function add_feature(name: string, type: featureTypes, parent: Feature, script_handler: (feat: Feat) => void|never): Feat;
|
||||
function delete_feature(id: int): boolean;
|
||||
function set_menu_can_navigate(): void;
|
||||
function get_version(): 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
|
||||
function is_threading_mode(mode: int): boolean
|
||||
/**
|
||||
* @privateRemarks callback declaration may be wrong
|
||||
*/
|
||||
export function create_thread(callback: () => void, context: any): Thread
|
||||
|
||||
export function has_thread_finished(id: Thread): boolean
|
||||
|
||||
export function delete_thread(id: Thread): boolean
|
||||
function create_thread(callback: (() => void|never), context: any): Thread
|
||||
function has_thread_finished(id: Thread): boolean
|
||||
function delete_thread(id: Thread): boolean
|
||||
|
||||
}
|
||||
65
ts-lua/types/structs/v2.d.ts
vendored
65
ts-lua/types/structs/v2.d.ts
vendored
@@ -1,66 +1,33 @@
|
||||
/**
|
||||
* a 2x1 matrix
|
||||
* @public
|
||||
* @noSelf
|
||||
*/
|
||||
declare class v2 {
|
||||
|
||||
readonly x: float;
|
||||
readonly y: float;
|
||||
|
||||
/**
|
||||
*
|
||||
* @remarks float
|
||||
* **instanciating this class with `new` will break the lua**
|
||||
* @deprecated
|
||||
*/
|
||||
readonly x: number;
|
||||
|
||||
/**
|
||||
*
|
||||
* @remarks float
|
||||
*/
|
||||
readonly y: number;
|
||||
|
||||
/**
|
||||
*
|
||||
* @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;
|
||||
constructor(x: float, y: float);
|
||||
|
||||
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 __lt(val: v2): boolean;
|
||||
|
||||
public __le(val: v2): boolean;
|
||||
|
||||
public __tostring(): string
|
||||
|
||||
/**
|
||||
*
|
||||
* @returns float
|
||||
*/
|
||||
public magnitude(val: v2|null): number;
|
||||
public magnitude(val: v2|null): float;
|
||||
|
||||
}
|
||||
|
||||
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
|
||||
*
|
||||
* @public
|
||||
* @noSelf
|
||||
*/
|
||||
declare class v3 {
|
||||
|
||||
/**
|
||||
*
|
||||
* @remarks float
|
||||
*/
|
||||
readonly x: number;
|
||||
readonly x: float;
|
||||
readonly y: float;
|
||||
readonly z: float;
|
||||
|
||||
/**
|
||||
*
|
||||
* @remarks float
|
||||
* **instanciating this class with `new` will break the lua**
|
||||
* @deprecated
|
||||
*/
|
||||
readonly y: number;
|
||||
|
||||
/**
|
||||
*
|
||||
* @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;
|
||||
constructor(x: float, y: float, z: float);
|
||||
|
||||
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 __lt(val: v2): boolean;
|
||||
|
||||
public __le(val: v2): boolean;
|
||||
|
||||
public __tostring(): string
|
||||
|
||||
/**
|
||||
*
|
||||
* @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 magnitude(val: v3|null): float;
|
||||
public transformRotToDir(): void;
|
||||
|
||||
public radToDeg(): 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