Jump to content

Object relays chats and talks as Owner


Zamboi Bracken
 Share

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

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

Recommended Posts

Hi all.

I made a script which could relay chat typed in the presence of an object back to its owner if he/she/it was not around. I use llTextbox for the owner to type back as if the object was engaging in the conversation. 

1) I was wondering if there was a better way than using the Textbox to act like the object was talking

2) Is it possible to use  name and message in the no_sensor event so it can use llOwnerSay(name + ": " + message)  

instead of declaring:

nam = name;
msg = message;  

which shows it to Owner by  llOwnerSay(nam + ": " + msg)

 

 

Thanks in advance!

 

 

//Script start

integer listener;
integer Channel = 23;

string nam;
string msg;

textbox()
{
llListenRemove(listener);
listener = llListen(Channel,"","","");
llTextBox(llGetOwner(),"\n\nType as object below: ",Channel);
}

default
{
state_entry()
{
}
touch_start(integer total_number)
{
textbox();
llListen(0,"","","");
}
listen(integer channel,string name,key id,string message)
{
if(llGetOwnerKey(id) == llGetOwner() & (channel == Channel) )
{
llSay(0,message);
}
else if(llGetOwnerKey(id) != llGetOwner() & (channel == 0) )
{
nam = name;
msg = message;
textbox();
llSensor("",llGetOwner(),AGENT,20,PI);
}
// To be contacted wherever you are on the grid eg. remote listener, uncomment the following line
// llInstantMessage(llGetOwner(),name + ": " + message + " | Channel: "+ (string)channel);
}
sensor (integer numberDetected)
{
}
no_sensor()
{
llOwnerSay(nam + ": " + msg);
}

//End 

Link to comment
Share on other sites

llTextBox is fine.  

Putting the llOwnerSay message in the no_sensor event is also fine, so long as you are always planning to be in the same sim to receive the message.  Otherwise, use llInstantMessage.  You obviously can't use the variables name and message directly, since they are not global variables.  Your solution is the only way to go.

You may want to use a channel other than 23, which could pick up cross-talk from other scripts.  My own solution is to create a negative channel from the first six characters in the owner's UUID, but there are many other possible ways to create a unique channel.

Link to comment
Share on other sites

Thank you for your inputs Rolig.

Is there any way for the Owner to say something in the chat line which could be picked up by the Object and spoken.

Textbox is good but I wish it could publish the typed text when the Enter key is pressed (like with chat) 

 

For eg.

Owner typing   /Object How are you

would make the Object say "How are you" 

Also that the owner's call should not be visible on chat.

I think that is not be possible but just fishing for ideas. Thanks again!

Link to comment
Share on other sites

Hello if the object is listening to e.g. channel -123 then the owner can type

/-123 blah blah blah

If i remember right this won´t show up in chat but the object can "hear" it, so far only when it´s in chat range what makes it obsolete as a long distance relay. You could have an attachment that listen and forward .... but that´s going to be a mess ;)

You might best stay with your textbox solution.

Monti

Link to comment
Share on other sites

The public chat channel is 0 ... perfectly good for us to talk on, although I would generally avoid scripting an object to listen on it because that makes a lot of work for the servers.  Shout still works.  If you're scripting it, you can use llShout.  If you're typing it in chat, shout it with CTRL + Enter.  If you're worried about chat range, use llRegionSayTo, which sends a directed message to a specific person or object anywhere in the sim.

Link to comment
Share on other sites

    state_entry(){        llListen( 42, "", "", "" ); //-- listen on channel 42 for any messages    }        listen( integer vIntChn, string vStrNom, key vKeySrc, string vStrMsg){        if (llGetOwner() == llGetOwnerKey( vKeySrc )){ //-- only respond to owner or objects they own            vStrMsg = llStringTrim( vStrMsg, STRING_TRIM ); //-- remove leading/trailing spaces            if (!llSubStringIndex( llToLower( vStrMsg ), "object " )){ //-- make sure the sentence starts with "object " (case insensitive)                llSay( 0, llGetSubString( vStrMsg, 7, -1 ); //-- repeat what was said, minus the keyword            }        }    }}

 the listen is not filtered in the call to allow for multiple inputs, and is intead filtered in the listen event

llGetOwnerKey returns the the owner of the speaking object (avatars own themselves)

llStringTrim lets you remove spaces at the begining, end, or both, allowing numbers at the start of a chatted channel message to not be appended to the channel (not needed here, but helpful in general)

!llSubStringIndex == (llSubStringIndex == 0)

llLower lets you ignore capitilization and test only that the letters are correct

llGetSubstring( vStrMSg, 7, -1 ) reads the string starting aftert the 7th character to the end of the line, skipping the command phrase.

Link to comment
Share on other sites

Void,

First off thanks for the script.

 I was wondering if the object could relay only the chats in which it was referenced .

For. eg. How are you doing Object.............this would be relayed to the owner becasue it has the word object

 How are you doing......would not be relayed 

This is just for not requiring the sentence to start with object 

Link to comment
Share on other sites

to detect the keyword anywhere in the sentence you could use
~llSubstringIndex( vStrMsg )

or if you wanted to be sure that the keyword was separate from other words (like "Objective") you could use
~llListFindList( llParseStringToList( vStrMsg, [" ", ",", "'", "\"", ".", "?", "!"], [] ), ["Object"] )

Link to comment
Share on other sites

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