Any help on this would be great. Thank you.
CODE
integer index;
integer max;
integer price;
string texture;
string object;
string info;
default
{
state_entry()
{
max = 0;
llRequestPermissions( llGetOwnerKey( llGetKey() ), PERMISSION_DEBIT );
llWhisper( 0, "Getting setup");
llGetNotecardLine( "MultiVend.inf", 0 );
}
dataserver( key requested, string data )
{
if( ((integer)data) == 0 ) {
state running;
}
else {
max = max + 1;
llGetNotecardLine( "MultiVend.inf", max );
}
}
link_message(integer sender_num, integer num, string str, key id)
{
llWhisper( 0, "Still setting up, Please wait....");
}
}
state running
{
state_entry()
{
llListen( 0, "", llGetOwnerKey(llGetKey()),"reset machine");
llWhisper( 0, "Found " + (string) max + " items, Ready for use" );
llGetNotecardLine( "MultiVend.inf", 0);
}
touch_start(integer total_number)
{
llSay( 0, "To use me, simply cycle though the items by touching");
llSay( 0, "the arrows in the bottom corners of the screen.");
llSay( 0, "The price is in the lower center of the screen. ");
llSay( 0, "To purchase any item, simply click the ");
llSay( 0, "right mouse button over the screen and select pay.");
llSay( 0, "Product:" + info);
}
listen(integer channel, string name, key id, string message)
{
state default;
}
dataserver( key requested, string data )
{
list information;
information = llCSV2List( data );
price = llList2Integer( information, 0 );
texture = llList2String( information, 1 );
object = llList2String( information, 2 );
info = llList2String( information, 3 );
if( price == 0 )
{
return ;
}
if ( price < 10 )
{
llMessageLinked( LINK_ALL_OTHERS, price % 10, "100", "" );
llMessageLinked( LINK_ALL_OTHERS, 10, "10", "" );
llMessageLinked( LINK_ALL_OTHERS, 10, "1", "" );
}
else if (price < 100)
{
llMessageLinked( LINK_ALL_OTHERS, price / 10 % 10, "100", "" );
llMessageLinked( LINK_ALL_OTHERS, price % 10, "10", "" );
llMessageLinked( LINK_ALL_OTHERS, 10, "1", "" );
}
else
{
llMessageLinked( LINK_ALL_OTHERS, price / 100 % 10, "100", "" );
llMessageLinked( LINK_ALL_OTHERS, price / 10 % 10, "10", "" );
llMessageLinked( LINK_ALL_OTHERS, price % 10, "1", "" );
}
llSetTexture( texture, 2 );
llSay( 0, "Product:" + info);
}
link_message( integer sender_num, integer num, string str, key id)
{
if( str == "move" )
{
index = (index + num + max) % max;
}
llGetNotecardLine("MultiVend.inf",index);
}
money( key giver, integer amount )
{
if ( amount < price )
{
llSay( 0, "This item costs L$" + (string) price );
llSay( 0, "You did not pay enough" );
llGiveMoney( giver, amount );
}
else
{
llSay( 0, "Thank you for shopping with us");
llSay( 0, "Enjoy your " + object );
llGiveInventory( giver, object );
llGiveMoney( giver, amount - price );
}
}
}