Jump to content
Sign in to follow this  
Loki Eliot

Need help with scripting scenario

Recommended Posts

I have a scenario im trying to work out, any advice would be spiffing.

Scenario...

I have an object that tells the user info on where to find a key

object say: Find key in the woods

 

I want the user to find the key and return then drop the key next to the object

Object says: you found the key.

 

That bits simple.

 

BUT between the first click of the object and the dropping of the key, i want the object to say something else when clicked

object say : Have you not found that key yet?"

this bit i dont know how to do. 

The object would have to remember the person who clicked the first time so that it does not repeat the first message. It's probably dead simple, i just need pointing towards the area of scripting. :)

Share this post


Link to post
Share on other sites

I'd simply keep a name/key list of the avs who previously clicked the object and  go check the list for it when clicked ( llListFindList() )

 

something like:

 

touch(integer num_detected){    if(~llListFindList(avList, (list)llDetectedKey(0)))    {        // AV is in the list, so already clicked once    }    else    {        // AV is not in list, say your thing and        avList += (list)llDetectedKey(0); // Add the person to the list    }}

 

Then when the person rez the object next to it, you can clear the person name from the list using llListFindList again like;

 

integer bleh = llListFindList(avList, (list)llDetectedKey(0));avList = llDeleteSubList(avList, bleh, bleh);

 

You could manage more than 2 phrases like this by just adding an integer next to the person's name to keep how many time the person clicked the object

 

 

  • Like 1

Share this post


Link to post
Share on other sites

Might also want to keep the list to a known safe length, forcibly forgetting the oldest records at the front of the list, to not exhaust memory. Those oldest records are likely folks who have abandoned the quest anyway.

  • Like 1

Share this post


Link to post
Share on other sites

I wouldn't determine how old the record is, but I could know which one is the oldest: I'd just always add new records to the end of the list, and delete them from the front when the list was getting too long.

To answer the question literally: one might use a strided list, so you always store two elements, the avatar's key and a timestamp such as that returned by llGetUnixTime, then remove the pairs with timestamps too much less than the current timestamp value. Or, equivalently, keep two parallel lists, one with avatar keys and the other with timestamps, and manage those accordingly. 

The thing is, it's just to avoid the dreaded stack/heap collision--there's no right answer to "how old is too old?"--so I'd just punt on that, and make the list some fixed length.

  • Like 1

Share this post


Link to post
Share on other sites

Really struggling to understand all this. Thanks everyone for your help though. 

I cobbled together this script, but it seems to throw out messages twice :-s

 

list AvList;default{     state_entry()    {        llSay(0, "Hello, Avatar!");    }touch(integer num_detected){    if(~llListFindList(AvList, (list)llDetectedKey(0)))    {        // AV is in the list, so already clicked once               llSay(0, "IM IN THE LIST!");}    else      {        // AV is not in list, say your thing and        llSay(0, "I JUST GOT ADDED TO THE LIST");        AvList += (list)llDetectedKey(0); // Add the person to the list    }}}

 As for implamenting a timed, old record deletion, your on a level thats byond my current abilities. :-p

Share this post


Link to post
Share on other sites

Ok i think i understand this actually, but wouldn't i need to have more than 5 entries before this works,i'd never get a list above 1 becasue it would keep deleting the last 5 entiries?

Share this post


Link to post
Share on other sites

how does one dictate how long a list can be before deleting , do i doe something like

avList = llDeleteSubList(avList, 20);

 would this mean the list would grow to 20 then each time after record 20 would be deleted?

Share this post


Link to post
Share on other sites

This would always  keep 5 etries in your list

list AvList;default{     state_entry()    {        llSay(0, "Hello, Avatar!");    }touch(integer num_detected){    if(~llListFindList(AvList, (list)llDetectedKey(0)))    {        // AV is in the list, so already clicked once               llSay(0, "IM IN THE LIST!");}    else      {        // AV is not in list, say your thing and        llSay(0, "I JUST GOT ADDED TO THE LIST");        if(llGetListLength(AvList) - 5 > 0) {        	AvList = llDeleteSubList(AvList, 0, llGetListLength(AvList) - 5);        }        AvList += (list)llDetectedKey(0); // Add the person to the list    }}}

 ETA:

And use touch_end instead tuch as I did here ;)

  • Like 1

Share this post


Link to post
Share on other sites

just so i understand th '5' in this 

       if(llGetListLength(AvList) - 5 > 0) {        	AvList = llDeleteSubList(AvList, 0, llGetListLength(AvList) - 5);

 makes sure there are always the 5 latest records in the list? so if i replaced the '5' with say '10' then the list would always be 10?

Share this post


Link to post
Share on other sites

Things were really rolling with this untill i tried to add a bit where after recieving the correct password the objects removes the person from the list. Im thinking this might be inpossible unless the object can figure out who owns the object the password comes from :-s

Share this post


Link to post
Share on other sites

Yes the avatar rezes a key which says on a channel the password which in turn twlls the object with the list to say well done and was hoping would remove the person who rezzed the key from the list so they could start again if wanted to

Share this post


Link to post
Share on other sites

well, if the key says the password, then you can easily figure out the avas key. The listen event gives you the UUID of the key - just get the owner of the owner of the key by using llGetOwnerKey()

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...