Scripts¶
In Visual Scripting, a script is similar to any scripts in other languages: it is a sequence of instructions or commands that are visually constructed using Nodes and Links. These commands are then executed during runtime on the end user's device. Scripts are typically used to determine which Game Offers should be shown to an end user.
Creating a Script¶
Scripts are created in the Scripts page, which can be found under the LiveOps
section of the Navigation panel. Upon creating a Script, it can be opened by pressing the View
button next to the Script name, which will bring you to the Script View.
Using a Script¶
Activation By Game Event¶
After creating a Script, it can be activated in-game by first attaching it to a Game Event. The Script activates as soon as the Game Event itself activates when its conditions are met.
Note: If a Game Event has no conditions, it will immediately activate upon starting the game.
If the Script's Input Port is named exactly 'GameEvent' and is of Document type, it will automatically receive Game Event document which has activated this Script. It is useful to get access to Game Event's parameters.
Activation From Code¶
Documents can have parameters of Script type. Check Dynamic Reward script param of Store Item for example. If you create parameters of the Script type in your custom documents, you can execute scripts from the code.
On Balancy side the script for this example would have been like this:
Inner Scripts¶
Scripts can also be used within other Scripts. This Script will act like any other Node and can be connected to other Nodes using Links. This allows you to reuse any Scripts you've created previously, so you won't have to recreate any logic you find yourself using often.
Below is a normal Script and how it could be used inside other Scripts.
Tip: Try to make your Scripts do only one thing. This helps prevent redundant logic if you ever need to use the same logic in another Script. It also makes updating a particular logic easier, since you will only need to do the updates in one Script.