Skip to the article
NeuraCoreUser Wiki
โ† Back to this chapter
Embedded Python

Reading the answer, and reading a refusal

Every call answers. Understanding the two shapes an answer can take is most of what makes a script reliable.

A result is data

Almost every action answers with a dictionary or a list of them. You can print it while you are learning what is in it, and then read the one field you actually want.

Nothing is hidden. If you are not sure what an action gives back, print it once and look.

A refusal is an exception

A refused action does not answer "no". It raises PermissionError, which stops the script where it stands unless you catch it.

try:
    avatar.pay_linden_dollars("00000000-0000-0000-0000-000000000000", "Someone Resident", 10)
except PermissionError as refusal:
    print("refused:", refusal)
  • try runs the risky line, and except catches the refusal instead of letting it end the script.
  • Printing the refusal is worth it: the message says which action and why.
  • This is the same exception whether the action was switched off in Action Permissions, or refused because your licence does not carry it.

Three reasons a call does not do what you expected

They look similar in the output and have completely different fixes.

  • Refused. PermissionError, and the message names the action. Fix it in Automation, Action Permissions, or by upgrading the licence the message points at.
  • Nothing to answer with. The call succeeds and the result is empty or zero, because the avatar is offline, or the region has not sent the information yet.
  • Nothing happened, and no error. Usually the avatar was already in the state you asked for. Execution History shows a no-change result for exactly this case.

Where to look afterwards

Automation, Execution History lists every call with its caller, its result and the time. A script's calls are marked as coming from Python.

The Errors tab collects what NeuraCore refused, dropped or gave up on, in plain words, with one row per problem and a count. A script can read the same list.

report = avatar.get_errors(limit=20)

for problem in report["errors"]:
    print(problem["area"], problem["operation"], problem["occurrences"])