Thanks, Ilan, I am just trying to fingure out how to change the old language phrase to the new language phrase for each and I am aware it takes more than a simple copy/paste.Ilan Tochner wrote:Hi Ghaelen,
Top Scripts no longer counts time spent in llSleep but all of Kayaker's recommendations are still very relevant for improving your script performance.
What specifically do you wish to know?
As a (hopefully) simple example, this is a nice sliding door script from Bob Sutor's tutorials. I'd like to add it sliding door script to the list of scripts here on the forum, but in a way that uses the newer language.
So....
It uses
Code: Select all
llSetPos(closed_position); // Move door to closed position
Code: Select all
llSetPos(pos); replace with llSetLinkPrimitiveParamsFast(LINK_THIS,[PRIM_POSITION,pos]);
Code: Select all
// Sliding door LSL script #4
// Author Bob Sutor
// Handles the touch event.
// Handles the collision event.
// Handles closing the door automatically via a timer event.
// Triggers sounds when the door opens or closes.
// Parameters you might want to change
float delay = 3.0; // time to wait before
// automatically closing door
vector delta = <0.0, 1.0, 0.0>; // amount to move door
// when we open it
float volume = 0.7; // 0.0 is off, 1.0 is loudest
// Variables you will most likely leave the same
vector closed_position; // original position of the
// door when closed
key open_sound = "cb340647-9680-dd5e-49c0-86edfa01b3ac";
key close_sound = "e7ff1054-003d-d134-66be-207573f2b535";
// Processing for the script when it first starts up
default {
// What we do when we first enter this state
state_entry() {
closed_position = llGetPos(); // Save position when door is closed
state closed; // Move to the closed state
}
}
// Processing for the script when it is in the closed state
state closed {
// What we do when we first enter this state
state_entry() {
llTriggerSound(close_sound, volume); // Trigger the sound of the door closing
llSetPos(closed_position); // Move door to closed position
}
// What we do when the door is clicked ("touched") with the mouse
touch_start(integer total_number) {
state open; // Move to the open state
}
// What to do when something hits the door
collision_start(integer total_number)
{
state open; // Move to the open state
}
// What to do when the timer goes off
timer()
{
llSetTimerEvent(0.0); // Set the timer to 0.0 to turn it off
}
}
// Processing for the script when it is in the open state
state open {
// What we do when we first enter this state
state_entry() {
llTriggerSound(open_sound, volume);// Trigger the sound of the door opening
llSetPos(closed_position + delta); // Move door to open position
llSetTimerEvent(delay); // Set the timer to automatically close it
}
// What we do when the door is clicked ("touched") with the mouse
touch_start(integer total_number) {
state closed; // Move to the closed state
}
// What to do when something hits the door
collision_start(integer total_number)
{
// Do nothing, the door is already open
}
// What to do when the timer goes off
timer()
{
llSetTimerEvent(0.0); // Set the timer to 0.0 to turn it off
state closed; // Move to the closed state
}
}