2012-02-07

Random content giver

Yesterday Miss Eve IMd me in-world to ask if it would be possible, with a script, to give a random object out from an object, on touch. Moreover, would it be possible if the objects were transfer-only. Obviously, I've written plenty of code before that gives inventory, but I've never done anything that quite relates to this particular situation (coincidently it also crossed over nicely with a question that had been asked in a scripting help group the day before, to which I'd suggested an approach but which I'd not tried myself).

So, having said that I couldn't see a reason why it would be a problem, I had a quick play. What follows is the result. I'll stress that this was just for testing purposes, I suspect that it wouldn't scale too well if you had an object with a large inventory to give out, and I'd suspect that the script time peak when loading the array would be higher than I'd like too.

But, on the off chance that it's a useful start for someone to work from, here's what I came up with when testing (note that it also has a "give only once to each avatar" checker in there too):

2 comments:

  1. The swing is still upside-down though... send the field guys over for a spanking :P

    ReplyDelete
  2. Well Miss, considering Z&A is a team that hails from Oz and the UK, it's technically correct. But seeing as how it's the swing that's upside-down I guess that's Z's fault. I'll let her know...

    ReplyDelete