Jump to content
Sign in to follow this  
Aeryn Brooks

Object Give Inventory in One At a Time

Recommended Posts

Hi everyone. I'm relatively new to scripting and need to find a way for an object to give one of it's copy inventory objects at a time.

 

I'm making a dispenser of ribbons for a game I plan to sell. The ribbons are set to copy/trans so the holders can give their one away, but not make infinite copies and cheat. To ensure that the purchaser/overseer of the game doesn't just buy the system and give it away, I need to make the ribbons copy/trans and include several in the box with names like "Ribbon", "Ribbon 1", "Ribbon 2", etc. How can I script the box to just give one ribbon to whomever clicks it, and not all of them at once? I know there's a way because the RPS roleplay system has a vendor script that does exactly that.

 

I appreciate any help anyone can give me. :matte-motes-bashful-cute-2:

Share this post


Link to post
Share on other sites

Are you sure? I would think that would give away "Ribbon", but once that one's gone it'll break the script and won't give away "Ribbon 1", "Ribbon 2", etc. Remember, whomever buys the game will receive several copy/transfer ribbons in the dispenser that he or she will give away to others.

Share this post


Link to post
Share on other sites

You don't need a list. The inventory is already a list. Here is a very short script for an object to give its inventory one item at a time until it's empty. (I suppose your ribbons are objects.)

default{    touch_end(integer num)    {        key av = llDetectedKey(0); // First toucher        string item = llGetInventoryName(INVENTORY_OBJECT, 0); // First object        if (item != "") // Still one item left at least...        {            llGiveInventory(av, item); // Give it.        }        else // ...otherwise, complain.        {            llRegionSayTo(av, 0, "Sorry, the box is empty.");        }    }}

 Simple, isn't it?

(Although I typed it directly into the popup window to paste scripts, I'm confident it will compile.)

 

Share this post


Link to post
Share on other sites

Wow, that's easy too! Thank you, I haven't gotten a chance to try either yet but I'll try this one first.

 

ADDENDUM: Except that "default" was misspelled, it worked perfectly! Thank you both so much!

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...