Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

1 Prim, Multi item, multi price, split proceeds Vendor

Ilayda Reina
Registered User
Join date: 21 Nov 2007
Posts: 31
12-07-2008 05:29
Hello
I made this script earlier sometime and now I decided to open the code here. though it still needs improvements.

it is basically note card configured, menu driven, multi item, multi price, split proceeds vendor

Bear in mind that;
1. I am still considering myself as novice in scripting
2. it wasn't tested enough
3. it really needs improvements

here is the code

Vendor script:

From: someone

//1prim vendor script, written by ilayda Reina in November 01, 2008.
//This script is released for free use by anyone.

key id;
string mess ;
list menu = ["<< PREV","CANCEL","NEXT >>"];
integer chan;
integer h;
integer index;
string notecardName;
key notecardQuery;
integer notecardIndex;
list notecardList;
integer price;
string itemName;
key partner=""; //place the AV key of your partner
integer split;
//=======================================================
dialog()
{
id = llDetectedKey(0);
chan = llFloor(llFrand(100000.0)) + 1000;
llListenRemove(h);
h = llListen(chan, "",id, "";);
llDialog(id,"Current item ;\n" + mess,menu,chan);
}
//======================================================================================
displayItem()
{
string textureName = llList2String(notecardList,index*4);
itemName = llList2String(notecardList,(index*4)+1);
string p = llList2String(notecardList,(index*4)+2);
mess = llList2String(notecardList,(index*4)+3);
price = (integer)p;
string display = itemName + "\nL$" + p;
llSetText(display, <1,1,1>, 1);
llMessageLinked(LINK_THIS , 0, ":"+display, NULL_KEY);
llSetLinkPrimitiveParams(0,[PRIM_TEXTURE, 1, textureName, <1,1,1>, <0,0,0>, 0 ]);
llSetPayPrice(PAY_HIDE, [price, PAY_HIDE, PAY_HIDE, PAY_HIDE]);
}
//======================================================================================
default
{
state_entry()
{
if( llGetListLength(notecardList)==0 )
{
notecardName = "Config";
state loading;
}
else
{
index = 0;
displayItem();
}
}
touch_start(integer total_number)
{

dialog();
}
listen( integer channel, string name, key id, string message )
{
if (message == "<< PREV";)
{
index--;
llDialog(id,"Current item ;\n" + mess,menu,chan);
}
if (message == "NEXT >>";)
{
index++;
llDialog(id,"Current item ;\n" + mess,menu,chan);
}
if (message == "CANCEL";)
{
llListenRemove(h);
}
if(index>=(llGetListLength(notecardList)/4) )
index = 0;

if(index<0 )
{
index = (llGetListLength(notecardList)/4);
index--;
}
displayItem();
}
money(key id, integer amount)
{

if( amount>=price )
{
split = (integer)llGetObjectDesc();
llGiveInventory(id,itemName);
llSay(0,"Thanks for your purchase!";);
integer splitted=(price*split)/100;
llGiveMoney(partner,splitted);
llInstantMessage(partner,"You have been payed L$ " + ((string)splitted) + " by " + llGetObjectName());
}
}
}
//================================================================================
state loading
{
state_entry()
{
llSay(0,"Hold on, loading product data...";);
notecardIndex = 0;
notecardQuery = llGetNotecardLine(notecardName,notecardIndex++);
}
dataserver(key query_id, string data)
{
if ( notecardQuery == query_id)
{
if (data == EOF)
{
llSay(0,"Products loaded...";);
state default;
}
else
{
notecardList += [data];
notecardQuery = llGetNotecardLine(notecardName,notecardIndex++);
}
}
}
}


Notecard format
From: someone

texture1
product1
500
Description for product 1
texture2
product2
300
Description for product 2
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
12-07-2008 06:50
one thing i might change, if you really want to keep the vendor at 1 prim is using the touch face features (haven't tried it yet) and use next and back buttons that way. or you could as seperate prim buttons, i know if i was a customer, i wouldn't want to mess with a dialog over and over to skip thru items unless it was an actual menu. i would prefer a button to press on the vendor itself.

also, as i'm not in world to try it, does the detected key actually get passed to the dialog() function, or would it need to be something like

touch_start(integer num)
{
dialog(llDetectedKey(0);
}


and then the dialog function would be

dialog(key avatar)

llDialog(avatar,....etc,... etc
_____________________
Dark Heart Emporium

http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020

want more layers for tattoos, specifically for the head? vote here
http://jira.secondlife.com/browse/VWR-1449?

llDetectedCollision* Functions similar to touch
http://jira.secondlife.com/browse/SVC-3369
Nexii Malthus
[Cubitar]Mothership
Join date: 24 Apr 2006
Posts: 400
12-07-2008 14:47
All llDetection* function are passed over to user-defined functions when they are calling in the event that supports the detection functions.

A little fact that my opensourced UI project takes advantage of.
_____________________

Geometric Library, for all your 3D maths needs.
https://wiki.secondlife.com/wiki/Geometric

Creator of the Vertical Life Client