ssod

<script> Tag

The <script> tag allows you to embed custom JavaScript logic inside a location. This is a powerful and flexible tag for advanced behaviour — but should only be used by experienced content authors.

Important: Players should refer to the separate [Embedded JavaScript Reference Guide] for the full list of available functions, structures, and safe execution rules. This guide will be made available separately.


Behaviour

When a <script> tag is encountered in a paragraph, the engine collects all text until it sees a matching </script> closing tag. This embedded text is then passed to the internal JavaScript engine for execution.

The script has full access to:

These are provided as JS objects: player and paragraph.

Scripts must not attempt to modify the existing paragraph text directly. Instead, use the special print(...) function to append new content to the paragraph output.

✅ Example

<script>
  if (player.rations < 1) {
    print("\nYou feel hungry and weak.\n");
  } else {
    print("\nYou still have food.\n");
  }
</script>

This script will insert one of the two lines into the paragraph output based on whether the player has rations.


Best Practices


Safety

Scripts are sandboxed. They:


Output

After running the script, the modified paragraph and player state are used as-is. This allows the script to:


Reference

See the separate [Embedded JavaScript Reference Guide] (coming soon) for:

📚 Use Cases

💡 Tips