<script> TagThe <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.
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.
<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.
<script> when tag-based tools (like <if>, <mod>, <set>) cannot do what you need.Scripts are sandboxed. They:
After running the script, the modified paragraph and player state are used as-is. This allows the script to:
print(...) to append output.See the separate [Embedded JavaScript Reference Guide] (coming soon) for:
player and paragraph<if> tags</script>.