integer DEBUG_CHANNEL = 2147483647; integer DEBUG_CHANNEL = 0x7FFFFFFF;
The integer constant DEBUG_CHANNEL has the value 2147483647.
Used as chat channel constant, to send messages to the debug channel.
Example
Shows "This is a debugging message." in the Script Warning/Error Window:
default { state_entry() { llSay(DEBUG_CHANNEL, "This is a debugging message!"); } }
Remarks
When used as chat channel in combination with the output functions of the Chat category, it will send text to the Script Warning/Error Window of the client. If that option is activated in the client's preferences, it will display that text also in the public chat window, hightlighted with the color for error messages.
The channel can be used for user-defined script errors and debugging purposes.
Notes
This channel is reserved to the described purpose. Don't use the constant or it's value for regular communication between scripts or objects.
Always use DEBUG_CHANNEL and not it's value directly. The reason lays in the definition of the constants value in the client source code and to maintain compatibility even for the most unlike situation, where code could break otherwise.
Other scripts can listen to messages on this channel, except scripts belonging to the same prim as the script, that sends the message. It is possible that way, to have a script in another prim that handles, protocols or responds to error and debug messages.
When used frequently, it is suggested to setup a function that simplifies debugging, as in this example:
//setting DEBUG to FALSE deactivates debugging in the whole script integer DEBUG = TRUE; _debug(string message) { if (DEBUG) { llSay(DEBUG_CHANNEL, llGetScriptName() + ": " + message); } } default { state_entry() { //simple use _debug("Entering default state_entry."); //more code, but makes debug code run faster, when DEBUG = FALSE if (DEBUG) _debug("Entering default state_entry."); } }
Related Constants
- PUBLIC_CHANNEL - Used as chat channel constant, to send messages to the public chat
Platforms
SecondLife (agni), Secondlife (aditi), OpenSimulator
See also[]
- Chat category
- Communications category
- DEBUG_CHANNEL - Constant reference at SecondLife LSL Wiki
- DEBUG_CHANNEL - Constant reference at lslwiki.net
Advanced Debug example[]
Should the debug example moved to a separate "Code Snippets" page, to be linked through other chat-function pages and contain little more explanations?
-- JamMeili 08:32, January 2, 2010 (UTC)