Cloud Script

The PlayFab Cloud Script Module is a feature that enables script function calls to the PlayFab Cloud Server.

This enables the developer to extend features of PlayFab from the server using the PlayFab Server API or custom processes.

It is easy to use, similar to Construct's Function feature, although instead of calling from the event sheet, it is calling from the PlayFab Server Automation JavaScript script.

With this feature, you can extend the features of PlayFab with your own customized implementation.

 

Intstructions

1. The first step is to add the PlayFab API addon into the project.

2. Then, add the Authentication addon into the project.

3. Finally, add the Cloud Script addon into the project.

Features :

  • Server Functions with the Server API.

  • Easy Server Function call features.

  • Automation features.

  • Security features with server scripting.

  • Account synced and profiled.

  • Organized request and update feature.

Network Services :

  • Facebook

  • Google Plus

  • Game Center

  • Google Play

  • Facebook Instant Games

  • Steam

  • Xbox Live

  • Nintendo Switch

  • PS4

  • PlayFab

Property    Instructions

1. Take a look at the Properties Bar while the PlayFab Cloud Script object is selected. 

This will show the 3 configuration properties, which are the Revision, Specific Version and the Generate Play Stream toggle.

For more information, read the properties description from the properties section. But basically, there are 3 types of revisions, the Live, Latest and Specific, the options speak for themselves. Although, if Specific, the version to be chosen will be determined by the Specific property. Lastly, the Generate Play Stream Event toggle, enabling it will generate logs on the Play Stream Monitor from the PlayFab Console Dashboard.

2. The revisions are basically the JavaScript code sheets to place your functions for the Cloud Script feature. You can load different revisions, either Live, Latest or Specific, where you need to specify the version by the label from the Specific property.

The used revision will be the one called when running the Cloud Script addon.

3. The Generate Play Stream Event toggle is a to enable generation of the 'player_executed_cloudscript'  play stream stream event containing the results of the function execution and other contextual information.

The event will show up in the PlayStream Debugger Console for the player in the Game Manager. This is useful for error tracking analytics.

That covers the Cloud Script's property features.

Cloud Script Introduction

The Cloud Script feature is a bit of an advanced feature, it involves basic JavaScript scripting from the PlayFab Server's Automation feature. Although, it's a very powerful feature and a must have for every game developer using PlayFab.

Even though it's an advanced feature, this documentation is here to help you out make it easy for you. But it's still a requirement to learn the very basic of JavaScript syntax. You don't need to learn much, you just need the basics like the writing structure syntax, variables, data types and functions.  

It's not a difficult course, you can learn the basics from CodeAcademy, W3Schools or Tutorialspoint in just days. I recommend to start with the game sample project below, it includes a tutorial to introduce you to cloud scripting and get you started while you learn.

Actions, Conditions & Expressions

Actions

Actions.png

Cloud Function :

  • Plan Parameter - Plan a parameter for the next "Cloud Call Function".

    • Key - The key of the parameter.

    • Value - The value of the parameter.

  • Call Function - Call a "Cloud Script Function".

    • Name - The name of the CloudScript function to execute.

Conditions

Cloud Function :

  • On Finished - Triggered when a function is called and has responded with a success.

    • Name - The name of the function that is being called.

  • On Finished Failed - Triggered when a function is called and has responded with a failure.

    • Name - The name of the function that is being called.

  • On Any Finished - Triggered when any function is called and has responded with a success.

  • On Any Finished Failed - Triggered when any function is called and has responded with a failure.

Conditions.png

Checking :

  • Has Error - Checks if the latest Cloud Function response has an error during execution.

  • Results Too Large - Checks if the latest Cloud Function response return value is too large (>350KB) and was dropped.

  • Logs Too Large - Checks if the latest Cloud Function response logs are too large, when the total event size is (>350KB).

Logs :

  • For Each Log - Loops through all the logs received from the recent "Call Function".

Expressions

Cloud Function :

  • ReturnValue - Get the value set to return from the "Cloud Script Function".

    • Key - The key of the parameter.

  • Name - Get current Cloud Function Name.

Logs :

  • LogAt - Get the entry by index, logged during the function execution.​

    • Index - The index of the log to retrieve.

  • LogCount - Get Details about the error, if any, that occurred during execution.

  • LogIndex - Get the current log index from the "For Each Log".

 


Tools :

  • BytesConsumed - Get the Memory Consumed Bytes.

  • ProcessorTime - Get the Processor Time in Seconds. Processor time consumed while executing the function. This does not include time spent waiting on API calls or HTTP requests.

  • APIRequestsCount - Get the number of PlayFab API requests issued by the CloudScript function.

  • HTTPRequestsCount - Get the number of external HTTP requests issued by the CloudScript function.

  • Revision - Get the revision of the CloudScript that executed.

 


Debug :

  • Error - Get Error Information like Error Codes, if any, that occurred during execution.

  • ErrorMessage - Get Details about the error, if any, that occurred during execution.

  • StackTrace - Get Point during the execution of the script at which the error occurred, if any.

 


Server Response :

  • ServerResponse - Return the "Server Response" from every request from the PlayFab Server. The server response can also be shown in the "Chrome Developer Tools : Console", if in "debug mode".

Properties

  • Revision - 'Latest' executes the most recently created revision, 'Live' executes the current live, published revision, and 'Specific' executes the specified revision.

    • Live

    • Latest

    • Specific

 

  • Specific - The specivic revision to execute, when RevisionSelection is set to 'Specific'.

  • GeneratePlayStreamEvent - Generate a 'player_executed_cloudscript' PlayStream event containing the results of the function execution and other contextual information. This event will show up in the PlayStream debugger console for the player in Game Manager.

    • Enabled

    • Disabled

Easy Game Project

Sample Setup Project

Specifications

  • Instructions - The sample project has comments and instructions on how to use the addon and its features.

  • A.C.E. Coverage - It covers the implementation of each action, condition and expression.

  • Tips and Tricks - It provides some tips and tricks to a better use of the addon and of the event-sheet system alongside it.

Supporters

Only

Game Project

Sample Setup Project

Specifications

  • Instructions - The sample project has comments and instructions on how to use the addon and its features.

  • A.C.E. Coverage - It covers the implementation of each action, condition and expression.

  • Tips and Tricks - It provides some tips and tricks to a better use of the addon and of the event-sheet system alongside it.

Supporters

Only

 
 
 
 
 

Get the tools

for your pro games!

Constuct Master Collection - Itch.io
Constuct Master Collection - Discord
Constuct Master Collection - Construct 3

© Construct Master Collection 2020 • All rights reserved

Contact Information: