The 2.0 includes these new features:
attachmessage: whispered message when attach
detachmessage: whispered message when detach
siptime: time between each sip
drinktime: total drinking time (0 for infinite)
____
All this configured by notecard. Please do not resell this by itself, of course you can use it in your own creations.
For this script you will need two animations:
'sip rest loop'
'sipping sl'
They are free and you can get them in lot of places, If you don't have them send me an IM.
Script:
// Original sip script By Theda Twilight
// Animations by Robin Sojourner
// Attach/detach message + drinking time configuration by Kahiro Watanabe
key drinker; //agent wearing the object
// This data is taken from notecard //
string attachMessage; //whispered message on attach
string detachMessage; //whispered message on detach
float sipTime; //time between each sip
float drinkTime; //total drink time
///////////////////////////////////////
float currentDrinkTime; //keeps track of current drink time
// for dataserver queries //
key notecardQuery;
integer notecardLine;
default
{
state_entry()
{
drinker = llGetOwner();
notecardLine = 0;
notecardQuery = llGetNotecardLine("!config",notecardLine);
}
attach(key attached)
{
if (attached) // someone is wearing it
{
drinker = attached;
notecardLine = 0;
notecardQuery = llGetNotecardLine("!config",notecardLine);
}
}
dataserver(key queryId, string data)
{
if (queryId == notecardQuery)
{
if (data != EOF)
{
if (llGetSubString(data,0,0) != "#"
// keep passing lines until finds a "#"
{
notecardLine = notecardLine + 1;
notecardQuery = llGetNotecardLine("!config",notecardLine);
}
else if (data != EOF) // "#" was found, time to read configuration
{
list tempList = llParseString2List(data, [",","#"],[]);
string tempString = llToLower(llList2String(tempList,0));
string tempString2 = llList2String(tempList,1);
if (tempString == "attachmessage"
{
attachMessage = tempString2;
}
else if (tempString == "detachmessage"
{
detachMessage = tempString2;
}
else if (tempString == "siptime"
{
sipTime = (float)tempString2;
}
else if (tempString == "drinktime"
{
drinkTime = (float)tempString2;
}
notecardLine = notecardLine + 1;
notecardQuery = llGetNotecardLine("!config",notecardLine);
}
}
else // end of notecard reached go to 'ready' state
{
state ready;
}
}
}
}
state ready
{
state_entry() // when state is entered permissions are requested
{
llRequestPermissions(drinker, PERMISSION_TRIGGER_ANIMATION);
}
attach(key id) // this is because a LSL bug next time cup is attached script will start in this state
{ // and we don't want that so this takes the script to default state
if (id != NULL_KEY)
{
llResetScript();
}
}
run_time_permissions(integer perms)
{
if(perms & PERMISSION_TRIGGER_ANIMATION)
{
if (attachMessage != ""
llWhisper(0,attachMessage); // 'attachMessage' is whispered
llSetTimerEvent(0.1); // lets go to the timer
llStartAnimation("sip rest loop"
; // and start the base animation
}
}
timer()
{
llStartAnimation("sipping sl"
;
if ((currentDrinkTime < drinkTime) | (drinkTime == 0)) // keep drinkning until time is over (or drinktime equals zero)
{
llSetTimerEvent(sipTime);
}
else if (drinkTime != 0) // stop drinking if time is over
{
if (detachMessage != ""
llWhisper(0,detachMessage);
llStopAnimation("sip rest loop"
;
llStopAnimation("sipping sl"
;
llSetTimerEvent(0.0);
llDetachFromAvatar();
}
currentDrinkTime = currentDrinkTime + sipTime; // keeps track of current drink time
}
}
// Animations by Robin Sojourner
// Attach/detach message + drinking time configuration by Kahiro Watanabe
key drinker; //agent wearing the object
// This data is taken from notecard //
string attachMessage; //whispered message on attach
string detachMessage; //whispered message on detach
float sipTime; //time between each sip
float drinkTime; //total drink time
///////////////////////////////////////
float currentDrinkTime; //keeps track of current drink time
// for dataserver queries //
key notecardQuery;
integer notecardLine;
default
{
state_entry()
{
drinker = llGetOwner();
notecardLine = 0;
notecardQuery = llGetNotecardLine("!config",notecardLine);
}
attach(key attached)
{
if (attached) // someone is wearing it
{
drinker = attached;
notecardLine = 0;
notecardQuery = llGetNotecardLine("!config",notecardLine);
}
}
dataserver(key queryId, string data)
{
if (queryId == notecardQuery)
{
if (data != EOF)
{
if (llGetSubString(data,0,0) != "#"

{
notecardLine = notecardLine + 1;
notecardQuery = llGetNotecardLine("!config",notecardLine);
}
else if (data != EOF) // "#" was found, time to read configuration
{
list tempList = llParseString2List(data, [",","#"],[]);
string tempString = llToLower(llList2String(tempList,0));
string tempString2 = llList2String(tempList,1);
if (tempString == "attachmessage"

{
attachMessage = tempString2;
}
else if (tempString == "detachmessage"

{
detachMessage = tempString2;
}
else if (tempString == "siptime"

{
sipTime = (float)tempString2;
}
else if (tempString == "drinktime"

{
drinkTime = (float)tempString2;
}
notecardLine = notecardLine + 1;
notecardQuery = llGetNotecardLine("!config",notecardLine);
}
}
else // end of notecard reached go to 'ready' state
{
state ready;
}
}
}
}
state ready
{
state_entry() // when state is entered permissions are requested
{
llRequestPermissions(drinker, PERMISSION_TRIGGER_ANIMATION);
}
attach(key id) // this is because a LSL bug next time cup is attached script will start in this state
{ // and we don't want that so this takes the script to default state
if (id != NULL_KEY)
{
llResetScript();
}
}
run_time_permissions(integer perms)
{
if(perms & PERMISSION_TRIGGER_ANIMATION)
{
if (attachMessage != ""

llWhisper(0,attachMessage); // 'attachMessage' is whispered
llSetTimerEvent(0.1); // lets go to the timer
llStartAnimation("sip rest loop"

}
}
timer()
{
llStartAnimation("sipping sl"

if ((currentDrinkTime < drinkTime) | (drinkTime == 0)) // keep drinkning until time is over (or drinktime equals zero)
{
llSetTimerEvent(sipTime);
}
else if (drinkTime != 0) // stop drinking if time is over
{
if (detachMessage != ""

llWhisper(0,detachMessage);
llStopAnimation("sip rest loop"

llStopAnimation("sipping sl"

llSetTimerEvent(0.0);
llDetachFromAvatar();
}
currentDrinkTime = currentDrinkTime + sipTime; // keeps track of current drink time
}
}
Notecard:
Sip script 2.0 with timer
Help:
attachmessage: whispered message when attach
detachmessage: whispered message when detach
siptime: time between each sip
drinktime: total drinking time (0 for infinite)
--------------------------------------------------------------------------------------------------------------------
Notecard configuration:
#attachmessage,Enjoy it
#detachmessage,Mmmhhh that was yummy!
#siptime,4
#drinktime,20
Help:
attachmessage: whispered message when attach
detachmessage: whispered message when detach
siptime: time between each sip
drinktime: total drinking time (0 for infinite)
--------------------------------------------------------------------------------------------------------------------
Notecard configuration:
#attachmessage,Enjoy it
#detachmessage,Mmmhhh that was yummy!
#siptime,4
#drinktime,20