Skip to content

Codingstyle

lickx edited this page Sep 10, 2018 · 5 revisions

Variables

Variables are prefixed with their type:

  • integer iMyInt
  • string sMyString
  • vector vMyVector
  • rotation rMyRot
  • list lMyList
  • float fMyFloat

Booleans are written as iMyBoolean

Global variables get an additional prefix: g_

  • integer g_iMyInt
  • string g_sMyString

Constants

Constants don't have a prefix and are written in ALL_CAPS:
integer LOCATION_FLAGS = 31;

Functions

Function names are camelcase without prefix for the return value:
integer MyFunction(string sMyParam)

Identation

We use four spaces to ident, not tabs!

Brackets/braces placement

Here the project is less consistent
Try to avoid inline brackets:
if (x) { DoSomething(); DoSomethingElse(); }
OpenSim might choke on nested conditional statements if no brackets are used on the outer condition:

if (x)
    if (z)
        DoSomething();
    else
        DomSomethingElse();
else
    AnotherThing();

This should have been written as:

if (x) {
    if (z)
        DoSomething();
    else
        DomSomethingElse();
} else
    AnotherThing();

Clone this wiki locally