Difference between revisions of "TotalControl for LSL/Commands/BOT LOCATION"

From SmartBots Developers Docs
Jump to: navigation, search
(Added example)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 
{{DISPLAYTITLE:BOT_LOCATION}}
 
{{DISPLAYTITLE:BOT_LOCATION}}
 
<onlyinclude>Returns the location of the bot.</onlyinclude>
 
<onlyinclude>Returns the location of the bot.</onlyinclude>
 +
 +
<syntaxhighlight lang="lsl">
 +
llMessageLinked(LINK_SET, BOT_LOCATION, "", "");
 +
</syntaxhighlight>
  
 
{{API Variables Table}}
 
{{API Variables Table}}
Line 13: Line 17:
  
 
The following event will be raised with the location of the bot
 
The following event will be raised with the location of the bot
* [[TotalControl_for_LSL/Events/BOT_LOCATION|BOT_LOCATION_REPLY]]
+
* [[TotalControl_for_LSL/Events/BOT_LOCATION_REPLY|BOT_LOCATION_REPLY]]
  
 
== Example ==
 
== Example ==
  
 
<syntaxhighlight lang="lsl">
 
<syntaxhighlight lang="lsl">
llMessageLinked(LINK_SET, BOT_LOCATION, "", "");
+
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));
 +
}
 +
}
 +
}
 
</syntaxhighlight>
 
</syntaxhighlight>
  

Latest revision as of 01:38, 13 March 2019

Returns the location of the bot.

llMessageLinked(LINK_SET, BOT_LOCATION, "", "");

Variables

The following table shows input values (you send them with the API call) and returned output values.

Variable Required Description


str yes --
id yes --

Result

The following event will be raised with the location of the bot

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));
		}
	}
}