Returns the value of an object local variable (as reference). Each object can hold any number of local variables. This are
stored in the object until the object is deleted. A newly created local variable always has the value 0.
Since Local() returns a reference, the variable can be modified using operators such as Local(0) = 20 or Local(1)++
Where possible, a local
named variable should be used instead of a local variable.
/* Objektscript */
Hit:
Local(0) = 1;
Local(1) = 10;
return(1);
Timer:
if(Local(0) == 0) return();
// Geräusch machen
Sound("Fuse");
// Variable herunterzählen
Local(1)--;
// Anzeigen
Message(" %d ", Local(1));
// Zeit um?
if(Local(1) == 0)
// Explosion!
Explode(50);
return();
This script is invoked through the engine callback 'Hit' which occurs when the object hits the ground.
The script sets the local variable 0 to value 1 and the variable 1 to value 10.
The second script function is called 'Timer' and should be called periodically (see Timer entry in DefCore). This function
will check whether the object has already hit the ground (Local(0) ist set). If this is the case, a sound is played and the
counter variable 1 is decreased. When the counter reaches zero, the object explodes. For example this could be a timed grenade
activated by impact.