Category:LSL Constants

From InWorldz Wiki
Jump to: navigation, search


Scripting Wiki

InWorldz Functions | LSL Functions | Bot / NPC Functions | Events | Bot Events | Types | Operators | Constants | Flow Control | Glossary


CONSTANT

A constant is a value which cannot be changed by the action of a script. Constants are typically used because it is easier to remember a name than a value. For example, if you're trying to convert degrees to radians for use in, say, llCos, it's easier to remember DEG_TO_RAD than 0.01745329238.

By design, all constants in LSL are in uppercase and use underscore characters ( _ ) to separate words within the name.

Scripters will often define their own "constants" in a script by declaring them before the default state, in the form of variable = value;. If such a value is not intended to be changed, it helps to use the same convention as LSL's 'hardwired' constants - all uppercase and underscores - to remind them that these variables should not be altered in the script code. Otherwise such is merely a variable assignment rather than a user-defined constant and can be defined using any variable naming convention.

Examples

Using a pre-defined constant

default
{
  state_entry()
  {
    llSay(0,"The sine of 45 degrees is " + (string)llSin( 45 * DEG_TO_RAD );
  }
}

Defining and using a custom constant

integer DIALOG_CHANNEL = -710232349;     // assign a negative channel to use for dialog functions

// begin script
default
{
  state_entry()
  {
    llListen( DIALOG_CHANNEL, "", NULL_KEY, "");
  }

  ...
}

A

I

M

O

P

Pages in category "LSL Constants"

The following 100 pages are in this category, out of 100 total.