// Some useful Unicode graphics for menu operations ⬢⬡☐☑☒🔘◯■□▶▼▲◀
// You may delete these first three lines, they're only used for copying and
// pasting into the source code while writing the script
// Populate the list _menu_all (below) with your attachments.
// First column must always be "Attach"
// Second column is a short name for the attachment
// The short name is the name which will appear in the "Attach" menu when the
// attachment containing this menu script is clicked.
// The short name is also the folder name for the attachment in the #RLV folder
// the folder name will also have the attachment point in paranthesis
// example: Bow (neck)
// the list of attachment points can be found in the rlv api (google for it)
// and are:
// none,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
// HUD attachment points are:
// center 2,top right,top,top left,center,bottom left,bottom,bottom right
// the actual attachment will be in the folder; you do not have to change its name
//
// In your #RLV folder, create a subfolder for your avatar
// example: #RLV/Teddy_Bear
// in the Teddy_Bear folder, create a new folder "Attach"
// example: #RLV/Teddy_Bear/Attach
// in the Attach folder, create a folder for each attachment
// Keep it SHORT! It will be used as a menu item
// You will need to add the attachment point in parenthesis after the name
// example: #RLV/Teddy_Bear/Attach/Bow (neck)
// note the space before (neck)
//
// Replace "Teddy_Bear" in _Avatar with the name you will be using for your
// avatar in the #RLV folder
string _Avatar = "Teddy_Bear";
// Replace the two "Attach" items in the _menu_all list with your attachment info
//
list _menu_all = [
"Attach","Bell",
"This shiny bell swings back and forth with a pleasant jingling noise when flicked!",
"Attach","Bow",
"This color changing bow makes your bear look ever so stylish!",
"Cage","Hook",
"Keeps teddy from getting lost or underfoot by hanging them out of the way!",
"Cage","BalloonWrap",
"Keep your bear all wrapped up and shiny and ready to bounce in place!",
"Cage","Box",
"Lost bear? Keep it un a box until someone comes along to collect them!"
];
list _menu_cages = [
"Hook", "Bear Hook",
"BalloonWrap", "Updated Teddy Bear Avatar Balloon Wrap 1.04",
"Box", "Lost & Found Box"
];
string _me = "bear nose";
key _id_agent;
integer _dlg_ch;
integer _dlg_hdl;
integer _dlg_wait = 10;
integer _owner_ch;
integer _viewer_ch;
list _menu_main = [];
list _menu_sub = [];
string _menu_context = "main";
string _selected_type;
string _selected_item;
integer _attach_i;
integer _attach_n;
key _kBearHook;
key _kBubble;
say(string s)
{
string saved_obj_name;
saved_obj_name=llGetObjectName();
llSetObjectName(":");
llSay(0,s);
llSetObjectName(saved_obj_name);
}
setMainMenu()
{
integer i = 0;
integer n = llGetListLength(_menu_all);
string sType;
for (i=0; i< n; i+=3) {
sType = llList2String(_menu_all,i);
if (llListFindList(_menu_main, [sType]) == -1) {
_menu_main += [sType];
}
}
}
subMenuInit(string searchType)
{
_menu_sub = []; // clear previous contents
string sType;
integer n = llGetListLength(_menu_all);
integer i = 0;
_attach_i = 0;
_attach_n = 0;
_selected_item = "";
for (i=0; i<n; i+=3) {
sType = llList2String(_menu_all,i);
if (searchType == sType) {
_attach_n++;
}
}
}
setSubMenu(string searchType)
{
_menu_sub = []; // clear previous contents
string sType;
string sItem;
integer n = llGetListLength(_menu_all);
integer i = 0;
for (i=0; i<n; i+=3) {
sType = llList2String(_menu_all,i);
if (searchType == sType) {
sItem = llList2String(_menu_all,i+1);
_menu_sub += [sItem];
}
}
}
buildSubMenu(string searchType)
{
string sType;
string sItem;
string sRLVCmd;
integer n = llGetListLength(_menu_all);
integer i = 0;
for (i = _attach_i*3; i<n; i+=3) {
sType = llList2String(_menu_all,i);
sItem = llList2String(_menu_all,i+1);
if (searchType == sType) {
if (searchType == "Attach") {
string folder = "/"+_Avatar+"/"+sType+"/"+sItem;
sRLVCmd = "@getinvworn:"+folder+"="+(string)_viewer_ch;
llOwnerSay(sRLVCmd);
jump break;
}
}
}
call_menu();
@break;
}
call_menu()
{
llSetTimerEvent(_dlg_wait);
llListenControl(_dlg_hdl, TRUE);
if (_menu_context == "main") {
llDialog(_id_agent, "Main", _menu_main, _dlg_ch);
}
else if (_menu_context = "sub") {
llDialog(_id_agent, _selected_type, _menu_sub, _dlg_ch);
}
}
default
{
state_entry()
{
_dlg_ch = (integer)("0x"+llGetSubString((string)llGetKey(),-8,-1))+10;
_dlg_hdl = llListen(_dlg_ch,"","","");
_owner_ch = (integer)("0x"+llGetSubString((string)llGetOwner(),-8,-1));
_viewer_ch = llAbs((integer)("0x"+llGetSubString((string)llGetKey(),-8,-1)));
llListen(_owner_ch,"","","");
llListen(_viewer_ch,"","","");
setMainMenu();
}
on_rez(integer startup_param)
{
llResetScript();
}
changed(integer change)
{
if(change & CHANGED_OWNER) {
llResetScript();
}
if (change & CHANGED_INVENTORY) {
llOwnerSay("Resetting script due to change in inventory");
llResetScript();
}
}
listen(integer ch, string name, key id, string msg)
{
llSetTimerEvent(0);
llListenControl(_dlg_hdl, FALSE);
if (ch == _owner_ch) {
list lMsg = llParseString2List(msg, ["|"], []);
string src = llList2String(lMsg,0);
string tgt = llList2String(lMsg,1);
string cmd = llList2String(lMsg,2);
string arg = llList2String(lMsg,3);
if (tgt == _me) {
if (src == "bear hook") {
if (cmd == "ping") {
_kBearHook = id;
llSay(_owner_ch, _me+"|bear hook|pong|"+(string)llGetOwner());
}
}
else if (src == "bubble") {
if (cmd == "ping") {
_kBubble = id;
llSay(_owner_ch, _me+"|bubble|pong|"+(string)llGetOwner());
}
}
}
}
else if (ch == _viewer_ch) {
string item = llList2String(_menu_all, (_attach_i*3)+1);
if (llGetSubString(msg,0,0) == "|") {
if (llGetSubString(msg,1,1) == "3") {
_menu_sub += ["■ "+item];
}
else if (llGetSubString(msg,1,1) == "1") {
_menu_sub += ["□ "+item];
}
}
_attach_i++;
buildSubMenu(_selected_type);
}
else if (ch == _dlg_ch && _menu_context == "main") {
if (llListFindList(_menu_main, [msg]) != -1) {
_menu_context = "sub";
_selected_type = msg;
if (_selected_type == "Attach") {
subMenuInit(_selected_type);
buildSubMenu(_selected_type);
}
else if (_selected_type == "Cage") {
_menu_context = "sub";
setSubMenu(_selected_type);
call_menu();
}
}
}
else if (ch == _dlg_ch && _menu_context == "sub") {
if (_selected_type == "Attach") {
string sWorn = llGetSubString(msg,0,0);
integer worn = FALSE;
if (sWorn == "■") worn = TRUE;
string item = llGetSubString(msg, 2, -1);
string fqpItem = "/"+_Avatar+"/"+_selected_type+"/"+item;
string sRLVCmd;
_menu_context = "main";
if (!worn) {
integer i = llListFindList(_menu_sub, [msg]);
llInstantMessage(_id_agent, llList2String(_menu_all, (i*3)+2));
sRLVCmd = "@attachover:"+fqpItem+"=force";
}
else {
sRLVCmd = "@detach:"+fqpItem+"=force";
}
llOwnerSay(sRLVCmd);
}
else if (_selected_type == "Cage") {
string item = msg;
integer i = llListFindList(_menu_all, [item]);
llOwnerSay("i="+(string)i);
llInstantMessage(_id_agent, llList2String(_menu_all, i+1));
llInstantMessage(_id_agent, "Rez the "+item+" on the ground near you");
i = llListFindList(_menu_cages, [item]);
llOwnerSay("i="+(string)i);
string s = llList2String(_menu_cages, i+1);
llOwnerSay("s="+s);
llGiveInventory(_id_agent, s);
}
}
}
touch_start(integer num_detected)
{
_id_agent = llDetectedKey(0);
call_menu();
}
timer()
{
llSetTimerEvent(0.0);
_menu_context = "main";
llListenControl(_dlg_hdl, FALSE);
}
}