Scan nearby avatars

From SmartBots Developers Docs
Bot PlaygroundExamples
Revision as of 15:31, 18 October 2022 by Gg (Talk | contribs) (Created page with "{{DISPLAYTITLE:{{SUBPAGENAME}}}} Script scans for nearby avatars and logs them. Since console.log is limited to 4kb, avatars are logged one by one. <syntaxhighlight lang="ja...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


Script scans for nearby avatars and logs them. Since console.log is limited to 4kb, avatars are logged one by one.

// Bots Playground script: [TEST] nearbyAvatars (build 1 by Glaznah Gassner)
console.log(`${process.name} started`);

const result = await Bot.scanNearbyAvatars();
console.log(`Avatars arrived: (${JSON.stringify(result).length} bytes)`);

if(JSON.stringify(result).length < 1024) {
	console.log("Raw response:", result);
}

if(!result.success) {
	console.log("Error scanning avatars: " + result.error);
}

if(!result.avatars) {
	console.log(`No avatars found in command result`);
} else {
	for(const avatar of result.avatars) {
		// Uncomment below or raw output
		// console.log(JSON.stringify(avatar, null, 2)); 
		
		console.log(`${avatar.name}: seen for ${avatar.seenSeconds} seconds`);
	}
}

process.exit();