Cloud Script

The Cloud Script plugin is specifically designed to call Cloud Functions and Microsoft Azure Functions through PlayFab's automation feature, for games built using Construct 3 and Construct 2.


Cloud Script allows the developer to extend the features of PlayFab through server-side scripting with JavaScript, and a lot of other server-side scripting languages with Microsoft Azure.


The Cloud Script plugin is used similar to the Construct 3's functions feature, it calls a function using a name with parameters. Except the function called is in the script of PlayFab's Automation feature or Microsoft Azure's Cloud Function feature.


With Cloud Script, you can freely extend the features of PlayFab with your own server scripts.

PlayFab API v2.png

Introduction

Step 1.png

The Construct Master Collection supports the full and easy integration of the PlayFab service for both Construct 3 and Construct 2.


Please click here to learn more about PlayFab.

Features


Here are some of the features of the PlayFab service:

  • Server-side scripting

  • Cloud Script

  • Azure Functions (Coming soon!)

  • Server API

  • Admin API with Azure Functions (Coming soon!)

  • Automation features

  • Cloud functions

  • Security features with server scripting.

  • Organized request and update features.


For more information about all the integrated PlayFab service features, please click here to learn the introductory lessons to PlayFab.


Network Services


Here are some of the platform services that can be linked:

  • PlayFab

  • Google Play

  • Game Center

  • Facebook

  • Facebook Instant Games

  • Steam

  • Xbox Live

  • Instant Games (Android Studio port)

  • Nintendo Switch (3rd party porting services)

  • PS4 (3rd party porting services)

  • Nintendo Switch (3rd party porting services)


Editor Features


Here are some of the features in the Construct editor:

  • All platforms support, including web, mobile and desktop.

  • Construct 3

  • Construct 2

 
 

How to use?

It is easy to use the Cloud Script plugin, you will only need to follow the steps below.

  1. Set up the PlayFab API plugin, please click to visit the documentation. This includes creating a PlayFab account, studio and title.

  2. Set up the Authentication plugin, please click to visit the documentation.

  3. Finally, you can now use the Cloud Script object, and include more PlayFab addons for more features.


 
 

Documentation

There is currently nothing to show, we will add more in the future.



Introduction


Cloud Script is an advanced PlayFab feature, but it only involves basic JavaScript scripting. It's a powerful feature and a useful skill to game developers using PlayFab.


If you are new to JavaScript, then it is a great journey ahead of you. With PlayFab's automation feature, you only need basic JavaScript knowledge to use the scripting feature. There are some learning ahead, however it is a worth it endeavor and investment in your career since you can also use this skill for any development purposes, including using your skill to use Construct 3's Scripting feature, which allows you to do more advanced implementations with your projects.

The most important things you need to know to get started in writing JavaScript with Cloud Script is the writing structure or syntax. These include comments, variables, operators, arithmetic, assignment, data types, functions, objects... up until you reach arrow functions. You will learn the rest as you go.

It's not a difficult course to learn, everyone who managed to understand the event sheet system with Construct 3 or Construct 2 can certainly do it.

For further studies, you can lookup CodeAcademy, W3Schools or Tutorialspoint. For video based learning, we highly recommend Derek Banas' complete JavaScript tutorial.


If you already know JavaScript, then it is straightforward to use. You only need to write a handler function in your customized server-side script in the Automation features page of the PlayFab Console. In the server-side script, you can access the Server API and make requests alongside your customized functions. You can call these functions through their handler. You can call the handler function from Construct 3 through the Cloud Script plugin by passing the handler name and the parameters. To get started, please refer to the documentations below:

Make sure to also lookup the Introduction to Cloud Script tutorial, a basic learning guide for Cloud Scripting.



Azure Functions


Reminder!



Properties Guide


The Cloud Script plugin has a properties section to easily configure how you want to select and request server-side scripts.



Click to select the Cloud Script object and take a look at the Properties Bar while the Cloud Script object is selected. This will show the 3 configuration properties, the Revision, Specific Version and Generate Play Stream.


There are 3 types of revisions, Live, Latest and Specific. If the property is set to Specific, the specified version in the next property below will be used. The Generate Play Stream Event toggle will enable the log generation in the Play Stream Monitor from the PlayFab Dashboard, if checked.

You can also read each property's descriptions for more information.

 

Actions, Conditions & Expressions

Actions

press to zoom

press to zoom
1/1

The following action groups:

  • Cloud Function

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

The following condition groups:

  • Cloud Function

  • Checking

  • Logs

press to zoom

press to zoom
1/1

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.



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

press to zoom

press to zoom

press to zoom
1/2

The following expression groups:

  • Content Delivery Network

  • Server Response

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".

Object   Properties

Plugin Properties

press to zoom

press to zoom
1/1

The following properties groups:

  • Default

Default

  • 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 specific 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

 
 

Showcase

Here are one of the highlighted basic features of the Automation feature of PlayFab with Cloud Script and Azure Functions.







 

Game Projects 

Instructions Kit

Construct 3 Project
Construct 3 Project

press to zoom
Construct 2 Project
Construct 2 Project

press to zoom
Construct 3 Project
Construct 3 Project

press to zoom
1/2

Specifications

  • Instructions - The game project contains instructions and steps on how to use the addon and its features.

  • Action, Conditions and Expressions - It covers the implementation of each action, condition and expression.

  • Tips and Tricks - It provides some tips and tricks on the recommended ways of using the addon.

Supporters

Only