Difference between revisions of "Tail Messages (NewAge)"
Jump to navigation
Jump to search
m (<lsl> tag to <source>) |
(Replaced <source> with <syntaxhighlight>; minor syntax/grammar revisions; added to LSL Examples category) |
||
Line 1: | Line 1: | ||
=New Age Tail Click Script= | |||
Copy and Paste this into your tail and edit some things you may want to change like the | Copy and Paste this into your tail and edit some things you may want to change like the {{code|announce_type}} and {{tooltip|menu timeout|seconds_till_menu_timeout}}. | ||
To add more options, go to the list buttons, after "Kiss" you need to add a , then new space so it's like this | To add more options, go to the list buttons, after "Kiss" you need to add a <kbd>,</kbd> then new space so it's like this: | ||
< | <syntaxhighlight lang="lsl2">"Kiss", | ||
"New button here" | "New button here" | ||
]; | ]; | ||
</ | </syntaxhighlight> | ||
As you add new buttons, you need to add to the messages as well in the same order as the buttons otherwise it will mess up. | As you add new buttons, you need to add to the messages as well in the same order as the buttons otherwise it will mess up. | ||
< | <syntaxhighlight lang="lsl2"> | ||
///////////////////////////////// | ///////////////////////////////// | ||
// New Age Tail Click Script | // New Age Tail Click Script | ||
Line 19: | Line 19: | ||
string announce_type = "say"; | string announce_type = "say"; | ||
// Replace say with either | // Replace say with either: | ||
// "shout" = to shout out messages | // "shout" = to shout out messages | ||
// "whisper" = to whisper the messages | // "whisper" = to whisper the messages | ||
Line 152: | Line 152: | ||
} | } | ||
} | } | ||
</ | </syntaxhighlight> | ||
[[Category:LSL Examples]] |
Latest revision as of 09:30, 24 September 2022
New Age Tail Click Script
Copy and Paste this into your tail and edit some things you may want to change like the announce_type
and menu timeout.
To add more options, go to the list buttons, after "Kiss" you need to add a , then new space so it's like this:
"Kiss",
"New button here"
];
As you add new buttons, you need to add to the messages as well in the same order as the buttons otherwise it will mess up.
/////////////////////////////////
// New Age Tail Click Script
// By Asia Snowfall
// Version 1.0
/////////////////////////////////
string announce_type = "say";
// Replace say with either:
// "shout" = to shout out messages
// "whisper" = to whisper the messages
float seconds_till_menu_timeout = 30;
list buttons = [
"Hug",
"Stroke",
"Kiss"
];
list messages = [
"<users_first_name> picks up <owners_first_name>'s tail and hugs it gently",
"<users_first_name> gently strokes their fingers through <owners_first_name>'s tail",
"<users_first_name> picks up <owners_first_name>'s tail and kisses it"
];
string menu_text = "<owners_first_name>'s Tail Menu\nWhat do you want to do with my tail <users_first_name>?";
// Message Tags;
// <users_first_name> = Person clicking the button's first name will appear there
// <users_last_name> = Person clicking the button's last name will appear there
// <owners_first_name> = Tail owners first name will appear there
// <owners_last_name> = Tail owners last name will appear there
integer chan;
integer hand;
asMenuSetup(key id)
{
llListenRemove(hand);
chan = llRound(llFrand(99999)+10);
hand = llListen(chan, "", id, "");
if(llGetListLength(buttons) > 12)
{
llOwnerSay("Error: There is more than 12 options, please reduce the ammount");
}
else
{
llDialog(id, asTagScan(menu_text, id), buttons, chan);
}
}
asCheckSelected(string message, key id)
{
llListenRemove(hand);
integer index = llListFindList(buttons, [message]);
if(index != -1)
{
if(llToLower(announce_type) == "say")
{
llSay(0, asTagScan(llList2String(messages, index), id));
}
else if(llToLower(announce_type) == "shout")
{
llShout(0, asTagScan(llList2String(messages, index), id));
}
else
{
llWhisper(0, asTagScan(llList2String(messages, index), id));
}
}
}
string asTagScan(string message, key user)
{
integer ufn = llStringLength("<users_first_name>")-1;
integer uln = llStringLength("<users_last_name>")-1;
integer ofn = llStringLength("<owners_first_name>")-1;
integer oln = llStringLength("<owners_last_name>")-1;
list parse = llParseString2List(llKey2Name(user), [" "], []);
string user_first_name = llList2String(parse, 0);
string user_last_name = llList2String(parse, 1);
parse = llParseString2List(llKey2Name(llGetOwnerKey(llGetKey())), [" "], []);
string owner_first_name = llList2String(parse, 0);string owner_last_name = llList2String(parse, 1);integer ind;integer ind2;integer own;integer own2;integer done = FALSE;
do
{
@recheck;
ind = llSubStringIndex(message, "<users_first_name>");
ind2 = llSubStringIndex(message, "<users_last_name>");
own = llSubStringIndex(message, "<owners_first_name>");
own2 = llSubStringIndex(message, "<owners_last_name>");
if(ind != -1)
{
message = llDeleteSubString(message, ind, (ind+ufn));
message = llInsertString(message, ind, user_first_name);
jump recheck;
}
else if(ind2 != -1)
{
message = llDeleteSubString(message, ind2, (ind2+uln));
message = llInsertString(message, ind2, user_last_name);
jump recheck;
}
else if(own != -1)
{
message = llDeleteSubString(message, own, (own+ofn));
message = llInsertString(message, own, owner_first_name);
jump recheck;
}
else if(own2 != -1)
{
message = llDeleteSubString(message, own2, (own2+oln));
message = llInsertString(message, own2, owner_last_name);
jump recheck;
}
else if(ind == -1 && ind2 == -1 && own == -1 && own2 == -1)
{
done = TRUE;
}
}while(done < FALSE);
return message;
}
default
{
touch_start(integer x)
{
asMenuSetup(llDetectedKey(0));
llSetTimerEvent(seconds_till_menu_timeout);
}
listen(integer channel, string name, key id, string str)
{
asCheckSelected(str, id);
}
timer()
{
llListenRemove(hand);
llSetTimerEvent(0);
}
}