Learn SugarAdvanced

Use Lore in Sugar

Read Lore balances, charge the person using a creation, transfer Lore, and reward players through a verified App.

An Item action or Boop can read and move Lore. These related functions live in the Lore namespace, so each name begins with Lore::. When someone would spend Lore, JOI shows exactly what will happen and asks them to confirm.

Participant 1 is always the person using the creation.

Read a balance

Lore::get()

This returns participant 1’s Lore balance.

Give it a participant number to read someone else’s balance:

Lore::get(2)

If an earlier line in the same program charged or transferred Lore, Lore::get() includes that planned change.

Use a selected Joi instead of a participant number

Lore::get(), Lore::transfer(), and Lore::earn() also accept a Joi value. This is useful when the recipient comes from an input and is not one of the creation’s numbered participants.

var recipient -> "Recipient": Joi = Chat::partner() with {
  input: true,
  required: true,
};

text {
  let balance = Lore::get(recipient);
  "{recipient.name} currently has {balance} Lore."
}

In a direct chat, Chat::partner() begins with the other chat partner selected. In a group chat the input begins empty, and the person using the creation chooses the recipient.

Participant numbers keep their existing meaning. Passing 2 still means participant 2; passing recipient means the JOI stored in that variable.

Charge the person using the creation

Lore::charge(25);

This charges participant 1 and pays 25 Lore to the Item or Boop creator. The function returns the amount charged.

If the creator and participant 1 use the same wallet, the Lore is burned instead.

Transfer Lore to another participant

Lore::transfer(10, 2);

This sends 10 Lore from participant 1 to participant 2. The recipient cannot be participant 1 or use the same wallet.

Pass a selected Joi the same way:

Lore::transfer(10, recipient);

Reward a participant

let awarded = Lore::earn(20);

Lore::earn() rewards participant 1 by default. Pass another participant number as the second argument:

let awarded = Lore::earn(20, 2);

The second argument may also be a selected Joi:

let awarded = Lore::earn(20, recipient);

Rewards work only when the Item or Boop is linked to an App verified by JOI. They count toward each account’s daily Lore earning limit.

The function returns the amount actually awarded. It may be smaller than the amount requested, or 0 when the daily limit has been reached.

action completeChallenge -> "Complete challenge" {
  let awarded = Lore::earn(20);

  text if awarded > 0 {
    "@1 earned {awarded} Lore!"
  } else {
    "@1 completed the challenge, but reached today's Lore reward limit."
  }
}

Use the returned amount in your message so the result always tells the truth.

What happens when confirmation is needed

JOI places Lore costs, paid Item changes, Item transformations, and inventory Item uses on one confirmation screen.

If the person cancels, none of those changes happen and the result is not sent. If they confirm, JOI checks the balance and Items again before applying anything.

Sandbox Mode shows the same planned changes without moving real Lore or changing real Items.