Jump to content
Lexie Linden

Starting with LSL

Recommended Posts

So, let's start with a few of the online resources we use the most.

The LSL Portal on the Second Life wiki has a complete* reference for LSL syntax and functions, with examples, tutorials and more. The "old" LSL Wiki is still a great reference too, in a different style with many unique examples. You don't need to pick a favorite, bookmark both.

This new forum will fill up fast, but SL scripters have been talking for a long, long time. Check out the Scripting forum archive for what happened in 2010, and the old Scripting Tips archive for 2009 and back. The archives are huge, but so is the amount good information hiding in there.

When looking for threads here, remember to open the menu next to the green Search button, and pick All. This will make your seach include both active and archived (from 2010) forums.

Here on the forums we have a script library, maybe what you need has already been written and contributed. You can pull them apart and see what makes them go too. (See the stickies over there, we really have several libraries!).

*OK, none of these will ever be complete, but we try.

Share this post


Link to post
Share on other sites

Joining an in-world groups like SCRIPTS is a good option to ask questions and get advice instantly, to find beta testers for your scripts, have others watch over errors or ask for scripts or other in-world resources and locations regarding scripting. It's a general purpose group around Scripting. 

SCRIPTS can be joined over this URL (alternatively ask me for an invite):

secondlife:///app/group/2953b37f-edeb-5099-1c41-03b4d5068f68/about

There are other specialized groups (but not necessarily as big as SCRIPTS), like: Scripting Weapons, Scripts for Germany, Script collectors and many more. You can find them easily in the search. 

Share this post


Link to post
Share on other sites

There is general advice about learning to program in any language.  And then there is LSL.

If you haven't programmed before, I think LSL is OK to learn how, but not ideal, I'd start with Python - mainly because of the teaching resources.

LSL has some nasty little gotchas, like no proper arrays, that make you think. (A strided list can sometimes be used, but it's hard)

The best advice is to have a project, and start.  Just reading stuff, or copying other (much more skillful than you) scripts, usually generates more questions than knowledge.  It's not the programming you need to learn, it's the debugging, and since LSL doesn't have wonderful debugging tools, you need to 'get yer eye in'.

 

PS, I need an Ancient Thread Spotter built into this website please Mrs Linden!  Anything older than a month in purple?

Edited by anna2358
Just noticed it was OLD. Doh!
  • Like 1
  • Haha 1

Share this post


Link to post
Share on other sites

For other people who may stumble into this ancient thread ...   9_9 ... There is a growing collection of sticky threads at the top of this forum, each addressing some basic scripting challenges and methods in LSL. Those, and the LSL Library, are good resources for anyone who wants to see how experienced LSL scripters approach some common tasks, as well as some philosophical advice about work flow and professional practice.

  • Like 2

Share this post


Link to post
Share on other sites
On 2/26/2011 at 7:29 AM, Lexie Linden said:

What do you think is the best way to get started with learning LSL? 

come on this forum and ask Rolig how to fix it :)

Share this post


Link to post
Share on other sites
On 25/02/2011 at 2:29 PM, Lexie Linden said:

What do you think is the best way to get started with learning LSL? 

Don't get sucked into trying to learn to be a "good" coder. If the end result works, it works (eg don't worry one jot about script memory till you find yourself running out).

Start with a problem you need to solve - Just "learning to script" without a project isn't really helpful. Also try to make it something you have seen other items do.

Don't be afraid to google up an example script that does some/all of what you need and use that as a guide. Learn by example. Don't reinvent the wheel. Professional developers call this checking "stack exchange".

Be clear about what you want the script to do. Plan it out on paper.

If you get stuck. ASK. Post your script. Be clear about what you're trying to do.

Don't be afraid to share your work. Don't EVER give anyone a full perm copy of a script - put it in a notecard or pastebin.

  • Like 1

Share this post


Link to post
Share on other sites

holy moly - some thread necormnacy happened here again...

6 hours ago, CoffeeDujour said:

Don't be afraid to share your work. Don't EVER give anyone a full perm copy of a script - put it in a notecard or pastebin.

That is a good one, because they could completely replace your script and you would be tagged as the creator of something nasty...

  • Like 1

Share this post


Link to post
Share on other sites

Hi ....

so just like the title of the topic i am totally new with LSL, so i experimenting with teh stuff i have. i got this nice cheap switchblade which has touch script which i am trying to replace it with chat command . the script goes like this 

default
{
touch_start(integer tnum)
{
rotation rot = llEuler2Rot(<0 * DEG_TO_RAD, 0 * DEG_TO_RAD, 180 * DEG_TO_RAD>);
llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_ROT_LOCAL, rot]);
llSleep(0.2);
llPlaySound("switchblade-in", 1.0);
state open;
}
}

the rest of the script is reversal of above

Been experimenting with a attach/detach script and tried to replace the touch start with chat command but still no luck.

could someone please help me out...i am really blind here but really want to learn ;)

Thank you

Share this post


Link to post
Share on other sites
Posted (edited)

This might sound kinda weird initially, but learn how to read the wiki.

I don't mean just knowing that it's there and looking at it, but try to understand what it means when a line says (for example):
"Function: llMessageLinked( integer link, integer num, string str, key id );"

Do you know how to actually use that without looking at an example?
Do you know how to write that into a script without errors? (Even just without using any variables.)
What does "integer link" need to be replaced by or what does that even mean?

The wiki is a useful tool even for experienced scripters, but you need to know how to interpret and use it.

P.S. That line shows you the name of the function (llMessageLinked) and the parameters it uses (In the parentheses).
"integer link" is two-part. "integer" means that the first parameter has to be a value of the type integer. "link" is just an example name that describes what the integer is expected to represent. You may use either a literal integer, like 3, as the first parameter, or you can use any variable/expression (function/calculation of some kind) that is or returns a value of the type integer.

Edited by Wulfie Reanimator
  • Like 1

Share this post


Link to post
Share on other sites

@NawaliaTrea: Message me sometime, I have working side-and-front-opening models, with draw/hide/open/close via simple chat, and my models are made differently, which might give you some fun ideas on construction, too.

@Wulfie Reanimator: You said what I would say a hundred times a day on this forum if it wouldn't make me look like a Spammy Spammerson; There are times I just want to scream "READ THE WIKI!!!", because so much time can be saved, and so many questions wouldn't have to be asked, if people realized it's an actual study source, and you can learn from it.

It isn't just a collection of stuff about LSL. Everything a beginner needs to know is there, and you can look further and learn even more if you want. When I was brand-new here, I wouldn't even ask a question on the forums until I hit a dead-end, and it usually came down to simply not knowing which function to look up on the wiki.

Share this post


Link to post
Share on other sites
On 5/26/2018 at 7:14 AM, Berksey said:

@NawaliaTrea: Message me sometime, I have working side-and-front-opening models, with draw/hide/open/close via simple chat, and my models are made differently, which might give you some fun ideas on construction, too.

@Wulfie Reanimator: You said what I would say a hundred times a day on this forum if it wouldn't make me look like a Spammy Spammerson; There are times I just want to scream "READ THE WIKI!!!", because so much time can be saved, and so many questions wouldn't have to be asked, if people realized it's an actual study source, and you can learn from it.

It isn't just a collection of stuff about LSL. Everything a beginner needs to know is there, and you can look further and learn even more if you want. When I was brand-new here, I wouldn't even ask a question on the forums until I hit a dead-end, and it usually came down to simply not knowing which function to look up on the wiki.

@Berksey i definitely would message you sometime..and i did read the WIKi before actually posted this thread...since it is my last resort cos i really was stuck ;))

Share this post


Link to post
Share on other sites

My experience has been that trying to understand how scripting works by reading scripts made by others is extremely frustrating and a waste of time if you have no basics.

When all you want to do is make something undetachable or have it give a landmark to those who click on it, it feels like learning the basics is not worth the commitment, but it really is.

Learning to code properly doesn't take long. Spend about 8-10 hours learning from a programming tutorial and you will have a solid, functional grasp on what is important. You don't need to finish the whole tutorial, it's just more efficient to spend a few hours going through a tutorial than it is taking hours trying to make a stupid function work in your script when it should only take a minute.

Python was recommended earlier.  I recommend C# because it's extremely similar to LSL, so it's easy to transition from C# to LSL.

You don't need to make your script right now, it can wait. SL will still be here next week. So don't be in a hurry, learn this properly.

It will also make scripting enjoyable, and it will serve you well in a few months when you get a new scripting idea.

The tutorial I used is https://www.sololearn.com/Course/CSharp/
You don't need to complete it, but you will be thankful to yourself for every hour you spend on it.

Share this post


Link to post
Share on other sites

Keep the wiki on hand, a lot of seasoned scripters tend to ignore it and miss when we occasionally get new, powerful functions that make the "old ways" of doing a specific thing obsolete and inefficient.

Edited by Kyrah Abattoir
  • Like 2

Share this post


Link to post
Share on other sites
4 hours ago, Kyrah Abattoir said:

Keep the wiki on hand, a lot of seasoned scripters tend to ignore it and miss when we occasionally get new, powerful functions that make the "old ways" of doing a specific thing obsolete and inefficient.

I refer to the wiki regularly but I've never discovered any of the newly implemented functions through there. If anything, reading the forum or LL blog is more likely to inform you.

So I ask: where specifically should you be looking for the new stuff, aside from the page with every function listed?

Share this post


Link to post
Share on other sites
3 hours ago, Wulfie Reanimator said:

So I ask: where specifically should you be looking for the new stuff, aside from the page with every function listed?

That's where I would look -- just look at functions tagged with a "New" icon and see if there's anything there you don't recognise.

I agree that attending user group meetings, looking at simulator release notes and following this forum are probably better ways to keep up, but not everyone has the time or inclination to to that, and for them, the wiki is the best resource.

Share this post


Link to post
Share on other sites
On 05 August 2018 at 7:26 PM, Naskiff said:

My experience has been that trying to understand how scripting works by reading scripts made by others is extremely frustrating and a waste of time if you have no basics.

Trying to read Latin when you don't know any Latin at all is frustrating...

On 05 August 2018 at 7:26 PM, Naskiff said:

When all you want to do is make something undetachable or have it give a landmark to those who click on it, it feels like learning the basics is not worth the commitment, but it really is.

Learning the basics is always worth it...

On 05 August 2018 at 7:26 PM, Naskiff said:

Learning to code properly doesn't take long. Spend about 8-10 hours learning from a programming tutorial and you will have a solid, functional grasp on what is important.

So sayeth every failed amateur coder since the late 1940's, when the electronic programmable computers were first being built and developed...

Learning to program isn't an 8-10 hour task.

On 05 August 2018 at 7:26 PM, Naskiff said:

Python was recommended earlier.  I recommend C# because it's extremely similar to LSL, so it's easy to transition from C# to LSL.

There's a BIG problem with telling would-be LSL scripters to "learn the basics using [insert advisors favorite language here]".

That's how you aquire BAD habits, and end up constantly moaning that LSL doesn't support Feature-X of #Buttscript (tm).

It's the main source of those...

On 26 January 2018 at 10:54 AM, anna2358 said:

LSL has some nasty little gotchas, like no proper arrays, that make you think.

It's common, you learn some basic programming in Language-A, then switch to Language-B and "Waaaaaahhh! Why wont it do somesuch like Language-A?"

For a complete programming noob, you are better off as follows.

1. Try some simple problem, like making a lamp that you can turn on and off by clicking on it

2. Search for some copy mod scripts, specifically 2, a touch detector script and a light script

3. Make a new script of your own, and then read the two "sample scripts" and as you read each command, look it up on the LSL Wiki, each page for each command usually has examples at the bottom of the page, that give a clearer picture of what the syntax means.

4. By comparing the 2 sample scripts with the wiki, you can slowly figure which parts do what, and which parts you will need for your new script, and line by line you can assemble your new script.

5. When you attempt to save it it almost certainly will throw a script compile error or 10. By comparing your new script to the samples and the wiki, line by line you discover where you went wrong. THIS is how you learn.

...

Some people think being a programmer is all about memorising all the commands and their syntax, but it's not, you can look those up on a wiki or a programming manual when you need them.

Programming is being aware of what KINDS of things the language CAN do, in general, thus knowing where to look for the specifics when you need them, and in teaching your self to THINK like a program...

Too many would-be coders program as if their code was capable of human thought.

Separating a line of text into a first name and a last name? Obviously you separate at the space, right?

"Mr. Hank B. Yank"

Code: "Hi there Mr. Mr. Hank, let's be informal, may I call you Mr.?"

For an LSL beginner, learning to "flowchart" would be a damn sight more useful than learning a different programming language.

Flowcharting a program on paper without writing a single line of code give a better idea of the differences between the way code sees the world and the way humans do, things we take for granted as obvious are things a program won't know and cant know until we specifically tell it.



 

  • Like 4

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×