Jump to content

Giving no copy item from inventory of attached object


Anaiya Arnold
 Share

You are about to reply to a thread that has been inactive for 4601 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

My scripting skills are marginally below those of a beginner (fair warning given).

Ok, I wanted to make an object (a cake) that would give one random object from an inventory of no-copy & trans objects to someone who clicks it.  The item they receive is an attachment (cupcake) with an animation.  I wanted the new owner of the cupcake to be able to click their worn cupcake and get the object inside (without getting the script/animation). 

When I tested the cupcake I got an error, and had a look around and it seems (so far as I can understand) that I cannot do this (give a no-copy object from the inventory of an attached object).

Am I correct that this cannot be done, and if it can be done, what kind of lsl function should I be looking into?

 

Assuming it cannot be done (and this is where my face is gets red and I have to admit to being an idiot, as you will see when you read on), my problem is that I somehow managed to put a text floater over my cupcakes, that indicates the wearer should click for a surprise and now I cannot find how I did that to undo it (yes, I'm shaking my head at myself too). 

My plan is to change this floater to tell the wearer they can rezz the item in-world to get a surprise, but I cannot find where or how I put this floating text over the cupcake in the first place (I only did a couple of hours ago too).

So, (and please believe I feel so very stupid having to ask such a lame reqest), can someone please review this code and tell me where I set the floating text.  I know that no one who is not illiterate really has any business asking such a request, but I swear I've gone cross eyed looking and although I cannot explain it, I honestly cannot find where I set the floating text....(ok I'm going to sit in the corner and humbly die of shame).

// Original sip script By Theda Twilight

// Animations by Robin Sojourner

// Attach/detach message + drinking time configuration by Kahiro Watanabe

key drinker;                            //agent wearing the object

// This data is taken from notecard //
string attachMessage;                   //whispered message on attach
string detachMessage;                   //whispered message on detach
float sipTime;                          //time between each sip
float drinkTime;                        //total drink time
///////////////////////////////////////

float currentDrinkTime;                 //keeps track of current drink time


// for dataserver queries //
key notecardQuery;
integer notecardLine;

default 
{
    state_entry()
    {
        drinker = llGetOwner();
        notecardLine = 0;
        notecardQuery = llGetNotecardLine("!config",notecardLine);
    }
    attach(key attached)    
    {
        if (attached)                   // someone is wearing it
        {
            drinker = attached;
            notecardLine = 0;
            notecardQuery = llGetNotecardLine("!config",notecardLine);
        }
    }
    
    dataserver(key queryId, string data)
    {
        if (queryId == notecardQuery)   
        {
            if (data != EOF)    
            {
                if (llGetSubString(data,0,0) != "#")            // keep passing lines until finds a "#"
                {
                    notecardLine = notecardLine + 1;
                    notecardQuery = llGetNotecardLine("!config",notecardLine);
                }  
                else if (data != EOF)                           // "#" was found, time to read configuration
                { 
                    list tempList = llParseString2List(data, [",","#"],[]);
                    string tempString = llToLower(llList2String(tempList,0));
                    string tempString2 = llList2String(tempList,1);
                    if (tempString == "attachmessage")
                    {
                        attachMessage = tempString2;
                    }
                    else if (tempString == "detachmessage")
                    {
                        detachMessage = tempString2;
                    }
                    else if (tempString == "siptime")
                    {
                        sipTime = (float)tempString2;
                    }
                    else if (tempString == "drinktime")
                    {
                        drinkTime = (float)tempString2;
                    }
                    notecardLine = notecardLine + 1;
                    notecardQuery = llGetNotecardLine("!config",notecardLine);
                }
               
            }
            else                                                // end of notecard reached go to 'ready' state
            {
                state ready;
            }
        }
    }
}

state ready
{
    state_entry()                                               // when state is entered permissions are requested
    {
        llRequestPermissions(drinker, PERMISSION_TRIGGER_ANIMATION);
    }
    
    attach(key id)                                              // this is because a LSL bug next time cup is attached script will start in this state
    {                                                           // and we don't want that so this takes the script to default state
        if (id != NULL_KEY)
        {
            llResetScript();
        }
        
    }
    
    run_time_permissions(integer perms) 
    {
        if(perms & PERMISSION_TRIGGER_ANIMATION) 
        {
            if (attachMessage != "")
                llWhisper(0,attachMessage);                         // 'attachMessage' is whispered
            llSetTimerEvent(0.1);                               // lets go to the timer
            llStartAnimation("sip rest loop");                  // and start the base animation
        }
    }
    
    timer()
    {
        llStartAnimation("sipping sl");
        if ((currentDrinkTime < drinkTime) | (drinkTime == 0))  // keep drinkning until time is over (or drinktime equals zero)
        {
            llSetTimerEvent(sipTime);
        }
        else if (drinkTime != 0)                                // stop drinking if time is over
        {
            if (detachMessage != "")
                llWhisper(0,detachMessage);
            llStopAnimation("sip rest loop");
            llStopAnimation("sipping sl");
            llSetTimerEvent(0.0);
            llDetachFromAvatar();

        }
        currentDrinkTime = currentDrinkTime + sipTime;          // keeps track of current drink time
    }
}

 Config notecard:

Sip script 2.0 with timer
Help:
attachmessage: whispered message when attach
detachmessage: whispered message when detach
siptime: time between each sip
drinktime: total drinking time (25 for infinite)
--------------------------------------------------------------------------------------------------------------------
Notecard configuration:
#attachmessage, Nom Nom Nom
#detachmessage,
#siptime,5
#drinktime,0

 

There is also a random object giver script in the cupcakes, but God help me if the floating text is there because I deserve to be taken out and shot if I cannot locate a simple text string in such a short code snippet......

Just in case though, here it is.

//Emmas Seetan
 //21 September, 16:46
 
 default
 {
     touch_start(integer total_number)
     {
         float totalobjects = llGetInventoryNumber(INVENTORY_OBJECT); //number of objects
         totalobjects = llFrand(totalobjects); //Total objects
         llGiveInventory(llDetectedKey(0),llGetInventoryName(INVENTORY_OBJECT, (integer)totalobjects)); //Give any random  object out of the total
     }
    }

 Also, while I am here, I actually want the cupcakes to give all the objects in the inventory (most have only one but at least one has two objects and I want them to be given from a single touch event if possible).  Would that happen if I changed the code above to

default

{

touch_start (integer gift)

{

gift = llGetInventory(INVENTORY_OBJECT);

llGiveInventory(llDetectedKey(0),llGetInventoryName(integer gift));

}

}

 

Thanks so much to anyone who is willing to help (especially with the very lame request helping me figure out how to unset that floating text).

 

 

Link to comment
Share on other sites

the caveat for llGiveInventory note that it's true that attachments can't give no-copy items.... BUT, I'm not sure this holds true for llGiveInventoryList (they both behave slightly different). if it does work then your immediate problem is solved, and your problem of giving multiple items too... be warned that function creates a new folder with the item specified inside of it. they do not go into the normal system folders.

as for your hover text problem, that would be because the llSetText function sets a prim property... once set it remains even if the script does not...  calling it again with blank (or new) text will solve the problem (there is also the PRIM_TEXT constant that can be used with the llSetPrimitiveParams family of functions now.

as for your very last question...

//-- corrected to initialize the variable and the misspelled function name on the next lineinteger gift = llGetInventoryNumber( INVENTORY_OBJECT );llGiveInventory( llDetectedKey(0),llGetInventoryName( gift ) );//-- corrected mistaking insertion of "integer" initialization on previous line

 won't work, because gift gets a total,  and llGetInventoryName expects an index (and then only give that index).

you either need to use a loop to count through the indexes (which start at 0) or use the function mentioned above to give them all at once (although you will likely still need a loop to create the list it needs)

Link to comment
Share on other sites

Ok, thanks so much Void.  I nearly understand that on the first reading!

 

So I must have actually put a text script in and then deleted it?  I honestly to goodness do not remember doing that but I've been mucking around with scripts all day so I guess I lost track of what I had done.

Thanks again!

 

I'm off to go read up about llGiveInventoryList...this may take me a while...lol

Link to comment
Share on other sites

I'm afraid I don't think llGiveInventoryList gives no-copy items under any circumstances, whether it's attached or not.

The only work-round I can think of -- and I've used it pretty successfully when I want products I'm selling to give out props that I don't want to make copy-transfer -- is to use llHttpRequest to send a message, via an external service, to an in-world server telling it what to send and who to send it to, and have that send out the objects in question.   I'm wondering if a variation of that would work.

It sounds complicated, but, in practice, I was very pleasantly surprised at how easy it was, using this example in the wiki as a model to adapt.   They even provide the external service, which was very useful when I was testing it.

 

Link to comment
Share on other sites

There's no need to use an external service for this Innula, it's just the way networked vendors throughout SL work, and yes, it is a good idea.

Keeping ALL your things in one server (plus optional backups) and having different vendors/objects send the delivery instructions is tried & tested and makes it a lot easier to maintain everything.

  • Like 1
Link to comment
Share on other sites

Yes, you seem to be right about the GetInventoryList.  Or at least using the code snippet I found I kept getting error messages about no-copy items.

I'll look into llHtppRequest because although I do not think I will use it this time, I'd still like to know as much about it as I can.

Thanks for your help Innula.

 

I did really want the person to be able to unpack their cupcake while wearing it (and it worked so well when testing with the avatar who created and so has copy perms on the contents......but of course fell apart when I sent the cupcake to my testing-alt....heh heh), but I guess I'll have to settle for rezzing in-world because I'd like to get it finished (Halloween is getting closer), hopefully today.

 

Thanks for your input Void, Innula, and Peter.:matte-motes-grin:

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4601 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...