Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Library: Sip Script 2.0

Kahiro Watanabe
Registered User
Join date: 28 Sep 2007
Posts: 572
10-25-2008 17:28
This is a modification/improvment of the "Sip Script" (script) if I'm not wrong the original script is from Theda Twilight.

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:

From: someone
// 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
}
}



Notecard:

From: someone
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
_____________________
Jocko Domo japanese goods



[Blog]
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Library bump
11-12-2008 06:10
:)
_____________________
i've got nothing. ;)
BigJohn Jade
Registered User
Join date: 5 Aug 2003
Posts: 93
Drinking script.
11-04-2009 18:12
Not bad for a free version of a drinking script. :)

If anyone is looking for more pro like version then check this url out.

https://xstreetsl.com/modules.php?name=Marketplace&file=item&ItemID=1894162
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
11-05-2009 03:28
EDIT TO WORD THIS MORE NICELY

BigJohn please remove your post. You have been around long enough to know that this is not the place for advertisements.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum