Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

llSay, llInstantMessage, llOwnerSay, and why I hate you.

WhiteStar Magic
Build it+Script it=RUN!
Join date: 24 Jul 2008
Posts: 36
03-04-2009 16:10
// Sample Applet to demonstrate Quiet (spamless) Communications
// The Methods here can be applied to many systems.
//
// The Main Purpose is to demonstrate how one can make use of
// Spam-Less Methods to communicate directly with individuals
// and to provide a basic working framework that shows this in action.
//
// NOTE:
// This is part of a considerably larger system I developed, which "chats"
// as it works with people, depending on their access levels/controls.
// I have included a bit of TEST DATA so that you can see how this works
// and some samples that call it and make it work.
//
// Use this or any part herein AS/IS Whereis however you wish.
//
// A Few parts of this code are NOT optimal but for the purposes of this
// example / sample, it should work fine.
//
// chat_out(key av_key, string babble) is the item of most interest in this example
//
// ======================================================================
//
integer counter = 0; // for the sample
//
list auth_list = ["John Doe","Peter Rabbit","Easter Bunny"]; // Authorized Users
list manager = ["Zeus", "Appolo", "Psycho Babbler"]; // Managers
list owner = []; // Owners
//
key avi_key; // changing avi key for passing
string name; // tmp store of name
integer Commanding = 0;
// comms
integer ListenHandle;
integer CHANNEL;
//==== TOOL FUNCTIONS ==== \\
//======================== \\
string FreeMem()
{
//float mempct = (100 * llGetFreeMemory() / (float)(16*1024)); // for non-MONO
float mempct = (100 * llGetFreeMemory() / (float)(64*1024)); // for MONO
string percent = llGetSubString((string)mempct,0,4); // displays 75.25%
string memtmpA = (string)(llGetFreeMemory()/1024)+"k ("+percent+"%)";
return memtmpA;
}
//
chat_out(key av_key, string babble)
{
if(IsInLst(owner, name)) llOwnerSay(babble);
else if(av_key != NULL_KEY) llInstantMessage(av_key,babble);
else llOwnerSay("ERROR: Module Chat_Out, av_key = "+(string)av_key);
return;
}
/// --- NEXT --- Strictly for sample excersize Don't Message anyone with anything
/// that would need this.
//chat_out_LONG(key av_key, string babble)
//{
// // String Checking [OwnerSay & InstantMessage Max Len = 1023 bytes
// integer TooLong = FALSE;
// string SplitA;
// string SplitB;
// integer slen = llStringLength(babble);
// if(slen > 1022) // This is WAY TOO MUCH CHATTER ! :D
// {
// TooLong = TRUE;
// SplitA = llGetSubString(babble,0,1022);
// SplitB = llGetSubString(babble,1023,-1);
// //IF it's longer than this ! NUTZ The Sun Rises in the West!
// } // If trying to send THIS Much, better use a LinkMessage to a Messenger Slave
// //Applet and use a Compression for the data
// if(IsInLst(owner, name))
// {
// if(!TooLong) llOwnerSay(babble);
// else
// {
// llOwnerSay(SplitA);
// llOwnerSay(SplitB);
// }
// }
// else if(av_key != NULL_KEY)
// {
// if(!TooLong) llInstantMessage(av_key,babble);
// else
// {
// llInstantMessage(av_key,SplitA);
// llInstantMessage(av_key,SplitB);
// }
// }
// else llOwnerSay("ERROR: Module Chat_Out, av_key = "+(string)av_key);
// TooLong = FALSE;
// return;
//}
///===== END OF TOO_LONG =====\\\
//
touched(key av_id)
{
string avi_name = llKey2Name(av_id);
if (IsInLst(owner,avi_name)) // always check owners first !
{
chat_out(av_id, "Owner Access Granted";);
Commanding = 1;
authorized(av_id);
}
else if (IsInLst(manager,avi_name)) // Check Managers next
{
avi_key = av_id;
chat_out(av_id, "Manager Command Access Granted";);
Commanding = 2;
authorized(av_id);
}
else if (IsInLst(auth_list,avi_name)) // Check regular users last
{
Commanding = 0;
authorized(av_id);
}
else
{
chat_out(av_id, "Sorry "+avi_name+" Authorization Not Granted, Contact an Owner or Manager to Continue";);
}
return;
}
//
authorized(key av_id)
{
if(Commanding == 1)
{
chat_out(av_id, "\nManagers:";);
ListOut(av_id, manager);
chat_out(av_id, "\nAuthorized Guests:";);
ListOut(av_id, auth_list);
// proceed to Owners Functions
MENU_Owner(av_id);
}
else if(Commanding == 2)
{
chat_out(av_id, "\nAuthorized Guests:";);
ListOut(av_id, auth_list);
// proceed to Managers Functions
MENU_Mgr(av_id);
}
else
{
chat_out(av_id, "Authorized Access Granted, Proceeding";);
MENU_Usr(av_id);
// Procceed to Regular Functions
}
}
//
float ListOut(key av_id,list lst) // Dumps lst contents out clean with a CRLF after each entry
{ // For Large Lists StringLength Checking is warranted to prevent
// data loss. chat_out_LONG example (COMMENTED OUT) provided above
integer iLen = -1;
iLen = llGetListLength(lst);
if(iLen >= 0)
{
if(IsInLst(owner,name))
{
llOwnerSay("\n"+llDumpList2String(lst,"\n";)+"\nFree Memory = "+FreeMem());
}
else if(IsInLst(manager,name))
{
llInstantMessage(av_id,"\n"+llDumpList2String(lst,"\n";)+"\nFree Memory = "+FreeMem());
}
}
else llOwnerSay("LIST IS EMPTY";);
return TRUE;
}
//
integer IsInLst(list test_list, string test_item) // test_list to verify if item exist
{
if(~llListFindList(test_list, (list)test_item)) return TRUE; // in list
else return FALSE; // not in list
}
//
// == MENU FUNC'S == \\
OpenChannel() // Generate a Random - Channel for Comms
{
CHANNEL = (integer) llFrand(-100000 - 99999999) - 100000; // Menu Channel (random)
ListenHandle = llListen(CHANNEL,"","","";);
llSetTimerEvent(60.0);
}
MENU_Owner(key id)
{
OpenChannel();
llDialog(id,"== Owners Menu ==",["ONE","TWO"],CHANNEL);
}
MENU_Mgr(key id)
{
OpenChannel();
llDialog(id,"== Manager Menu ==",["ONE","TWO"],CHANNEL);
}
MENU_Usr(key id)
{
OpenChannel();
llDialog(id,"== Users Menu ==",["Process"],CHANNEL);
}
//
// ******** CODE ENTRY ********* \\
//===============================\\
default
{
state_entry()
{
name = llKey2Name(llGetOwner());
owner += name;
}
touch_start(integer total_number)
{
// for the SAMPLE PURPOSES
if(counter < 2 && llDetectedName(0) != name) auth_list += llDetectedName(0);
++counter;
// Have a couple of people touch this so their name is entered
touched(llDetectedKey(0));
}
timer()
{
llListenRemove(ListenHandle);
llSetTimerEvent(0.0);
}
listen(integer channel, string name, key id, string msg)
{
// Owner & Manager COMMANDS
if ((IsInLst(owner,name)) || (IsInLst(manager,name)))
{
llListenRemove(ListenHandle);
if(msg == "ONE";)
{
chat_out(id, "Processing... Please Wait for Completion.\n ! ADVISORY !\nBackup when Completed";);
//excecute(routine_1);
}
else if(msg == "TWO";)
{
chat_out(id, "This can't be undone! Hope you Backed Up!!";);
//excecute(routine_2);
}
}
else if(IsInLst(auth_list,name))
{
llListenRemove(ListenHandle);
if(msg == "Process";)
{
chat_out(id, "Processing Request";);
//excecute(routine_A);

}
}
}
}
_____________________
Build it, Script it & Enjoy It, then Share it !!!
Milton Hayek
Registered User
Join date: 28 Apr 2006
Posts: 25
04-16-2009 16:28
From: Argent Stonecutter
Oh, that's a *sweet* idea. Or else use llInstantMessage(llDetectedKey(0)). Or even... dare I suggest it... promote good coding practice and show people a little conditional love:

touch_start(integer num_detected)
{
key id = llDetectedKey(0);
if(id == llGetOwner()) llOwnerSay("Hello Boss!";);
else llInstantMessage(id, "Hello, Avatar!";);
}


This won't compile for me. Tried it with and without mono checked. I get a syntax error at 0,0. I'm talking about the second suggestion beginning "touch_start ..."

addendum: Neither does the 1st shorter suggestion. It gives a syntax error at 0,17. I think I've figured out the answer to why people use llsay instead of llInstantMessage. Say is easier to figure out how to use. I've been struggling with llInstantMessage for an couple of hours. So, kick me out of Mensa.
Milton Hayek
Registered User
Join date: 28 Apr 2006
Posts: 25
04-16-2009 16:51
From: Lily Cicerone
Re: the 2 second llInstantMessage delay --

For some reason, people always seem to neglect the llMessageLinked function. Instead of having your main script send the instant message, redirect it to another script via

string text = your message here;
key target = the person whom you'd like to contact;
llMessageLinked ( LINK_THIS, 1, text, target );

then in a separate script within the same prim:

link_message ( integer sender, integer number, string message, key id )
{
if ( number == 1 )
{
llInstantMessage ( id, message );
}
}

Now the separate instant message script takes the delay instead of your main script, which is free to continue processing data. Problem solved.

And finally, yes, I agree about chat spam, but do we really need rants in the scripting tips forum? If the spam annoys customers, they'll avoid that store, and the owner will learn or lose sales. If you don't like it, don't visit there. I'm assuming most people who have been in Second Life for more than a year have long since stopped frequenting clubs anyway.


This looks pretty useful. I'm a scripting newb and maybe I'm in the wrong forum. I'd love to have ready to use version of this I could copy and paste into a script to see it work. That way I could change a little bit at a time until it breaks and then back up. Damfino what to do with this.
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
04-16-2009 19:11
From: Milton Hayek
This won't compile for me. Tried it with and without mono checked. I get a syntax error at 0,0. I'm talking about the second suggestion beginning "touch_start ..."

that would be because it's just a fragment... it needs
default{
in front of it, and
}
after it

the other qouted piece is also a fragment
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
SuezanneC Baskerville
Forums Rock!
Join date: 22 Dec 2003
Posts: 14,229
04-16-2009 19:37
From: Milton Hayek
I'd love to have ready to use version of this I could copy and paste into a script to see it work..


CODE

string text = "your message here";
key target = NULL_KEY;

default
{
touch_start(integer total_number)
{
target = llDetectedKey(0);
llMessageLinked ( LINK_THIS, 1, text, target );

}
}


CODE

default
{

link_message ( integer sender, integer number, string message, key id )
{
if ( number == 1 )
{
llInstantMessage ( id, message );
}
}
}
_____________________
-

So long to these forums, the vBulletin forums that used to be at forums.secondlife.com. I will miss them.

I can be found on the web by searching for "SuezanneC Baskerville", or go to

http://www.google.com/profiles/suezanne

-

http://lindenlab.tribe.net/ created on 11/19/03.

Members: Ben, Catherine, Colin, Cory, Dan, Doug, Jim, Philip, Phoenix, Richard,
Robin, and Ryan

-
Milton Hayek
Registered User
Join date: 28 Apr 2006
Posts: 25
Thank you very much! :)
04-16-2009 21:41
Void; SuezanneC:

Thank you both very much. You've made my day.
Milton Hayek
Registered User
Join date: 28 Apr 2006
Posts: 25
inconsistent linked script action - why?
04-22-2009 07:57
Can anyone suggest why this


From: SuezanneC Baskerville
CODE

string text = "your message here";
key target = NULL_KEY;

default
{
touch_start(integer total_number)
{
target = llDetectedKey(0);
llMessageLinked ( LINK_THIS, 1, text, target );

}
}


CODE

default
{

link_message ( integer sender, integer number, string message, key id )
{
if ( number == 1 )
{
llInstantMessage ( id, message );
}
}
}


(with a larger block of text for "your message here" would work as expected one day and two days later the IMs will no longer appear across the screen like chat (as they should and, at first, did) nor cause a blue IM button to appear (not that I expected the button) even though they still show up in chat history? My prefs haven't been changed and I verified they were still set to show IMs in chat (not that that SHOULD be relevant if I understand this). I tried resetting the scripts and I tried creating a new object, creating two new scripts in it, deleting the default text in the new scripts and copying the version with longer text in anew. New object behaved the same way. Then I tried copying in the exact text SuezanneC posted in again. It worked. I made the message longer in steps until it failed again in the same way. A limit to the length of the string is understandable but why should the limit be different at different times?

I just tried this:

string text1 = "This is a long message, line 1";
string text2 = "This is a long message, line 2";
string text3 = "This is a long message, line 3";
string text4 = "This is a long message, line 4";
string text5 = "This is a long message, line 5";
string text6 = "This is a long message, line 6";
string text7 = "This is a long message, line 7";
string text8 = "This is a long message, line 8";
string text9 = "This is a long message, line 9";
string text10 = "This is a long message, line 10";
string text11 = "This is a long message, line 11";
string text12 = "This is a long message, line 12";
key target = NULL_KEY;

default
{
touch_start(integer total_number)
{
target = llDetectedKey(0);
llMessageLinked ( LINK_THIS, 1, text1, target );
llMessageLinked ( LINK_THIS, 1, text2, target );
llMessageLinked ( LINK_THIS, 1, text3, target );
llMessageLinked ( LINK_THIS, 1, text4, target );
llMessageLinked ( LINK_THIS, 1, text5, target );
llMessageLinked ( LINK_THIS, 1, text6, target );
llMessageLinked ( LINK_THIS, 1, text7, target );
llMessageLinked ( LINK_THIS, 1, text8, target );
llMessageLinked ( LINK_THIS, 1, text9, target );
llMessageLinked ( LINK_THIS, 1, text10, target );
llMessageLinked ( LINK_THIS, 1, text11, target );
llMessageLinked ( LINK_THIS, 1, text12, target );



}
}

and it seems to work for now. But will it work tomorrow? How can I tell? Is there a maximum string length at which this sort of thing will DEPENDABLY show up in chat for the person touching the object?
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
04-22-2009 22:54
From: Milton Hayek
Can anyone suggest why this




(with a larger block of text for "your message here" would work as expected one day and two days later the IMs will no longer appear across the screen like chat (as they should and, at first, did) nor cause a blue IM button to appear (not that I expected the button) even though they still show up in chat history? My prefs haven't been changed and I verified they were still set to show IMs in chat (not that that SHOULD be relevant if I understand this). I tried resetting the scripts and I tried creating a new object, creating two new scripts in it, deleting the default text in the new scripts and copying the version with longer text in anew. New object behaved the same way. Then I tried copying in the exact text SuezanneC posted in again. It worked. I made the message longer in steps until it failed again in the same way. A limit to the length of the string is understandable but why should the limit be different at different times?

I just tried this:

string text1 = "This is a long message, line 1";
string text2 = "This is a long message, line 2";
string text3 = "This is a long message, line 3";
string text4 = "This is a long message, line 4";
string text5 = "This is a long message, line 5";
string text6 = "This is a long message, line 6";
string text7 = "This is a long message, line 7";
string text8 = "This is a long message, line 8";
string text9 = "This is a long message, line 9";
string text10 = "This is a long message, line 10";
string text11 = "This is a long message, line 11";
string text12 = "This is a long message, line 12";
key target = NULL_KEY;

default
{
touch_start(integer total_number)
{
target = llDetectedKey(0);
llMessageLinked ( LINK_THIS, 1, text1, target );
llMessageLinked ( LINK_THIS, 1, text2, target );
llMessageLinked ( LINK_THIS, 1, text3, target );
llMessageLinked ( LINK_THIS, 1, text4, target );
llMessageLinked ( LINK_THIS, 1, text5, target );
llMessageLinked ( LINK_THIS, 1, text6, target );
llMessageLinked ( LINK_THIS, 1, text7, target );
llMessageLinked ( LINK_THIS, 1, text8, target );
llMessageLinked ( LINK_THIS, 1, text9, target );
llMessageLinked ( LINK_THIS, 1, text10, target );
llMessageLinked ( LINK_THIS, 1, text11, target );
llMessageLinked ( LINK_THIS, 1, text12, target );



}
}

and it seems to work for now. But will it work tomorrow? How can I tell? Is there a maximum string length at which this sort of thing will DEPENDABLY show up in chat for the person touching the object?

if I understand what you're doing, correctly it's not limiting the text size, it's limiting flooding... one long message will get through, but repeated short messages get cut off right?


PS while it's called llInstantMessage, the truth is it actually a direct chat.. it always shows as chat, and never triggers the IM interface
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Milton Hayek
Registered User
Join date: 28 Apr 2006
Posts: 25
04-24-2009 20:20
From: Void Singer
if I understand what you're doing, correctly it's not limiting the text size, it's limiting flooding... one long message will get through, but repeated short messages get cut off right? ...


Void, thanks for the response, but actually, no.

Rather the opposite. One big block of text is what causes it to malfunction, SOMETIMES. When I break it up into small messages as in the second example it works consistently as advertised. That will do for my purposes although it seems a wee bit slower than the first method is when it works. What I can't understand is why using a script of the first sort, like SuezanneC's post, with a big block of text will work one night and not work a couple of days later. I don't mean another similar script. I mean the same object left laying out inworld. At first it will perform as expected. Later it will quit putting out any text visible on the screen but it will still be there when you look in chat history, just as it should be. It may just be some freaky glitch on my own system. My computer is haunted you know. By typo demons and malicious electrons.
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
04-25-2009 07:30
From: Milton Hayek
Void, thanks for the response, but actually, no.

Rather the opposite. One big block of text is what causes it to malfunction, SOMETIMES. When I break it up into small messages as in the second example it works consistently as advertised. That will do for my purposes although it seems a wee bit slower than the first method is when it works. What I can't understand is why using a script of the first sort, like SuezanneC's post, with a big block of text will work one night and not work a couple of days later. I don't mean another similar script. I mean the same object left laying out inworld. At first it will perform as expected. Later it will quit putting out any text visible on the screen but it will still be there when you look in chat history, just as it should be. It may just be some freaky glitch on my own system. My computer is haunted you know. By typo demons and malicious electrons.

hmm, then that sounds like some separate limiting code in the viewer (since it's still in the history).... which means it's the viewer doing it (probably to duplicate messages, it's own form of flood control)... I'd have never noticed that as I use the history almost exclusively.
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
1 2