warcraft-3-w3ts-utils 0.1.9 → 0.1.11
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/dist/package.json +1 -1
- package/dist/utils/item.d.ts +2 -3
- package/package.json +1 -1
- package/readme.md +68 -0
package/dist/package.json
CHANGED
package/dist/utils/item.d.ts
CHANGED
|
@@ -10,13 +10,12 @@ export declare function unitHasItem(u: Unit, itemTypeId: number): boolean;
|
|
|
10
10
|
* Determines items that are created by recipes.
|
|
11
11
|
*/
|
|
12
12
|
export declare function registerItemsRecipes(recipesConfiguration: Map<RecipeItem, RecipeItemRequirement[]>): void;
|
|
13
|
-
interface RecipeItemRequirement {
|
|
13
|
+
export interface RecipeItemRequirement {
|
|
14
14
|
itemTypeId: number;
|
|
15
15
|
quantity: number;
|
|
16
16
|
charges: number;
|
|
17
17
|
}
|
|
18
|
-
interface RecipeItem {
|
|
18
|
+
export interface RecipeItem {
|
|
19
19
|
recipeId: number;
|
|
20
20
|
itemId: number;
|
|
21
21
|
}
|
|
22
|
-
export {};
|
package/package.json
CHANGED
package/readme.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# WC3-W3TS-utils
|
|
2
|
+
|
|
3
|
+
Small collection of utility helpers for projects using W3TS (Warcraft III TypeScript, v3.x). Designed to be lightweight and easy to drop into your WC3 TypeScript projects to simplify common tasks (tables, math, cloning, timers, safe wrappers, etc.).
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
- Safe wrappers for native WC3 APIs
|
|
7
|
+
- Common math and clamp helpers
|
|
8
|
+
- Table/object deep clone and merge
|
|
9
|
+
- Timer helpers and simple schedulers
|
|
10
|
+
- Small, dependency-free TypeScript utilities
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
Copy the utils folder into your project or install via your package manager if published:
|
|
14
|
+
|
|
15
|
+
npm
|
|
16
|
+
```
|
|
17
|
+
npm install wc3-w3ts-utils
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
yarn
|
|
21
|
+
```
|
|
22
|
+
yarn add wc3-w3ts-utils
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Or add the files directly to your W3TS project (recommended for custom Warcraft builds).
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
Import only what you need:
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import { clamp, deepClone, createTimer } from 'wc3-w3ts-utils';
|
|
32
|
+
|
|
33
|
+
// clamp example
|
|
34
|
+
const v = clamp(10, 0, 5); // 5
|
|
35
|
+
|
|
36
|
+
// deep clone example
|
|
37
|
+
const copy = deepClone(original);
|
|
38
|
+
|
|
39
|
+
// timer example
|
|
40
|
+
const t = createTimer(() => {
|
|
41
|
+
// do something each tick
|
|
42
|
+
}, 1.0, true);
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
If copied directly into a W3TS project, adjust import paths accordingly:
|
|
46
|
+
```ts
|
|
47
|
+
import { clamp } from './utils/math';
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## API (examples)
|
|
51
|
+
- clamp(value: number, min: number, max: number): number
|
|
52
|
+
- deepClone<T>(obj: T): T
|
|
53
|
+
- merge<T>(target: T, source: Partial<T>): T
|
|
54
|
+
- createTimer(callback: () => void, period: number, repeating?: boolean)
|
|
55
|
+
- safeCall<T>(fn: () => T, fallback?: T): T
|
|
56
|
+
|
|
57
|
+
(See source files for full signatures and docs.)
|
|
58
|
+
|
|
59
|
+
## Contributing
|
|
60
|
+
- Open an issue for bugs or enhancement requests.
|
|
61
|
+
- Fork, create a feature branch, and submit a PR with tests/examples where applicable.
|
|
62
|
+
- Keep changes small and well-documented.
|
|
63
|
+
|
|
64
|
+
## License
|
|
65
|
+
MIT — see LICENSE file.
|
|
66
|
+
|
|
67
|
+
## Notes
|
|
68
|
+
Built to be simple and compatible with W3TS v3.x and Warcraft III modding workflows. Adjust imports when integrating directly into your map project.
|