Sign In Register

How can we help you today?

Start a new topic
Answered

Cloud code call from other cloud call event

Just double checking that it is not possible to call cloud code in another cloud code event

example:

GetFoo


can not be called in some way from 

GetBlah


Best Answer
Hey Travis,

Its not possible to call an event request from another event, but you can use Modules to stick your code into functions, and then call those from wherever you want.

For example if you wanted to check a players friend-list in your GetFoo event, you can create a module with a getFriends function in it...

 

function getFriends(playerID)
{
    return Spark.loadPlayer(playerID).getFriendIds();
}

 

Then you can call on that function by accessing the Module at the top of your cloud-code script and call the function as if it is in that event...


 

require("FRIENDS_MODULE"); 

var playerList = getFriends(Spark.getPlayer().getPlayerId());

 

Hope that answers your question

 

1 Comment

Answer
Hey Travis,

Its not possible to call an event request from another event, but you can use Modules to stick your code into functions, and then call those from wherever you want.

For example if you wanted to check a players friend-list in your GetFoo event, you can create a module with a getFriends function in it...

 

function getFriends(playerID)
{
    return Spark.loadPlayer(playerID).getFriendIds();
}

 

Then you can call on that function by accessing the Module at the top of your cloud-code script and call the function as if it is in that event...


 

require("FRIENDS_MODULE"); 

var playerList = getFriends(Spark.getPlayer().getPlayerId());

 

Hope that answers your question

 


3 people like this