----------------------------
integer lkey ;
integer idx ;
integer valid;
key payee ;
// Mango, Papaya, Apricot, Blueberry, Pineapple, Pink Lemonade
list objects = [ ];
default
{
state_entry()
{
llOwnerSay ( "Readin objects - wait a sec "
;idx = 0;
objects = objects + ["Cancel"];
for ( idx= 0;idx<llGetInventoryNumber( INVENTORY_OBJECT );idx++ )
{
string oname =llGetInventoryName( INVENTORY_OBJECT, idx );
if ( llStringLength( oname ) > 24 )
{
llOwnerSay ( ">>> " + oname + " has been rejected as it's name is too long ( 24 characters )" );
}
else
{
objects = objects + [oname];
llOwnerSay ( oname + " added to the menu." );
}
if ( idx == 10 ) {idx = 999 ;}
}
llSetPayPrice( PAY_HIDE,[1,PAY_HIDE,PAY_HIDE,PAY_HIDE]);
llRequestPermissions( llGetOwner(),PERMISSION_DEBIT );
}
run_time_permissions( integer perm )
{
if ( perm & PERMISSION_DEBIT )
{
state ready ;
}
else
{
llOwnerSay ( "Permission is required to issue refunds." );
llResetScript();
}
}
}
state ready
{
state_entry()
{
llSetText( "Juice L$1- 6 Flavors to Choose From" ,<1,1,1>,1 );
}
on_rez( integer r )
{
llResetScript();
}
listen( integer ch, string nm, key id, string mess)
{
llListenRemove( lkey );
llSetTimerEvent( 0 );
if ( mess == "Cancel" )
{ //Refund their $1 as they cancelled
llGiveMoney( id, 1 );
return;
}
valid = FALSE;
for ( idx=0; idx<llGetListLength( objects ) ;idx++ )
{ // find out which object
if ( mess == llList2String( objects,idx ) )
{
llGiveInventory( id,mess ) ;
llWhisper( 0 , "MmMm so delicious. I think I want another" );
return;
}
}
if ( valid ) {return;}
llGiveMoney( id, 1 ); // Refund the money - they didnt use the menu
}
money ( key id, integer amt )
{
payee = id;
if ( amt > 1 )
{
llGiveMoney( id,amt ) ;
llWhisper( 0, " I only accept L$1 - refunding your money " );
return;
}
lkey = llListen( 8888,"",id,"" );
llSetTimerEvent( 60 );
llDialog( id,"Choose your object :" , objects, 8888 );
}
timer()
{
llGiveMoney( payee,1 ) ; // Menu timed out - refund the money
llSetTimerEvent( 0 );
llListenRemove( lkey );
}
changed( integer c )
{
if ( c && CHANGED_INVENTORY )
{
llResetScript();
}
}
}
