Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Discussion: Face expression animations script

Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
07-17-2005 06:54
It has taken around a one third year since I began to learn LSL who didn't know any program language. I go on much these sample scritpts in this forum. I return a favor even though a little.
This is a face expression animations script. It is used a built-in animatiions.
CODE
// Created by Seagel Neville
// Thanks to Catherine Omega, the dialog boxes came to keep showing.
// You can not only just put this script in your attached object, but also
// put into a prim you rez to execute.

integer CHANNEL = 42; // dialog channel

list MENU_UNHAPPY = // The limit of dialog is only twelve. So I cannot help
[ // separating the list.
"disdain", "repulsed", "anger",
"bored", "sad", "cry",
"embarrased", "frawn","shrug",
"afraid", "worry", "surprise"
];

list MENU_HAPPY =
[
"wink", "toungue out", "kiss",
"toothesmile", "smile", "laugh",
"open mouth"
];


default {
state_entry()
{
llListen(CHANNEL, "", NULL_KEY, "");
llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
llInstantMessage(llGetOwner(), "Just typing \"/42menu\", you can express your emotions");
}
on_rez(integer total_number)
{
llResetScript();
}
listen(integer channel, string name, key id, string message)
{

if (llListFindList(MENU_UNHAPPY, [message]) != -1) // verify dialog choice
{
if (message == "afraid")
{
llStartAnimation("express_afraid_emote");
}
if (message == "anger")
{
llStartAnimation("express_anger_emote");
}
if (message == "bored")
{
llStartAnimation("express_bored_emote");
}
if (message == "cry")
{
llStartAnimation("express_cry_emote");
}
if (message == "disdain")
{
llStartAnimation("express_disdain");
}
if (message == "embarrased")
{
llStartAnimation("express_embarrassed_emote");
}
if (message == "frawn")
{
llStartAnimation("express_frown");
}
if (message == "repulsed")
{
llStartAnimation("express_repulsed_emote");
}
if (message == "sad")
{
llStartAnimation("express_sad_emote");
}
if (message == "shrug")
{
llStartAnimation("express_shrug_emote");
}
if (message == "surprise")
{
llStartAnimation("express_surprise_emote");
}
if (message == "worry")
{
llStartAnimation("express_worry_emote");
}
llDialog(llGetOwner(), "What do you want to express?", MENU_UNHAPPY, CHANNEL);
// The dialog box keeps showing until you chose "Ignore".
}
if (llListFindList(MENU_HAPPY, [message]) != -1) // verify dialog choice
{
if (message == "kiss")
{
llStartAnimation("express_kiss");
}
if (message == "laugh")
{
llStartAnimation("express_laugh_emote");
}
if (message == "open mouth")
{
llStartAnimation("express_open_mouth");
}
if (message == "smile")
{
llStartAnimation("express_smile");
}

if (message == "toungue out")
{
llStartAnimation("express_tongue_out");
}
if (message == "toothesmile")
{
llStartAnimation("express_toothsmile");
}
if (message == "wink")
{
llStartAnimation("express_wink_emote");
}
llDialog(llGetOwner(), "What do you want to express?", MENU_HAPPY, CHANNEL);
// The dialog box keeps showing until you chose "Ignore".
}
else if (message == "menu")
//If you cleard the dialog boxes, you could recall them by /42menu.
{
llDialog(llGetOwner(), "What do you want to express?", MENU_UNHAPPY, CHANNEL);
llDialog(llGetOwner(), "What do you want to express?", MENU_HAPPY, CHANNEL);
}
}
}

Hope you enjoy it. :)
_____________________
:) Seagel Neville :)
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
original thread
07-19-2005 21:49
/15/ef/54153/1.html
_____________________
i've got nothing. ;)
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
07-27-2005 13:06
Leanne Burleigh improved this script and sent me in world. I got her acceptance and post it here.
CODE
// Leanne Burleigh improved this script.

// Adding an event "changed"

// Created by Seagel Neville
// Thanks to Catherine Omega, the dialog boxes came to keep showing.
// You can not only just put this script in your attached object, but also
// put into a prim you rez to execute.

integer CHANNEL = 42; // dialog channel

list MENU_UNHAPPY = // The limit of dialog is only twelve. So I cannot help
[ // separating the list.
"disdain", "repulsed", "anger",
"bored", "sad", "cry",
"embarrased", "frown","shrug",
"afraid", "worry", "surprise"
];

list UNHAPPY_EMOTES = // List of the emotes each command triggers; same order as MENU_UNHAPPY
[
"express_disdain","express_repulsed_emote","express_anger_emote",
"express_bored_emote","express_sad_emote","express_cry_emote",
"express_embarrassed_emote","express_frown","express_shrug_emote",
"express_afraid_emote","express_worry_emote","express_surprise_emote"
];

list MENU_HAPPY =
[
"wink", "toungue out", "kiss",
"toothesmile", "smile", "laugh",
"open mouth"
];

list HAPPY_EMOTES = // List of the emotes each command triggers; same order as MENU_HAPPY
[
"express_wink_emote","express_tongue_out","express_kiss",
"express_toothsmile","express_smile","express_laugh_emote",
"express_open_mouth"
];


default {
state_entry()
{
//llListen(CHANNEL, "", NULL_KEY, "");

//I believe you only want to listen for when the owner triggers it...?
//Else people can have way too much fun making you do things *giggle*

llListen(CHANNEL, "", llGetOwner(), "");

llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);

// llInstantMessage(llGetOwner(), "Just typing \"/42menu\", you can express your emotions");

// That above line works fine, but seeing as how you made the channel configurable; how about a bit
// of flexibility so you don't have to change that line if you change channel? ^.-

string channelPrefix = "";

if (CHANNEL != 0) channelPrefix = "/"+(string)CHANNEL; // If it's not listening on the main channel, prefix message with a "/channel", e.g. "/42"

llInstantMessage(llGetOwner(), "Just typing \""+channelPrefix+"menu\", you can express your emotions");


//Optionally, use llOwnerSay(...) instead of llInstantMessage(llGetOwner(),...):
//Less intrusive and saves you the 3 second delay
}
on_rez(integer total_number)
{
llResetScript();
}
changed(integer change)
{
if (change & 128)
{
llResetScript();
}
}
listen(integer channel, string name, key id, string message)
{

if (llListFindList(MENU_UNHAPPY, [message]) != -1) // verify dialog choice
{
llStartAnimation(
llList2String(UNHAPPY_EMOTES,
llListFindList(MENU_UNHAPPY, [message])
)
);
llDialog(llGetOwner(), "What do you want to express?", MENU_UNHAPPY, CHANNEL);
// The dialog box keeps showing until you choose "Ignore".
}
else if (llListFindList(MENU_HAPPY, [message]) != -1) // verify dialog choice
{
llStartAnimation(
llList2String(HAPPY_EMOTES,
llListFindList(MENU_HAPPY, [message])
)
);
llDialog(llGetOwner(), "What do you want to express?", MENU_HAPPY, CHANNEL);
// The dialog box keeps showing until you choose "Ignore".
}
else if (message == "menu")
//If you cleard the dialog boxes, you could recall them by /42menu.
{
llDialog(llGetOwner(), "What do you want to express?", MENU_UNHAPPY, CHANNEL);
llDialog(llGetOwner(), "What do you want to express?", MENU_HAPPY, CHANNEL);
}
}
}
_____________________
:) Seagel Neville :)
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
08-02-2005 05:50
I made this keep doing animations inspired by Gattz Gilman. And made it change channel number randomly. :)
CODE
// Seagel improved to make this keep animation. Inspired by Gattz Gilman.
// Made channle number be assigned randomly.

// Leanne Burleigh improved this script.

// Seagel added an event "changed" by way of precaution

// Created by Seagel Neville
// Thanks to Catherine Omega, the dialog boxes came to keep showing.
// You can not only just put this script in your attached object, but also
// put into a prim you rez to execute.

integer CHANNEL; // dialog channel. It supposed to be changed in random order.
string channelPrefix = "";
string ANIMATION;

list MENU_UNHAPPY = // The limit of dialog is only twelve. So I cannot help
[ // separating the list.
"disdain", "repulsed", "anger",
"bored", "sad", "cry",
"embarrased", "frown","shrug",
"afraid", "worry", "surprise"
];

list UNHAPPY_EMOTES = // List of the emotes each command triggers; same order as MENU_UNHAPPY
[
"express_disdain","express_repulsed_emote","express_anger_emote",
"express_bored_emote","express_sad_emote","express_cry_emote",
"express_embarrassed_emote","express_frown","express_shrug_emote",
"express_afraid_emote","express_worry_emote","express_surprise_emote"
];

list MENU_HAPPY =
[
"wink", "toungue out", "kiss",
"toothe smile", "smile", "laugh",
"stop", "open mouth"
];

list HAPPY_EMOTES = // List of the emotes each command triggers; same order as MENU_HAPPY
[
"express_wink_emote","express_tongue_out","express_kiss",
"express_toothsmile","express_smile","express_laugh_emote",
"stop", "express_open_mouth"
];

opendialog_unhappy()
{
llDialog(llGetOwner(), "What do you want to express?", MENU_UNHAPPY, CHANNEL);
}

opendialog_happy()
{
llDialog(llGetOwner(), "What do you want to express?", MENU_HAPPY, CHANNEL);
}


default {
state_entry()
{
CHANNEL = llRound(llFrand(89) + 10); // This supposed to be changed randomly from 10 to 99.
llListen(CHANNEL, "", llGetOwner(), "");
if (!(llGetPermissions() & PERMISSION_TRIGGER_ANIMATION))
{
llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
}
if (CHANNEL != 0) channelPrefix = "/"+(string)CHANNEL;
// If it's not listening on the main channel, prefix message with a "/channel", e.g. "/42"
llOwnerSay("Just typing \""+channelPrefix + "menu\", you can express your emotions.");
}
on_rez(integer total_number)
{
llResetScript();
}
changed(integer change) // You'd better put the this changed() event when you use llGetOwner
{ // by way of precaution.
if (change & 128)
{
llResetScript();
}
}
timer()
{
llStopAnimation(ANIMATION);
llStartAnimation(ANIMATION);
}
listen(integer channel, string name, key id, string message)
{
if (llListFindList(MENU_UNHAPPY, [message]) != -1) // verify dialog choice
{
llOwnerSay("You can change emotions. Press \"stop\" button or type \""+channelPrefix
+ "stop\" if you want to stop this animation.");
opendialog_unhappy(); // The dialog box keeps showing until you choose "Ignore".
ANIMATION = llList2String(UNHAPPY_EMOTES, llListFindList(MENU_UNHAPPY, [message]));
llSetTimerEvent(0.5);
}
if (llListFindList(MENU_HAPPY, [message]) != -1) // verify dialog choice
{
if(message == "stop")
{
opendialog_happy(); // The dialog box keeps showing until you choose "Ignore".
llSetTimerEvent(0);
llOwnerSay("Stop animation.");
}
else
{
llOwnerSay("You can change emotions. Press \"stop\" button or type \""+channelPrefix
+ "stop\" if you want to stop this animation.");
opendialog_happy(); // The dialog box keeps showing until you choose "Ignore".
ANIMATION = llList2String(HAPPY_EMOTES, llListFindList(MENU_HAPPY, [message]));
llSetTimerEvent(0.5);
}
}
else if (message == "menu")
//If you cleard the dialog boxes, you could recall them by /42menu.
{
opendialog_unhappy();
opendialog_happy();
}
}
}
_____________________
:) Seagel Neville :)
Tarina Sewell
Just Browsing Thank you
Join date: 20 Jul 2007
Posts: 2,180
11-11-2009 12:52
great script! Thank you! Makes my candle holding animation brilliant with the facial expressions!!! HUGS! :D
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
11-11-2009 14:01
WooHoo! Four years, three months, and nine days! :D
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at
Jeredin Denimore
Romani Ite Domum
Join date: 5 Jul 2008
Posts: 95
11-12-2009 15:03
From: Rolig Loon
WooHoo! Four years, three months, and nine days! :D


Heh better a necrothankyou than not searching the forums to see if it's been answered before :)