Articles on: Blocks Creator
This article is also available in:

⬛ 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


  1. The player has accumulated a score of 150 points in a quest.
  2. You want to apply a 10% discount if the score exceeds 100, otherwise a 5% discount.
  3. Place the Execute Javascript block in your graph and connect the player's score to it via a dynamic score input.
  4. In the code field, enter:
   const score = celestoryPoints.get('score', 0);
const reduction = score > 100? 0.1:0.05;
celestoryPoints.set('AmountReduction', reduction);
  1. The block automatically generates an output amountReduction containing 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() or celestoryPoints.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 celestoryPoints object. Blocking or asynchronous operations can impact module performance.

Updated on: 04/03/2026

Was this article helpful?

Share your feedback

Cancel

Thank you!