Difference between revisions of "TotalControl for LSL/Events/BOT LOCATION REPLY"

From SmartBots Developers Docs
Jump to: navigation, search
(Updated example)
 
Line 12: Line 12:
  
 
<syntaxhighlight lang="lsl">
 
<syntaxhighlight lang="lsl">
link_message( integer sender_num, integer num, string str, key id ) {
+
integer BOT_SETUP_SETBOT = 280101;
    /////////////////// Bot list group reply event
+
integer BOT_LOCATION = 290232;
    if(num==BOT_LOCATION_REPLY) {
+
integer BOT_LOCATION_REPLY = 290233;
        // Parse each group separated by a new line "\n"
+
        list location = llParseString2List(str, ["\n"], []);
+
  
        llOwnerSay("Region: " + llList2String(location, 0));
+
integer READY = FALSE;
        llOwnerSay("X: " + llList2String(location, 1));
+
 
        llOwnerSay("Y: " + llList2String(location, 2));
+
string name = "SmartBots Resident";
        llOwnerSay("Z: " + llList2String(location, 3));
+
string accesscode = "f7dheb7fba9";
    }
+
 
 +
default
 +
{
 +
state_entry()
 +
{
 +
llMessageLinked(LINK_SET,BOT_SETUP_SETBOT,name,accesscode);
 +
}
 +
 
 +
touch_start(integer total_number)
 +
{
 +
if (READY) {
 +
llMessageLinked(LINK_SET,BOT_LOCATION,"","");
 +
llOwnerSay("Requesting the bot's location.");
 +
} else {
 +
llOwnerSay("The bot is not ready. If you received a Setup Failed message then please check your access code is correct, otherwise please try again in a moment.");
 +
}
 +
}
 +
 
 +
link_message(integer sender, integer cmd, string data, key idk) {
 +
string id = (string)idk;
 +
if(cmd == BOT_SETUP_SUCCESS) {
 +
READY = TRUE;
 +
llOwnerSay("Setup Success: data=" + data + "\nkey= " + id);
 +
} else if(cmd == BOT_SETUP_FAILED ) {
 +
READY = FALSE;
 +
llOwnerSay("Setup Failed: data=" + data + "\nkey= " + id);
 +
} else if(num==BOT_LOCATION_REPLY) {
 +
list location = llParseString2List(str, ["\n"], []);
 +
llOwnerSay("Bot ("+name+") is at: secondlife://" + llList2String(location, 0) + "/" + llList2String(location, 1) + "/" + llList2String(location, 2) + "/" + llList2String(location, 3));
 +
}
 +
}
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
{{NavMenu}}
 
{{NavMenu}}

Latest revision as of 01:40, 13 March 2019

Raised when bot returns its location

Reference

This event comes with the following event object:

Variable Required Description
event object properties:
str List of roles in the format "region\nx\ny\nz"
id ---

Example

integer BOT_SETUP_SETBOT = 280101;
integer BOT_LOCATION = 290232;
integer BOT_LOCATION_REPLY = 290233;

integer READY = FALSE;

string name = "SmartBots Resident";
string accesscode = "f7dheb7fba9";

default
{
	state_entry()
	{
		llMessageLinked(LINK_SET,BOT_SETUP_SETBOT,name,accesscode);
	}

	touch_start(integer total_number)
	{
		if (READY) {
			llMessageLinked(LINK_SET,BOT_LOCATION,"","");
			llOwnerSay("Requesting the bot's location.");
		} else {
			llOwnerSay("The bot is not ready. If you received a Setup Failed message then please check your access code is correct, otherwise please try again in a moment.");
		}
	}

	link_message(integer sender, integer cmd, string data, key idk) {
		string id = (string)idk;
		if(cmd == BOT_SETUP_SUCCESS) {
			READY = TRUE;
			llOwnerSay("Setup Success: data=" + data + "\nkey= " + id);
		} else if(cmd == BOT_SETUP_FAILED ) {
			READY = FALSE;
			llOwnerSay("Setup Failed: data=" + data + "\nkey= " + id);
		} else if(num==BOT_LOCATION_REPLY) {
			list location = llParseString2List(str, ["\n"], []);
			llOwnerSay("Bot ("+name+") is at: secondlife://" + llList2String(location, 0) + "/" + llList2String(location, 1) + "/" + llList2String(location, 2) + "/" + llList2String(location, 3));
		}
	}
}