ExamplesAdvanced

Apps and Automations

Adapt patterns for App-wide progress, player energy, daily challenges, scheduled recovery, and reusable App resources.

Daily challenge

In App Main:

app var $dailyChallenge: choice = "TRUTH" with {
  choices: ("TRUTH" -> "Truth", "DARE" -> "Dare", "DUEL" -> "Duel"),
};

In Automations, add a daily App Automation:

app automation chooseDailyChallenge {
  config {
    schedule: daily("09:00"),
  }

  $dailyChallenge = Rand::pick("TRUTH", "DARE", "DUEL");
}

In a linked Boop’s Code module:

text "@1 receives today's {$dailyChallenge} challenge.";

Player energy recovery

In App Main:

player var $energy = 10;
player var $maxEnergy = 10;

In Automations:

player automation restoreEnergy {
  config {
    schedule: hourly(0),
  }

  $energy = clamp($energy + 5, 0, $maxEnergy);
}

The Automation runs separately for every JOI registered with the App. It may change $energy, but it cannot change variables in the App scope.

App-wide jackpot

In App Main:

app var $jackpot = 100;
player var $plays = 0;

In a linked Boop’s Code module:

text {
  $jackpot += 5;
  $plays++;
  show variables $jackpot, $plays;
  "@1 adds 5 points to the shared jackpot."
}

Everyone sees the same jackpot. Each JOI has a separate play count.

Item variables changing over time

In each linked non-stackable Item’s Code module, declare mem var durability = 100;.

Then add this Host Automation in the App’s Automations tab:

host automation lowerDurability {
  config {
    schedule: daily("00:00"),
  }

  if durability > 0 {
    durability--;
  }
}

The Automation changes each linked Item separately. A Host Automation may also change hosted Memory variables, but not variables in the Player or App scope.

Use a reusable App embed

An App Embed Template may combine App variables with information from the Item or Boop that shows it. The HOST constant represents that creation:

embed eventStatus -> "Event Status" {
  description: format("{HOST.name} is participating. {$eventProgress} of {$eventGoal}"),
  fields: (
    $personalContribution -> "Your contribution",
  ),
}

Different linked creations can provide their own image for the same template media name. JOI uses that local image instead of the App’s default.

Build a complete shared event