Jump to content

Confused about how to identify owner of an object on touch to allow only them to affect object


Katherine Heartsong
 Share

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

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

Recommended Posts

I'm trying hard to understand the basic "if" and "else" statements but basically keep not having them compile correctly.

If simply trying to do the following on the touch of an object ...

if the owner touches this
do this
else
say "you're not the owner" (and stop)

Can someone help me with that first line?

 

Link to comment
Share on other sites

Off the top of my head:

if(llDetectedTouch(0) == llGetOwner())
{
	llSay(0, "Hi, boss!);
} else {
{
	llSay(0, "You're not the boss of me!");
}


Another way of achieving pretty much the same is as follows:
 

if(llDetectedTouch(0) != llGetOwner()) // if the toucher is NOT the owner
{
	return; 
} 

This makes the script simply abort the touch event if touched by anyone else but the owner, no matter what comes after this little snippet

Edited by Fritigern Gothly
added the other method
  • Thanks 1
Link to comment
Share on other sites

3 minutes ago, Fritigern Gothly said:

Off the top of my head:

default
{
    touch_start(integer num_detected) // this "event handler" is called automatically on a touch
    {
        if (llDetectedTouch(0) == llGetOwner()) // llDetected Touch only works only inside touch event handlers
        {   llSay(0, "Hi, boss!); } 
        else
        {   llSay(0, "You're not the boss of me!"); }
    }
}

That needs to be inside a touch event handler, like this.

  • Thanks 1
Link to comment
Share on other sites

If you want to be really fancy. . .

default()
{
  touch_start(integer n)
  {  key owner = llGetOwner();
     while(~--n)
     {  key toucher = llDetectedKey(n);
        if(toucher!=owner)
        {  llRegionSayTo(toucher,0,"This object is owner only");
        }else
        {  // do the thing for the owner.
        }
     }
  }
}

 

Edited by Quistess Alpha
';'
Link to comment
Share on other sites

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