@momo2555/koppeliajs 0.0.169 → 0.0.171

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.
@@ -33,9 +33,9 @@ export declare class Device {
33
33
  onEvent(eventName: string, callback: () => void): string;
34
34
  /**
35
35
  * Enables the cursor module and listens for coordinate updates.
36
- * @param callback Function to execute with the incoming (x, y) coordinates.
36
+ * @param callback Function to execute with the incoming (x, y, a) coordinates.
37
37
  */
38
- onCursor(callback: (x: number, y: number) => void): string;
38
+ onCursor(callback: (x: number, y: number, a: number) => void): string;
39
39
  /**
40
40
  * Enables the biking module and listens for speed updates.
41
41
  * @param callback Function to execute with the incoming speed data.
@@ -50,14 +50,14 @@ export class Device {
50
50
  }
51
51
  /**
52
52
  * Enables the cursor module and listens for coordinate updates.
53
- * @param callback Function to execute with the incoming (x, y) coordinates.
53
+ * @param callback Function to execute with the incoming (x, y, a) coordinates.
54
54
  */
55
55
  onCursor(callback) {
56
56
  this._enableModule("cursor");
57
57
  this._attachEvent("cursor");
58
58
  let callbackId = this._console.onRequest((request, params, form, address) => {
59
59
  if (request == "cursor" && address == this._address) {
60
- callback(params.x, params.y);
60
+ callback(params.x, params.y, params.a);
61
61
  }
62
62
  });
63
63
  this._callbackIds.push(callbackId);
@@ -123,6 +123,13 @@ export declare class Koppelia {
123
123
  * @returns A promise resolving to the active Play.
124
124
  */
125
125
  getCurrentPlay(): Promise<Play>;
126
+ /**
127
+ * Asynchronously executes a named API function on the master peer with the given arguments.
128
+ * @param functionName The name of the API function to invoke.
129
+ * @param args A dictionary of string arguments to pass to the function.
130
+ * @returns A promise resolving to the result returned by the API function.
131
+ */
132
+ runApiFunction(functionName: string, args: Record<string, string>): Promise<unknown>;
126
133
  /**
127
134
  * Enables a live difficulty cursor, allowing difficulty changes during gameplay.
128
135
  * @param callback Function to execute when the difficulty changes.
@@ -293,6 +293,25 @@ export class Koppelia {
293
293
  });
294
294
  });
295
295
  }
296
+ /**
297
+ * Asynchronously executes a named API function on the master peer with the given arguments.
298
+ * @param functionName The name of the API function to invoke.
299
+ * @param args A dictionary of string arguments to pass to the function.
300
+ * @returns A promise resolving to the result returned by the API function.
301
+ */
302
+ async runApiFunction(functionName, args) {
303
+ return new Promise((resolve, reject) => {
304
+ let request = new Message();
305
+ request.setRequest("runApiFunction");
306
+ request.addParam("functionName", functionName);
307
+ request.addParam("args", args);
308
+ request.setDestination(PeerType.MASTER, "");
309
+ this._console.sendMessage(request, (response) => {
310
+ let result = response.getParam("result", null);
311
+ resolve(result);
312
+ });
313
+ });
314
+ }
296
315
  /**
297
316
  * Enables a live difficulty cursor, allowing difficulty changes during gameplay.
298
317
  * @param callback Function to execute when the difficulty changes.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo2555/koppeliajs",
3
- "version": "0.0.169",
3
+ "version": "0.0.171",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && npm run package",