Difference between revisions of "LSL Errors"

From Second Life Wiki
Jump to navigation Jump to search
m (balance the pre tags in the format)
(launch a section to collect surprising compile-time error messages, with the missing typecast to vector/ rotation from 3 & 4 element lists)
Line 2: Line 2:


==Script run-time error messages==
==Script run-time error messages==
A script may stop running, and chat at you the complaint "Script run-time error", followed by another complaint such as:


* '''Lists may not contain lists'''
* '''Lists may not contain lists'''
Line 10: Line 12:
** This can occur if the running script is too big. The script compiles and saves successfully, but when an object containing it is instantiated the script crashes.
** This can occur if the running script is too big. The script compiles and saves successfully, but when an object containing it is instantiated the script crashes.


==Examples==
==Sample scripts that demo script run-time error messages==


<pre>
<pre>
Line 32: Line 34:
         float quotient = one / zero; // Script run-time error: Math Error
         float quotient = one / zero; // Script run-time error: Math Error
         llOwnerSay((string) quotient);
         llOwnerSay((string) quotient);
    }
}
</pre>
==Surprising compile-time ERROR messages==
The SL GUI may reject some code that you feel is perfectly clear, printing ERROR at you and then explaining with some further complaint.
Examples follow ...
You must name the .x .y .z .s components of a vector or rotation that you're assigning, you can't assign them all at once from a list, for instance:
<pre>
default
{
    state_entry()
    {
        vector vec = (vector) [1, 2, 3]; // Type mismatch
        llOwnerSay((string) vec);
     }
     }
}
}
</pre>
</pre>

Revision as of 12:04, 6 September 2007

Script run-time error messages

A script may stop running, and chat at you the complaint "Script run-time error", followed by another complaint such as:

  • Lists may not contain lists
  • Math Error - float divided by zero, integer divided by zero, etc.
  • Stack-Heap Collision - The Stack has collided with the Heap.
    The LSL memory space contains three sections Bytecode, Stack and Heap which all must be contained in 16kib of memory.
    • This can occur if the running script is too big. The script compiles and saves successfully, but when an object containing it is instantiated the script crashes.

Sample scripts that demo script run-time error messages

default
{
    state_entry()
    {
        list once = [];
        list twice = [once, once]; // Script run-time error: Lists may not contain lists
    }
}
default
{
    state_entry()
    {
        float one = 1.0;
        float zero = 0.0;
        float quotient = one / zero; // Script run-time error: Math Error
        llOwnerSay((string) quotient);
    }
}

Surprising compile-time ERROR messages

The SL GUI may reject some code that you feel is perfectly clear, printing ERROR at you and then explaining with some further complaint.

Examples follow ...

You must name the .x .y .z .s components of a vector or rotation that you're assigning, you can't assign them all at once from a list, for instance:

default
{
    state_entry()
    {
        vector vec = (vector) [1, 2, 3]; // Type mismatch
        llOwnerSay((string) vec);
    }
}