Jump to content

llGetOwner breaks my tiny script


PeterAims
 Share

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

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

Recommended Posts

I have a tiny listener script that breaks when I change it to llGetOwner. I have read that I need to add this function because its appropiate for HUD's, but it seems to break my listener script, please help.

 

This works:

default
{
state_entry()
{
llListen(1234, "", NULL_KEY, "");
}

listen(integer channel, string name, key id, string message)
{
if (message == "tex3") llSetTexture("xxxxx-xxxxx-xxxxx-xxxxx-xxxxx", ALL_SIDES);
}
}

When I change NULL_KEY to llGetOwner it stops working

default
{
state_entry()
{
llListen(1234, "", llGetOwner(), "");
}

listen(integer channel, string name, key id, string message)
{
if (message == "tex3") llSetTexture("xxxxx-xxxxx-xxxxx-xxxxx-xxxxx", ALL_SIDES);
}
}

Link to comment
Share on other sites

Where is the message coming from?   The llListen in the first example tells the script to listen for all messages on channel 1234.   The llListen in the second example tells the script to listen only for messages from the owner on that channel.  

If, as may be the case, you want to listen for messages from objects belonging to the owner, as well as messages from the owner , you need something like this

 

key owner;//placeholder for the owner's uuiddefault{	state_entry()	{		owner = llGetOwner();//get the owner's uuid		llListen(1234, "", NULL_KEY, ""); //listen to messages from anyone on 1234	}	changed(integer change)	{		if (change & CHANGED_OWNER){//if the owner changes			owner = llGetOwner();//get the new owner's uuid		}	}	listen(integer channel, string name, key id, string message)	{		if (llGetOwnerKey(id) == owner){ // if the message is from an object belonging to my owner, or from my owner,			if (message == "tex3") llSetTexture("xxxxx-xxxxx-xxxxx-xxxxx-xxxxx", ALL_SIDES);		}	}}

 

  • Like 1
Link to comment
Share on other sites

I opologize, I didn't think of including the HUD script beleiveing it wasn't the problem also. Here is the sending script.

 

integer channel = 1234;

default
{
touch_start(integer total_number)
{
if (llDetectedLinkNumber(0)== 2)
llRegionSay(channel, "tex3");
}
}

Link to comment
Share on other sites

Thanks.   Then my fix should do it.    llListen(1234,"",llGetOwner(),"") tells the object to listen for messages coming from your uuid.   Since the hud has its own uuid, the script can't hear messages from the hud.  Use an open listener and, in the listen event,  the filter I suggest

if (llGetOwnerKey(id) == owner) 

and then the script will react only to messages from you or from your objects.

Link to comment
Share on other sites

A key owner place holder seems like It won't be suited for giving the HUD and receiving object away to others. From what I seem to under stand a key owner place holder would restrict the HUD to only working for me.

Link to comment
Share on other sites

No, I'm sorry but you are misunderstanding.

You want your script to listen to messages not only from you but also from objects belonging to you (in this case, your hud).

LSL doesn't support regular expressions in llListen, so you need to use an open listener, llListen(1234,"",NULL_KEY,""), which means "listen for all messages on channel 1234" and then to filter in the listen event for messages from objects belonging to you  -- if (llGetOwnerKey(id)==llGetOwner()).   If that test returns TRUE, go ahead and do something.   Otherwise ignore it.

The only reason I used a placeholder, "owner", to hold the owner's uuid (not the hud's) rather than llGetOwner() is that the UUID of the owner isn't going to change very frequently, so it's a waste of time to keep on checking to see who the owner is every time the script hears something on 1234.  

 

Link to comment
Share on other sites

Oh right, I am so new, it was a small hurdle coming up with this on my own. This is good homework to study with, your help is invaluable for a new mind trying to understand scripting.

I just remembered one last question. I this script properly suited for giving it away to others, or when a owner changes?

Link to comment
Share on other sites

Wow. This works fine, I can't thank you enough. This makes giving away functional objects so much more enjoyable.

P.S.

"If the new owner changes, get the new owner's uuid" 

I had missed that on first looking at it. lol

Link to comment
Share on other sites

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