Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Discussion: SN_AnimVendor

Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
11-26-2007 21:13
Aha, your point was smarter and more compact of codes.
Thank you. I learned it. I'll adopt your codes :)

---Several hours later---
OK, I did. What about this?
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.

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

integer def_PRICE = 10;

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

integer PRICE;
integer CHANNEL;
integer ListenHandle;
list AnimList;
list AnimList01;
list AnimList02;
list AnimList03;
list AnimList04;
list AnimList05;
list AnimList06;
list AnimList07;
integer AllAnimNum;
string ANIMATION;
key AVKey;
integer AnimNum;
string AnimName;
integer gPage = 1;
integer maxPage;
string msg = "Right-click on the pedestal and \"Pay\" amount to purchase.";
integer freeFlag;


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

GenDIALOG(key id, integer page)
{
llListenControl(ListenHandle, TRUE);
if(page == 1)
{
llDialog(id, msg, AnimList01, CHANNEL);
}
else if(page == 2)
{
llDialog(id, msg, AnimList02, CHANNEL);
}
else if(page == 3)
{
llDialog(id, msg, AnimList03, CHANNEL);
}
else if(page == 4)
{
llDialog(id, msg, AnimList04, CHANNEL);
}
else if(page == 5)
{
llDialog(id, msg, AnimList05, CHANNEL);
}
else if(page == 6)
{
llDialog(id, msg, AnimList06, CHANNEL);
}
else if(page == 7)
{
llDialog(id, msg, AnimList07, CHANNEL);
}
}

list genList (integer start, integer end) //Espresso Saarinen advised.
{
integer i = start - 1;
list lst = [];
while (i <= end - 1)
{
string name = llGetInventoryName(INVENTORY_ANIMATION, i);
AnimList += name;
lst += llGetSubString(name, 0, 20);
i++;
}
return lst;
}

integer maxNum(integer input, integer max)
{
if(input > max)
{
input = max;
}
return input;
}

Init()
{
GenCHANNEL();
ListenHandle = llListen(CHANNEL, "", "", "");
llListenControl(ListenHandle, FALSE);
AnimList01 = ["<<", "CANCEL", ">>"];
AnimList02 = ["<<", "CANCEL", ">>"];
AnimList03 = ["<<", "CANCEL", ">>"];
AnimList04 = ["<<", "CANCEL", ">>"];
AnimList05 = ["<<", "CANCEL", ">>"];
AnimList06 = ["<<", "CANCEL", ">>"];
AnimList07 = ["<<", "CANCEL", ">>"];
AllAnimNum = llGetInventoryNumber(INVENTORY_ANIMATION);
llOwnerSay("Found " + (string)AllAnimNum + " animations.");
if(AllAnimNum > 63)
{
llWhisper(0, "Warning, you can put up to only " + (string)63 + " animations into this.");
AllAnimNum = 63;
}
if(AllAnimNum > 0)
{
maxPage = 1;
AnimList01 += genList(1, maxNum(AllAnimNum, 9));
}
if(AllAnimNum > 9)
{
maxPage = 2;
AnimList02 += genList(10, maxNum(AllAnimNum, 18));
}
if(AllAnimNum > 18)
{
maxPage = 3;
AnimList03 += genList(19, maxNum(AllAnimNum, 27));
}
if(AllAnimNum > 27)
{
maxPage = 4;
AnimList04 += genList(28, maxNum(AllAnimNum, 36));
}
if(AllAnimNum > 36)
{
maxPage = 5;
AnimList05 += genList(37, maxNum(AllAnimNum, 45));
}
if(AllAnimNum > 45)
{
maxPage = 6;
AnimList06 += genList(46, maxNum(AllAnimNum, 54));
}
if(AllAnimNum > 54)
{
maxPage = 7;
AnimList07 += genList(55, maxNum(AllAnimNum, 63));
}
}

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() + "kb.");
}
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 < 1)
{
gPage = maxPage;
}
GenDIALOG(AVKey, gPage);
}
else if(message == ">>")
{
gPage++;
if(gPage > maxPage)
{
gPage = 1;
}
GenDIALOG(AVKey, gPage);
}
else
{
string FireAnim;
if(llListFindList(AnimList01, [message]) != -1)
{
FireAnim = llList2String(AnimList, llListFindList(AnimList01, [message]) - 3);
}
else if(llListFindList(AnimList02, [message]) != -1)
{
FireAnim = llList2String(AnimList, llListFindList(AnimList02, [message]) + 6);
}
else if(llListFindList(AnimList03, [message]) != -1)
{
FireAnim = llList2String(AnimList, llListFindList(AnimList03, [message]) + 15);
}
else if(llListFindList(AnimList04, [message]) != -1)
{
FireAnim = llList2String(AnimList, llListFindList(AnimList04, [message]) + 24);
}
else if(llListFindList(AnimList05, [message]) != -1)
{
FireAnim = llList2String(AnimList, llListFindList(AnimList05, [message]) + 33);
}
else if(llListFindList(AnimList06, [message]) != -1)
{
FireAnim = llList2String(AnimList, llListFindList(AnimList06, [message]) + 42);
}
else if(llListFindList(AnimList07, [message]) != -1)
{
FireAnim = llList2String(AnimList, llListFindList(AnimList07, [message]) + 51);
}
AnimNum = llListFindList(AnimList, [FireAnim]);
StartAnim(FireAnim);
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 :)
Espresso Saarinen
old geek
Join date: 22 Jan 2006
Posts: 93
11-27-2007 11:09
aside from a trivial syntax silly ("INVENTORY_SCRI PT";) works great!
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
11-27-2007 17:08
From: Espresso Saarinen
aside from a trivial syntax silly ("INVENTORY_SCRI PT";) works great!
Sorry, I couldn't avoid it. :(

And thank you, Espresso. I can't stop posting code here as far as there is a person like you. :)
_____________________
:) Seagel Neville :)
Markus Brendel
Registered User
Join date: 16 Oct 2006
Posts: 13
12-13-2007 07:18
Seagel, the code is working great, i do have a question though. is it possible to reactivate the menu by touching the object if you were to ignore the menu other than standing and then sitting again, maybe a touch option?

I am slowly learning the scripting stuff, so if this is a dumb question, please bear with my LOL
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
12-13-2007 17:51
From: Markus Brendel
Seagel, the code is working great, i do have a question though. is it possible to reactivate the menu by touching the object if you were to ignore the menu other than standing and then sitting again, maybe a touch option?

Not impossible, but I used the touch event to give a free animation. They will be confusing. I think you have to find another method to give free animations if you would like to touch and open dialog box.
I suppose its not so hard to keep off the ignore button.
_____________________
:) Seagel Neville :)
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
12-13-2007 19:08
this litte snippet
CODE

string FireAnim;
if(llListFindList(AnimList01, [message]) != -1)
{
FireAnim = llList2String(AnimList, llListFindList(AnimList01, [message]) - 3);
}
else if(llListFindList(AnimList02, [message]) != -1)
{
FireAnim = llList2String(AnimList, llListFindList(AnimList02, [message]) + 6);
}
else if(llListFindList(AnimList03, [message]) != -1)
{
FireAnim = llList2String(AnimList, llListFindList(AnimList03, [message]) + 15);
}
else if(llListFindList(AnimList04, [message]) != -1)
{
FireAnim = llList2String(AnimList, llListFindList(AnimList04, [message]) + 24);
}
else if(llListFindList(AnimList05, [message]) != -1)
{
FireAnim = llList2String(AnimList, llListFindList(AnimList05, [message]) + 33);
}
else if(llListFindList(AnimList06, [message]) != -1)
{
FireAnim = llList2String(AnimList, llListFindList(AnimList06, [message]) + 42);
}
else if(llListFindList(AnimList07, [message]) != -1)
{
FireAnim = llList2String(AnimList, llListFindList(AnimList07, [message]) + 51);
}
AnimNum = llListFindList(AnimList, [FireAnim]);
StartAnim(FireAnim);
GenDIALOG(AVKey, gPage);

might be better expressed as
CODE

AnimNum = llListFindList( AnimList, (list)message ) );
StartAnim( llList2String( AnimList, AnimNum ) );
GenDIALOG( AVKey, gPage );


you could also abstract the animlistXX listings in GenDIALOG by just using
Dialog( id, msg, llList2List( AnimList, page * 9, page * 9 + 8 ) + ["<<", "Cancel", ">>"], CHANNEL );
instead of all those if statements, an eliminate those extra lists completely

this would be used to find the page
maxPage = llCeil( llGetInventoryNumber( INVENTORY_ANIM ) / 9 ) - 1;

and you'd need to tweak gen list not to return a temp list...
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
12-13-2007 22:20
The limit of the letters for button was pain in the neck from the first time. There are a lot of animations which have more than 24 letters' name. To make matters worse, I empolied the method adding letters to the name to price each animation.
The names of animations and the names for buttons are another. That is the reason why I can't get rid of if statements. :(
_____________________
:) Seagel Neville :)
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
12-14-2007 03:01
you could still, just instead of making a whole bunch of friendly name lists, make one big one, get your index in the listen from that, and use the index against the master list.... that should free up a little code memory anyways... probably still want to limit it like you did though...

I do hate the thing about dialog buttons, 24char max, but you're lucky if you can see more than 8 in display
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
Excellent!
12-14-2007 18:13
Gee, I've realized that you were really right. And I learned much more. I really appreciate your advice. Thanks to you, I could get rid of not only setting the max number of pages, but also animations, except the limit of memory. :)

Here is the new code.
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 :)
Ana Lutetia
=^.^=
Join date: 19 Nov 2006
Posts: 34
12-30-2007 10:15
From: Seagel Neville
HUD? I guess you mean that it is the dialog box. I dared to change such names on it because there was the limit to show the number of letters on each button.
If you want to show your animation's name, change lines under Init() functions.

Change from all '"ANIM" + (string)(i + 1);' to 'llGetInventoryName(INVENTORY_ANIMATION, i);'

For example,
From: AnimList1 += "ANIM" + (string)(i + 1);
To: AnimList1 += llGetInventoryName(INVENTORY_ANIMATION, i);
You have to do the same thing on AnimList2 and 3, too.


Is it possible to add a notecard to the pedestal with the anims (in my case, poses) names and prices to be read by the script?
_____________________
-Ana Lutetia-
http://analutetia.com
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
12-31-2007 19:07
From: Ana Lutetia
Is it possible to add a notecard to the pedestal with the anims (in my case, poses) names and prices to be read by the script?

Yes, it is, but just a hassle for sellers. Can you tell me the advantage of using a notecard?
_____________________
:) Seagel Neville :)
AngelEyes Lewis
Registered User
Join date: 18 Oct 2005
Posts: 49
01-12-2008 22:29
You did a great job, i love it.. its clean and easy to use :D

I was wondering, is there anyway to set a permission to debit in so that there can be an automatic refund if the customer pays too much, or too little?

I tried messing with the script, but im completely N00B status when it comes to debit scripting :/


TIA for such an awesome script :D
_____________________
http://slurl.com/secondlife/Jamaica/74/129/30
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
01-13-2008 04:42
From: AngelEyes Lewis
I was wondering, is there anyway to set a permission to debit in so that there can be an automatic refund if the customer pays too much, or too little?

I tried messing with the script, but im completely N00B status when it comes to debit scripting :/

First of all, refer to #12 to #18 on this thread, nevertheless if you want to know how to write it, here is an idea.
I don't think that you can let it request animation and debit on the same script, so you need to separate it.
CODE
integer gCorrectAmount;
integer gPaidAmount;

default
{
state_entry()
{
llRequestPermissions(llGetOwner(),PERMISSION_DEBIT);
}
link_message(integer sender_num, integer num, string str, key id)
{
if(str == "CorrectAmount")
{
gCorrectAmount = num;
}
else if(str == "PaidAmount")
{
gPaidAmount = num;
if(gPaidAmount < gCorrectAmount)
{
llWhisper(0,"You didn't pay enough, " + llKey2Name(id) + ". Refunding your payment of L$" + (string)gPaidAmount + ".");
llGiveMoney(id, gPaidAmount);
}
else
{
integer refund = gPaidAmount - gCorrectAmount;
llWhisper(0,"You paid too much, " + llKey2Name(id) + ". Your change is L$" + (string)refund + ".");
llGiveMoney(id, refund);
}
}
}
}

And modify the money event on SN_AnimVendor II script like followings.
CODE

money(key giver, integer amount)
{
if(amount == PRICE)
{
llGiveInventory(giver, ANIMATION);
llWhisper(0, "Thank you for purchase, " + llKey2Name(giver));
}
else
{
llMessageLinked(LINK_THIS, PRICE, "CorrectAmount", NULL_KEY);
llMessageLinked(LINK_THIS, amount, "PaidAmount", giver);
}
}
}
_____________________
:) Seagel Neville :)
1 2