Jump to content

Need help with scripting scenario


Loki Eliot
 Share

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

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

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

Link to comment
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
Link to comment
Share on other sites

  • 2 weeks later...

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
Link to comment
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

Link to comment
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
Link to comment
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?

Link to comment
Share on other sites

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