Custom scripting gives experienced developers even more power by allowing you to run your own javascript.
By Tiers:
Free and Pro-tier developers only have access to in-play scripting. Enterprise customers can run javascript anywhere in their game, including sets, community pages, landing pages, etc.
Getting started with JavaScript
The simplest way to try custom scripting is through the custom javascript action in the effect builder.
To use it, use the custom javascript action. All javascript is executed in the context of that action. Custom javascript action can be executed either client side or server side. Server side execution effects the logic of the game while client-side execution effects the rendering and visuals on the client. Even if your game doesn't have a server the logic of the game is still server-side with a local server.
Examples of custom javascript commands on the server:
console.log(thisCard)
thisCard.variable = {
"foo": "bar"
}
console.log(parseVariable('$variable'))
console.log(dotSyntax('$variable.variable2'))
Included third party libraries
Server side libraries:
- Async
- Lodash
Client side Libraries:
- Async
- Lodash
- jQuery
- three.js
- hammer.js
Server side API
Local Variables
Global Variables
thisMatch
Helper Functions
> runEffect(thisMatch, options, callback)
thisMatch parameter
Specify the match. Should always be "thisMatch".
options parameter
key | description | type |
---|---|---|
ciid | The ciid of the card you're executing. | int |
effectIndex | The index of the effect you're executing on the target card. | int |
callback parameter
Optional.
getIndexFromEffectName(effectName)
effectAfterAction()
Proceed to the effect completion.
assignTargetVariable(target)
This assigns to the target to the line like the assign variable action. The target may be any number, string, object, function or array of ciids.
stringVariableReplacement(string)
With a string, replace any variables within. Example: stringVariableReplacement("This card is called $title. It has an attack power of $atk and a health of $health.")