Karandas Banjo
Registered User
Join date: 7 Jan 2005
Posts: 35
|
05-29-2005 04:07
This is a simple script I whipped up, using some code I found in the Products Wanted forum as a base, that makes a 3+ prim vendor that vends individual textures. The price stays constant for every texture in the vendor, but apart from that, it works well. Note: The next and previous buttons dont need any scripts, the prims just have to be named "next" and "prev" respectively (and without the "s of course  ) // TWO-BUTTON TEXTURE VENDOR // Origional script by Thili Playfair // Heavily Modified by Karandas Banjo // 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".
// 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 = 50; // The price of any texture in this // vendor.
float time = 0; // Enter a value if you want time based // scrolling otherwise set to zero.
// NO TOUCHY BELOW HERE
string vendorname; integer total; integer counter; integer change;
next() { total=llGetInventoryNumber(INVENTORY_TEXTURE); vendorname = llGetObjectName(); counter++; if(counter>=total) { counter=0; } llSetTexture(llGetInventoryName(INVENTORY_TEXTURE, counter),ALL_SIDES); if (price > 0) { llSetText(vendorname + "\n" + llGetInventoryName(INVENTORY_TEXTURE, counter) + "\n L$" + (string)price + "\n", <1,1,1>, 1); } else { llSetText(vendorname + "\n" + llGetInventoryName(INVENTORY_TEXTURE, counter) + "\n Touch to recieve \n", <1,1,1>, 1); } llTriggerSound("Pressed", 1); } prev() { total=llGetInventoryNumber(INVENTORY_TEXTURE); vendorname = llGetObjectName(); if (counter > 0) { counter--; } else { counter=total - 1; } llSetTexture(llGetInventoryName(INVENTORY_TEXTURE, counter),ALL_SIDES); if (price > 0) { llSetText(vendorname + "\n" + llGetInventoryName(INVENTORY_TEXTURE, counter) + "\n L$" + (string)price + "\n", <1,1,1>, 1); } else { llSetText(vendorname + "\n" + llGetInventoryName(INVENTORY_TEXTURE, counter) + "\n Touch to recieve \n", <1,1,1>, 1); } llTriggerSound("Pressed", 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_TEXTURE, counter)); } } } timer() { next(); } money(key giver, integer amount) { if (amount < price) { llSay(0, "Too little payed, 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_TEXTURE, counter)); llInstantMessage(llGetOwner(), llKey2Name(giver) + " bought " + llGetInventoryName(INVENTORY_TEXTURE, counter) + " for L$" + (string)price); } else if (amount == price) { llGiveInventory(giver, llGetInventoryName(INVENTORY_TEXTURE, counter)); llInstantMessage(llGetOwner(), llKey2Name(giver) + " bought " + llGetInventoryName(INVENTORY_TEXTURE, counter) + " for L$" + (string)price); } } on_rez(integer start_param) { llResetScript(); } }
EDIT: Added touch-giving for when price is set to L$0
|
SeXXXy Bliss
SL Addict
Join date: 21 Dec 2004
Posts: 436
|
Great Script, but....
05-29-2005 16:21
I used this script and it worked fine, except it kept saying that it couldn't find the sound 'press'...so I took it out completely and it works fine now! I would like to thank you for posting this script, it's what I have been looking for!! Script now reads like this:
// TWO-BUTTON TEXTURE VENDOR // Origional script by Thili Playfair // Heavily Modified by Karandas Banjo // 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".
// 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 = 50; // The price of any texture in this // vendor.
float time = 0; // Enter a value if you want time based // scrolling otherwise set to zero.
// NO TOUCHY BELOW HERE
string vendorname; integer total; integer counter; integer change;
next() { total=llGetInventoryNumber(INVENTORY_TEXTURE); vendorname = llGetObjectName(); counter++; if(counter>=total) { counter=0; } llSetTexture(llGetInventoryName(INVENTORY_TEXTURE, counter),ALL_SIDES); if (price > 0) { llSetText(vendorname + "\n" + llGetInventoryName(INVENTORY_TEXTURE, counter) + "\n L$" + (string)price + "\n", <1,1,1>, 1); } else { llSetText(vendorname + "\n" + llGetInventoryName(INVENTORY_TEXTURE, 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; } llSetTexture(llGetInventoryName(INVENTORY_TEXTURE, counter),ALL_SIDES); if (price > 0) { llSetText(vendorname + "\n" + llGetInventoryName(INVENTORY_TEXTURE, counter) + "\n L$" + (string)price + "\n", <1,1,1>, 1); } else { llSetText(vendorname + "\n" + llGetInventoryName(INVENTORY_TEXTURE, 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_TEXTURE, counter)); } } } timer() { next(); } money(key giver, integer amount) { if (amount < price) { llSay(0, "Too little payed, 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_TEXTURE, counter)); llInstantMessage(llGetOwner(), llKey2Name(giver) + " bought " + llGetInventoryName(INVENTORY_TEXTURE, counter) + " for L$" + (string)price); } else if (amount == price) { llGiveInventory(giver, llGetInventoryName(INVENTORY_TEXTURE, counter)); llInstantMessage(llGetOwner(), llKey2Name(giver) + " bought " + llGetInventoryName(INVENTORY_TEXTURE, counter) + " for L$" + (string)price); } } on_rez(integer start_param) { llResetScript(); } }
|
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
|
Original Thread:
05-29-2005 16:51
_____________________
i've got nothing. 
|
Sky Metropolitan
Registered User
Join date: 14 May 2005
Posts: 3
|
06-18-2005 06:24
Is there a way to edit this script so instead of selling textures, you are just displaying them like a gallery? 
|
Sydney Alexander
Registered User
Join date: 19 Feb 2005
Posts: 69
|
06-19-2005 18:07
From: Sky Metropolitan Is there a way to edit this script so instead of selling textures, you are just displaying them like a gallery?  There are a few here: /54/b5/20936/1.html
|