Difference between revisions of "User:EddyFragment Robonaught/lsl Tutorial Videos"

From Second Life Wiki
Jump to navigation Jump to search
(Will be filled out at some point soon.)
(and blah)
 
Line 1: Line 1:
{{RightToc}}
== Learn Basic lsl Secondlife Scripting in 2 hours ==


=== Intro ===
I created these videos (Hosted on YouTube) with the purpose of explaining to a newcomer to lsl in a very basic way how to ''compile'' a [[script]] and why it looks and reads the way it does. They are not meant to taken as a definitive guide and so far only cover a few very simple basics. For those with no previous programming experience but a desire to create ''living'' objects in Second Life, take a look at these to get a first grasp on the basic structure of a script and some of its components.
I will be continuing the series as time goes on. My apologies for the poor quality and extraordinary dullness of my voice. Feel free to comment on the discussion page.
=== Links ===
'''[[Getting_started_with_LSL|This internal wiki page is a good ''written'' place to start too]]''' (I didn't know it existed until two days after making the first of these videos. Grumble grumble)
'''[http://www.youtube.com/user/EddyFragment#play/user/A1B5507CA136EA91 This is the whole 2 hour playlist hosted on YouTube URL]'''
'''The individual parts hosted on YouTube are as follows'''
'''[http://www.youtube.com/watch?v=MW9KSsUubdo Part 1 introduction to states]'''
'''[http://www.youtube.com/watch?v=rDCQme7PfaI Part 2 introduction to types and variables]'''
'''[http://www.youtube.com/watch?v=JgVFppwrcQo Part 3 continuing types]'''
'''[http://www.youtube.com/watch?v=2wcoVT3so08 Part 4 more on types and specifically lists + introduction to events]'''
'''[http://www.youtube.com/watch?v=Ebw0hyC01mk Part 5 events]'''
'''[http://www.youtube.com/watch?v=neN-wFAHLbk Part 6 continuing events]'''
'''[http://www.youtube.com/watch?v=dtnTWyCEKwM Part 7 introduction to functions]'''
'''[http://www.youtube.com/watch?v=li_sg0rMouw Part 8 continuing functions]'''
'''[http://www.youtube.com/watch?v=rNzmvyabAvg Part 9 continuing functions + being surprised how well it's all going]'''
'''[http://www.youtube.com/watch?v=Qg1SKFxnL0Q Part 10 demonstrating script in action]'''
'''[http://www.youtube.com/watch?v=5mv54dEXVxc Part 11 continuing demo]'''
'''[http://www.youtube.com/watch?v=BNIre4wiRb0 Part 12 end of demo]'''
=== The Basic Tutorial Scripts ===
'''The following 2 scripts are those used in the above videos'''
*'''First Object Script (the one I use for most of the "basic" tutorial)'''
<lsl>integer chan;
integer lis;
float time;
string sentence = "Can you hear me?";
list info = [<0.0,0.0,1.0>, "My stored words", -1234, 3.74];
key owner;
rotation turn;
vector XYZ;
default
{
    state_entry()
    {
        owner = llGetOwner();
        chan = 0;
        lis = llListen(chan, "EddyFragment Robonaught", owner, "");
        llSay(chan, "Ready and willing to respond");
    }
    listen(integer channel, string name, key id, string msg)
    {
        llInstantMessage(owner, "I hear you");
        if(msg == "Vector")
        {
            llSetColor(llList2Vector(info, 0), ALL_SIDES);
        }
        else if(msg == "String")
        {
            llOwnerSay(llList2String(info, 1));
        }
        else if(msg == "Integer")
        {
            llSay(chan, (string)chan);
        }
        else if(msg == "Float")
        {
            time = llList2Float(info, -1);
            chan = llList2Integer(info, 2);
            llSetTimerEvent(time);
        }
        else
        {
            XYZ = (vector)msg;
            llListenRemove(lis);
            chan = llList2Integer(info, 2);
            state new_state;
        }
    }
    timer()
    {
        llSetTimerEvent(0.0);
        llShout(chan, sentence);
        chan = 0;
    }
}
state new_state
{
    state_entry()
    {
        turn = llEuler2Rot(<90.0,0.0,0.0>*DEG_TO_RAD);
        llSetRot(turn);
    }
    touch_start(integer detected)
    {
        llSetPos(llGetPos() + XYZ);
        llSetPos(llGetPos() + XYZ);
        llSetPos(llGetPos() + XYZ);
        llSetPos(llGetPos() + XYZ);
        llSetPos(llGetPos() + XYZ);
        lis = llListen(chan, "", "", "");
    }
    listen(integer channel, string name, key id, string msg)
    {
        chan = PUBLIC_CHANNEL;
        llListenRemove(lis);
        llWhisper(chan, msg);
        llSetColor(<1.0,1.0,1.0>, ALL_SIDES);
        llResetScript();
    }
}</lsl>
*'''Second Object Script (the one at 50 meters above the start)'''
<lsl>integer chan = -1234;
integer lis;
float time = 10.0;
string sentence = "Can you hear me?";// This was supposed to be in the string to listen for section
                                    //  of the listen function but I forgot to add it.
default
{
    state_entry()
    {
        lis = llListen(chan, "", "", ""); // Should have been > lis = llListen(chan, "", "", sentence);
    }
    listen(integer channel, string name, key id, string msg)
    {
        if(name == "First Object")
        {
            llListenRemove(lis);
            llSetTimerEvent(time);
        }
    }
    timer()
    {
        llWhisper(chan, llGetObjectName() + " Says - " + "I can hear you");
    }
}</lsl>
== Slightly More Advanced lsl ==
'''Coming soon.'''
I will take the viewer through step by step instructions to build a simple local (96 meter range) '''"Radar" HUD'''. The device its self will be of some use but the purpose of the videos will be to show slightly more advanced technical use of lsl. This will include [[list]] building and reading, nested conditions ([[if]]s and [[else]]s) and simple [[llDialog]] (menu) creation. Although the tutorials will not show ''true'' advanced scripting they will take a newcomer to lsl to the next level after learning the basics. So would be ideal as a lead on from my "Basic" course (above).

Latest revision as of 23:21, 27 November 2009