DevPortal

How do we use Bots Playground

I’m excited to see that Bots Playground becomes popular. I’ve been asked what was the main reason of creating it: automated bots, alive bots, games or… adult stuff? lol

Well, at the beginning the main idea was to get a versatile scripting tool for our Second Life business. We do a lot of various SL bot (including bots for roleplaying games). We were using LSL objects as bots’ “brains”, controlling bots via HTTP API calls. But managing LSL code was really inconvenient, especially when scripted object is an attachment of the bot (you just can’t edit it in handy way).

Playground for our bots

So, we decided that we need to write scripts in a handy modern language – like JavaScript. And then we’ve thought: why don’t we give this ability to all SL developers?..

Currently we have several bots running on Bots Playground. For example, we have a Dancer Bot who is dancing on a pole. The pole object itself is scripted and menu-driven, so bot needs to navigate the menu to start dancing:

Pole menu. With some special features.

Pole menu. It has some special features, but we need a “POLEDANCE*” menu

After clicking on "POLEDANCE" menu bot needs to choose a dance.

After clicking on “POLEDANCE” menu we also need to choose a dance

We developed a simple Playground script so bot selects the necessary menu automatically:

// SmartBots Playground code start v1.0 (automatic line)

//
// After logging in, bot sits on a pole automatically. Menu appears and
// bot navigates through the menu.
Bot.on("script_dialog", function(event) {
	console.log("Got a dialog:\n" +
		event.text + "\n\n" + 
		"channel: " + event.channel + "\n" +
		"buttons:\n" + event.buttons.join("\n"));
	
	if(event.buttons[0] != "[SWAP]") {
		// 1. Press the dance menu button
		Bot.replyDialog(event.channel, event.object_uuid, "POLEDANCE*");
	} else {
		// 2. Select automatic dance
		Bot.replyDialog(event.channel, event.object_uuid, "Auto1");
	}
});

//
// This piece of code is to manually sit on a pole. No control protection here yet.
Bot.on("instant_message", function(event) {
	if(event.message == "stand") {
		Bot.sit("00000000-0000-0000-0000-000000000000");
		Bot.im(event.speaker_uuid, "standing...");
	}
	
	if(event.message == "sit") {
		Bot.sit("8e01d0ce-d6f9-acc9-a955-b936c5f8fb0e");
		Bot.im(event.speaker_uuid, "sitting...");
	}
});

Leave a Reply

Your email address will not be published. Required fields are marked *