first commit

This commit is contained in:
codeviolet 2017-07-31 17:43:31 +10:00
parent e7d01132b3
commit 34f30ac80a
48 changed files with 13160 additions and 534 deletions

View file

@ -1,3 +1,17 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* Copyright (c) the AVsitter Contributors (http://avsitter.github.io)
* AVsitter™ is a trademark. For trademark use policy see:
* https://avsitter.github.io/TRADEMARK.mediawiki
*
* Please consider supporting continued development of AVsitter and
* receive automatic updates and other benefits! All details and user
* instructions can be found at http://avsitter.github.io
*/
// Placed in prop objects, this script sends the uuid of any Lockguard rings to the script in furniture.
// Ring prims in the prop should be named with "ring" in their prim name. e.g. "ring1", "ring2"

View file

@ -1,12 +1,21 @@
// LSL-AVSITTER-LockGuard-PLUGIN
// Copyright (c) 2016
// Permission given to modify and adapt this script
//
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* Copyright (c) the AVsitter Contributors (http://avsitter.github.io)
* AVsitter™ is a trademark. For trademark use policy see:
* https://avsitter.github.io/TRADEMARK.mediawiki
*
* Please consider supporting continued development of AVsitter and
* receive automatic updates and other benefits! All details and user
* instructions can be found at http://avsitter.github.io
*/
// For use attaching particle chains to LockGuard V2 compatible cuffs such as Open Collar
// This script should be placed inside the prim that contains your poses and props.
// Inspiration and function (not code) from the Bright CISS system by Shan Bright & Innula Zenovka.
// SITTER:
// The AVsitter SITTER # the cuff settings are for.

View file

@ -0,0 +1,188 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* Copyright (c) the AVsitter Contributors (http://avsitter.github.io)
* AVsitter™ is a trademark. For trademark use policy see:
* https://avsitter.github.io/TRADEMARK.mediawiki
*
* Please consider supporting continued development of AVsitter and
* receive automatic updates and other benefits! All details and user
* instructions can be found at http://avsitter.github.io
*/
string product = "AVsitter™ Xcite!";
string version = "1.02";
string notecard_name = "[AV]Xcite_settings";
key notecard_key;
key notecard_query;
integer notecard_line;
integer verbose = 0;
list POSE_AND_SITTER;
list XCITE_COMMANDS;
list XCITE_TILT;
integer TIMER_DEFAULT = 30;
string CURRENT_POSE;
list TIMERS;
list SITTERS;
integer DEBUG;
Out(integer level, string out)
{
if (verbose >= level)
{
llOwnerSay(llGetScriptName() + "[" + version + "]:" + out);
}
}
key key_request;
string parse_text(string say)
{
integer i;
for (i = 0; i < llGetListLength(SITTERS); i++)
{
string sitter_name = llList2String(llParseString2List(llKey2Name(llList2String(SITTERS, i)), [" "], []), 0);
if (sitter_name == "")
{
sitter_name = "(nobody)";
}
say = strReplace(say, "/" + (string)i, sitter_name);
}
return say;
}
string strReplace(string str, string search, string replace)
{
return llDumpList2String(llParseStringKeepNulls(str, [search], []), replace);
}
default
{
state_entry()
{
notecard_key = llGetInventoryKey(notecard_name);
Out(0, "Loading...");
notecard_query = llGetNotecardLine(notecard_name, 0);
}
changed(integer change)
{
if (change & CHANGED_INVENTORY)
{
if (llGetInventoryKey(notecard_name) != notecard_key)
{
llResetScript();
}
}
if (change & CHANGED_LINK)
{
if (llGetAgentSize(llGetLinkKey(llGetNumberOfPrims())) == ZERO_VECTOR)
{
TIMERS = [];
}
}
}
link_message(integer sender, integer num, string msg, key id)
{
if (sender == llGetLinkNumber())
{
if (num == 90045)
{
string name = llKey2Name(id);
if (name != "")
{
integer i = llGetListLength(TIMERS);
while (i > 0)
{
i--;
if (!llSubStringIndex(llList2String(TIMERS, i), name + "|"))
{
TIMERS = llDeleteSubList(TIMERS, i, i);
}
}
llSetTimerEvent(TIMER_DEFAULT);
list data = llParseStringKeepNulls(msg, ["|"], []);
integer script_channel = (integer)llList2String(data, 0);
CURRENT_POSE = llList2String(data, 1);
SITTERS = llParseStringKeepNulls(llList2String(data, 4), ["@"], []);
integer index = llListFindList(POSE_AND_SITTER, [CURRENT_POSE + "|" + (string)script_channel]);
if (!~index)
{
index = llListFindList(POSE_AND_SITTER, [CURRENT_POSE + "|*"]);
if (!~index)
{
index = llListFindList(POSE_AND_SITTER, ["*|*"]);
if (!~index)
{
return;
}
}
}
if (llList2Integer(XCITE_TILT, index) != 0)
{
if (DEBUG)
{
Out(0, "Setting " + name + "'s tilt to " + (string)llList2Integer(XCITE_TILT, index));
}
llMessageLinked(LINK_SET, 20020, name + "|" + (string)llList2Integer(XCITE_TILT, index), "");
}
else
{
if (DEBUG)
{
Out(0, "Restoring " + name + "'s tilt.");
}
llMessageLinked(LINK_SET, 20014, name, "");
}
data = llParseStringKeepNulls(llList2String(XCITE_COMMANDS, index), ["|"], []);
TIMERS += [name + "|" + llList2String(data, 0) + "|" + llList2String(data, 1) + "||" + llList2String(data, 3)];
string commands = parse_text(llList2String(XCITE_COMMANDS, index));
llMessageLinked(LINK_SET, 20001, name + "|" + commands, NULL_KEY);
if (DEBUG)
{
Out(0, "Sending xcite commands: " + name + "|" + commands);
}
}
}
}
}
timer()
{
integer i;
for (; i < llGetListLength(TIMERS); i++)
{
llMessageLinked(LINK_SET, 20001, llList2String(TIMERS, i), NULL_KEY);
if (DEBUG)
{
Out(0, "Sending xcite commands: " + llList2String(TIMERS, i));
}
}
}
dataserver(key query_id, string data)
{
if (query_id == notecard_query)
{
if (data == EOF || llStringTrim(llToLower(data), STRING_TRIM) == "end")
{
Out(0, (string)llGetListLength(POSE_AND_SITTER) + " items Ready, Mem=" + (string)llGetFreeMemory());
}
else
{
data = llStringTrim(data, STRING_TRIM);
string command = llGetSubString(data, 0, llSubStringIndex(data, " ") - 1);
list parts = llParseStringKeepNulls(llGetSubString(data, llSubStringIndex(data, " ") + 1, -1), [" | ", " |", "| ", "|"], []);
if (command == "TIMER")
{
TIMER_DEFAULT = (integer)llList2String(parts, 0);
}
else if (command == "DEBUG")
{
DEBUG = (integer)llList2String(parts, 0);
}
else if (command == "XCITE")
{
POSE_AND_SITTER += [llStringTrim(llList2String(parts, 0), STRING_TRIM) + "|" + llList2String(parts, 1)];
XCITE_COMMANDS += [llList2String(parts, 2) + "|" + llList2String(parts, 3) + "|" + llList2String(parts, 4) + "|" + llList2String(parts, 5)];
XCITE_TILT += (integer)llList2String(parts, 6);
}
notecard_query = llGetNotecardLine(notecard_name, ++notecard_line);
}
}
}
}

View file

@ -0,0 +1,72 @@
#############################################################
Example Xcite! notecard for use with AVsitter™ Xcite! plugin.
#############################################################
//
// Your object MUST contain your Xcite! partner script (provided by Xcite!) and/or your Sensations partner script (provided by Sensations).
//
// Please refer to your Xcite! and/or Sensations partner information for details.
//
// This notecard must be called "[AV]Xcite_settings"
//
// Format of each line is as follows:
//
// XCITE pose_name|sitter_number|arousal|arousal_max|text|kink|tilt
//
// For pose_name you can use * to apply to all poses, otherwise use the menu name of one pose.
//
// For sitter_number you can use * to apply to all sitters otherwise it should be 0,1, etc
//
// arousal and arousal_max are described in your Xcite! and Sensations partner information.
//
// For text you may include any text messages that you want to be said out when this arousal occurs.
// If you want the message to take the form of an emote simply start the text message with '/me'.
// You may also use any of the following special codes for appropriate pronouns in the text:
//
// %o - Replaced by the owner's first name
// %f - Replaced by the owner's full name
// %p - Replaced by the possessive pronoun according to sex (his, her)
// %r - Replaced by the objective pronoun (him, her)
// %s - Replaced by the subjective pronoun (he, she)
// %w - Replaced by the possessive form appropriate to the target rather than the owner
//
// Refer to your Xcite! partner information for full details on text.
//
// You can also refer to the sitters by first name with /0 /1 etc.
//
// Adding text is optional and isn't required for the arousal to occur.
//
// Note each notecard line can only be 255 characters maximum.
//
// You may also include a custom timer as follows:
// TIMER 30
//
// Arousal will be re-applied at this interval (default is 30 seconds)
//
// If you wish to debug Xcite commands sent, include:
// DEBUG 1
//
// Switching off Xcite! or Sensations features should be done via your Xcite or Sensations product's menu.
//
#############################################################
Example data follows....
#############################################################
DEBUG 0
TIMER 30
// Typical settings for poses
XCITE Couples1|0|15|95|/0 takes /1 by the hand...|kink|0
XCITE Couples1|1|5|95|example text for male...|kink|50
XCITE Couples_Climax|*|10|100||kink|50
// Pose with slowly diminishing arousal
XCITE Waiting|*|-15|95
// Pose that sets arousal to 0
XCITE Rest|*|0|0
// Default arousal for all poses
XCITE *|*|5|90
// Default arousal for sitter1's poses
XCITE *|1|5|90

View file

@ -0,0 +1,432 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* Copyright (c) the AVsitter Contributors (http://avsitter.github.io)
* AVsitter™ is a trademark. For trademark use policy see:
* https://avsitter.github.io/TRADEMARK.mediawiki
*
* Please consider supporting continued development of AVsitter and
* receive automatic updates and other benefits! All details and user
* instructions can be found at http://avsitter.github.io
*/
string product;
string version = "2.2";
integer RELAY_CHANNEL = -1812221819;
integer RELAY_GETSTATUS_CHANNEL;
integer GETSTATUShandle;
integer menu_channel;
integer menu_handle;
key CONTROLLER = "";
string controllerName;
key SLAVE;
string menu;
integer menuPage;
list folderPath;
list folderOptions;
list folderNamesFullLength;
list CLOTHING_LAYERS = ["gloves", "jacket", "pants", "shirt", "shoes", "skirt", "socks", "underpants", "undershirt", "", "", "", "", "alpha", "tattoo"];
list ATTACHMENT_POINTS = ["", "chest", "skull", "left shoulder", "right shoulder", "left hand", "right hand", "left foot", "right foot", "spine", "pelvis", "mouth", "chin", "left ear", "right ear", "left eyeball", "right eyeball", "nose", "r upper arm", "r forearm", "l upper arm", "l forearm", "right hip", "r upper leg", "r lower leg", "left hip", "l upper leg", "l lower leg", "stomach", "left pec", "right pec", "", "", "", "", "", "", "", "", "neck", "root"];
list RLV_RESTRICTIONS = ["Chat", "sendchat", "sending chat", "IM", "sendim", "sending IM", "Touch", "touchall", "touching", "Names", "shownames", "seeing names", "Rez/Edit", "edit,rez", "editing and rezzing objects", "Inventory", "showinv", "accessing their inventory", "Map", "showworldmap,showminimap", "seeing their map", "Location", "showloc", "seeing their location"];
string iconActive = "✘ ";
string iconInactive = "✔ ";
string iconEmpty = "○";
string iconHalf = "◑";
string iconFull = "●";
string iconAdd = "[]";
string iconSubtract = "[]";
string pagedMenuText;
list pagedMenuButtons;
integer verbose = 0;
Out(integer level, string out)
{
if (verbose >= level)
{
llOwnerSay(llGetScriptName() + "[" + version + "]:" + out);
}
}
string strReplace(string str, string search, string replace)
{
return llDumpList2String(llParseStringKeepNulls(str, [search], []), replace);
}
list order_buttons(list buttons)
{
return llList2List(buttons, -3, -1) + llList2List(buttons, -6, -4) + llList2List(buttons, -9, -7) + llList2List(buttons, -12, -10);
}
relay(key av, string msg)
{
msg = "RLV," + (string)av + "," + msg;
Out(1, "Sending RLV Command: " + msg);
llSay(RELAY_CHANNEL, msg);
}
remove_menu(string worn, list slots)
{
list menu_items;
Out(1, "remove menu:" + worn + ":" + llDumpList2String(slots, ","));
integer i;
for (i = 0; i < llGetListLength(slots); i++)
{
if (llList2String(slots, i) != "" && llGetSubString(worn, i, i) == "1")
{
menu_items += llList2String(slots, i);
}
}
Out(1, "remove menu2:" + llDumpList2String(menu_items, ","));
string text = "'s RLV setup may prevent some items from being removed.\n\nSelect an item to remove:";
if (!llGetListLength(menu_items))
{
text = " is not wearing any items to " + llToLower(menu) + ".";
}
new_paged_menu(menu + " menu for " + llKey2Name(SLAVE) + "\n\nThe captive" + text, menu_items);
}
new_paged_menu(string text, list menu_items)
{
pagedMenuText = text;
pagedMenuButtons = menu_items;
menuPage = 0;
paged_menu();
}
paged_menu()
{
list MypagedMenuButtons = pagedMenuButtons;
if (llGetListLength(pagedMenuButtons) > 11)
{
integer numberPages = llGetListLength(pagedMenuButtons) / 9;
if (llGetListLength(pagedMenuButtons) % 9)
{
numberPages++;
}
if (menuPage >= numberPages)
{
menuPage = 0;
}
else if (menuPage < 0)
{
menuPage = numberPages - 1;
}
MypagedMenuButtons = llList2List(pagedMenuButtons, menuPage * 9, menuPage * 9 + 8);
while (llGetListLength(MypagedMenuButtons) < 9)
{
MypagedMenuButtons += " ";
}
MypagedMenuButtons += ["[<<]", "[>>]"];
}
Out(1, "paged menu:" + llDumpList2String(MypagedMenuButtons, ","));
dialog(pagedMenuText, ["[BACK]"] + MypagedMenuButtons);
}
dialog(string text, list buttons)
{
while (llGetListLength(buttons) % 3)
buttons += " ";
llDialog(CONTROLLER, "AVsitter™ RLV " + product + " " + version + "\n\n" + text, order_buttons(buttons), menu_channel);
}
remove_script(string reason)
{
string message = "\n" + llGetScriptName() + " ==Script Removed==\n\n" + reason;
llDialog(llGetOwner(), message, ["OK"], -3675);
llInstantMessage(llGetOwner(), message);
llRemoveInventory(llGetScriptName());
}
main_menu()
{
menu = "";
dialog("Un/Dress menu for " + llKey2Name(SLAVE), ["[BACK]", "Browse #RLV", "Fast Strip", "Undress", "Detach"]);
}
default
{
state_entry()
{
if (llSubStringIndex(llGetScriptName(), " ") != -1)
{
remove_script("Use only one copy of this script!");
}
else
{
state running;
}
}
}
state running
{
state_entry()
{
}
link_message(integer sender, integer num, string msg, key id)
{
if (num == 90208 || num == 90209)
{
list data = llParseStringKeepNulls(id, ["|"], []);
SLAVE = (key)llList2String(data, 0);
CONTROLLER = (key)llList2String(data, 1);
product = llList2String(data, 2);
llListenRemove(menu_handle);
llListenRemove(GETSTATUShandle);
menu_handle = llListen(menu_channel = ((integer)llFrand(2147483646) + 1) * -1, "", CONTROLLER, "");
GETSTATUShandle = llListen(RELAY_GETSTATUS_CHANNEL = (integer)llFrand(999999999), "", "", "");
if (num == 90208)
{
main_menu();
}
else
{
menu = "Restrict";
relay(SLAVE, "@getstatus=" + (string)RELAY_GETSTATUS_CHANNEL);
}
}
else if (num == 90065)
{
if (id == SLAVE)
{
llListenRemove(menu_handle);
llListenRemove(GETSTATUShandle);
SLAVE = "";
}
}
}
listen(integer channel, string name, key id, string msg)
{
Out(1, "Listen Received: " + msg);
string command;
if (channel == menu_channel)
{
if (msg == "[>>]" || msg == "[<<]")
{
if (msg == "[<<]")
{
menuPage--;
}
else
{
menuPage++;
}
paged_menu();
}
else if (menu == "Browse #RLV")
{
integer index = llListFindList(folderOptions, [msg]);
if (~index)
{
msg = llList2String(folderNamesFullLength, index);
folderPath += msg;
relay(SLAVE, "@getinvworn:" + llDumpList2String(folderPath, "/") + "=" + (string)RELAY_GETSTATUS_CHANNEL);
}
else if (msg == "[BACK]")
{
if (!llGetListLength(folderPath))
{
main_menu();
}
else
{
folderPath = llDeleteSubList(folderPath, -1, -1);
relay(SLAVE, "@getinvworn:" + llDumpList2String(folderPath, "/") + "=" + (string)RELAY_GETSTATUS_CHANNEL);
}
}
else if (msg == iconAdd || msg == iconSubtract)
{
command = "attach";
if (msg == iconSubtract)
{
command = "detach";
}
relay(SLAVE, "@" + command + ":" + llDumpList2String(folderPath, "/") + "=force");
llSleep(4);
relay(SLAVE, "@getinvworn:" + llDumpList2String(folderPath, "/") + "=" + (string)RELAY_GETSTATUS_CHANNEL);
}
}
else if (msg == "[BACK]")
{
if (menu == "Restrict" || menu == "")
{
llMessageLinked(LINK_THIS, 90100, "0|Control...|" + (string)SLAVE, CONTROLLER);
}
else
{
main_menu();
}
}
else if (menu == "Detach" || menu == "Undress")
{
integer index = llListFindList(CLOTHING_LAYERS, [msg]);
command = "outfit";
if (!~index)
{
index = llListFindList(ATTACHMENT_POINTS, [msg]);
command = "attach";
}
if (~index)
{
relay(SLAVE, "@rem" + command + ":" + msg + "=force");
llSleep(2);
relay(SLAVE, "@get" + command + "=" + (string)RELAY_GETSTATUS_CHANNEL);
}
}
else if (msg == "Detach" || msg == "Undress" || msg == "Browse #RLV")
{
menu = msg;
folderPath = [];
command = "getoutfit";
if (msg == "Detach")
command = "getattach";
if (msg == "Browse #RLV")
command = "getinvworn";
relay(SLAVE, "@" + command + "=" + (string)RELAY_GETSTATUS_CHANNEL);
}
else if (msg == "Fast Strip")
{
menu = "fs";
dialog("Are you really sure? This will try to remove almost everything the avatar is wearing.", ["[BACK]", "YES!"]);
}
else if (msg == "YES!")
{
integer i;
for (i = 0; i < llGetListLength(CLOTHING_LAYERS); i++)
{
if (llList2String(CLOTHING_LAYERS, i))
{
relay(SLAVE, "@remoutfit:" + llList2String(CLOTHING_LAYERS, i) + "=force");
}
}
for (i = 0; i < llGetListLength(ATTACHMENT_POINTS); i++)
{
if (llList2String(ATTACHMENT_POINTS, i))
{
if (i != 2)
{
relay(SLAVE, "@remattach:" + llList2String(ATTACHMENT_POINTS, i) + "=force");
}
}
}
main_menu();
}
else
{
integer index = llListFindList(llList2ListStrided(RLV_RESTRICTIONS, 0, -1, 3), [llList2String(llParseString2List(msg, [" "], []), 1)]);
if (~index)
{
list subRestrictions = llParseString2List(llList2String(RLV_RESTRICTIONS, index * 3 + 1), [","], []);
string param = "n";
string chatText = strReplace(llKey2Name(SLAVE), " Resident", "") + " is ";
if (~llSubStringIndex(msg, iconActive))
{
param = "y";
chatText += "no longer ";
}
integer i;
while (i < llGetListLength(subRestrictions))
{
relay(SLAVE, "@" + llList2String(subRestrictions, i) + "=" + param);
i++;
}
llSay(0, chatText + "restricted from " + llList2String(RLV_RESTRICTIONS, index * 3 + 2) + ".");
relay(SLAVE, "@getstatus=" + (string)RELAY_GETSTATUS_CHANNEL);
}
}
}
else if (channel == RELAY_GETSTATUS_CHANNEL)
{
if (menu == "Browse #RLV")
{
folderOptions = [];
folderNamesFullLength = [];
list BUTTONS;
list results = llParseStringKeepNulls(msg, [","], []);
string folderInfo;
string subInfo;
integer i;
for (i = 0; i < llGetListLength(results); i++)
{
list item = llParseStringKeepNulls(llList2String(results, i), ["|"], []);
string folder = llList2String(item, 0);
integer worn = llList2Integer(item, 1);
integer wornThis = worn / 10;
integer wornSub = worn % 10;
string icon = "no items";
if (i)
{
if (wornThis || wornSub)
{
icon = iconEmpty;
if (wornThis > 1 || wornSub > 1)
{
icon = iconHalf;
}
if (wornThis == 3 && wornSub == 0 || (wornThis == 0 && wornSub == 3) || (wornThis == 3 && wornSub == 3))
{
icon = iconFull;
}
folderOptions += icon + " " + llGetSubString(folder, 0, 12);
folderNamesFullLength += folder;
subInfo = "\nSubfolders:\n" + iconEmpty + " = none worn\n" + iconHalf + " = some worn\n" + iconFull + " = all worn";
}
}
else
{
if (wornThis)
{
icon = "none worn";
if (wornThis == 2)
{
icon = "some worn";
}
if (wornThis == 3)
{
icon = "all worn";
}
BUTTONS += [iconAdd, iconSubtract];
folderInfo = "\n" + iconAdd + " = wear\n" + iconSubtract + " = remove\n";
}
msg = "Folder: /" + llDumpList2String(folderPath, "/") + "\n[" + icon + "]\n" + folderInfo;
}
}
if ((!llGetListLength(folderOptions)) && (!llGetListLength(BUTTONS)))
{
msg = "#RLV folder empty";
}
new_paged_menu(msg + subInfo, BUTTONS + folderOptions);
}
else if (menu == "Detach")
{
remove_menu(msg, ATTACHMENT_POINTS);
}
else if (menu == "Undress")
{
remove_menu(msg, CLOTHING_LAYERS);
}
else if (menu == "Restrict")
{
list currentRestrictions = llParseString2List(msg, ["/"], []);
list menu_items = ["[BACK]"];
integer i;
while (i < llGetListLength(RLV_RESTRICTIONS))
{
list subRestrictions = llParseString2List(llList2String(RLV_RESTRICTIONS, i + 1), [","], []);
integer inActive;
integer j;
while (j < llGetListLength(subRestrictions))
{
if (!~llListFindList(currentRestrictions, [llList2String(subRestrictions, j)]))
{
inActive = TRUE;
}
j++;
}
string symbol = iconInactive;
if (!inActive)
{
symbol = iconActive;
}
string btntext = symbol + llList2String(RLV_RESTRICTIONS, i);
while (llStringLength(btntext) < 20)
btntext += " ";
btntext += ".";
menu_items += btntext;
i += 3;
}
dialog("RLV for " + llKey2Name(SLAVE) + "\n\n" + iconInactive + "= Allowed\n" + iconActive + "= Restricted", menu_items);
}
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,195 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* Copyright (c) the AVsitter Contributors (http://avsitter.github.io)
* AVsitter™ is a trademark. For trademark use policy see:
* https://avsitter.github.io/TRADEMARK.mediawiki
*
* Please consider supporting continued development of AVsitter and
* receive automatic updates and other benefits! All details and user
* instructions can be found at http://avsitter.github.io
*/
string product = "AVsitter™ Menu Control";
string version = "2.2";
string security_script = "[AV]root-security";
string RLV_script = "[AV]root-RLV";
list DESIGNATIONS_NOW;
key CONTROLLER = NULL_KEY;
integer KEY_TAKEN;
string CONTROLLER_NAME;
list SITTERS_MENUKEYS;
list SITTERS_SHORTNAMES;
integer menu_channel;
integer menu_handle;
key key_request;
integer verbose = 1;
Out(integer level, string out)
{
if (verbose >= level)
{
llOwnerSay(llGetScriptName() + "[" + version + "]:" + out);
}
}
list order_buttons(list buttons)
{
return llList2List(buttons, -3, -1) + llList2List(buttons, -6, -4) + llList2List(buttons, -9, -7) + llList2List(buttons, -12, -10);
}
string strReplace(string str, string search, string replace)
{
return llDumpList2String(llParseStringKeepNulls(str, [search], []), replace);
}
controller_menu(key id)
{
CONTROLLER = id;
CONTROLLER_NAME = llKey2Name(id);
list SITTERS;
integer count = llGetNumberOfPrims();
while (llGetAgentSize(llGetLinkKey(count)) != ZERO_VECTOR)
{
SITTERS += llGetLinkKey(count);
count--;
}
if ((~llListFindList(SITTERS, [id])) && check_for_RLV())
{
llMessageLinked(LINK_SET, 90005, "", id);
}
else
{
if (llGetListLength(SITTERS) == 1 && ((!check_for_RLV()) || (!~llListFindList(DESIGNATIONS_NOW, ["S"])) || llGetListLength(DESIGNATIONS_NOW) == 1))
{
if (check_for_RLV())
{
llMessageLinked(LINK_THIS, 90100, "x|Control...|" + llList2String(SITTERS, 0), id);
}
else
{
llMessageLinked(LINK_SET, 90005, "", llDumpList2String([id, llList2Key(SITTERS, 0)], "|"));
}
}
else
{
list menu_items;
SITTERS_MENUKEYS = [];
integer i;
for (i = 0; i < llGetListLength(SITTERS); i++)
{
if (llList2Key(SITTERS, i) != NULL_KEY)
{
menu_items += llGetSubString(strReplace(llKey2Name(llList2Key(SITTERS, i)), " Resident", ""), 0, 11);
SITTERS_MENUKEYS += llList2Key(SITTERS, i);
}
}
SITTERS_SHORTNAMES = menu_items;
string text = "Which avatar?";
if (check_for_RLV())
{
if (!llGetListLength(menu_items))
{
llMessageLinked(LINK_THIS, 90211, "", id);
return;
}
if ((~llListFindList(DESIGNATIONS_NOW, ["S"])) && llGetListLength(SITTERS) < llGetListLength(DESIGNATIONS_NOW))
{
text += "\n\nCapture = trap a new avatar.";
menu_items += "Capture...";
}
}
if (llGetListLength(menu_items))
{
dialog(text, order_buttons(menu_items), id);
}
}
}
}
dialog(string text, list menu_items, key id)
{
llListenRemove(menu_handle);
menu_handle = llListen(menu_channel = ((integer)llFrand(2147483646) + 1) * -1, "", id, "");
llDialog(id, product + " " + version + "\n\n" + text + "\n", order_buttons(menu_items), menu_channel);
llSetTimerEvent(120);
}
integer check_for_RLV()
{
if (llGetInventoryType(RLV_script) == INVENTORY_SCRIPT)
{
return TRUE;
}
return FALSE;
}
default
{
state_entry()
{
llSetTimerEvent(0);
}
on_rez(integer x)
{
llResetScript();
}
timer()
{
llListenRemove(menu_handle);
}
link_message(integer sender, integer num, string msg, key id)
{
if (num == 90007)
{
if (id == CONTROLLER || CONTROLLER == NULL_KEY)
{
controller_menu(id);
}
else
{
string text = "Take control of the menu?";
if (llGetAgentSize(CONTROLLER) != ZERO_VECTOR)
{
text += "\n\nCurrently controlled by: " + CONTROLLER_NAME;
}
dialog(text, ["Take Control", "[CANCEL]"], id);
}
}
else if (num == 90206)
{
DESIGNATIONS_NOW = llParseStringKeepNulls(msg, ["|"], []);
}
}
listen(integer channel, string name, key id, string message)
{
llListenRemove(menu_handle);
integer index = llListFindList(SITTERS_SHORTNAMES, [message]);
if (~index)
{
if (check_for_RLV())
{
llMessageLinked(LINK_THIS, 90100, "x|Control...|" + llList2String(SITTERS_MENUKEYS, index), CONTROLLER);
}
else
{
llMessageLinked(LINK_SET, 90005, "", llDumpList2String([CONTROLLER, llList2Key(SITTERS_MENUKEYS, index)], "|"));
}
}
else if (message == "Capture...")
{
llMessageLinked(LINK_THIS, 90211, "", id);
}
else if (message == "Take Control")
{
llMessageLinked(LINK_SET, 90033, "", "");
if (id != CONTROLLER)
{
llRegionSayTo(CONTROLLER, 0, llKey2Name(id) + " has taken control of the menu.");
}
controller_menu(id);
}
}
changed(integer change)
{
if (llGetAgentSize(llGetLinkKey(llGetNumberOfPrims())) == ZERO_VECTOR)
{
CONTROLLER = NULL_KEY;
}
}
}