| Keyword | Scope | Location |
var |
function local | Function |
local |
object local | Object Script |
static |
global | any script |
{ var / local / static } name [= expr] [, name [= expr] ... ];
static variables. Without initialization variables always start with nil.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;
}
this is a definition, local variables are constant. That protects against accidental modifications that would appear to work fine while there is only one object of a kind, but break in subtle ways as soon as there are multiple instances.obj.foo or obj["foo"] notation one can access local variables in other objects.static variable may also be used in object scripts (see example). If a static variable of the same name is defined in another script, the name will refer to the same variable.