Difference between revisions of "User talk:Toady Nakamura"

From Second Life Wiki
Jump to navigation Jump to search
(Commenting on listen script)
m
Line 45: Line 45:
I couldn't resist commenting on your recently posted script. Easiest is if I post the script here with my comments inserted (enclosed within **  **)
I couldn't resist commenting on your recently posted script. Easiest is if I post the script here with my comments inserted (enclosed within **  **)


<lsl>
(content omitted)
// Toady's simple listen script. ** Comments added by Omei Qunhua **
 
integer CHN = 33; // zero channel is public chat - use a different one
 
// ** This is not a correct description of 'listener'. The variable holds the current listen handle, it's not an on/off switch **
integer listener; // records if the listener is on or off (1 or 0)  
key owner; // holds the owner's key ID
default
{
    state_entry()
    {
        // ** It is impossible for any listener to be active at the start of a 'state_entry' event **
        // ** Because either the script is running for the first time (hence no listeners have been set up) **
        // ** or a change of state occurred (which clears all listeners) **
        // ** So llListenRemove() is pointless here **
        llListenRemove(listener); // clear any old listeners
 
        owner = llGetOwner(); // find out who owns prim
 
        listener = llListen(CHN,"",owner,""); // open a listener for just the owner
    }
 
    listen(integer channel, string name, key id, string msg)    // ** you changed 'message' to 'msg' ... but your following code refers to 'message' **
    {
        // ** 'p' is a very unhelpful variable name here! **
        // ** Why not called it lc_msg or LowerCaseMsg  etc. **
        string p = llToLower(message); // convert the message heard to lower case
 
        // ** I've seen this kind of statement in scripts before { if(owner==llGetOwnerKey(id)) }  and can never see the purpose **
        // ** What is it testing? "Is the key of the owner of the speaker equal to the owner of the object?" **
        // ** What on earth is the 'owner of the speaker' when we're talking about an avatar, in this case the owner ?? **
        // ** Much simpler is    if (id == owner)      or    if (id == llGetOwner() ) **
        // ** BUT - in your case, your listener is already filtered to ONLY listen to the owner, so this test is pointless and can be removed **
        if(owner==llGetOwnerKey(id))
        {
            // ** personally I would try to avoid coding llSetColor() multiple times **
            // ** By using a local variable called, say, color, set your colour vectors into it, and call llSetColor() once at the end **
            // ** This would save quite a bit of bytecode space, as function calls are expensive on space **
            if (p == "red") // if what is heard is "red"
            {
                llSetColor(<1,0,0>, ALL_SIDES);  // turn the prim red on all sides
            }
            else if (p == "green")
            {
                llSetColor(<0,1,0>, ALL_SIDES);
            }
            else if (p  == "blue")
            {
                llSetColor(<0,0,1>, ALL_SIDES);
            }
            else  // if the message is none of the above ...
            {
                llSetColor(<1,1,1>, 0);  // just the top of the box will turn white
 
                // ** It would be less confusing to say the original message, not your lower-case version **
                llOwnerSay(p);  // and it will tell you the message in open chat 
            }
 
            // ** your script is missing a closing curly brace }  here **
 
        // ** As your new llListen here has exactly the same parameters as the existing listener, the SAME listen handle will be returned **
        // ** So there is no need or point in releasing the listener **
        // ** And indeed there is no need to open a new listener **
        // ** This in turn all means that in this script, there is no point in ever saving the listen handle **
 
        llListenRemove(listener); // close that session
        listener = llListen(CHN,"",owner,""); // open a new one
    }
 
    on_rez(integer start_param)
    {
        llResetScript();
    }
}
</lsl>
 
[[User:Omei Qunhua|Omei Qunhua]] 01:38, 29 January 2014 (PST)
[[User:Omei Qunhua|Omei Qunhua]] 01:38, 29 January 2014 (PST)
:Thank you for your comments, you corrected a script I expect my students to correct in class so I have removed your corrections here so they don't cheat and just use yours.  [[User:Toady Nakamura|Toady Nakamura]] 14:16, 11 March 2014 (PDT)

Revision as of 14:16, 11 March 2014

Leave me a message !!! Toady Nakamura 23:44, 5 July 2012 (PDT)

<lsl> //Counts down from 5 to 1, then can do something else default {

   state_entry()
   {
       integer count = 5;
       do
       {
           llSay(0, (string)count);
       //  wait a sec
           llSleep(1.0);
       }
       while (--index);

       llWhisper(0, "I am done counting now.");
   }

} </lsl>

Debug error

Um I am sorry if I am going about this the wrong way but from what I can tell this was the only way to talk on the wiki and I had a question about the LSL 101 Logic page, the example script in particular, I copied it(sort of, I actually typed it out because of the note at the bottom) in the LSLEditor community edition and ran the debug... thing, and got the error "Field 'n' is never assigned to, and will always have its default value"

I was wondering if this was an actual issue, and I wonder this because I have no actual coding knowledge. I apologize profusely if I have the wrong person or posted this where I shouldn't have. If you would like to see how it came out exactly I will of course provide what was written.

--Rohise Resident 22:56, 9 October 2012 (PDT)

Variable names

Greetings, I rewrote your example script on User:Toady_Nakamura/Simple_Recording_Tipjar. For sake of readability, please use variable names that actually mean something amd not i, m, n and what not. Your doing yourself a favor by doing so! -- Kireji Haiku 11:18, 19 October 2012 (PDT)

I replied on your talk page, as is customary. You did not reply and you wiped out my reply to you. Toady Nakamura 10:07, 4 November 2012 (PST)

Regarding your question about lists in LSL on User_talk:Strife Onizuka 's page:

Please read this intro of how to iterate over a list in LSL. Hope it helps, kind regards. -- Kireji Haiku 12:40, 5 November 2012 (PST)

Your simple listen script

You do say at the top of your talk page "Leave me a message !!!" ... so I am :)

I couldn't resist commenting on your recently posted script. Easiest is if I post the script here with my comments inserted (enclosed within ** **)

(content omitted) Omei Qunhua 01:38, 29 January 2014 (PST)

Thank you for your comments, you corrected a script I expect my students to correct in class so I have removed your corrections here so they don't cheat and just use yours. Toady Nakamura 14:16, 11 March 2014 (PDT)