Author Topic: All Loop  (Read 965 times)

I am trying to make every emitter (including light) activate once, and then it repeats.

Code: [Select]
package AllLoop
{
function allloop()
{
schedule(500,0,commandToServer('Light'));
schedule(1700,0,commandToServer('Alarm'));
schedule(2900,0,commandToServer('Love'));
schedule(4100,0,commandToServer('Hate'));
schedule(6300,0,commandToServer('confusion'));
schedule(7500,0,allloop);
}
};
activatePackage( "AllLoop" );
It does not contain any Syntax errors, but the schedule doesn't seem to be working.
Just by looking at it, I know that something's wrong, but I can't seem to find the screw-up.
Help please?

It's lilke this:

Code: [Select]
schedule(500, 0, commandToServer, 'Light');

There is flood protection on emitters.

There is flood protection on emitters.
Yes, but I added delays.

I suggest that you include some safety checks so that you do not run the schedule more than once. If you're going to start using loops more often then I suggest you look at the isEventPending and cancel functions within that AllLoop() function. You also don't really need to package functions like this, packages tend to be used for parenting functions or huge scripts like Slayer. I never use packages if it's a single function or a function that doesn't need to be turned off. I guess it's personal preference.

package AllLoop
{
   function allloop()
   {
      if(isEventPending($AllLoop::Schedule))
         cancel($AllLoop::Schedule);
      
      schedule(500,0,commandToServer,'Light');
      schedule(1700,0,commandToServer,'Alarm');
      schedule(2900,0,commandToServer,'Love');
      schedule(4100,0,commandToServer,'Hate');
      schedule(6300,0,commandToServer,'confusion');
      $AllLoop::Schedule = schedule(7500,0,allloop);
   }
};
activatePackage( "AllLoop" );


I may have put the isEventPending area in the wrong place, I'm at school so I'm having to switch between windows and my head is killing, so pardon me if I create any issues. Also Blockland doesn't run on school computers so I'm unable to see whether that code is correct or not. Hopefully somebody will check it.