Skip to content

Classes

Journal

Methods

clear()
ts
clear(): void

Clears/forgets the journal history. This is useful if you don't want to process older journal entries.

Example
ts
player.say('Hello there');
journal.waitForText('Hello there'); // This will succeed quickly as the text was just added
journal.clear();
journal.waitForText('Hello there'); // this will time out, as the string is now empty.

containsText()
ts
containsText(text: string, author?: string): boolean

Checks for the existence of text in the journal

Parameters
ParameterTypeDescription
textstring
author?string
Returns

boolean

true/false if the text exists in the journal.


waitForText()
ts
waitForText(
   text: string,
   author?: string,
   timeout?: number): boolean

Waits for the text to appear in the journal.

  • Use clear() to clear the journal text.
Parameters
ParameterTypeDescription
textstring
author?string
timeout?number
Returns

boolean

true/false if the text was found.

Example
ts
const healthBefore = player.hits;

journal.clear();
player.useType(0xe21);
target.waitTargetSelf();

if (journal.waitForText('You healed', 'System', 8000)) {
  client.headMsg(`Bandaged +${player.hits - healthBefore}`, player, 66);
}

waitForTextAny()
ts
waitForTextAny(
   text: string[],
   author?: string,
   timeout?: number): null | string

Waits for ANY string in an array of strings to be found in the Journal, or for the timeout to be hit. Returns the first string to be found or null if the timeout was reached.

This method is useful if you're waiting for any one of a list of strings to appear. If you want all the strings to appear you should use waitForTextEvery

Parameters
ParameterTypeDescription
textstring[]
author?string
timeout?number
Returns

null | string

The string if it was found, or null if not.

Example
typescript
const waitMessage = 'You must wait';
const failMessage = 'You cannot focus';
const successMessage = 'You enter a meditative trance.';

journal.clear();
const response = journal.waitForTextAny([waitMessage, failMessage, successMessage]);

switch (response) {
  case waitMessage: {
    // sleep
    break;
  }
  case failMessage: {
    // retry
    break;
  }
  case successMessage: {
    // loop
    break;
  }
}

waitForTextEvery()
ts
waitForTextEvery(
   text: string[],
   author?: string,
   timeout?: number): string[]

Waits for EVERY string in an array of strings to be found in the Journal, or for the timeout to be hit. Returns all the strings that were found, may be less than the input if the timeout was hit.

This method is useful if you're waiting for several strings to all appear. If you want to wait for any string in the input array use waitForTextAny

Parameters
ParameterTypeDescription
textstring[]
author?string
timeout?number
Returns

string[]

All the strings that were found within the timeout, or an empty array if none were found.

Example
ts
const waitMessage = 'You must wait';
const failMessage = 'You cannot focus';
const successMessage = 'You enter a meditative trance.';

journal.clear();
const response = journal.waitForTextEvery([waitMessage, failMessage, successMessage]);

if (response.includes(successMessage)) {
  client.headMsg(`Meditating...`, player, 66);
}