Author Topic: Spacetick, what is it?  (Read 711 times)

I seen it in some add-ons by space guy.
What does it do?

Could you post an example of how it's used?

Code: [Select]
package SpaceTick
{
 function SpaceTick(%ticknum)
 {
  //Controller Ticks
  for(%i=1;(%str = getField($SpaceMods::SpaceTick::Controllers,%i)) !$= "";%i++)
  {
   if(isObject(%str))
   %str.tick();
  }
  $SpaceMods::SpaceTick = schedule(33,0,spacetick);
 }
 function disconnect()
 {
  cancel($SpaceMods::SpaceTick);
  $SpaceMods::SpaceTick = 0;
  for(%i=1;(%str = getField($SpaceTick::SpaceTick::Controllers,%i)) !$= "";%i++)
  {
   if(isObject(%str))
   %str.delete();
  }
  Parent::disconnect();
 }
 function SimSet::tick(%this) //Can't call "XCtrlSO::Tick()" for some reason
 {
  call(%this.callFn,%this);
 }
};activatepackage(SpaceTick);
$SpaceMods::SpaceTick = schedule(33,0,SpaceTick);

It's pretty much a function that acts as a timer. There is truly no reason why it's called "SpaceTick", It can be called anything really.
« Last Edit: December 01, 2012, 03:54:25 AM by Honorabl3 »

Every add-on Space Guy made that needed a timed tick hooks into this function. It's just so that it's clean, instead of having 5 ticks running concurrently for 5 different add-ons he made, there's 1 tick that he packages.

But what if different add-ons need to tick at different times?
Then he can't use it?

Multiple ticks can run on the same variable unless canceled.

But what if different add-ons need to tick at different times?
Then he can't use it?
Then you make a separate tick. This is for things that need to consistently check frequently.