In the last week, I have had the pleasure of giving a number of scripting tutorials, ranging from making a poseball to building a vendor. I didn't seek out any assistance when I started scripting. Had I done so, perhaps I would be better versed than I currently am. At the same time, "Eureka!" moments are best after repeated failures.
You see, in any profession, there are little things you must learn from experience, whether that experience is you own or somebody else's. You must observe closely the mistakes of others, and be keen to recognize your own.
There are also little caveats that are rarely mentioned, as those with experience take them for granted as understood. As a result, they are readily missed by the novice, who only learns them after much frustration.
Scripting in LSL is no different.
So, a few notes for the rank beginner-
Collect freebies, read the SL scripting Forums, tear apart every script you meet.
Indent, and keep your opening and closing brackets aligned.
When working on a complex script, break the project down into smaller projects. As you work out the bugs you can fold them into your bigger project.
Use llOwnerSay rather than llSay or llWhisper if nobody but the owner really needs to hear the script output.
When tweaking a script, change one thing at a time.
Syntax Error? The line looks textbook? Look for missing semicolons, closing parentheses, and missing quote marks in previous lines.
Once you start getting used to the idea of rotations, note that there is a long standing bug in SL (going back to the beginning) that effects dividing a rotation by a rotation. Save yourself hours of debugging and workaround this through multiplication.
Do not pay for scripts. Paying someone for custom work is one thing, but most of the scripts for sale out there are lifted directly from freebie items, copied wholesale from the forums, or available for the asking.
Setting a Listen to open chat (Channel 0) is very laggy when local chat is busy. Set Listen to a high channels when at all possible. Remember, the more specific you can make the Listen, the better.
Explicitly close Listens when you are done with them, as each use of llListen adds another listener. These build up.
Unlike Listen, you can only have one Timer going per script. If you need multiple things to happen at different time, set an interval that is a common factor in the intervals you want then increment a counter variable to count off each tick of the timer.
Scripts get last shot at a sim's resources. As such, timers are never completely accurate.
Avoid using Sensors. Try to stick to Touch events, and passive methods such as llDetectVolume
When debugging, if you need to know the value of a variable at a certain point, use llOwnerSay((string)VariableName); This is called type casting. Similarly, if you need the Z axis component of a vector or rotation, you can use llOwnerSay((string)VariableName.z);
Camelot?
1 day ago

0 comments:
Post a Comment