Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

How to make this vendor ?

Own Westland
Second.Life@msn.com
Join date: 24 Dec 2007
Posts: 49
01-17-2008 19:29
A vendor with my product photos sliding manually, or automatically and periodly. If a resident clicks current photo slide, the vendor will pop up a payment window. If the resident clicks 'previous' or 'next', the photo slides to the corresponding one and show its order as '3/6' or '2/7' ... .

How to buid this kind of vendor? Including the object, script and so on. Thanks.
_____________________
Helpful MSN Group: Second.Life@msn.com
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
01-17-2008 20:04
From: Own Westland
A vendor with my product photos sliding manually, or automatically and periodly. If a resident clicks current photo slide, the vendor will pop up a payment window. If the resident clicks 'previous' or 'next', the photo slides to the corresponding one and show its order as '3/6' or '2/7' ... .

How to build this kind of vendor? Including the object, script and so on. Thanks.

Welcome to the forum Own. We love to help people to learn how to script here but a vendor script from scratch is a lot to bite off if you have no previous coding expirience. Hopefull you do. Have to be extremely careful whenever you start dealing with a script handling money. Very easy to either loose all of yours, or end up with a flurry of abuse reports filed against you.

If you really want to build your own then do a search in the Scripting Library for "vendor". Should be something there that you can modify to fit your needs.

I am not trying to discourage you, as I pointed out we WANT people to learn. If you can cobble up even a basic script and post it here then we could help you debug it and get it up to speed.
_____________________
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
Cherry Hainsworth
Registered User
Join date: 31 Jul 2006
Posts: 125
01-17-2008 20:30
Hello, Own

I made a vendor pretty much like this, using some free scripts as a starting point. I'm attaching my script below. When you have questions about it, please ask them here in this thread, and we will try to answer :)

CODE

// TWO-BUTTON TEXTURE VENDOR
// Origional script by Thili Playfair
// Heavily Modified by Karandas Banjo
// Modified to display background panels & sell the panels as objects
// by Cherry Hainsworth, January 2008
// Please include these names if you modify or
// re-distribute this code ^_^


// To set up your vendor, you will need at least 3 prims,
// the main prim, and two buttons.

// The two buttons must both be linked to the main prim,
// one must be called "next", the other called "prev".
// The Buttons do NOT need any script if you name them as shown above.

// Next, enter the price of the textures in this vendor,
// and if you want, time to wait for auto-scrolling.

// After that, just drop your textures into the main prim,
// and press one of the scroll buttons, and you're ready
// to go!

integer price = 10;// The price of any object in this vendor.
// Added touch-giving for when price is set to L$0


float time = 0; // Enter a value if you want time based
// scrolling otherwise set to zero.


string vendorname;
integer total;
integer counter;
integer change;
// The textures must be named the same as the objects, plus their panel number
// like so: item name is "flower garden" so texture names are "flower garden 1" etc.
string texturename1; //goes on prim link #1
string texturename2; //goes on prim link #2
string texturename3; //goes on prim link #3
string texturename4; //goes on prim link #4

// Which face is the image on? (number or ALL_SIDES)
integer face = 3;

// functions
// ---------------------------------------------

setchosenimage()
{
texturename1 = (llGetInventoryName(INVENTORY_OBJECT, counter) + " 1" );
llSetLinkTexture(1, texturename1, face);
texturename2 = (llGetInventoryName(INVENTORY_OBJECT, counter) + " 2" );
llSetLinkTexture(2, texturename2, face);
texturename3 = (llGetInventoryName(INVENTORY_OBJECT, counter) + " 3" );
llSetLinkTexture(3, texturename3, face);
texturename4 = (llGetInventoryName(INVENTORY_OBJECT, counter) + " 4" );
llSetLinkTexture(4, texturename4, face);
}

// ---------------------------------------------

next()
{
total=llGetInventoryNumber(INVENTORY_OBJECT);
vendorname = llGetObjectName();
counter++;
if(counter>=total)
{
counter=0;
}
setchosenimage();
if (price > 0)
{
llSetText(vendorname + "\n" + llGetInventoryName(INVENTORY_OBJECT, counter) + "\n L$" + (string)price + "\n", <1,1,1>, 1);
}
else
{
llSetText(vendorname + "\n" + llGetInventoryName(INVENTORY_OBJECT, counter) + "\n Touch to recieve \n", <1,1,1>, 1);
}

}

// ---------------------------------------------

prev()
{
total=llGetInventoryNumber(INVENTORY_TEXTURE);
vendorname = llGetObjectName();
if (counter > 0)
{
counter--;
}
else
{
counter=total - 1;
}
setchosenimage();
if (price > 0)
{
llSetText(vendorname + "\n" + llGetInventoryName(INVENTORY_OBJECT, counter) + "\n L$" + (string)price + "\n", <1,1,1>, 1);
}
else
{
llSetText(vendorname + "\n" + llGetInventoryName(INVENTORY_OBJECT, counter) + "\n Touch to recieve \n", <1,1,1>, 1);
}
}

// ---------------------------------------------

default
{
state_entry()
{
llRequestPermissions(llGetOwner(),PERMISSION_DEBIT );
next();
llSetTimerEvent(time);
}
touch_start(integer total_number)
{
if ( llGetLinkName(llDetectedLinkNumber(0)) == "next" )
{
next();
}
else if ( llGetLinkName(llDetectedLinkNumber(0)) == "prev" )
{
prev();
}
else
{
if (price > 0)
{
llWhisper(0, "Pay L$" + (string)price + " to buy");
}
else
{
llGiveInventory(llDetectedKey(0), llGetInventoryName(INVENTORY_OBJECT, counter));
}
}
}
timer()
{
next();
}
money(key giver, integer amount)
{
if (amount < price)
{
llSay(0, "Too little paid, refunding");
llGiveMoney(giver, amount);
}
else if (amount > price)
{
change = amount - price;
llSay(0, "Overpaid. vending item and giving L$" + (string)change + " change");
llGiveMoney(giver, change);
llGiveInventory(giver, llGetInventoryName(INVENTORY_OBJECT, counter));
llInstantMessage(llGetOwner(), llKey2Name(giver) + " bought " + llGetInventoryName(INVENTORY_OBJECT, counter) + " for L$" + (string)price);
}
else if (amount == price)
{
llGiveInventory(giver, llGetInventoryName(INVENTORY_OBJECT, counter));
llInstantMessage(llGetOwner(), llKey2Name(giver) + " bought " + llGetInventoryName(INVENTORY_OBJECT, counter) + " for L$" + (string)price);
}
}
on_rez(integer start_param)
{
llResetScript();
}
}
Own Westland
Second.Life@msn.com
Join date: 24 Dec 2007
Posts: 49
01-17-2008 21:24
Cherry, thank you very much. I'll turn to you if there's any problem after I modify and run it. Have a good day ! :)
_____________________
Helpful MSN Group: Second.Life@msn.com