Jump to content

One avatar at a time touch controller


Ackley Bing
 Share

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

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

Recommended Posts

I made a routine that gives touch ownership allowing only one person at a time to access your touch commands.

If a second avatar touches, the first person must give the second person permission before touch control is handed over. Touch control is automatically given to anyone as long as they are the first one to touch it. Add your own code for additional security (listen channel, etc).

key controllerKey = NULL_KEY;
key requesterKey = NULL_KEY;

default
{
    touch_start(integer total_number)
    {
        if (controllerKey != NULL_KEY)
        {
            if (llDetectedKey(0) == controllerKey)
            {
                // YOUR TOUCH COMMANDS GO HERE
            }
            else
            {
                requesterKey = llDetectedKey(0);
                llListen(1, "", controllerKey, "");
                llDialog(controllerKey, llKey2Name(requesterKey) + "wants contol of me.  Hand over controls?", ["Yes","No"], 1);
            }
        }
        else if (controllerKey == NULL_KEY) controllerKey = llDetectedKey(0);
    }

    listen(integer chan, string name, key id, string message)
    {
        if (chan == 1 && id == controllerKey)
        {
            if (message == "Yes")
            {
llListenRemove(1);
llInstantMessage(controllerKey, "You have granted control to " + llKey2Name(requesterKey) + "."); llInstantMessage(requesterKey, llKey2Name(controllerKey) + " has granted control to you."); controllerKey = requesterKey; } else if (message == "No")
{
llListenRemove(1);
llInstantMessage(requesterKey, llKey2Name(controllerKey) + " is already in control.\nYou must wait until they are done.");
} } } }

 

I have no idea what will happen if many people are all trying to touch it at the same time. :smileywink: I didn't test that possibility.

Link to comment
Share on other sites

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