Learning to script
|
|
Jak McLuhan
Registered User
Join date: 13 Sep 2005
Posts: 17
|
07-15-2007 23:31
Hey all I've played SL for a long time (Jak McLuhan wasn't my first Av here, look up Kerri Fortune...  Don't ask me why I made a new one) and I've experienced a lot of what SL has to offer. My first love was building. I've done a lot for friends and the like, never really commercially. However, when a lot of my friends left SL for other things, building and hanging out on my own seemed to lose its luster, so I took a break. Now I'm thinking about coming back and learning something I've never tried to learn before... You guessed it, scripting. Now my question to all you experienced scripters, is how's the best way to learn it? Please keep in mind that I've really got no programming experience as of yet (altho I'm working to change that) and I've also tried going to a few places in world that have step by step process and the like. Those were great, if I wanted to learn to color boxes randomly when touched, but in the end that's not my goal... and I really just ended up copying the code, not learning what parts of the code actually make it do what. So any advice on how to learn LSL would be much appreciated. I glanced at the wiki for a few minutes when I had time earlier but I didn't have time to do much exploring there. Thanks for any thoughts!
|
|
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
|
07-16-2007 00:03
when i first started i did all the sample scripts and lsl 101 ect and didnt learn a damn thing im hardheaded ... the thing that helped me out the most was deciding on a project and fighting with it to the bitter end that requred lots of ciggeretts and trips to the lsl wiki, along with support with buddies in world now that script i wrote soo long ago really sucks when i look back at it, but it was a world opening to me some things to learn first brackets {} learn where they go, its really simple but such a pain in the arse at first heres something about them i wrote awhile back in another thread /54/4d/183264/1.html#post1506575dont forget your semicolons at the end of functions , the lsl editor will tell you synax error and put the cursor at the top of a block, which can cause major headace when your trying to figure out what went wrong bookmark the wiki! either lslwiki.net (old) or wiki.secondlife.com (new) mirror sites like rpgstats, or my own lslwm are just copies and may not contain the newest information (ie mine i only update every 3 months) theres a huge difference tween x= 0 and x == 0, the first one assigns the variable x to the value of zero, the second one looks at x and sees if it equals zero .. big one there for noobies please for the love of all that is good learn how to write a if tree /54/02/144383/1.htmlok enugh for now, but also here is a really ez lsl guide for scripting noobs http://bldsong.net/2L/tutorials/lsl-page1.htmgood luck and welcome to the club
|
|
Milambus Oh
Registered User
Join date: 6 Apr 2007
Posts: 224
|
07-16-2007 06:06
I agree with Osgeld, the best way to learn programming is to simply jump in. Find a simple project that you want to do, and start breaking it down. Post questions here, and read every thread that you can. Make sure you read through as much code as you can, trying to follow the logic flow.
The wiki is your friend. I not only have it bookmarked (at home and work) but when I'm working on a project I'll often open up a new Firefox window just for it. Then keep the homepage open in one tab, and open up individual function pages in other tabs. That makes it easy to go through lots of information.
If you have never programmed before at all, you may want to look into picking up a book on it. I'd suggest a simple language like JavaScript or Java. The idea would be to read through the very introductory lessons in such a book. Explaining variables, constants, program flow, conditions and loops. The syntax between Java and LSL is similar enough that those things should directly port over.
However, to start off here is something you can do. Pick a simple project, something that interests you. Start breaking down what you will need to know to complete such a project. What types of data (if any), what types of inputs (in any), what manipulation of objects you may want to do. Write that all up in a list and post it here. I (or someone else) can then go through the list and post our own thoughts. Kinda nudge you in the right direction. So you know which stuff you actually need to learn first.
|
|
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
|
07-16-2007 06:34
Another second to the "learn by doing" approach. A slight twist, though: I started not so much with a project as with something that really annoyed me (poseball scripts, in my case), and just hacked them into submission. (I would, however, recommend *against* starting with vehicles: too many esoteric parameters that have nothing to do with the script, per se.)
And Milambus is probably right that a good Java book might help with picking up the basic concepts of programming. (I think I've been programming since the cradle, though, so my memory of how that stuff is acquired is pretty murky.)
|
|
Lyn Mimistrobell
(waiting)
Join date: 11 Jan 2007
Posts: 179
|
07-16-2007 06:36
From: Milambus Oh If you have never programmed before at all, you may want to look into picking up a book on it. I'd suggest a simple language like JavaScript or Java. I've done Java and it is in _no way_ simple, and hardly compares to LSL. JavaScript is easier but for the most part LSL is different (variable declaration, LSL lists vs JS arrays, states, events, etc). Use the Wiki ( http://www.lslwiki.net/lslwiki/wakka.php?wakka=HomePage), this forum, SL scripting groups, and check the events in SL search for scripting classes. On the Wiki homepage you can also find information about scripting mentors, groups and teachers. Also, look at some scripts in the library (in the Wiki and the forum) and scripts that have been posted in this (scripting tips) forum. First and foremost, check the Wiki's "LSL 101 - The Complete Newbie's Guide to Scripting in Second Life" on http://www.lslwiki.net/lslwiki/wakka.php?wakka=LSL101Good luck, hope we can see some of your work soon Lyn
|
|
Jak McLuhan
Registered User
Join date: 13 Sep 2005
Posts: 17
|
07-16-2007 09:41
Wow! I don't think I've ever seen such fast response times on a forum, ever! Thanks for the advice guys, that sounds about the best way that I learn as well is to just jump in and do it. It's nice to know that I can actually come here and get advice instead of asking something, and the only response I get is "noob!" I haven't even attempted much in java yet, but I did buy a book on C++ the other day and I've started reading through that. Hopefully that will help me. I heard somewhere that LSL and C++ are quite similar, so here goes nothing! As far as what interests me, I'm quite fascinated by things that make avatars do something... so i'm thinking that I might go for a simple weapon script for like a sword or something. Any advice on that would be much appreciated as well. Thanks again!
|
|
Milambus Oh
Registered User
Join date: 6 Apr 2007
Posts: 224
|
07-16-2007 10:01
Yes, C++, Java, LSL and several other languages fall into the category of "C-like". This mean they have a similar syntax structure, and use many of the say keywords. There are of course differences in each language, but they look alike.
If you like, post the names of the chapters in the book and we may be able to give you more guidance as to which of them will be applicable to LSL.
As for a weapon script.. my only advice would be to start simpler. Weapons can be very complicated depending on how they are implemented from what I have seen. However, I have not worked on any personally. But if that is what interests you, I am sure there are several people here that can offer some advice.
|
|
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
|
07-16-2007 10:24
From: Jak McLuhan I heard somewhere that LSL and C++ are quite similar, so here goes nothing! You can safely ignore everything object-oriented about C++, though, because LSL doesn't even have arrays, let alone structs, to say nothing of... well, nevermind. It's just possible that C# (and .NET) might end up being relevant, come Mono. (Bated breath optional.  ) One thing: Although I've done some event-driven programming in C and assembler, LSL is the first "event driven language" I've ever used. I would guess this might be a bit tricky to pick up at first, but I don't know what to suggest to help with that.
|
|
Shadow Subagja
Registered User
Join date: 29 Apr 2007
Posts: 354
|
07-16-2007 10:32
I would start by reading the primers, scripting basics, or scripting 101 articles that have been posted on the wikis or as chapters to the official LSL guide from the Lindens. Work through those basic step by step exercises but pay attention to the description of what you are doing which often helps describe the syntax and basics. For example 'what is a state?', why the {'s and ;'s in the script? Once you have a basic handle on simple scripts and can even venture guesses as to how they can be modified, thats when you can start cracking open scripts from sample libraries, looking up the commands you see them using in the LSL wiki ( www.rpgstats.com), and following forums like this one for common problems we have ALL had to work through getting our feet wet. Some of my favorite links from when I was starting out (well I am STILL starting out lol): official doc (worth a read through) http://secondlife.com/developers/resources/pdfs/LSLGuide.pdfwiki reference/examples (look up commands here, see what they do, plus sample code) http://www.rpgstats.nethands on examples (a great tutorial style walk through of some script tasks) http://www.kan-ed.org/second-life/using-LSL.html
|
|
Jak McLuhan
Registered User
Join date: 13 Sep 2005
Posts: 17
|
07-16-2007 12:33
From: Milambus Oh As for a weapon script.. my only advice would be to start simpler. Weapons can be very complicated depending on how they are implemented from what I have seen. However, I have not worked on any personally. But if that is what interests you, I am sure there are several people here that can offer some advice. hmm... i will definatley keep that in mind. Any advice on a type of script that might be easier to learn. (although I am looking for a tad bit more complicated than changing colors on a box...  )
|
|
Shadow Subagja
Registered User
Join date: 29 Apr 2007
Posts: 354
|
07-16-2007 13:39
At their most basic, weapons are quite simple. You can set the damage on a physical object with llSetDamage ( http://rpgstats.com/wiki/index.php?title=LlSetDamage). A gun will rez a bullet, and the bullet will set its damage so that when it collides it does that damage to its target. However, there is a lot more to really putting a gun together as you can see from this example: http://lslwiki.net/lslwiki/wakka.php?wakka=ExampleGun And a sword is essentially the same thing AFAIK. Since attached objects are phantom, I think swords (at least mine does this) rez an object to do their damage each swing. This might be an invisible object representing the sword swath, for example. This is just my guess though  . Some even call it 'sword bullet', you will see the sword failing to rez these on no-create land. The real magic with weapons seems to come from avatar animation, cool design of the weapon itself, or fancy techniques for making bullets beat shields, orbit people and all that.
|
|
Adelle Fitzgerald
Trying...very very trying
Join date: 6 Jan 2007
Posts: 17
|
07-16-2007 14:40
A great thing that I have learned not so long ago is sending messages between prims with llMessageLinked. Its not very complex at all once you get your head around it and is great for bringing your creations to life instead of using llSay, as using a listner in each prim can eventually calse lag if you use too many. I also like other things like sensors (llSensor), changing textures (llSetTexture), prim paramaters (llSetPrimitiveParams) - you can do a lot to a prim with this from making a simple light turn on/off to making a sliding door.
I find scripting really fun when my builds come to life with them, but I also find it frustraiting from time to time when things wont work and I don't know why. Then I turn to the wiki and this forum which has helped me a lot.
|
|
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
|
07-16-2007 21:39
From: Jak McLuhan hmm... i will definatley keep that in mind. Any advice on a type of script that might be easier to learn. (although I am looking for a tad bit more complicated than changing colors on a box...  ) maby a radio script, this tackles all kinds of "most common" questions, reading a notecard, dealing with strings as input and output maby even llDialog (blubox pushbutton interface) weapon scripts like you mentioned can be as simple as the pop gun, .. or as complicated as a full blown combat system for a sword setup its mostly a poseball maby mixed in with some controls or user chat commands (or dialog which are just chat commands on pushbuttons) , the only hard part is getting a decent animation
|
|
Marianne McCann
Feted Inner Child
Join date: 23 Feb 2006
Posts: 7,145
|
07-17-2007 07:50
Hi Jak!
I've learned what little I know by taking apart freebie scripts, reading here, going through the wiki, an so on. My brother also seems to have liked the LSL "boot camp" classes inworld, too.
Mari
_____________________
  "There's nothing objectionable nor illegal in having a child-like avatar in itself and we must assume innocence until proof of the contrary." - Lewis PR Linden "If you find children offensive, you're gonna have trouble in this world  " - Prospero Linden
|