Sign In Register

How can we help you today?

Start a new topic
Answered

Query related to scheduling module

Hello Sir,
         I have created one event in Which I am scheduling one module. Below is my code.
I have set timer of 20 second for this module to execute. But it is not getting executed. Can you please help what is the issue in this ?
Event Code :
var theScheduler = Spark.getScheduler();
theScheduler.inSeconds("Wel", 20, {"Messgae":"Welcome"});

In this I am calling module with name as "Wel" .
Module Code :
var objmsg=Spark.getData().Message;

var objpass=Spark.setScriptData("Message", objmsg);

Best Answer

Hi Ram,


You don't use scriptData in this situation as there is no response to attach it to. Try using a log instead.

 

//in your event
var theScheduler = Spark.getScheduler();
theScheduler.inSeconds("Wel", 2, {"Message":"Welcome"});

//in the Wel module
var objmsg=Spark.getData().Message //get the value for Message from the data set in the scheduler
Spark.getLog().info("Message = " + objmsg)

  

Now if you navigate to NoSql and check your script.log you should find a log like this.


{
 "_id": {
  "$oid": "586f913d0373773bb04237c3"
 },
 "script": "Wel",
 "playerId": "58599aba18416804a3b6ba5c",
 "log": "Message = Welcome",
 "stackTrace": [
  "@modules/Wel.js:9"
 ],
 "level": "INFO",
 "ts": {
  "$date": {
   "$numberLong": "1483706685578"
  }
 }
}


Thanks,

Liam




Answer

Hi Ram,


You don't use scriptData in this situation as there is no response to attach it to. Try using a log instead.

 

//in your event
var theScheduler = Spark.getScheduler();
theScheduler.inSeconds("Wel", 2, {"Message":"Welcome"});

//in the Wel module
var objmsg=Spark.getData().Message //get the value for Message from the data set in the scheduler
Spark.getLog().info("Message = " + objmsg)

  

Now if you navigate to NoSql and check your script.log you should find a log like this.


{
 "_id": {
  "$oid": "586f913d0373773bb04237c3"
 },
 "script": "Wel",
 "playerId": "58599aba18416804a3b6ba5c",
 "log": "Message = Welcome",
 "stackTrace": [
  "@modules/Wel.js:9"
 ],
 "level": "INFO",
 "ts": {
  "$date": {
   "$numberLong": "1483706685578"
  }
 }
}


Thanks,

Liam



But this way I am not able pass this message to unity side. I want this message as response on Unity Side. Can I do that?

 Hi Ram,


To message a user from your cloud code, please use the ScriptMessage functionality, the documentation for which you can find here.


Regards,

-Dave

But what if I want to send after some time ?
 How can I achieve auto response functionality from Gamespark to Unity engine ?

Like I have a game in which 2 players are there on table to play. Now I want to start the game after 60 second of Second player connects ?

Login to post a comment