Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

How to create a simple Easter Egg Hunt?

Welleran Kanto
Registered User
Join date: 15 Mar 2008
Posts: 64
05-27-2008 13:50
I'm working on creating my own scavenger hunt, also commonly called an Easter Egg Hunt. I'm new to scripting, and not an experienced coder. Here's what I want to create:

East Egg Hunt

An avatar takes a copy of my "scoring object". When the avatar explores Second Life and clicks one of my "easter eggs", the scoring object records that click. When *all* 5 easter eggs have been touched by this avatar, the scoring object knows it, and gives a prize.

I've gotten some good advice from helpful people in the NCI Scripters' group [sadly, I can't name names; it's against the rules]. I was advised to start simple:

Create one Egg object that sends a message, when an avatar touches it. Create a 2nd object that listens for such messages, and sends a message that tells who touched the Egg.

I've done that. Now I face the challenge of keeping score.

How should I do this? My Eggs can say "Avatar Smith touched me". I think I need to know how to make the scoring object keep track of which Egg Avatar Smith touched, and to check whether all the Eggs have been touched yet.
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
05-27-2008 15:24
You have basically answered your own question, the actual mechanics are open to individual preferences.

You need a mechanism for Knowing which "eggs" are in the current game.
Lots of different approaches to this. The simplest would be to hardcode the data into the scorecard. Very limiting but would be ok for 5 eggs as a tester.
Create your eggs and then record their ID's in a list in the script. Then as each is found tick them off to prevent doubling up - I'd delete them from the list and then when the list length is zero you have won.

Another way would be an inworld server object that issued a list of eggs for a game, as you place eggs they would regiser them selves with the server. hen teh user could request a new game and of you go....

See how this snow balls?
_____________________
I'm back......
Nih Grun
Registered User
Join date: 30 Apr 2008
Posts: 58
05-27-2008 20:10
One way of doing this (that I found easy, at least) is to keep a database that stores the user's UUID, their egg count, and which eggs have been collected. The script simply tells the database which user has touched which egg and allows php to handle the scoring logic. Your egg simply waits for a response from the server as to how to continue.

You can also give the user a textured egg, just for fun. Make them physical and they can race them down a hill.

Not to be too much of a link whore, but you can see this method in action here:

http://slurl.com/secondlife/Tiramisu/13/154/2601/?title=Skull%20Service%20Platform%2077&msg=Skull%20Service%20Platform%2077

Click the yellow exclamation marks to begin questing. It's persistent, much like how you want your eggs to be.
Squirrel Wood
Nuteater. Beware!
Join date: 14 Jun 2006
Posts: 471
05-27-2008 23:42
How to keep track:

Each egg has a specific message it tells the player who touches it.

Your score keeper script has these messages stored in a list. And removes the specific message from the list when it hears it.

That way each egg is only counted once and you also know that you are done with the quest once the list which holds the messages to check for is empty.
Atom Burma
Registered User
Join date: 30 May 2006
Posts: 685
05-28-2008 06:20
This script will give out cash for a scavenger hunt. Just drop it into a prim and set the price. Maybe that will help you.


// Pay&Die by Dackedidi Miles 2007
//
key id;
integer amount = 10; // amount to give
default
{
state_entry()
{
llRequestPermissions(llGetOwner(), PERMISSION_DEBIT);
}
//
//
touch_start(integer total_number)
{
id = llDetectedKey(0);
llGiveMoney(id, amount);
llDie();
}
on_rez(integer start_param)
{
llResetScript();
}
}
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
05-28-2008 07:07
From: Atom Burma
This script will give out cash for a scavenger hunt....

Unless you really, really want to give out LOTS of money, I strongly advise NOT using that script. It doesn't check for duplicates, and requires only a click from the recipient. You may wind up with a crowd of avatars standing around your object, their users continuously clicking and clicking and clicking. If that's the next form of camping, it's going to get expensive quickly!
Welleran Kanto
Registered User
Join date: 15 Mar 2008
Posts: 64
05-28-2008 10:08
I'm so glad I asked... I never thought of making a list first, and then *removing* items in it.

Brilliant! Thanks so much! I will take this idea and see what I can code with it.

Any prize this Hunt would give would be an item, not L$. I'm making this for teachers to use; they won't have money to give, usually. I've seen free giver scripts, so I'm not worried about the giving part.

I also don't care much about security -- simply choosing a channel with a large number would be enough. I won't care if someone hacks it and gets a free item -- as another kind person told me, in-world, if your professor-guest can hack the system, then you've already accomplished your mission [which is to coax them to explore SL and learn how to use it].

Thank you, everyone!
Nichiren Dinzeo
Registered User
Join date: 14 Feb 2007
Posts: 203
06-01-2008 07:24
neat idea...... i invite you to visit slgeocaching.com
its a metaverse cache hunt site. been around for awhile....lots of fun