getting the code you need - q&a

4
“Getting the Code You Need” Presented by Lea Tesoro / Opal Lei at the Non-Profit Commons in Second Life on November 9, 2012 This document contains the questions asked in the pre-talk survey and Opal’s answers. To receive a copy of the expanded version of the LSL spec-writing guideline as a pdf file, please fill out the post-talk survey at http://www.surveymonkey.com/s/R3VDKJV or send email to [email protected] . If Opal updates the document, you will automatically receive a copy by email. Q&A Q: What are the best current resources for learning more about scripting? The LSL portal in the Second Life wiki should be your bible: http://wiki.secondlife.com/wiki/LSL_Portal . I still refer to it every time to look up the correct spelling of a function name and/or to check the parameters it requires. Copying and pasting the syntax avoids wasted time looking for a bug caused by misspelling or by the wrong parameter type. An older resource is lslwiki.net, but I’m not sure how up-to-date that is. However, some of the functions are better described there than in the SL wiki. Don’t read it all at once. Just take the time to look up the one or two functions that you need. DISCLAIMER: I cannot vouch for nor recommend any of the following individuals, groups, sites or organizations, because I have no connections nor interactions with them. College of Scripting: http://maps.secondlife.com/secondlife/Horsa/57/243/84 Builder’s Brewery (buildersbrewery.com) Groups: o “Scripting Mentors” looks like a good one to join. o Search for “scripting” in Groups. YouTube: o Search for “lsl scripting tutorial”. A website that generates LSL based on your answers to multiple choice questions: o http://www.3greeneggs.com/autoscript/ A website that generates LSL particle scripts (Thank you, Patio Plasma, for the tip!): o http://particles-lsl-generator.bashora.com

Upload: virtuasapient

Post on 05-Dec-2014

253 views

Category:

Technology


2 download

DESCRIPTION

Presented at the Non-Profit Commons in Second Life on Nov 9, 2012.

TRANSCRIPT

Page 1: Getting the Code You Need - Q&A

“Getting the Code You Need”

Presented by Lea Tesoro / Opal Lei at the Non-Profit Commons in Second Life on November 9, 2012

This document contains the questions asked in the pre-talk survey and Opal’s answers.

To receive a copy of the expanded version of the LSL spec-writing guideline as a pdf file, please fill out the

post-talk survey at http://www.surveymonkey.com/s/R3VDKJV or send email to [email protected]. If

Opal updates the document, you will automatically receive a copy by email.

Q&A

Q: What are the best current resources for learning more about scripting?

The LSL portal in the Second Life wiki should be your bible: http://wiki.secondlife.com/wiki/LSL_Portal .

I still refer to it every time to look up the correct spelling of a function name and/or to check the

parameters it requires. Copying and pasting the syntax avoids wasted time looking for a bug caused by

misspelling or by the wrong parameter type.

An older resource is lslwiki.net, but I’m not sure how up-to-date that is. However, some of the functions

are better described there than in the SL wiki.

Don’t read it all at once. Just take the time to look up the one or two functions that you need.

DISCLAIMER: I cannot vouch for nor recommend any of the following individuals, groups, sites or

organizations, because I have no connections nor interactions with them.

College of Scripting: http://maps.secondlife.com/secondlife/Horsa/57/243/84

Builder’s Brewery (buildersbrewery.com)

Groups: o “Scripting Mentors” looks like a good one to join. o Search for “scripting” in Groups.

YouTube: o Search for “lsl scripting tutorial”.

A website that generates LSL based on your answers to multiple choice questions: o http://www.3greeneggs.com/autoscript/

A website that generates LSL particle scripts (Thank you, Patio Plasma, for the tip!): o http://particles-lsl-generator.bashora.com

Page 2: Getting the Code You Need - Q&A

Getting the Code You Need – Q&A 2

v20121109 ©2012 Eleanor (Lea) Tesoro / Opal Lei (VirtuaSapient.com)

Q: How come a script such as a moving texture stays in the prim even after you delete the

script? I made some moving water and wanted to stop it but couldn't even after I deleted the

script.

Texture animation is a property of the prim. Same as the hovertext. To stop the animation, you need to

run a script that explicitly “stops” the animation by changing the value of that prim property.

default

{

state_entry()

{

llSetTextureAnim( 0, ALL_SIDES, 1, 1, 1.0, 1, 1 );

}

}

Q: Why do scripts suddenly stop working?

It could be one of many reasons.

Assuming that you’re in a parcel that allows scripts to run, …

Assuming that the script is actually running, …

Assuming that the script doesn’t have other conditions that prevent it from running; i.e.: it only works if

you’re the owner of the object, or it only works underwater, or there’s an expiration built into the code

(These conditions are, of course, usually rare, except the owner one), …

… If the script is very old, it might be hitting some limitations that LL had imposed sometime after the

script was written, like the length of the object name, the length of the description, the length of the

hovertext allowed. These are typically where scripts store data. It could also be other changes in the

LSL API that affect the script.

… If the scripts depends on data outside SL, like a website or a database, and the creator had left SL and

deleted the website and the database, … depending how user-friendly the script is, it might just stop

running and not give you any idea why.

… If the script exceeds the memory allocated to it, ... for example, if you’re saving the names of all your

visitors and you usually clear the log once a day, but you had an unusually high number of visitors that

day, then your script could crash for lack of memory space, again depending on how it’s scripted to

handle errors. Most scripters usually don’t handle errors gracefully or validate data. That’s because

they’re focused on the performance of the script or on getting it done as quickly as possible, and those

things add complexity and bulk to the script. Or they really don’t know good coding practices.

Page 3: Getting the Code You Need - Q&A

Getting the Code You Need – Q&A 3

v20121109 ©2012 Eleanor (Lea) Tesoro / Opal Lei (VirtuaSapient.com)

Q: How do you get scripts to talk to each other?

Depends how far away they are from each other.

If they’re in the same prim or object, use llMessageLinked.

If they’re in different objects but are within 20m of each other, use llSay in a private channel and llListen in the recipient.

If within 96m of each other, use llShout in a private channel.

If within the same sim, use llRegionSay or llRegionSayTo in a private channel.

If they are in different sims, use llEmail. Watch out for restrictions to that function though.

In any of these, I would suggest using measures to secure your communication channel and avoid lag by

cutting down the noise you listen to. For example, if you have to listen to channel 0, which is the public

chat channel, limit it to listen to only one person. Ideally, use another channel. Ideally, as far away from

zero as allowed. Ideally, a negative number.

Of course, there are hacky ways to exchange information too.

Q: How many scripts can you put into an object?

Theoretically, as many items as you can put into the object, regardless of type.

Practically, depending on the scripts. If they are all running, you’ll probably crash the sim before you get

to that theoretical limit. Please let me know if you try it. ;)

Q: How do you know it is okay to modify a script?

If the script is intentionally open-source, the creator will probably include a license statement in it that

tells you what you’re allowed to do with the script.

If the creator gave you a modifiable script and does not explicitly give you permission to do what you

will with it, it’s best to explicitly ask the creator what you’re allowed to do with it. They might allow you

to modify it for personal use only or for your products only, but not to distribute it otherwise, whether

you modified it or not. That applies to the script as a whole and to significant parts of the script.

When in doubt, ask the creator.

Page 4: Getting the Code You Need - Q&A

Getting the Code You Need – Q&A 4

v20121109 ©2012 Eleanor (Lea) Tesoro / Opal Lei (VirtuaSapient.com)

Q: What kind of credit do you need to keep posted inside a script that you modified?

If it’s open-source, leave in what other contributors before you had written. When you modify a part of

it, you can create a comment with your unique name, email address or however you want to be known,

the date of modification, a description of the modification, and why.

Q: what is the difference between creating machinima and animating an avatar more

responsively for a mixed reality event?

It sounds like there are some misconceptions mixed in there, so I’ll try to explain as best as I can.

A machinima is a movie filmed inside a game environment, like SL. When you said “animating an

avatar”, I’m guessing that you don’t mean animations, but artificial intelligence. There are systems using

external code and special viewers that animate bots inside SL. But I think they’re still expensive and the

technology is still really barely developed so it cannot do much beyond inviting you to join a group or

giving you a predefined greeting or a notecard. I could be wrong.