Change 'list' command to 'query'
This commit is contained in:
@@ -11,7 +11,7 @@ arguments:
|
||||
remove MODULE remove MODULE
|
||||
enable MODULE enable MODULE
|
||||
disable MODULE disable MODULE
|
||||
list list installable modules
|
||||
query query installable modules
|
||||
current list currently installed modules
|
||||
|
||||
optional arguments:
|
||||
@@ -41,7 +41,7 @@ string pkg(list params)
|
||||
|
||||
string cmd = llList2String(params, 0);
|
||||
|
||||
if(cmd == "list") return list_modules();
|
||||
if(cmd == "query") return query_modules();
|
||||
else if(cmd == "current") return list_installed_modules();
|
||||
|
||||
// Parse module param; check for errors and append '.lsl'
|
||||
@@ -115,12 +115,12 @@ string disable_module(string module)
|
||||
return llList2Json(JSON_OBJECT, ["error", "Module '" + name + "' is already disabled."]);
|
||||
}
|
||||
|
||||
string list_modules()
|
||||
string query_modules()
|
||||
{
|
||||
/* Broadcast a message with a request to list available modules.
|
||||
/* Broadcast a message with a query for available modules.
|
||||
*/
|
||||
listen_handle = llListen(CHANNEL, "", "", "");
|
||||
string data = llList2Json(JSON_OBJECT, ["command", "list"]);
|
||||
string data = llList2Json(JSON_OBJECT, ["command", "query"]);
|
||||
llRegionSay(CHANNEL, data);
|
||||
return "AWAIT";
|
||||
}
|
||||
|
||||
@@ -34,6 +34,24 @@ integer module_is_available(string module)
|
||||
else return TRUE;
|
||||
}
|
||||
|
||||
list get_modules()
|
||||
{
|
||||
/* Return a list of available modules.
|
||||
*/
|
||||
list modules;
|
||||
integer count = llGetInventoryNumber(INVENTORY_SCRIPT);
|
||||
while(count--)
|
||||
{
|
||||
string name = llGetInventoryName(INVENTORY_SCRIPT, count);
|
||||
if(name != llGetScriptName())
|
||||
{
|
||||
string extension = llGetSubString(name, -4, -1);
|
||||
if(extension == ".lsl") modules += [name];
|
||||
}
|
||||
}
|
||||
return modules;
|
||||
}
|
||||
|
||||
default
|
||||
{
|
||||
state_entry()
|
||||
@@ -63,6 +81,13 @@ default
|
||||
llRemoteLoadScriptPin(id, module, pin, TRUE, 0xDEADBEEF);
|
||||
return;
|
||||
}
|
||||
else if(command == "query")
|
||||
{
|
||||
string modules = llList2Json(JSON_ARRAY, get_modules());
|
||||
string response = llList2Json(JSON_OBJECT, ["modules", modules]);
|
||||
llRegionSayTo(id, channel, response);
|
||||
return;
|
||||
}
|
||||
|
||||
string response = llList2Json(JSON_OBJECT, ["error", "Invalid command."]);
|
||||
llRegionSayTo(id, channel, response);
|
||||
|
||||
Reference in New Issue
Block a user