@rbxts/axis 0.2.3 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +68 -0
- package/out/index.d.ts +54 -45
- package/out/input.luau +4 -2
- package/package.json +39 -39
package/README.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# @rbxts/axis
|
|
2
|
+
|
|
3
|
+
roblox-ts typings for [axis](https://neond00m.github.io/Axis/)
|
|
4
|
+
|
|
5
|
+
## Deviations
|
|
6
|
+
|
|
7
|
+
### Map<T>
|
|
8
|
+
|
|
9
|
+
```diff
|
|
10
|
+
- export type Map<T> = { [any]: any }
|
|
11
|
+
+ export type _Map<T> = Map<defined, T> | defined[];
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
### InputConstructor
|
|
15
|
+
|
|
16
|
+
```diff
|
|
17
|
+
- export type InputConstructor = <T>(Map<T> | (Map<T> & { deadzone: number? })) -> Input<T>
|
|
18
|
+
+ export type InputConstructor = <T>(keyMap: _Map<T>, deadzone?: number) => Input<T>;
|
|
19
|
+
```
|
|
20
|
+
### Input Constructor function
|
|
21
|
+
|
|
22
|
+
```diff
|
|
23
|
+
- local function new<T>(inputMap: types.Map<T> & { deadzone: number? }): types.Input<T>
|
|
24
|
+
+ local function new<T>(inputMap: types.Map<T>, deadzone: number?): types.Input<T>
|
|
25
|
+
local input: types.Input<T> = {
|
|
26
|
+
vector = false,
|
|
27
|
+
current = {},
|
|
28
|
+
previous = {},
|
|
29
|
+
active = {
|
|
30
|
+
{}, -- separate input axes for each controller
|
|
31
|
+
},
|
|
32
|
+
resets = {}, --resets input on next update
|
|
33
|
+
connections = {},
|
|
34
|
+
inputMap = inputMap,
|
|
35
|
+
- deadzone = inputMap.deadzone
|
|
36
|
+
+ deadzone = deadzone,
|
|
37
|
+
|
|
38
|
+
read = read,
|
|
39
|
+
pressing = pressing,
|
|
40
|
+
pressed = pressed,
|
|
41
|
+
released = released,
|
|
42
|
+
changed = changed,
|
|
43
|
+
hold = hold,
|
|
44
|
+
map = map,
|
|
45
|
+
update = update,
|
|
46
|
+
move = move,
|
|
47
|
+
}
|
|
48
|
+
map(input, inputMap)
|
|
49
|
+
|
|
50
|
+
return input
|
|
51
|
+
end
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Examples
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
input(
|
|
58
|
+
new Map<Enum.KeyCode, Vector3>([
|
|
59
|
+
[Enum.KeyCode.Up, new Vector3(0, 1, 0)],
|
|
60
|
+
[Enum.KeyCode.Down, new Vector3(0, -1, 0)],
|
|
61
|
+
[Enum.KeyCode.Left, new Vector3(-1, 0, 0)],
|
|
62
|
+
[Enum.KeyCode.Right, new Vector3(1, 0, 0)],
|
|
63
|
+
]),
|
|
64
|
+
, 1);
|
|
65
|
+
|
|
66
|
+
input([Enum.KeyCode.W, Enum.KeyCode.A, Enum.KeyCode.S, Enum.KeyCode.D], 1);
|
|
67
|
+
```
|
|
68
|
+
|
package/out/index.d.ts
CHANGED
|
@@ -1,49 +1,58 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* @type DeviceType "Desktop" | "Touch" | "Controller"
|
|
5
|
-
*/
|
|
6
|
-
type DeviceType = "Desktop" | "Touch" | "Controller";
|
|
1
|
+
export type DeviceType = "Desktop" | "Touch" | "Controller";
|
|
2
|
+
|
|
3
|
+
export type _Map<T> = Map<defined, T> | defined[];
|
|
7
4
|
|
|
5
|
+
export interface Input<T> {
|
|
8
6
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* Reads current and previous values for the axis
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* const [current, previous] = attack.read()
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* @param controller
|
|
11
14
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
connections: RBXScriptConnection[];
|
|
32
|
-
keyMap: _Map<T>;
|
|
33
|
-
inputMap: Map<Enum.KeyCode | Enum.UserInputType, T>;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
type InputConstructor = <T>(input: _Map<T> | (_Map<T> & { deadzone?: number })) => Input<T>;
|
|
37
|
-
|
|
38
|
-
interface Axis {
|
|
39
|
-
device: (inputType: Enum.UserInputType | undefined) => DeviceType;
|
|
40
|
-
update: (inputs: Map<defined, Input<defined>>) => void;
|
|
41
|
-
input: InputConstructor;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function input<T>(inputMap: (_Map<T> & { deadzone?: number }) | _Map<T>): Input<T>;
|
|
45
|
-
|
|
46
|
-
function update(inputs: Map<defined, Input<defined>>): void;
|
|
47
|
-
|
|
48
|
-
function device(input?: Enum.UserInputType): DeviceType;
|
|
15
|
+
read(controller?: number): LuaTuple<[T, T]>;
|
|
16
|
+
pressing(controller?: number): boolean;
|
|
17
|
+
pressed(controller?: number): boolean;
|
|
18
|
+
released(controller?: number): boolean;
|
|
19
|
+
changed(controller?: number): boolean;
|
|
20
|
+
hold(value: T, controller?: number): void;
|
|
21
|
+
move(value: T, controller?: number): void;
|
|
22
|
+
map(keyMap: _Map<T>): void;
|
|
23
|
+
update(): void;
|
|
24
|
+
|
|
25
|
+
deadzone?: number;
|
|
26
|
+
vector: boolean;
|
|
27
|
+
current: T[];
|
|
28
|
+
previous: T[];
|
|
29
|
+
active: Array<Map<defined, T>>;
|
|
30
|
+
resets: Map<defined, defined>;
|
|
31
|
+
connections: RBXScriptConnection[];
|
|
32
|
+
keyMap: _Map<T>;
|
|
33
|
+
inputMap: Map<Enum.KeyCode | Enum.UserInputType, T>;
|
|
49
34
|
}
|
|
35
|
+
|
|
36
|
+
export type InputConstructor = <T>(keyMap: _Map<T>, deadzone?: number) => Input<T>;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Gets the device of the provided UserInputType (or the last UserInputType if none is provided)
|
|
40
|
+
* @param inputType UserInputType
|
|
41
|
+
* @returns "Desktop" "Touch" or "Controller"
|
|
42
|
+
*/
|
|
43
|
+
export function device(inputType?: Enum.UserInputType): DeviceType;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Updates all input axes in a array
|
|
47
|
+
*
|
|
48
|
+
* @param inputs A array of `Input` to update,
|
|
49
|
+
*/
|
|
50
|
+
export function update(inputs: Input<unknown>[]): void;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Creates a new input axis with the provided keymap
|
|
54
|
+
*
|
|
55
|
+
* @param keyMap It can be a `Map<Enum.KeyCode | string, defined | number>` for deadzone or `Map<Enum.KeyCode, defined>` or Enum.KeyCode[]
|
|
56
|
+
* @returns The input axis
|
|
57
|
+
*/
|
|
58
|
+
export const input: InputConstructor;
|
package/out/input.luau
CHANGED
|
@@ -306,7 +306,8 @@ local function update<T>(input: types.Input<T>)
|
|
|
306
306
|
end
|
|
307
307
|
end
|
|
308
308
|
|
|
309
|
-
|
|
309
|
+
-- Added a parameter of deadzone for roblox-ts typings!
|
|
310
|
+
local function new<T>(inputMap: types.Map<T>, deadzone: number?): types.Input<T>
|
|
310
311
|
local input: types.Input<T> = {
|
|
311
312
|
vector = false,
|
|
312
313
|
current = {},
|
|
@@ -317,7 +318,8 @@ local function new<T>(inputMap: types.Map<T> & { deadzone: number? }): types.Inp
|
|
|
317
318
|
resets = {}, --resets input on next update
|
|
318
319
|
connections = {},
|
|
319
320
|
inputMap = inputMap,
|
|
320
|
-
deadzone = inputMap.deadzone
|
|
321
|
+
--Changed deadzone = inputMap.deadzone to deadzone parameter for roblox-ts typings!
|
|
322
|
+
deadzone = deadzone,
|
|
321
323
|
|
|
322
324
|
read = read,
|
|
323
325
|
pressing = pressing,
|
package/package.json
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
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
|
-
|
|
2
|
+
"name": "@rbxts/axis",
|
|
3
|
+
"version": "0.2.5",
|
|
4
|
+
"description": "roblox-ts typings for NeonD00m/axis",
|
|
5
|
+
"main": "out/init.lua",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "rbxtsc",
|
|
8
|
+
"watch": "rbxtsc -w",
|
|
9
|
+
"prepublishOnly": "npm run build"
|
|
10
|
+
},
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/teakzc/axis-types.git"
|
|
14
|
+
},
|
|
15
|
+
"homepage": "https://neond00m.github.io/Axis/",
|
|
16
|
+
"keywords": [],
|
|
17
|
+
"author": "teakzc",
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"type": "commonjs",
|
|
20
|
+
"types": "out/index.d.ts",
|
|
21
|
+
"files": [
|
|
22
|
+
"out",
|
|
23
|
+
"!**/*.tsbuildinfo"
|
|
24
|
+
],
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@rbxts/compiler-types": "^3.0.0-types.0",
|
|
30
|
+
"@rbxts/types": "^1.0.906",
|
|
31
|
+
"@typescript-eslint/eslint-plugin": "^8.55.0",
|
|
32
|
+
"@typescript-eslint/parser": "^8.55.0",
|
|
33
|
+
"eslint": "^9.39.2",
|
|
34
|
+
"eslint-config-prettier": "^10.1.8",
|
|
35
|
+
"eslint-plugin-prettier": "^5.5.5",
|
|
36
|
+
"eslint-plugin-roblox-ts": "^1.3.1",
|
|
37
|
+
"prettier": "^3.8.1",
|
|
38
|
+
"roblox-ts": "^3.0.0",
|
|
39
|
+
"typescript": "^5.9.3"
|
|
40
|
+
}
|
|
41
41
|
}
|