Advanced Puzzles

Use these puzzles to implement advanced features in your apps, such as networking, interation with JavaScript code, data conversion, state saving/restoring and more.


Puzzles Reference

call JS function

Executes a function specified in the JavaScript code of the application. Optionally passes parameters to be used as function arguments.

In order to add a function to JavaScript code, open the application .js file (for example, my_awesome_app.js located in verge3d/applications/my_awesome_app) with any text editor. Search for "prepareExternalInterface" and add your function inside that declaration (between the curly brackets), so that it looks like this:

function prepareExternalInterface(app) { app.ExternalInterface.myJSFunction = function(numericArg, textArg) { alert('Got some params from Puzzles: ' + numericArg + ' and ' + textArg); } }

exec script

This puzzle executes the specified javascript code.

You can use the following built-in variables:

load data

Attempts to load data from a specified location. The puzzles in the "once ready do" slot are interpreted regardless of whether the attempt was a success. The retrieved data can be accessed via the loaded data puzzle.

send data

Attempts to send a specified data to a remote location using an asynchronous POST HTTP request. The puzzles in the "once ready do" slot are interpreted regardless of whether the attempt was a success. If there is any response data, it can be accessed via the loaded data puzzle.

loaded data

Returns data retrieved by the load data or send data puzzles.

read JSON

Interprets text as JavaScript Object Notation data which are returned in a dictionary.

read CSV

Interprets text as comma-separated values. Returns a list of table rows, with each row represented as a list of values. The delimiter can be selected with the drop-down to correspond a CSV file's export settings. "From row" value denotes how many rows will be skipped starting from the top.

Table rows and values are accessed by their numeric indices starting from 0.

save state

Saves the state of specified objects and/or the values of variables specified by their names. The objects are cloned and stored in memory. The values of the variables are retrieved and stored in memory for each specified variable name.

If this puzzle is called several times, the states are saved in sequence so that it is possible to return to any previous state with the undo state puzzle.

undo state

Restores the state of objects and/or variables saved with the save state puzzle.

If this puzzle is called several times, the states are restored from the saved sequence (if any) which makes it possible to return to any previously saved state from the stack.

all variable names

Returns a list with the names of all variables used in Puzzles.

variable value by name

Returns the value of a variable specified by its name. This puzzle works similarly to the standard variable value puzzle, yet does not require to select a variable from the predefined dropdown menu.

wait promise

Wait for the promise to be resolved or rejected and return its value (or rejection reason) in the promise value puzzle.

This puzzle may be required to get value of the export to gltf and generate normal map puzzles. Being async puzzles by their nature, these puzzle do not return resolved values immediately. Instead, they return promise values which are resolved in the puzzles they are used as inputs. In some rare cases, however, this resolving does not happen. In these cases you should use wait promise to resolve promise values.

promise value

Resolved promise value (in case of resolved promise) or error string (in case of rejected promise).

Having Troubles with Puzzles?

Seek help on the forums!