Variables

Variables are placeholders for values stored in a script. A variable stores a value in one of several data types.
There are three different scopes in which a variable can be declared.
Keyword Scope Location
var function local Function
local object local Object Script
static global any script
Variables are declared using the following syntax:
{ var / local / static } name [= expr] [, name [= expr] ... ];
The variable's scope, followed by the variable's name.
Optionally, you can assign a value to the variable directly at declaration time. However, this is not possible for static variables. Without initialization variables always start with nil.
Additional variable declarations may follow, separated by comma. The declaration must always be ended with a semicolon.

Example:

static object_count;
local  time_to_live = 100;

protected func Initialize()
{
  object_count++;
}

protected func Destruction()
{
  object_count--;
}

protected func Timer()
{
  if(!--time_to_live)
  {
    RemoveObject();
    return;
  }

  var obj = FindObject(Find_ID(Clonk), Sort_Distance());

  if(ObjectDistance(obj) < 20)
    DoDamage(-10, obj);

  return;
}

Addendum:

PeterW, her-long ago
G√ľnther, 2010