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    Guide

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


There are 3 types of revisions. The Live, Latest and Specific.
If
Specific, the specified version will be used.

The
Generate Play Stream Event toggle will enable the log generation on the Play Stream Monitor from the PlayFab Dashboard.

You may read the property descriptions for more information.

2. The revisions are the cloud code sheets, this is where you input your custom server code.
This feature can be found from the Automation side-tab.

The selected revision from the Cloud Script addon's properties will be used.

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

The events will show up in the PlayStream Debugger Console, which is useful for debugging.

That covers the entirety of Cloud Script's property features.

 

Introduction

The Cloud Script feature is an advanced feature, it involves basic JavaScript scripting from PlayFab's Automation feature.

However, it's a powerful feature and a must have skill for every game developer using PlayFab. As a bonus, you can also use this skill for Construct 3 Scripting.

The only thing you need to know how to write JavaScript with Cloud Script is the writing structure syntax. These include the comments, variables, operators, arithmetic, assignment, data types, functions, objects... up until you reach arrow functions. The rest you learn as you go.

It's not a difficult course to learn, everyone from every field who learned Construct 2 or Construct 3 can certainly do it. 


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


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

That's it for the introduction, good luck!

 

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:

Expressions - 1