Difference between revisions of "HTTP API/Examples/Get bot status"
From SmartBots Developers Docs
Line 10: | Line 10: | ||
<syntaxhighlight lang="lsl"> | <syntaxhighlight lang="lsl"> | ||
− | // Paste SmartBots LSL Helper Functions here | + | // <= Paste SmartBots LSL Helper Functions here |
default { | default { |
Latest revision as of 14:37, 14 October 2019
This script requests bot status and displays it.
Place this code to an in-world object, and replace variables at the beginning with your values (read more about api key and Bot access code);
LSL Code
IMPORTANT! Paste SmartBots LSL Helper Functions (smartbotsAPI/smartbotsAPIJSON) before saving.
// <= Paste SmartBots LSL Helper Functions here
default {
state_entry() {
llOwnerSay("Script initialized");
}
touch_start(integer total_number) {
llOwnerSay("Requesting bot status...");
smartbotsAPIJSON("status", []);
}
// Get the SmartBots API reply
http_response(key request_id, integer status, list metadata, string body) {
// llOwnerSay("API raw response: " + body);
string status = llJsonGetValue(body, ["status"]);
string slname = llJsonGetValue(body, ["slname"]);
string uuid = llJsonGetValue(body, ["uuid"]);
string location = llJsonGetValue(body, ["location"]);
llOwnerSay("Bot status:\n" +
"name: " + slname + " / " + uuid + "\n" +
"online status: " + status + "\n" +
"location: " + location
);
}
}