Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Best Way to Do This: Item w/Multiple Buy Options

Ael Oh
Registered User
Join date: 1 Jul 2007
Posts: 4
10-15-2007 15:08
I'm working on something for an RP sim that is becoming much more complex than I want it to be, and I'm hoping someone with more scripting experience can tell me a better way to get the effect I want.

The basic idea is a candy store, where the avatar can pick from several choices of candy, or a random assortment. The candy has various RP effects, represented by animation changes, sounds, particles, and text. I want the candy to disappear when eaten. I would like candy to be able to be shared. I don't want to flood the customer with 50 pieces of candy going into their inventory. Candy must be wearable, since the avatar might not be able to rez it.

The easiest way I can think of to allow multiple effects, control inventory, and make eating the candy relatively easy is to store the candy in a bag, and have the bag wearable, and possess most of the scripting power. The candy could be objects, but since they're never actually rezzed, I was thinking of making them just notecards, that contain the information needed to generate their effects. So when a piece of candy is eaten, the bag script reads the notecard, figures out what text and animations to play, then removes the notecard to represent the candy being eaten. A menu system would make it easy to pick the type of candy (and have controls to shut off candy effects if they're bothering the avatar).

So far, this is all more complex than I want it to be, but doable. The problem is getting the candy in the bag.

The candy vendor will allow the avatar to pick between 1 and 5 kinds of candy (depending on bag size), or a random selection. So what is going in any one bag of candy can vary widely. I can't just make up 15 different bags of candy, and let them pick one to buy. (Well I could, but that takes away the "picking your candy" candy shop feel I'm going for.) Instead, I have to build the contents of each bag individually at the time of purchase.

You can only give items to objects that are rezzed. So I will have to have the candy counter give an already rezzed bag of candy the candy notecards that represent their candy selection. Then the avatar buys the bag (and gets a copy of its contents). But apparently you can't give identical items to an object??? If I give the CoolCandy notecard 5 times, only one copy will appear? So if I want the candy store to put up to 25 pieces of CoolCandy in the bag, I would have to have 25 CoolCandy notecards in the candy vendor, and if I also want to sell NiftyCandy, then that's 25 more notecards? All so that I can ensure that I am always able to give up to 25 unique copies of the notecard. If I want to have 15 different kinds of candy, that's a lot of notecards, and will slow down script processing. I'd really like to avoid this. Am I being dumb? Am I misreading how giving inventory works?

All the other ways I could think of to keep track of inventory wouldn't work because of this or that SL limitation, but maybe I'm missing something really obvious. If you were trying to make this kind of vendor, what would you do to give objects, keep track of inventory, and keep it simple to use?
Darien Caldwell
Registered User
Join date: 12 Oct 2006
Posts: 3,127
10-15-2007 15:19
I would probably have all the info about what animations and effects for each type of candy, and have the candy counter tell the bag how many pieces of each it "contains" via a negative chat channel. Then have the script keep track of how many pieces are left. If the script and item are made no modify, then the script can't be reset by the user. Of course you could make it so the script defaults to 0 of all types of candy, that would prevent cheating should someone try resetting the script. Script data pesists when taken back into inventory, so you shouldn't have people losing candy. I would drop the whole notecard idea altogether. :)
_____________________
Ael Oh
Registered User
Join date: 1 Jul 2007
Posts: 4
10-15-2007 17:39
Yup, I missed the obvious. For some reason I thought that if I stored the inventory information in the script that it would be really fragile and prone to resetting, so I wanted something more persistent. It sounds like I'm dead wrong about that, so I'll try it the way you suggest and see how it goes.

I might keep the candy information in notecards anyway, to make the code a little more modular. I can just add a new notecard instead of changing the script. But at least there will only be one notecard of each type of candy, and I can have the script clear out notecards for any candy that is at zero to speed things up. I'll have to play with things and see what ends up being easier to maintain. I hope to add new candy every month, so I'd like the update to be as painless as possible.

Thanks so much for your quick and helpful reply!