ssod

Getting Started with JavaScript Scripting

This quick reference is for content authors new to scripting in Seven Spells of Destruction. It walks you through the basics of adding interactivity using JavaScript inside your paragraphs.

You do not need to be a programmer — just follow these patterns.


✨ What Can Scripts Do?

Scripts can:


🧾 Basic Format

Scripts go inside a <script> block on a single line, like this:

<script>print("Hello, adventurer!");</script>

Never place the closing </script> on its own line. Always inline:

✅ Good:

<script>print("Hello");</script>

❌ Bad:

<script>
print("Hello");
</script>

💰 Check Gold Example

<script>
if (player.gold >= 20) {
  player.gold -= 20;
  print("You hand over the coins.");
} else {
  print("You don’t have enough gold.");
}</script>

<script>
if (player.skill >= 6) {
  print("<AUTOLINK=123, Climb the cliff>");
}</script>

The link only appears if skill is 6 or higher.


🔒 Use Key/Value Storage

<script>
if (!get_key("has_met_lord")) {
  print("A cloaked man approaches.\n");
  set_key("has_met_lord", "true");
}</script>

This only prints once, even if the player comes back.


🧪 Use Tests

You can combine scripts with <test>:

<test luck><script>
if (paragraph.auto_test) {
  print("You narrowly escape!");
} else {
  print("You trip and fall!");
}</script>

🪧 Helpful Hints


🧵 Further Learning

You can do more complex scripting once you’re confident. See the full JavaScript Scripting Guide for details.

Happy scripting!