This commit is contained in:
2021-06-23 21:29:51 -05:00
parent 3b0ee59f47
commit 655edc3d16
45 changed files with 963 additions and 0 deletions

1
ts-lua/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
node_modules

143
ts-lua/package-lock.json generated Normal file
View File

@@ -0,0 +1,143 @@
{
"requires": true,
"lockfileVersion": 1,
"dependencies": {
"@rauschma/stringio": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/@rauschma/stringio/-/stringio-1.4.0.tgz",
"integrity": "sha512-3uor2f/MXZkmX5RJf8r+OC3WvZVzpSme0yyL0rQDPEnatE02qRcqwEwnsgpgriEck0S/n4vWtUd6tTtrJwk45Q==",
"requires": {
"@types/node": "^10.0.3"
},
"dependencies": {
"@types/node": {
"version": "10.17.60",
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.17.60.tgz",
"integrity": "sha512-F0KIgDJfy2nA3zMLmWGKxcH2ZVEtCZXHHdOQs2gSaQ27+lNeEfGxzkIw90aXswATX7AZ33tahPbzy6KAfUreVw=="
}
}
},
"@types/node": {
"version": "14.17.4",
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.17.4.tgz",
"integrity": "sha512-8kQ3+wKGRNN0ghtEn7EGps/B8CzuBz1nXZEIGGLP2GnwbqYn4dbTs7k+VKLTq1HvZLRCIDtN3Snx1Ege8B7L5A=="
},
"enhanced-resolve": {
"version": "5.8.2",
"resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.8.2.tgz",
"integrity": "sha512-F27oB3WuHDzvR2DOGNTaYy0D5o0cnrv8TeI482VM4kYgQd/FT9lUQwuNsJ0oOHtBUq7eiW5ytqzp7nBFknL+GA==",
"dev": true,
"requires": {
"graceful-fs": "^4.2.4",
"tapable": "^2.2.0"
}
},
"function-bind": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
"integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==",
"dev": true
},
"graceful-fs": {
"version": "4.2.6",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.6.tgz",
"integrity": "sha512-nTnJ528pbqxYanhpDYsi4Rd8MAeaBA67+RZ10CM1m3bTAVFEDcd5AuA4a6W5YkGZ1iNXHzZz8T6TBKLeBuNriQ==",
"dev": true
},
"has": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz",
"integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==",
"dev": true,
"requires": {
"function-bind": "^1.1.1"
}
},
"is-core-module": {
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.4.0.tgz",
"integrity": "sha512-6A2fkfq1rfeQZjxrZJGerpLCTHRNEBiSgnu0+obeJpEPZRUooHgsizvzv0ZjJwOz3iWIHdJtVWJ/tmPr3D21/A==",
"dev": true,
"requires": {
"has": "^1.0.3"
}
},
"lua-types": {
"version": "2.10.1",
"resolved": "https://registry.npmjs.org/lua-types/-/lua-types-2.10.1.tgz",
"integrity": "sha512-Ai7L25I5kHZYGN5C3LALUse7Eus0k/kM9tEO2zwReG2Xuker0c+0e2M4iyfiEvlGOmBc7cDouqJ5lFwyg8JqiQ==",
"dev": true,
"requires": {
"typescript-to-lua": "^0.39.0"
},
"dependencies": {
"typescript-to-lua": {
"version": "0.39.6",
"resolved": "https://registry.npmjs.org/typescript-to-lua/-/typescript-to-lua-0.39.6.tgz",
"integrity": "sha512-Yq+XsmFKknMlz9jm1FvTw5B7R4H8lYUly4uwxlR44aT4OFyG9S7mOImrTIF07j414PdrJSQ5dAAhQOBVRqHbMw==",
"dev": true,
"requires": {
"resolve": "^1.15.1",
"source-map": "^0.7.3",
"typescript": "~4.3.2"
}
}
}
},
"node-ts": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/node-ts/-/node-ts-5.1.1.tgz",
"integrity": "sha512-summDCKhk7qaMlhe50vSzdhLqTowv4xCD+jEkPToYQD0fU1jshfC61hj5oPE7PZmYG1Af+HsVu8Vhr/jhFVENA==",
"requires": {
"@rauschma/stringio": "^1.4.0",
"@types/node": "^14.14.0"
}
},
"path-parse": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz",
"integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==",
"dev": true
},
"resolve": {
"version": "1.20.0",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.20.0.tgz",
"integrity": "sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A==",
"dev": true,
"requires": {
"is-core-module": "^2.2.0",
"path-parse": "^1.0.6"
}
},
"source-map": {
"version": "0.7.3",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.3.tgz",
"integrity": "sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==",
"dev": true
},
"tapable": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.0.tgz",
"integrity": "sha512-FBk4IesMV1rBxX2tfiK8RAmogtWn53puLOQlvO8XuwlgxcYbP4mVPS9Ph4aeamSyyVjOl24aYWAuc8U5kCVwMw==",
"dev": true
},
"typescript": {
"version": "4.3.4",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.3.4.tgz",
"integrity": "sha512-uauPG7XZn9F/mo+7MrsRjyvbxFpzemRjKEZXS4AK83oP2KKOJPvb+9cO/gmnv8arWZvhnjVOXz7B49m1l0e9Ew==",
"dev": true
},
"typescript-to-lua": {
"version": "0.40.1",
"resolved": "https://registry.npmjs.org/typescript-to-lua/-/typescript-to-lua-0.40.1.tgz",
"integrity": "sha512-wbnXddF+kPWKDQMcuVZLRUeZsMde5Qni6FnYIc3SKOAhg2/ZAm9ctWQsyQLwH8piMUX+uZzFXaJ3pMe186crfw==",
"dev": true,
"requires": {
"enhanced-resolve": "^5.8.2",
"resolve": "^1.15.1",
"source-map": "^0.7.3",
"typescript": "~4.3.2"
}
}
}
}

11
ts-lua/package.json Normal file
View File

@@ -0,0 +1,11 @@
{
"private": true,
"scripts": {
"build": "tstl",
"dev": "tstl --watch"
},
"devDependencies": {
"lua-types": "^2.10.1",
"typescript-to-lua": "^0.40.1"
}
}

5
ts-lua/readme.md Normal file
View File

@@ -0,0 +1,5 @@
# notes
- all `number` will be classified as `integer` or `float` in the `@remarks` or `@param`/`@returns`
- `vector` in the docs is represented as a `table` in lua, which is just an `object` in typescript
- `uint*_t` are `number`, not `Uint*Array`

6
ts-lua/test.ts Normal file
View File

@@ -0,0 +1,6 @@
let a = new Feat('debug')
a.value_i
menu.add_feature('', '', 0, () => {
})

15
ts-lua/tsconfig.json Normal file
View File

@@ -0,0 +1,15 @@
{
"compilerOptions": {
"target": "esnext",
"lib": ["esnext"],
"moduleResolution": "node",
"types": ["lua-types/5.4"],
"strict": true,
"typeRoots": [
"./types"
]
},
"tstl": {
"luaTarget": "JIT"
}
}

15
ts-lua/types/2take1.d.ts vendored Normal file
View File

@@ -0,0 +1,15 @@
/**
* Menu Functions
* @public
*/
declare namespace lua2take1 {
type Player = number;
type Entity = number;
type Ped = number;
type Vehicle = number;
type Group = number;
type Hash = number;
type Ptfx = number;
type Any = number;
type Thread = number;
}

9
ts-lua/types/D3D.d.ts vendored Normal file
View File

@@ -0,0 +1,9 @@
/**
* D3D Functions
* @public
*/
declare namespace d3d {
}

9
ts-lua/types/Hooks.d.ts vendored Normal file
View File

@@ -0,0 +1,9 @@
/**
* Hook Functions
* @public
*/
declare namespace hook {
}

9
ts-lua/types/Input.d.ts vendored Normal file
View File

@@ -0,0 +1,9 @@
/**
* Input Functions
* @public
*/
declare namespace input {
}

45
ts-lua/types/Menu.d.ts vendored Normal file
View File

@@ -0,0 +1,45 @@
/**
* Menu Functions
* @public
*/
declare namespace menu {
/**
* @param parent integer
*/
export function add_feature(name: string, type: string, parent: number, script_handler: (feat: Feat) => void): Feat;
/**
* @param id int
*/
export function delete_feature(id: number): boolean;
export function set_menu_can_navigate(): void;
export function get_version(): void;
/**
* @param parent integer
*/
export function add_player_feature(name: string, type: string, parent: number, script_handler: (feat: Feat) => void): PlayerFeat
/**
* @param i uint32_t
*/
export function get_player_feature(i: number): PlayerFeat
/**
* @param mode int
*/
export function is_threading_mode(mode: number): boolean
/**
* @privateRemarks callback declaration may be wrong
*/
export function create_thread(callback: () => void, context: any): lua2take1.Thread
export function has_thread_finished(id: lua2take1.Thread): boolean
export function delete_thread(id: lua2take1.Thread): boolean
}

10
ts-lua/types/RAGE/AI.d.ts vendored Normal file
View File

@@ -0,0 +1,10 @@
/**
* AI Functions
* @public
*/
declare namespace ai {
}

10
ts-lua/types/RAGE/Audio.d.ts vendored Normal file
View File

@@ -0,0 +1,10 @@
/**
* Audio Functions
* @public
*/
declare namespace audio {
}

10
ts-lua/types/RAGE/Cam.d.ts vendored Normal file
View File

@@ -0,0 +1,10 @@
/**
* Cam Functions
* @public
*/
declare namespace cam {
}

10
ts-lua/types/RAGE/Control.d.ts vendored Normal file
View File

@@ -0,0 +1,10 @@
/**
* Control Functions
* @public
*/
declare namespace control {
}

10
ts-lua/types/RAGE/Cutscene.d.ts vendored Normal file
View File

@@ -0,0 +1,10 @@
/**
* Cutscene Functions
* @public
*/
declare namespace cutscene {
}

10
ts-lua/types/RAGE/Decorator.d.ts vendored Normal file
View File

@@ -0,0 +1,10 @@
/**
* Decorator Functions
* @public
*/
declare namespace decorator {
}

10
ts-lua/types/RAGE/Entity.d.ts vendored Normal file
View File

@@ -0,0 +1,10 @@
/**
* Entity Functions
* @public
*/
declare namespace entity {
}

10
ts-lua/types/RAGE/Fire.d.ts vendored Normal file
View File

@@ -0,0 +1,10 @@
/**
* Fire Functions
* @public
*/
declare namespace fire {
}

10
ts-lua/types/RAGE/Gameplay.d.ts vendored Normal file
View File

@@ -0,0 +1,10 @@
/**
* Gameplay Functions
* @public
*/
declare namespace gameplay {
}

10
ts-lua/types/RAGE/Graphics.d.ts vendored Normal file
View File

@@ -0,0 +1,10 @@
/**
* Graphics Functions
* @public
*/
declare namespace graphics {
}

10
ts-lua/types/RAGE/Interior.d.ts vendored Normal file
View File

@@ -0,0 +1,10 @@
/**
* Interior Functions
* @public
*/
declare namespace interior {
}

10
ts-lua/types/RAGE/Network.d.ts vendored Normal file
View File

@@ -0,0 +1,10 @@
/**
* Network Functions
* @public
*/
declare namespace network {
}

10
ts-lua/types/RAGE/Object.d.ts vendored Normal file
View File

@@ -0,0 +1,10 @@
/**
* Object Functions
* @public
*/
declare namespace object {
}

10
ts-lua/types/RAGE/Ped.d.ts vendored Normal file
View File

@@ -0,0 +1,10 @@
/**
* Ped Functions
* @public
*/
declare namespace ped {
}

10
ts-lua/types/RAGE/Player.d.ts vendored Normal file
View File

@@ -0,0 +1,10 @@
/**
* Player Functions
* @public
*/
declare namespace player {
}

10
ts-lua/types/RAGE/Script.d.ts vendored Normal file
View File

@@ -0,0 +1,10 @@
/**
* Script Functions
* @public
*/
declare namespace script {
}

10
ts-lua/types/RAGE/ScriptDraw.d.ts vendored Normal file
View File

@@ -0,0 +1,10 @@
/**
* ScriptDraw Functions
* @public
*/
declare namespace scriptdraw {
}

10
ts-lua/types/RAGE/Stats.d.ts vendored Normal file
View File

@@ -0,0 +1,10 @@
/**
* Stats Functions
* @public
*/
declare namespace stats {
}

10
ts-lua/types/RAGE/Streaming.d.ts vendored Normal file
View File

@@ -0,0 +1,10 @@
/**
* Streaming Functions
* @public
*/
declare namespace streaming {
}

10
ts-lua/types/RAGE/System.d.ts vendored Normal file
View File

@@ -0,0 +1,10 @@
/**
* System Functions
* @public
*/
declare namespace system {
}

10
ts-lua/types/RAGE/Time.d.ts vendored Normal file
View File

@@ -0,0 +1,10 @@
/**
* Time Functions
* @public
*/
declare namespace time {
}

10
ts-lua/types/RAGE/UI.d.ts vendored Normal file
View File

@@ -0,0 +1,10 @@
/**
* UI Functions
* @public
*/
declare namespace ui {
}

10
ts-lua/types/RAGE/Utils.d.ts vendored Normal file
View File

@@ -0,0 +1,10 @@
/**
* Utils Functions
* @public
*/
declare namespace utils {
}

10
ts-lua/types/RAGE/Vehicle.d.ts vendored Normal file
View File

@@ -0,0 +1,10 @@
/**
* Vehicle Functions
* @public
*/
declare namespace vehicle {
}

10
ts-lua/types/RAGE/Water.d.ts vendored Normal file
View File

@@ -0,0 +1,10 @@
/**
* Water Functions
* @public
*/
declare namespace water {
}

10
ts-lua/types/RAGE/Weapon.d.ts vendored Normal file
View File

@@ -0,0 +1,10 @@
/**
* Weapon Functions
* @public
*/
declare namespace weapon {
}

10
ts-lua/types/RAGE/Worldprobe.d.ts vendored Normal file
View File

@@ -0,0 +1,10 @@
/**
* Worldprobe Functions
* @public
*/
declare namespace worldprobe {
}

117
ts-lua/types/structs/Feat.d.ts vendored Normal file
View File

@@ -0,0 +1,117 @@
/**
* a feature from the menu
* @public
*/
declare class Feat {
/**
* only for testing,
*
* @param type "debug"
*
* @example
*
* new Feat("debug")
*
*/
constructor(type: "debug");
/**
* feature on/off boolean
*/
public get on(): boolean;
public set on(on: boolean);
readonly parent: Feat|null;
/**
* Only for parents
*/
readonly children: Feat[];
/**
* Only for parents
*/
readonly child_count: number;
readonly type: number;
/**
* Ids will be recycled after the feature is deleted
*/
readonly id: number;
/**
* value for integer features
*
* @remarks integer
*/
public get value_i(): number;
public set value_i(value_i: number);
/**
* min value
*
* @remarks integer
*/
public get min_1(): number;
public set min_1(min_1: number);
/**
* max value
*
* @remarks integer
*/
public get max_i(): number;
public set max_i(max_i: number);
/**
* step size
*
* @remarks integer
*/
public get mod_i(): number;
public set mod_i(mod_i: number);
/**
* deprecated
*
* @deprecated
*/
public get threaded(): boolean;
public set threaded(threaded: boolean);
public get name(): string;
public set name(name: string);
/**
* d3d handler
*
* @privateRemarks
*
* it's only defined as `any` because I don't understand the d3d handler function enough
*
*/
public get renderer(): any;
public set renderer(renderer: any);
/**
* show/hide featur
*
*/
public get hidden(): boolean;
public set hidden(hidden: boolean);
/**
* additional context passed to script handlers
*/
public get data(): any;
public set data(data: any);
/**
*
* @returns Feat
*/
public toggle(): Feat;
}

29
ts-lua/types/structs/MenuKey.d.ts vendored Normal file
View File

@@ -0,0 +1,29 @@
/**
*
* @public
*/
declare class MenuKey {
/**
* vector of virtual keys
*
* @remarks table<uint32_t>
*/
readonly keys: object;
/**
* @param virtualKeyCode uint32_t
*/
public push_vk(virtualKeyCode: number): void;
public push_str(key: string): boolean;
public pop(): void;
public clear(): void;
public is_down(): boolean;
public is_down_stepped(): boolean;
}

42
ts-lua/types/structs/PlayerFeat.d.ts vendored Normal file
View File

@@ -0,0 +1,42 @@
/**
* a player feature
* @public
*/
declare class PlayerFeat {
/**
* only for testing,
*
* @param type "debug"
*
* @example
*
* new Feat("debug")
*
*/
constructor(type: "debug");
readonly feats: Feat[];
readonly id: number;
readonly parent_id: number;
/**
* deprecated
*/
public get threaded(): boolean;
public set threaded(threaded: boolean);
/**
* Make sure you set the renderer with the PlayerFeat function, and not the Feat function. Otherwise the handler will not receive the player id in the second param.
*
* @privateRemarks
*
* it's only defined as `any` because I don't understand the d3d handler function enough
*
*/
public get renderer(): any;
public set renderer(renderer: any);
}

27
ts-lua/types/structs/Regex.d.ts vendored Normal file
View File

@@ -0,0 +1,27 @@
/**
*
* @public
*/
declare class Regex {
/**
* only for testing,
*
* @param type "debug"
*
* @example
*
* new Feat("debug")
*
*/
constructor(type: "debug");
readonly pattern: string;
constructor(pattern: string);
public search(subject: string): RegexResult;
public __tostring(): string;
}

44
ts-lua/types/structs/RegexResult.d.ts vendored Normal file
View File

@@ -0,0 +1,44 @@
/**
*
* @privateRemarks
*
* example directly translated from the api docs and is untested
*
* I also don't know if javascript's regex will work
*
* @example
*
* let r = new Regex("^(test123)"),
* s = "test123 abcd 345345",
* m = r.search(r, s)
*
* if (m.count > 0)
* ui.notify_above_map(m.matches[1], "Lua regex", 140)
*
* @public
*/
declare class RegexResult {
/**
* only for testing,
*
* @param type "debug"
*
* @example
*
* new Feat("debug")
*
*/
constructor(type: "debug");
/**
*
* @remarks integer
*/
readonly count: number;
readonly matches: string[];
public __tostring(): string;
}

64
ts-lua/types/structs/v2.d.ts vendored Normal file
View File

@@ -0,0 +1,64 @@
/**
* a 2x1 matrix
* @public
*/
declare class v2 {
/**
*
* @remarks float
*/
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;
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;
}

102
ts-lua/types/structs/v3.d.ts vendored Normal file
View File

@@ -0,0 +1,102 @@
/**
* a 3x1 matrix
*
* @privateRemarks
*
* example directly translated from the api docs and is untested
*
* @example
*
* let player_id = player.player_id(),
* player_ped = player.get_player_ped(player_id),
* pos = player.get_player_coords(player_id),
* rot = entity.get_entity_rotation(player_ped),
* dir = rot
*
* dir.transformRotToDir()
* dir *= 4
* pos += dir
*
* @public
*/
declare class v3 {
/**
*
* @remarks float
*/
readonly x: number;
/**
*
* @remarks float
*/
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;
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 transformRotToDir(): void;
public radToDeg(): void;
public degToRad(): void;
}