β¬ Run Javascript
β¬ Run Javascript
The Execute Javascript block allows you to execute a custom JavaScript script within a Celestory module, offering the possibility of manipulating data, performing complex calculations or implementing advanced algorithms.
This block is particularly useful for creators wanting to extend Celestory's core functionality with specific processing, while maintaining smooth integration with the rest of the graph via dynamic inputs and outputs.
π₯ Entries
- code (String): JavaScript code editor where the user enters their script. Syntax errors can cause malfunctions.
- (Dynamic incoming variables) (Any): Inputs created automatically via
celestoryPoints.get('VariableName', defaultValue)in the code. Each call generates a corresponding entry in the block.
π€ Outings
- out (Flow): Normal execution flow, activated if the script executes without errors.
- catch (Flow): Alternative execution flow, activated in case of an error in the script. Allows you to manage exceptions and avoid blocking the module.
- (Dynamic output variables) (Any): Outputs created automatically via
celestoryPoints.set('VariableName', value)in the code. Each call generates a corresponding output in the block.
π‘ Example of use
Scenario: Calculate a personalized reduction based on the player's score
- The player has accumulated a score of 150 points in a quest.
- You want to apply a 10% discount if the score exceeds 100, otherwise a 5% discount.
- Place the Execute Javascript block in your graph and connect the player's score to it via a dynamic
scoreinput. - In the code field, enter:
const score = celestoryPoints.get('score', 0);
const reduction = score > 100? 0.1:0.05;
celestoryPoints.set('AmountReduction', reduction);
- The block automatically generates an output
amountReductioncontaining the calculated value (0.1 or 0.05), which you can use to apply the reduction in the rest of the graph.
βοΈ Technical Details
- Dynamic variable management: Inputs/outputs are created on the fly during script execution. Their type depends on the value passed via
celestoryPoints.get()orcelestoryPoints.set(). - Error handling: Any exception not caught in the script activates the catch flow. It is recommended to use error handling blocks for critical scripts.
- Execution context: The script runs in an isolated environment with limited access to the Celestory APIs via the
celestoryPointsobject. Blocking or asynchronous operations can impact module performance.
Updated on: 04/03/2026
Thank you!
