@caspertech/node-metaverse 0.7.24 → 0.7.26

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.
@@ -1,81 +1,81 @@
1
- import { ExampleBot } from '../ExampleBot';
2
- import { Avatar } from '../../lib/classes/public/Avatar';
3
- import { Subscription } from 'rxjs';
4
-
5
- class Region extends ExampleBot
6
- {
7
- private subscriptions: { [key: string]: {
8
- onMovedSubscription: Subscription;
9
- onTitleSubscription: Subscription;
10
- onLeftRegionSubscription: Subscription;
11
- onVisibleSubscription: Subscription;
12
- } } = {};
13
-
14
- public async onConnected(): Promise<void>
15
- {
16
- this.bot.clientEvents.onAvatarEnteredRegion.subscribe(this.onAvatarEntered.bind(this));
17
-
18
- const avs = this.bot.clientCommands.region.getAvatarsInRegion();
19
- for (const av of avs)
20
- {
21
- this.onAvatarEntered(av);
22
- }
23
- }
24
-
25
- private onAvatarEntered(av: Avatar): void
26
- {
27
- console.log(av.getName() + ' entered the region (' + ((av.isVisible) ? 'visible' : 'invisible') + ')');
28
- const avatarKey = av.getKey().toString();
29
- this.unsubscribe(avatarKey);
30
- this.subscriptions[avatarKey] = {
31
- onLeftRegionSubscription: av.onLeftRegion.subscribe(this.onAvatarLeft.bind(this)),
32
- onMovedSubscription: av.onMoved.subscribe(this.onAvatarMoved.bind(this)),
33
- onTitleSubscription: av.onTitleChanged.subscribe(this.onTitleChanged.bind(this)),
34
- onVisibleSubscription: av.onVisibleChanged.subscribe(this.onAvatarVisible.bind(this))
35
- }
36
- }
37
-
38
- private unsubscribe(key: string): void
39
- {
40
- const sub = this.subscriptions[key];
41
- if (sub === undefined)
42
- {
43
- return;
44
- }
45
- delete this.subscriptions[key];
46
-
47
- sub.onVisibleSubscription.unsubscribe();
48
- sub.onMovedSubscription.unsubscribe();
49
- sub.onTitleSubscription.unsubscribe();
50
- sub.onLeftRegionSubscription.unsubscribe();
51
- }
52
-
53
- private onAvatarLeft(av: Avatar): void
54
- {
55
- console.log(av.getName() + ' left the region');
56
- this.unsubscribe(av.getKey().toString());
57
- }
58
-
59
- private onAvatarMoved(av: Avatar): void
60
- {
61
- console.log(av.getName() + ' moved, position: ' + av.position.toString());
62
- }
63
-
64
- private onTitleChanged(av: Avatar): void
65
- {
66
- console.log(av.getName() + ' changed their title to: ' + av.getTitle());
67
- }
68
-
69
- private onAvatarVisible(av: Avatar): void
70
- {
71
- console.log(av.getName() + ' is now ' + (av.isVisible ? 'visible' : 'invisible'));
72
- }
73
- }
74
-
75
- new Region().run().then(() =>
76
- {
77
-
78
- }).catch((err) =>
79
- {
80
- console.error(err);
81
- });
1
+ import { ExampleBot } from '../ExampleBot';
2
+ import { Avatar } from '../../lib/classes/public/Avatar';
3
+ import { Subscription } from 'rxjs';
4
+
5
+ class Region extends ExampleBot
6
+ {
7
+ private subscriptions: { [key: string]: {
8
+ onMovedSubscription: Subscription;
9
+ onTitleSubscription: Subscription;
10
+ onLeftRegionSubscription: Subscription;
11
+ onVisibleSubscription: Subscription;
12
+ } } = {};
13
+
14
+ public async onConnected(): Promise<void>
15
+ {
16
+ this.bot.clientEvents.onAvatarEnteredRegion.subscribe(this.onAvatarEntered.bind(this));
17
+
18
+ const avs = this.bot.clientCommands.region.getAvatarsInRegion();
19
+ for (const av of avs)
20
+ {
21
+ this.onAvatarEntered(av);
22
+ }
23
+ }
24
+
25
+ private onAvatarEntered(av: Avatar): void
26
+ {
27
+ console.log(av.getName() + ' entered the region (' + ((av.isVisible) ? 'visible' : 'invisible') + ')');
28
+ const avatarKey = av.getKey().toString();
29
+ this.unsubscribe(avatarKey);
30
+ this.subscriptions[avatarKey] = {
31
+ onLeftRegionSubscription: av.onLeftRegion.subscribe(this.onAvatarLeft.bind(this)),
32
+ onMovedSubscription: av.onMoved.subscribe(this.onAvatarMoved.bind(this)),
33
+ onTitleSubscription: av.onTitleChanged.subscribe(this.onTitleChanged.bind(this)),
34
+ onVisibleSubscription: av.onVisibleChanged.subscribe(this.onAvatarVisible.bind(this))
35
+ }
36
+ }
37
+
38
+ private unsubscribe(key: string): void
39
+ {
40
+ const sub = this.subscriptions[key];
41
+ if (sub === undefined)
42
+ {
43
+ return;
44
+ }
45
+ delete this.subscriptions[key];
46
+
47
+ sub.onVisibleSubscription.unsubscribe();
48
+ sub.onMovedSubscription.unsubscribe();
49
+ sub.onTitleSubscription.unsubscribe();
50
+ sub.onLeftRegionSubscription.unsubscribe();
51
+ }
52
+
53
+ private onAvatarLeft(av: Avatar): void
54
+ {
55
+ console.log(av.getName() + ' left the region');
56
+ this.unsubscribe(av.getKey().toString());
57
+ }
58
+
59
+ private onAvatarMoved(av: Avatar): void
60
+ {
61
+ console.log(av.getName() + ' moved, position: ' + av.position.toString());
62
+ }
63
+
64
+ private onTitleChanged(av: Avatar): void
65
+ {
66
+ console.log(av.getName() + ' changed their title to: ' + av.getTitle());
67
+ }
68
+
69
+ private onAvatarVisible(av: Avatar): void
70
+ {
71
+ console.log(av.getName() + ' is now ' + (av.isVisible ? 'visible' : 'invisible'));
72
+ }
73
+ }
74
+
75
+ new Region().run().then(() =>
76
+ {
77
+
78
+ }).catch((err) =>
79
+ {
80
+ console.error(err);
81
+ });
@@ -1,34 +1,34 @@
1
- import { ExampleBot } from '../ExampleBot';
2
-
3
- class Estate extends ExampleBot
4
- {
5
- wait(ms: number): Promise<void>
6
- {
7
- return new Promise<void>((resolve) =>
8
- {
9
- setTimeout(() =>
10
- {
11
- resolve();
12
- }, ms)
13
- });
14
- }
15
- async onConnected(): Promise<void>
16
- {
17
- console.log('Sending a message');
18
- await this.bot.clientCommands.region.simulatorMessage('In about 10 seconds, the region will begin to restart. This is only a test, and the restart will be cancelled.');
19
- await this.wait(10000);
20
- console.log('Restarting');
21
- await this.bot.clientCommands.region.restartRegion(120);
22
- await this.wait(10000);
23
- console.log('Canceling restart');
24
- await this.bot.clientCommands.region.cancelRestart();
25
- }
26
- }
27
-
28
- new Estate().run().then(() =>
29
- {
30
-
31
- }).catch((err) =>
32
- {
33
- console.error(err);
34
- });
1
+ import { ExampleBot } from '../ExampleBot';
2
+
3
+ class Estate extends ExampleBot
4
+ {
5
+ wait(ms: number): Promise<void>
6
+ {
7
+ return new Promise<void>((resolve) =>
8
+ {
9
+ setTimeout(() =>
10
+ {
11
+ resolve();
12
+ }, ms)
13
+ });
14
+ }
15
+ async onConnected(): Promise<void>
16
+ {
17
+ console.log('Sending a message');
18
+ await this.bot.clientCommands.region.simulatorMessage('In about 10 seconds, the region will begin to restart. This is only a test, and the restart will be cancelled.');
19
+ await this.wait(10000);
20
+ console.log('Restarting');
21
+ await this.bot.clientCommands.region.restartRegion(120);
22
+ await this.wait(10000);
23
+ console.log('Canceling restart');
24
+ await this.bot.clientCommands.region.cancelRestart();
25
+ }
26
+ }
27
+
28
+ new Estate().run().then(() =>
29
+ {
30
+
31
+ }).catch((err) =>
32
+ {
33
+ console.error(err);
34
+ });
@@ -1,31 +1,31 @@
1
- import { ExampleBot } from '../ExampleBot';
2
- import { LandStatReportType } from '../../lib/enums/LandStatReportType';
3
- import { LandStatFlags } from '../../lib/enums/LandStatFlags';
4
-
5
- class Parcels extends ExampleBot
6
- {
7
- async onConnected(): Promise<void>
8
- {
9
- const parcelInMiddle = await this.bot.clientCommands.region.getParcelAt(128, 128);
10
- console.log('Parcel at 128x128 is ' + parcelInMiddle.Name);
11
-
12
- const parcels = await this.bot.clientCommands.region.getParcels();
13
- console.log('Parcels on region:');
14
- console.log('========================');
15
- for (const p of parcels)
16
- {
17
- console.log(p.Name);
18
- }
19
- console.log('========================');
20
- const stats = await this.bot.clientCommands.parcel.getLandStats(parcels[0].ParcelID, LandStatReportType.Scripts, LandStatFlags.FilterByOwner);
21
- console.log(JSON.stringify(stats, null, 4));
22
- }
23
- }
24
-
25
- new Parcels().run().then(() =>
26
- {
27
-
28
- }).catch((err) =>
29
- {
30
- console.error(err);
31
- });
1
+ import { ExampleBot } from '../ExampleBot';
2
+ import { LandStatReportType } from '../../lib/enums/LandStatReportType';
3
+ import { LandStatFlags } from '../../lib/enums/LandStatFlags';
4
+
5
+ class Parcels extends ExampleBot
6
+ {
7
+ async onConnected(): Promise<void>
8
+ {
9
+ const parcelInMiddle = await this.bot.clientCommands.region.getParcelAt(128, 128);
10
+ console.log('Parcel at 128x128 is ' + parcelInMiddle.Name);
11
+
12
+ const parcels = await this.bot.clientCommands.region.getParcels();
13
+ console.log('Parcels on region:');
14
+ console.log('========================');
15
+ for (const p of parcels)
16
+ {
17
+ console.log(p.Name);
18
+ }
19
+ console.log('========================');
20
+ const stats = await this.bot.clientCommands.parcel.getLandStats(parcels[0].ParcelID, LandStatReportType.Scripts, LandStatFlags.FilterByOwner);
21
+ console.log(JSON.stringify(stats, null, 4));
22
+ }
23
+ }
24
+
25
+ new Parcels().run().then(() =>
26
+ {
27
+
28
+ }).catch((err) =>
29
+ {
30
+ console.error(err);
31
+ });
@@ -1,23 +1,23 @@
1
- import { ExampleBot } from '../ExampleBot';
2
- import { SimStatsEvent } from '../../lib/events/SimStatsEvent';
3
-
4
- class Region extends ExampleBot
5
- {
6
- async onConnected(): Promise<void>
7
- {
8
- this.bot.clientEvents.onSimStats.subscribe(this.onSimStats.bind(this));
9
- }
10
-
11
- onSimStats(stats: SimStatsEvent): void
12
- {
13
- console.log(JSON.stringify(stats, null, 4));
14
- }
15
- }
16
-
17
- new Region().run().then(() =>
18
- {
19
-
20
- }).catch((err) =>
21
- {
22
- console.error(err);
23
- });
1
+ import { ExampleBot } from '../ExampleBot';
2
+ import { SimStatsEvent } from '../../lib/events/SimStatsEvent';
3
+
4
+ class Region extends ExampleBot
5
+ {
6
+ async onConnected(): Promise<void>
7
+ {
8
+ this.bot.clientEvents.onSimStats.subscribe(this.onSimStats.bind(this));
9
+ }
10
+
11
+ onSimStats(stats: SimStatsEvent): void
12
+ {
13
+ console.log(JSON.stringify(stats, null, 4));
14
+ }
15
+ }
16
+
17
+ new Region().run().then(() =>
18
+ {
19
+
20
+ }).catch((err) =>
21
+ {
22
+ console.error(err);
23
+ });
@@ -1,60 +1,60 @@
1
- import { LureEvent, Vector3 } from '../../lib';
2
- import { ExampleBot } from '../ExampleBot';
3
-
4
- class Teleports extends ExampleBot
5
- {
6
- // We can make the bot always try to get to a certain region regardless of where it logged in
7
- protected stayRegion = 'Izanagi';
8
-
9
- // And we can optionally specify a position
10
- protected stayPosition = new Vector3([122, 156, 189]);
11
-
12
- async onConnected(): Promise<void>
13
- {
14
- // "OnLure" event fires when someone tries to teleport us
15
- this.bot.clientEvents.onLure.subscribe(this.onLure.bind(this));
16
-
17
- // Alternatively we can TP someone else to us
18
- await this.bot.clientCommands.comms.sendTeleport(this.masterAvatar);
19
- }
20
-
21
- async onLure(lureEvent: LureEvent): Promise<void>
22
- {
23
- try
24
- {
25
- const regionInfo = await this.bot.clientCommands.grid.getRegionMapInfo(lureEvent.gridX / 256, lureEvent.gridY / 256);
26
- if (lureEvent.from.toString() === this.masterAvatar)
27
- {
28
- console.log('Accepting teleport lure to ' + regionInfo.block.name + ' (' + regionInfo.avatars.length + ' avatar' + ((regionInfo.avatars.length === 1) ? '' : 's') + '' +
29
- ' present) from ' + lureEvent.fromName + ' with message: ' + lureEvent.lureMessage);
30
- try
31
- {
32
- await this.bot.clientCommands.teleport.acceptTeleport(lureEvent);
33
- }
34
- catch (error)
35
- {
36
- console.error('Teleport error:');
37
- console.error(error);
38
- }
39
- }
40
- else
41
- {
42
- console.log('Ignoring teleport lure to ' + regionInfo.block.name + ' (' + regionInfo.avatars.length + ' avatar' + ((regionInfo.avatars.length === 1) ? '' : 's') + ' ' +
43
- 'present) from ' + lureEvent.fromName + ' with message: ' + lureEvent.lureMessage);
44
- }
45
- }
46
- catch (error)
47
- {
48
- console.error('Failed to get region map info:');
49
- console.error(error);
50
- }
51
- }
52
- }
53
-
54
- new Teleports().run().then(() =>
55
- {
56
-
57
- }).catch((err) =>
58
- {
59
- console.error(err)
60
- });
1
+ import { LureEvent, Vector3 } from '../../lib';
2
+ import { ExampleBot } from '../ExampleBot';
3
+
4
+ class Teleports extends ExampleBot
5
+ {
6
+ // We can make the bot always try to get to a certain region regardless of where it logged in
7
+ protected stayRegion = 'Izanagi';
8
+
9
+ // And we can optionally specify a position
10
+ protected stayPosition = new Vector3([122, 156, 189]);
11
+
12
+ async onConnected(): Promise<void>
13
+ {
14
+ // "OnLure" event fires when someone tries to teleport us
15
+ this.bot.clientEvents.onLure.subscribe(this.onLure.bind(this));
16
+
17
+ // Alternatively we can TP someone else to us
18
+ await this.bot.clientCommands.comms.sendTeleport(this.masterAvatar);
19
+ }
20
+
21
+ async onLure(lureEvent: LureEvent): Promise<void>
22
+ {
23
+ try
24
+ {
25
+ const regionInfo = await this.bot.clientCommands.grid.getRegionMapInfo(lureEvent.gridX / 256, lureEvent.gridY / 256);
26
+ if (lureEvent.from.toString() === this.masterAvatar)
27
+ {
28
+ console.log('Accepting teleport lure to ' + regionInfo.block.name + ' (' + regionInfo.avatars.length + ' avatar' + ((regionInfo.avatars.length === 1) ? '' : 's') + '' +
29
+ ' present) from ' + lureEvent.fromName + ' with message: ' + lureEvent.lureMessage);
30
+ try
31
+ {
32
+ await this.bot.clientCommands.teleport.acceptTeleport(lureEvent);
33
+ }
34
+ catch (error)
35
+ {
36
+ console.error('Teleport error:');
37
+ console.error(error);
38
+ }
39
+ }
40
+ else
41
+ {
42
+ console.log('Ignoring teleport lure to ' + regionInfo.block.name + ' (' + regionInfo.avatars.length + ' avatar' + ((regionInfo.avatars.length === 1) ? '' : 's') + ' ' +
43
+ 'present) from ' + lureEvent.fromName + ' with message: ' + lureEvent.lureMessage);
44
+ }
45
+ }
46
+ catch (error)
47
+ {
48
+ console.error('Failed to get region map info:');
49
+ console.error(error);
50
+ }
51
+ }
52
+ }
53
+
54
+ new Teleports().run().then(() =>
55
+ {
56
+
57
+ }).catch((err) =>
58
+ {
59
+ console.error(err)
60
+ });
package/package.json CHANGED
@@ -1,71 +1,71 @@
1
- {
2
- "name": "@caspertech/node-metaverse",
3
- "version": "0.7.24",
4
- "description": "A node.js interface for Second Life.",
5
- "main": "dist/lib/index.js",
6
- "types": "dist/lib/index.d.ts",
7
- "scripts": {
8
- "setup": "npm install",
9
- "prepublish": "npm run build",
10
- "test-only": "mocha -r source-map-support/register 'dist/**/*.spec.js'",
11
- "pretest": "npm run build",
12
- "test": "npm run test-only",
13
- "build": "tsc --removeComments",
14
- "run": "node -r source-map-support/register example/testBot.js"
15
- },
16
- "engines": {
17
- "node": ">=7.6.0"
18
- },
19
- "author": "CasperTech Ltd",
20
- "license": "MIT",
21
- "repository": {
22
- "type": "git",
23
- "url": "git+https://github.com/CasperTech/node-metaverse.git"
24
- },
25
- "devDependencies": {
26
- "@angular-eslint/eslint-plugin": "^12.7.0",
27
- "@types/micromatch": "^4.0.4",
28
- "@types/node": "^22.4.0",
29
- "@types/tiny-async-pool": "^2.0.2",
30
- "@types/uuid": "^8.3.4",
31
- "@types/xml2js": "^0.4.14",
32
- "@typescript-eslint/eslint-plugin": "^4.33.0",
33
- "@typescript-eslint/eslint-plugin-tslint": "^4.33.0",
34
- "@typescript-eslint/parser": "^4.33.0",
35
- "eslint": "^7.32.0",
36
- "mocha": "^9.2.2",
37
- "source-map-support": "^0.5.21",
38
- "ts-node": "^10.9.1",
39
- "tslint": "^6.1.3",
40
- "typescript": "^5.5.4"
41
- },
42
- "dependencies": {
43
- "@caspertech/llsd": "^1.0.5",
44
- "@types/long": "^4.0.2",
45
- "@types/mocha": "^9.1.1",
46
- "@types/validator": "^13.11.5",
47
- "@types/xml": "^1.0.10",
48
- "@types/xmlrpc": "^1.3.9",
49
- "chalk": "^4.1.2",
50
- "flatted": "^3.2.9",
51
- "fs-extra": "^10.1.0",
52
- "glob": "^7.2.3",
53
- "got": "^11.8.6",
54
- "ipaddr.js": "^2.1.0",
55
- "logform": "^2.6.0",
56
- "long": "^4.0.0",
57
- "micromatch": "^4.0.5",
58
- "moment": "^2.29.4",
59
- "qs": "^6.5.3",
60
- "rbush-3d": "0.0.4",
61
- "rxjs": "^7.8.1",
62
- "tiny-async-pool": "^2.1.0",
63
- "uuid": "^8.3.2",
64
- "validator": "^13.11.0",
65
- "winston": "^3.11.0",
66
- "xml": "^1.0.1",
67
- "xml2js": "^0.5.0",
68
- "xmlbuilder": "^15.1.1",
69
- "xmlrpc": "github:CasperTech/node-xmlrpc"
70
- }
71
- }
1
+ {
2
+ "name": "@caspertech/node-metaverse",
3
+ "version": "0.7.26",
4
+ "description": "A node.js interface for Second Life.",
5
+ "main": "dist/lib/index.js",
6
+ "types": "dist/lib/index.d.ts",
7
+ "scripts": {
8
+ "setup": "npm install",
9
+ "prepublish": "npm run build",
10
+ "test-only": "mocha -r source-map-support/register 'dist/**/*.spec.js'",
11
+ "pretest": "npm run build",
12
+ "test": "npm run test-only",
13
+ "build": "tsc --removeComments",
14
+ "run": "node -r source-map-support/register example/testBot.js"
15
+ },
16
+ "engines": {
17
+ "node": ">=7.6.0"
18
+ },
19
+ "author": "CasperTech Ltd",
20
+ "license": "MIT",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/CasperTech/node-metaverse.git"
24
+ },
25
+ "devDependencies": {
26
+ "@angular-eslint/eslint-plugin": "^12.7.0",
27
+ "@types/micromatch": "^4.0.4",
28
+ "@types/node": "^22.4.0",
29
+ "@types/tiny-async-pool": "^2.0.2",
30
+ "@types/uuid": "^8.3.4",
31
+ "@types/xml2js": "^0.4.14",
32
+ "@typescript-eslint/eslint-plugin": "^4.33.0",
33
+ "@typescript-eslint/eslint-plugin-tslint": "^4.33.0",
34
+ "@typescript-eslint/parser": "^4.33.0",
35
+ "eslint": "^7.32.0",
36
+ "mocha": "^9.2.2",
37
+ "source-map-support": "^0.5.21",
38
+ "ts-node": "^10.9.1",
39
+ "tslint": "^6.1.3",
40
+ "typescript": "^5.5.4"
41
+ },
42
+ "dependencies": {
43
+ "@caspertech/llsd": "^1.0.5",
44
+ "@types/long": "^4.0.2",
45
+ "@types/mocha": "^9.1.1",
46
+ "@types/validator": "^13.11.5",
47
+ "@types/xml": "^1.0.10",
48
+ "@types/xmlrpc": "^1.3.9",
49
+ "chalk": "^4.1.2",
50
+ "flatted": "^3.2.9",
51
+ "fs-extra": "^10.1.0",
52
+ "glob": "^7.2.3",
53
+ "got": "^11.8.6",
54
+ "ipaddr.js": "^2.1.0",
55
+ "logform": "^2.6.0",
56
+ "long": "^4.0.0",
57
+ "micromatch": "^4.0.5",
58
+ "moment": "^2.29.4",
59
+ "qs": "^6.5.3",
60
+ "rbush-3d": "0.0.4",
61
+ "rxjs": "^7.8.1",
62
+ "tiny-async-pool": "^2.1.0",
63
+ "uuid": "^8.3.2",
64
+ "validator": "^13.11.0",
65
+ "winston": "^3.11.0",
66
+ "xml": "^1.0.1",
67
+ "xml2js": "^0.5.0",
68
+ "xmlbuilder": "^15.1.1",
69
+ "xmlrpc": "github:CasperTech/node-xmlrpc"
70
+ }
71
+ }