Sign In Register

How can we help you today?

Start a new topic

You can only schedule one script.

I am a bit confused about the scheduler.

I read that scheduled modules cannot schedule new actions. In my tests, this is not the case. I can schedule the same task in a scheduled task and create an infinite loop. But scheduling the same task multiple times (with different data) in one action is not working. Instead I get an error log with "You can only schedule one script." I would need to do something like this: 

var actions = getActions(); // some entities from DB
var delay;

for(var i = 0; i < actions.length; i++)
{
    delay = calculateDelayFromStartTimeStamp(actions[i].startTime);
    Spark.getScheduler().inSeconds("HandleAction", delay, {actionId: actions[i]._id});
}

 The first task is scheduled but after this I only get the above mentioned error logs. How can I solve this problem? I don't want to run thru all actions in GS_EVERY_MINUTE because it doesn't really scale.


David,


Specify different ids for each task.

 

for(var i = 0; i < actions.length; i++)
{
    delay = calculateDelayFromStartTimeStamp(actions[i].startTime);
    Spark.getScheduler().inSeconds("HandleAction", delay, {actionId: actions[i]._id}, ""HandleAction" + i);
}

 


Actually I am doing that already. The code snippet is no real copy paste.

Any news on this? I am a bit confused because the behaviour is exactly the other way around as I expected from what I read in the forums. (The documentation is totally lacking this information).

Any news on this? I am a bit confused because the behaviour is exactly the other way around as I expected from what I read in the forums. (The documentation is totally missing this information).

After some testing I found out, the behauviour is different in a normal LogEvent and in GS_MINUTE.

It is possible to schedule multiple scripts in a LogEvent but not in GS_MINUTE. This is a very unexpected behaviour.

How horrible would it be if I scheduled a module for every second (or maybe minute) of an established game time length? Effectively creating an "Every Second" (or minute as I started before) system module but relative (this is whats the most important) to when the game is started.

 That would be very bad :P
It would put a lot of strain on server performance depending on what each of those module scripts do. If you need that kind of synchronicity for your game you'd be better off using the RT service.

Login to post a comment