Jump to content

Help scripting a specific object giver


Charli Infinity
 Share

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

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

Recommended Posts

I want to make an prize giver  that will only give out an object (prize) when a person rezzes another object (the hidden object) on it.

 

It's for a simple finding hidden object game like this:

1. Person find hidden objects on a land (for example an apple, an orange, a lemon)

2. Person takes a copy of the hidden object

3. Person rezzes the hidden object on the prize giver station (something that looks like a table or pedestal)

4. Prize giver station detects the object rezzed on it and gives out the prize accordingly ( for example a red dress for an apple, a orange dress for an orange, yellow dress for a lemon) to the person

 

The prize station must detect the actual copy of hidden object found in the game only, meaning the person can not just make a cube name it "apple", rez it on the station and get the prize.

 

Help script this prize station that can detect object on it and give out prize accordingly?

Is there a script that can do this already?

 

 

There was an event called CSR in 2007 which uses a system like this where people can get a stamp card, go around collect stamps from different stores then when they have enough stamps they can rez the stampcard at a prize station and redeem different prizes. If the person does not have enough stamps the prize will not be given. It was an event by japanese creators if I remember correctly.

 

 

Link to comment
Share on other sites

That's a pretty common type of system.  All you really need is two scripts: one that sends a brief message a second or so after it is rezzed and a second one that listens and responds by giving a prize.  Generically....

default{    on_rez(integer startup)    {        llSleep(1.0);        llWhisper(-987654,"Sekrit message");    }}

 and

default{    state_entry()    {        llListen(-987654,"","","Sekrit message");    }    listen (integer channel, string name, key id, string msg)    {        llGiveInventory(llGetOwnerKey(id),"Big Prize");    }}

 You can add bells and whistles and you can take further steps to be sure that it's hard to game the system, but that's all it is.  You speak nicely, I give you a prize.

 

Link to comment
Share on other sites

Good.

Now, that's bare bones. If you want to take steps to keep someone from taking more than one prize, or claiming a prize after the deadline, or if you want to use the system for picking up more than one kind of prize, or you want people to pick up prizes in a particular order, or .....  you'll have to start adding bells and whistles.  You'll probably want to take steps to be sure that only the right people can get the key card and that it's no-copy/no-mod and that it won't work if it has been transferred to another person.  Once you get beyond the basic idea, there is still plenty of room for improvements.

Link to comment
Share on other sites

You start learning by working through tutorials like the ones in the LSL wiki and by practicing.  Find some freebie full-perm scripts and dissect them to see how they work (like the ones I posted).  Change something small.  When you get more confident, start changing more complicated things.

Or post a question in the InWorld Employment forum and hope that a hungry scripter is willing to write something for a price.  :smileywink:

Link to comment
Share on other sites

ok...thanks for the pointers.

 

Btw, are most scripters computer/software programmers in real life? Is LSL scripting like programing languages in real life? Like is it similar to Java or C in how it is written? Do people that know programming in real life automatically understand how to write LSL scripts?

Link to comment
Share on other sites

:catlol:I have started scripting after 7 years in SL because I totally wanted to make a system like yours. I had by chance a few SL friends who are great scripters and who gave me some guidance (plus people on this forum). I think I have become quite a good scripter in less than a year.

The first steps are the hardest, but once you understand the basic principles you'll see that it is like playing Sudoku with much nicer results at the end... 

 

 

 

 

Link to comment
Share on other sites

Ok I've noticed a problem with this whisper system

The problem is the prize station detects the hidden object even when the hidden object is rezzed far away from the prize station (anywhere within 10m of the prize station)

 

Is there a way to make the whisper range shorter than 10m?

I want the prize to be given out when the hidden object is rezzed on the prize station surface not anywhere around it.

Link to comment
Share on other sites

There are many ways to do that.  I used llWhisper because I didn't know that it was crucial for the rezzed object to be right on top of the prize giver, and whisper range is a convenient "close enough" distance for many things.  If you want to shorten the distance, you need some way to find out exactly where the rezzed object is.  You can do that with the function llGetObjectDetails, which you can manipulate to tell you the position of an object if you know its UUID.  Conveniently, you do, if the object speaks.  So

default{    state_entry()    {        llListen(-987654,"","","Sekrit message");    }    listen (integer channel, string name, key id, string msg)    {        list Details = llGetObjectDetails(id,[OBJECT_POS]);        vector Where = llList2Vector(Details,0);        if (llVecDist(Where,llGetPos()) < 0.5)        {            llGiveInventory(llGetOwnerKey(id),"Big Prize");        }    }}

llGetObjectDetails produces a list.  In this case, the list is really short, because I only asked it to tell me one thing about the object whose UUID is id.  I then find the object's position in the list and I ask, ,"OK, is that position within 0.5m of where this script is?"  If so, I hand out the prize.

Why 0.5m?  It's arbitrary, but I have to chose some distance, and I know it will have to be bigger than zero (because that's precisely where the center of the prize giver is).  So 0.5m is "close enough".

If you play with the problem only a little bit you'll probably think of many other ways to solve it, but this one is quick and simple.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3401 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...