Add module listing functionality

This commit is contained in:
Bridget
2020-04-19 21:30:11 +02:00
parent 7492023f8e
commit f71747edd8

View File

@@ -117,7 +117,12 @@ string disable_module(string module)
string list_modules()
{
return llList2Json(JSON_ARRAY, ["TODO 1", "TODO 2"]);
/* Broadcast a message with a request to list available modules.
*/
listen_handle = llListen(CHANNEL, "", "", "");
string data = llList2Json(JSON_OBJECT, ["command", "list"]);
llRegionSay(CHANNEL, data);
return "AWAIT";
}
string list_installed_modules()
@@ -250,6 +255,15 @@ default
return;
}
// Return the module listing if the repository returned it
string modules = llJsonGetValue(data, ["modules"]);
if(modules != JSON_INVALID)
{
string response = llList2Json(JSON_OBJECT, ["Modules"] + (list)modules);
respond(1, response, "");
return;
}
// Return an error message if the module is not available in the repository
integer available = (integer)llJsonGetValue(data, ["available"]);
if(!available)