Viv JavaScript Runtime - v0.10.2
    Preparing search index...

    Function selectAction

    • Invokes the Viv action manager to carry out action selection for the given initiator, and then returns the entity ID for the action that is performed as a result, if any, else null.

      Important: Calls to this function must be resolved sequentially, not concurrently (e.g., via Promise.all). The runtime assumes that each action is fully performed before the next selectAction call begins, because actions mutate shared simulation state that subsequent calls depend on. Concurrent calls could produce situations like a character performing a physical action with another character who has already left that location. In summary: action selection cannot be parallelized in Viv, at least at this time.

      Parameters

      Returns Promise<SelectActionResult>

      // Correct: sequential await for each character
      for (const characterID of allCharacterIDs) {
      await selectAction({ initiatorID: characterID });
      }

      VivNotInitializedError If Viv has not been initialized.

      VivInterpreterError If the Viv interpreter encounters an issue in the course of action targeting.

      VivValidationError If the supplied args do not conform to the expected schema.

      VivValidationError If initiatorID is not an entity ID for a character.