Jump to content

Fundamentals to start writing a script


zinc Nyn
 Share

You are about to reply to a thread that has been inactive for 543 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

How familiar are you with the build tools in Second Life? Do you understand concepts like objects, linksets, attachments, etc?

There are some written tutorials that'll teach you the absolute basics, such as: https://wiki.secondlife.com/wiki/LSL_101

Here's a list of stuff scripts can react to: https://wiki.secondlife.com/wiki/Category:LSL_Events

Once you come up with ideas or run into problems, there are many active posters here who can answer practically anything. 🙂

Edited by Wulfie Reanimator
  • Like 3
Link to comment
Share on other sites

Hi, 

Here's the link to the LSL portal. I like to copy it and put it on a notecard and put with scripting folder in inventory to easily find when I want to script something quickly without fussing to find this link. Looks like there's updates to the LSL Library, neat. Here's the link: LSL Portal - Second Life Wiki

In world for more hands on learning at your own pace, there's a sandbox that does not require group membership to use and learn with learning modules inside the large building I think around the 4th or 5th floor. It's the Ivory Tower Library of Primitives. Search Natoma in the map and wala. Lot of excellent educational resources there. 

Happy learning, don't forget to party makes the pain go away. Learn & party repeat and rinse. 

 

  • Thanks 1
Link to comment
Share on other sites

Prior experience with computer languages of any kind can be helpful because you already have a feel for logic, which is after all the heart of any programming exercise.  It can be a bit of a disadvantage too, because you will be led to expect that the next language you pick up will behave like ones you already know.  LSL is .... different.  The best advice I can offer is to start digging around in example scripts in the wiki and in the LSL Scripting Library to see how other people are using LSL.  Focus, in particular, on the concepts of States and Events.  Then wander through the sticky thread for new scripters at the top of this forum. 

Edited by Rolig Loon
  • Like 1
  • Thanks 2
Link to comment
Share on other sites

On 10/22/2022 at 12:52 AM, Wulfie Reanimator said:

How familiar are you with the build tools in Second Life? Do you understand concepts like objects, linksets, attachments, etc?

There are some written tutorials that'll teach you the absolute basics, such as: https://wiki.secondlife.com/wiki/LSL_101

Here's a list of stuff scripts can react to: https://wiki.secondlife.com/wiki/Category:LSL_Events

Once you come up with ideas or run into problems, there are many active posters here who can answer practically anything. 🙂

I am quite familiar with the building tool in SL. I do understand concepts of objects and attachment. However, linksets is something new for me. Thanks for providing me a good starting point!

Link to comment
Share on other sites

2 minutes ago, zinc Nyn said:

linksets is something new for me.

The basic idea is fairly easy to grasp, but there are rules that seem non-intuitive at times, and certainly limiting.  For example, a linkset can be thought of as a chain with the root element at its head. However,

The root is always the last element added to the linkset, yet it is link #1.  Except, of course, when the final link added to the linkset is an avatar.  In that case, the avatar is the last link.

Unlike links in a real chain, the links in a linkset are all linked to the root, not to each other.  That is, links do not have a hierarchy. 

Links in a linkset share properties ... sometimes.  So, if one link is phantom or physical, they all are.  However, you can apply different color, transparency, and many other properties to different links.

A script in the root prim affects the entire linkset, but you can put a script in any child link that affects only that link. (Although, you can tell the child link to llPassTouches or llPassCollisions to the root prim.)

And on and on ....

Even once you understand the rules, some link behavior defies logic, or is at least hard to predict.  For example, if you remove a link from a linkset, the remaining links are not renumbered according to any consistent rule. 

 

  • Thanks 1
Link to comment
Share on other sites

23 minutes ago, Rolig Loon said:

The basic idea is fairly easy to grasp, but there are rules that seem non-intuitive at times, and certainly limiting.  For example, a linkset can be thought of as a chain with the root element at its head. However,

The root is always the last element added to the linkset, yet it is link #1.  Except, of course, when the final link added to the linkset is an avatar.  In that case, the avatar is the last link.

Unlike links in a real chain, the links in a linkset are all linked to the root, not to each other.  That is, links do not have a hierarchy. 

Links in a linkset share properties ... sometimes.  So, if one link is phantom or physical, they all are.  However, you can apply different color, transparency, and many other properties to different links.

A script in the root prim affects the entire linkset, but you can put a script in any child link that affects only that link. (Although, you can tell the child link to llPassTouches or llPassCollisions to the root prim.)

And on and on ....

Even once you understand the rules, some link behavior defies logic, or is at least hard to predict.  For example, if you remove a link from a linkset, the remaining links are not renumbered according to any consistent rule. 

 

I am not sure, but I feel it is similar to Linked List Data Structure. However, thank you for the high-level idea. I am sure this would help when I furthermore dig into scripting. 

I found one wiki link sequence of topic. Could you verify if I can follow this page for learning LSL - LSL Tutorial - Second Life Wiki?

Link to comment
Share on other sites

28 minutes ago, zinc Nyn said:

I am not sure, but I feel it is similar to Linked List Data Structure.

A linkset is a group of objects. One object is the root (or "parent"), the rest are links (or "children"). It's a single-level hierarchy, the children can't also be parents of other objects.

It's closer to a plain old array (1-indexed), if you wanna think of it in terms of data structure. That's how you'd iterate through a linkset, too.

28 minutes ago, zinc Nyn said:

Could you verify if I can follow this page for learning LSL - LSL Tutorial - Second Life Wiki?

Those tutorials will be fine.

Edited by Wulfie Reanimator
  • Like 1
  • Thanks 1
Link to comment
Share on other sites

10 minutes ago, Wulfie Reanimator said:

A linkset is a group of objects. One object is the root (or "parent"), the rest are links (or "children"). It's a single-level hierarchy, the children can't also be parents of other objects.

It's closer to a plain old array (1-indexed), if you wanna think of it in terms of data structure. That's how you'd iterate through a linkset, too.

Got it. Appreciate for the explanation. 😁

12 minutes ago, Wulfie Reanimator said:

Those tutorials will be fine

beside https://wiki.secondlife.com/wiki/LSL_101. Are there any other suggestions for tutorials?

Link to comment
Share on other sites

5 minutes ago, zinc Nyn said:

Are there any other suggestions for tutorials?

Not really. As you will discover quickly, tutorials for LSL tend to be very entry-level. Once you understand the basic structure of the language -- in particular, the way that execution passes from one event or state to another in response to external stimuli -- the rest is largely a matter of becoming comfortable with the large library of built-in functions. That's why I suggested earlier that the best way to gain that level of comfort is to just start playing with short example scripts in each page in the wiki that describes one of the functions. Take a script, drop it into a prim in world, and see how it works.  Change a variable, add an option, combine it with another script and gradually get your feet under you.  Pay attention to some large topics like manipulating lists and dealing with moving and rotating objects, which cause the greatest headaches for even seasoned scripters. You will find many threads in this forum and in the LSL Scripting Library devoted to those themes.  

I am not saying "You're on your own", because LSL scripters tend to help each other out, but the path you take as you learn will depend largely on how you want to use LSL.  When you get much beyond entry level, you decide what you need to learn next..

  • Thanks 1
Link to comment
Share on other sites

2 hours ago, zinc Nyn said:

Are there any other suggestions for tutorials?

Azn Min at Builder's Brewery often does classes where she walks through some relatively simple scripts and how they work.

In my opinion though, the best way to learn is just to have a lot of ideas for simple projects and try to make them work. The "simplest" things to script can usually be summarized in the form "When X happens, do Y". Like a basic lightbulb (When I touch the object, turn on/off the light) or maybe a simple one-direction elevator (when an avatar stands on the elevator, move to position B, if nobody is on the elevator move back to position A) As you work through and try and translate the simple idea into a working usable project, you'll often find that your original idea wasn't as clearly specified as you thought ( the elevator description earlier has numerous holes), in which case you need to go back and about what should happen in various scenarios (should the elevator move if a physical ball gets dropped on it?) and how to  convert that part of the spec into a script (pro tip: one of the most accepted ways of detecting if a given key belongs to an avatar(agent) is with llGetAgentSize(), also for anything physics-based, you'll want to have a good understanding of llSetStatus and llSetPhysicsMaterial )

You also need ot find a comfy middle-ground between giving up on a project too early because scripting is hard and often frustrating, and spending too long on a project that may not even be possible or feasible within SL's limitations. Interacting with other scripters here or in-world is really the only way to know which end of that spectrum you're on other than experience.

  • Thanks 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 543 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...