Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

SN_AnimVendor

Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
05-20-2006 06:41
Hello there,

This is just one prim simple neat animation vendor.

:::USAGE:::
Just put this script into a prim. It changes the shape to a pedestal automatically. If you don't like it, just comment out Transform(); line under the state_entry(). And put your animations into the pedestal.
You can put your animations up to 36. (You can modify this)

*How to change the default price
Change value on the following section on the script. It means L$10. The default price affects all animations unless you designate a special price on each animation.

//////////////// Set default price here /////////////////////
integer def_PRICE = 10;
//////////////////////////////////////////////////////////

* How to change each animation's price
Add "L$" and price value on your animation?s name. For example, "YourAnimNameL$100". You can sell it for L$100. I recommend you set modifiable to your selling animations so that buyers can change their names after buying.

CODE
// Simple neat anim vendor was made by Seagel Neville as public domain, May 2006.
// modified by Kru Flan.
// Recreated by Seagel Neville.(ver0.2)
// ver0.3 released May 20th 2006.

///////////////////////// Set default price here ////////////////////////////////

integer def_PRICE = 10;

/////////////////////////////////////////////////////////////////////////

integer PRICE;
integer CHANNEL;
integer ListenHandle;
list AnimList;
list AnimList1;
list AnimList2;
list AnimList3;
integer AllAnimNum;
string ANIMATION;
key AVKey;
integer AnimNum;
string AnimName;
integer OpenedDialog;

GenCHANNEL()
{
CHANNEL = -(integer)(llFrand(100000 - 10000) + 10000);
}

GenDIALOG(key id)
{
llListenControl(ListenHandle, TRUE);
if(OpenedDialog == FALSE)
{
OpenedDialog = TRUE;
if(AllAnimNum < 13)
{
llDialog(id, "Right-click on the pedestal and \"Pay\" amount to purchase.", AnimList1, CHANNEL);
}
else if(AllAnimNum < 25)
{
llDialog(id, "Right-click on the pedestal and \"Pay\" amount to purchase.", AnimList2, CHANNEL);
llDialog(id, "Right-click on the pedestal and \"Pay\" amount to purchase.", AnimList1, CHANNEL);
}
else if(AllAnimNum < 37)
{
llDialog(id, "Right-click on the pedestal and \"Pay\" amount to purchase.", AnimList3, CHANNEL);
llDialog(id, "Right-click on the pedestal and \"Pay\" amount to purchase.", AnimList2, CHANNEL);
llDialog(id, "Right-click on the pedestal and \"Pay\" amount to purchase.", AnimList1, CHANNEL);
}
}
else
{
if(AnimNum < 12)
{
llDialog(id, "Right-click on the pedestal and \"Pay\" amount to purchase.", AnimList1, CHANNEL);
}
else if(AnimNum >= 12 && AnimNum < 24)
{
llDialog(id, "Right-click on the pedestal and \"Pay\" amount to purchase.", AnimList2, CHANNEL);
}
else if(AnimNum >= 24 && AnimNum < 36)
{
llDialog(id, "Right-click on the pedestal and \"Pay\" amount to purchase.", AnimList3, CHANNEL);
}
}
}

Init()
{
GenCHANNEL();
ListenHandle = llListen(CHANNEL, "", "", "");
llListenControl(ListenHandle, FALSE);
OpenedDialog = FALSE;
AnimList = [];
AnimList1 = [];
AnimList2 = [];
AnimList3 = [];
AllAnimNum = llGetInventoryNumber(INVENTORY_ANIMATION);
integer i;
for(i = 0; i < AllAnimNum; i++)
{
AnimList += llGetInventoryName(INVENTORY_ANIMATION, i);
}
if(AllAnimNum < 13)
{
for(i = 0; i < AllAnimNum; i++)
{
AnimList1 += "ANIM" + (string)(i + 1);
}
}
else if(AllAnimNum < 25)
{
for(i = 0; i < 12; i++)
{
AnimList1 += "ANIM" + (string)(i + 1);
}
for(i = 12; i < AllAnimNum; i++)
{
AnimList2 += "ANIM" + (string)(i + 1);
}
}
else if(AllAnimNum < 37)
{
for(i = 0; i < 12; i++)
{
AnimList1 += "ANIM" + (string)(i + 1);
}
for(i = 12; i < 24; i++)
{
AnimList2 += "ANIM" + (string)(i + 1);
}
for(i = 24; i < AllAnimNum; i++)
{
AnimList3 += "ANIM" + (string)(i + 1);
}
}
}

StartAnim(string ANIM)
{
llStopAnimation(ANIMATION);
ANIMATION = ANIM;
llStartAnimation(ANIMATION);
GenText();
llInstantMessage(AVKey, "Now showing \"" + AnimName + "\"");
}

GenText()
{
integer separator = llSubStringIndex(ANIMATION, "L$");
if(separator == -1)
{
AnimName = ANIMATION;
PRICE = def_PRICE;
}
else
{
AnimName = llGetSubString(ANIMATION, 0, separator - 1);
integer PriceValue = (integer)llGetSubString(ANIMATION, separator + 2, -1);
PRICE = PriceValue;
}
llSetText("item " +(string)(AnimNum+1)+" of "+(string)AllAnimNum+"\n"+ AnimName
+ "\nL$" + (string)PRICE, <0, 1, 0>, 1.0);
llSetPayPrice(PAY_HIDE, [PRICE, PAY_HIDE, PAY_HIDE, PAY_HIDE]);
}

Transform()
{
llSetPrimitiveParams([
PRIM_TYPE, PRIM_TYPE_CYLINDER,
0, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <0.8, 0.8, 0.0>, <0.0, 0.0, 0.0>,
PRIM_SIZE, <1, 1, 0.2>,
PRIM_TEXTURE, ALL_SIDES, "5748decc-f629-461c-9a36-a35a221fe21f", <1,1,0>, <0,0,0>, 0,
PRIM_BUMP_SHINY, 0, PRIM_SHINY_LOW, PRIM_BUMP_NONE,
PRIM_BUMP_SHINY, 1, PRIM_SHINY_LOW, PRIM_BUMP_BRICKS,
PRIM_MATERIAL, PRIM_MATERIAL_STONE
]);
llSetObjectName("SN_AnimVendor");
}


default
{
state_entry()
{
Transform();
llSetSitText("TRY ON");
llSitTarget(<0, 0, 1>, ZERO_ROTATION);
llSetCameraEyeOffset(<2.5, 0, 2>);
llSetCameraAtOffset(<0, 0, 1.5>);
Init();
ANIMATION = llList2String(AnimList, AnimNum);
GenText();
}
changed(integer change)
{
if(change & CHANGED_INVENTORY)
{
Init();
GenText();
ANIMATION = llList2String(AnimList, AnimNum);
}
if(change & CHANGED_LINK)
{
AVKey = llAvatarOnSitTarget();
if (AVKey != NULL_KEY)
{
ANIMATION = llList2String(AnimList, AnimNum);
llRequestPermissions(llAvatarOnSitTarget(), PERMISSION_TRIGGER_ANIMATION);
}
else
{
llStopAnimation(ANIMATION);
OpenedDialog = FALSE;
llListenControl(ListenHandle, FALSE);
}
}
}
run_time_permissions(integer perm)
{
if(perm & PERMISSION_TRIGGER_ANIMATION)
{
llStopAnimation("sit");
llStopAnimation("sit_generic");
llStartAnimation("stand");
GenDIALOG(AVKey);
}
}
listen(integer channel, string name, key id, string message)
{
string FireAnim;
if(llListFindList(AnimList1, [message]) != -1)
{
FireAnim = llList2String(AnimList, llListFindList(AnimList1, [message]));
}
else if(llListFindList(AnimList2, [message]) != -1)
{
FireAnim = llList2String(AnimList, llListFindList(AnimList2, [message]) + 12);
}
else if(llListFindList(AnimList3, [message]) != -1)
{
FireAnim = llList2String(AnimList, llListFindList(AnimList3, [message]) + 24);
}
AnimNum = llListFindList(AnimList, [FireAnim]);
StartAnim(FireAnim);
GenDIALOG(AVKey);
}
money(key giver, integer amount)
{
if(amount == PRICE)
{
llGiveInventory(giver, ANIMATION);
llWhisper(0, "Thank you for purchase, " + llKey2Name(giver));
}
else
{
llWhisper(0, "Sorry, something strangge happened. Plz contact the owner.");
}
}
}
_____________________
:) Seagel Neville :)
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Discussion Thread
05-20-2006 07:00
/54/76/107870/1.html
_____________________
i've got nothing. ;)
Marlon Brocco
Registered User
Join date: 15 Jul 2005
Posts: 132
05-21-2006 10:56
Seagel, is there a way to make this work for Gestures too?
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
SN_AnimVendor II
11-24-2007 00:13
CODE
// Simple neat anim vendor was made by Seagel Neville as public domain, May 2006.
// modified by Kru Flan.
// Recreated by Seagel Neville.(ver0.2)
// ver0.3 released May 20th 2006.
// Showing the name of anims on button and opeining a compact dialog box on ver0.4, Nov 2007.
// Espresso Saarinen advised me a useful function on ver0.52. Nov 2007.
// Void Singer advised me how to eliminate extra lists and make compact codes, Dec 2007.
// Fixed a bug that Argnit Igaly reported on ver0.54. The page number was weird.

///////////////////////// Set default price here ////////////////////////////////

integer def_PRICE = 10;

/////////////////////////////////////////////////////////////////////////

integer PRICE;
integer CHANNEL;
integer ListenHandle;
list AnimList;
list AnimButtonList;
integer AllAnimNum;
string ANIMATION;
key AVKey;
integer AnimNum;
string AnimName;
integer gPage;
integer maxPage;
string msg;
integer freeFlag;


GenCHANNEL()
{
CHANNEL = -(integer)(llFrand(100000 - 10000) + 10000);
}

GenDIALOG(key id, integer page)
{
llListenControl(ListenHandle, TRUE);
msg = "Right-click on the pedestal and \"Pay\" amount to purchase. \n Page:" + (string)(page + 1);
llDialog(id, msg,["<<", "CANCEL", ">>"] + llList2List(AnimButtonList, page * 9, page * 9 + 8), CHANNEL);
//Void Singer advised this.
}

Init()
{
GenCHANNEL();
ListenHandle = llListen(CHANNEL, "", "", "");
llListenControl(ListenHandle, FALSE);
AllAnimNum = llGetInventoryNumber(INVENTORY_ANIMATION);
llOwnerSay("Found " + (string)AllAnimNum + " animations.");
if(AllAnimNum > 0)
{
integer i;
for(i = 0; i < AllAnimNum; i++)
{
string name = llGetInventoryName(INVENTORY_ANIMATION, i);
AnimList += name;
AnimButtonList += llGetSubString(name, 0, 20);
}
maxPage = llCeil(AllAnimNum / 9); //Void Singer advised this.
if(AllAnimNum % 9 == 0) //Fixed on ver0.54
{
--maxPage;
}
}
}

StartAnim(string ANIM)
{
llStopAnimation(ANIMATION);
ANIMATION = ANIM;
llStartAnimation(ANIMATION);
GenText();
llInstantMessage(AVKey, "Now showing \"" + AnimName + "\"");
}

GenText()
{
integer separator = llSubStringIndex(ANIMATION, "L$");
if(separator == -1)
{
AnimName = ANIMATION;
PRICE = def_PRICE;
if(PRICE == 0)
{
freeFlag = TRUE;
llSetText("item " +(string)(AnimNum+1)+" of "+(string)AllAnimNum+"\n"+ AnimName
+ "\nTouch To Take", <0, 1, 0>, 1.0);
return;
}
else
{
freeFlag = FALSE;
}
}
else
{
AnimName = llGetSubString(ANIMATION, 0, separator - 1);
integer PriceValue = (integer)llGetSubString(ANIMATION, separator + 2, -1);
PRICE = PriceValue;
if(PRICE == 0)
{
freeFlag = TRUE;
llSetText("item " +(string)(AnimNum+1)+" of "+(string)AllAnimNum+"\n"+ AnimName
+ "\nTouch To Take", <0, 1, 0>, 1.0);
return;
}
else
{
freeFlag = FALSE;
}
}
llSetText("item " +(string)(AnimNum+1)+" of "+(string)AllAnimNum+"\n"+ AnimName
+ "\nL$" + (string)PRICE, <0, 1, 0>, 1.0);
llSetPayPrice(PAY_HIDE, [PRICE, PAY_HIDE, PAY_HIDE, PAY_HIDE]);
}

Transform()
{
llSetPrimitiveParams([
PRIM_TYPE, PRIM_TYPE_CYLINDER,
0, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <0.8, 0.8, 0.0>, <0.0, 0.0, 0.0>,
PRIM_SIZE, <1, 1, 0.2>,
PRIM_TEXTURE, ALL_SIDES, "5748decc-f629-461c-9a36-a35a221fe21f", <1,1,0>, <0,0,0>, 0,
PRIM_BUMP_SHINY, 0, PRIM_SHINY_LOW, PRIM_BUMP_NONE,
PRIM_BUMP_SHINY, 1, PRIM_SHINY_LOW, PRIM_BUMP_BRICKS,
PRIM_MATERIAL, PRIM_MATERIAL_STONE
]);
llSetObjectName("SN_AnimVendor II");
}


default
{
state_entry()
{
Transform();
llSetSitText("TRY ON");
llSitTarget(<0, 0, 1.2>, ZERO_ROTATION);
llSetCameraEyeOffset(<2.5, 0, 2>);
llSetCameraAtOffset(<0, 0, 1.5>);
Init();
ANIMATION = llList2String(AnimList, AnimNum);
GenText();
llOwnerSay("The rest memory is " + (string)llGetFreeMemory() + " byte.");
}
on_rez(integer reset)
{
llResetScript();
}
changed(integer change)
{
if(change & CHANGED_INVENTORY)
{
llResetScript();
}
if(change & CHANGED_LINK)
{
AVKey = llAvatarOnSitTarget();
if (AVKey != NULL_KEY)
{
ANIMATION = llList2String(AnimList, AnimNum);
llRequestPermissions(llAvatarOnSitTarget(), PERMISSION_TRIGGER_ANIMATION);
}
else
{
llStopAnimation(ANIMATION);
llListenControl(ListenHandle, FALSE);
}
}
}
run_time_permissions(integer perm)
{
if(perm & PERMISSION_TRIGGER_ANIMATION)
{
llStopAnimation("sit");
llStopAnimation("sit_generic");
llStartAnimation("stand");
GenDIALOG(AVKey, gPage);
}
}
touch_start(integer num_detected)
{
if(freeFlag)
{
llGiveInventory(llDetectedKey(0), ANIMATION);
}
}
listen(integer channel, string name, key id, string message)
{
if(message == "CANCEL")
{
llUnSit(AVKey);
}
else if(message == "<<")
{
gPage--;
if(gPage < 0)
{
gPage = maxPage;
}
GenDIALOG(AVKey, gPage);
}
else if(message == ">>")
{
gPage++;
if(gPage > maxPage)
{
gPage = 0;
}
GenDIALOG(AVKey, gPage);
}
else
{
AnimNum = llListFindList(AnimButtonList, (list)message);
StartAnim(llList2String(AnimList, AnimNum));
GenDIALOG(AVKey, gPage);
}
}
money(key giver, integer amount)
{
if(amount == PRICE)
{
llGiveInventory(giver, ANIMATION);
llWhisper(0, "Thank you for purchase, " + llKey2Name(giver));
}
else
{
llWhisper(0, "Sorry, something strangge happened.
This trouble is reported to the owner. "
+ llKey2Name(llGetOwner()) + " will contact you as soon as possible.
And this vendor becomes deactivated untill the investigation is finished.
Sorry for inconvenience and please be patient.");
llInstantMessage(llGetOwner(), "Warning: Trouble happened. "
+ llKey2Name(giver) + " paied L$" + (string)amount + " for " + ANIMATION + ".
This vendor's location is " + llGetRegionName() + (string)llGetPos() + ".");
llSetText("Sorry, this is currently not available.", <1, 0, 0>, 1.0);
llSetScriptState(llGetInventoryName(INVENTORY_SCRIPT, 0), FALSE);
}
}
}
_____________________
:) Seagel Neville :)
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
Discussion Thread
11-26-2007 03:57
I posted this in the discussion thread, too.
/54/76/107870/1.html
_____________________
:) Seagel Neville :)
Ana Lutetia
=^.^=
Join date: 19 Nov 2006
Posts: 34
help
12-30-2007 10:03
Can this script read a notecard with the anims prices or do I have to change the name of the anims?
_____________________
-Ana Lutetia-
http://analutetia.com
John Trihey
Registered User
Join date: 28 Jun 2007
Posts: 2
01-01-2008 21:06
Hey thanks for this creation this thing is wonderful for selling animations in woot.