Skip to content

EN API UO WaitingForJournalText

LIHACHTETAN edited this page Nov 28, 2026 · 3 revisions

Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어

UO.WaitingForJournalText

Home · C# · IDE · UO API · A–Z · Examples · Languages

C# signatures

void UO.WaitingForJournalText(object? startTime, object? maxDelay, object? text);
void UO.WaitingForJournalText(object? startTime, object? maxDelay, object? text, object? equals);
void UO.WaitingForJournalText(object? startTime, object? maxDelay, object? text, object? equals, object? ignoreCase);
void UO.WaitingForJournalText(object? startTime, object? maxDelay, object? text, object? equals, object? ignoreCase, object? skillNameOrObjectId);

Expects text with additional comparison modes and optional skill/item launch.

Parameters

  • startTime — Mandatory label Now(), int milliseconds from the start of runtime. Lines with a label not less than startTime are checked; 0 includes entries with a zero label.
  • maxDelay — Mandatory maximum wait in milliseconds. 0 and negative values ​​mean one immediate pass rather than an infinite wait.
  • text — The searched substring or several alternatives via |, for example success|failed. Spaces at the edges of each alternative are removed, empty alternatives are skipped. This is plain text, not a regular expression. Use a non-empty template.
  • equals - Optional int: 0 (default) - substring; non-zero value - all text must match one alternative.
  • ignoreCase — Optional int: 0 (default) — case sensitive; non-zero - ignore.
  • skillNameOrObjectId - Optional skill by name, serial/hex string or resolvable object alias. The name of the skill is recognized first, otherwise the object is used. 0/empty line disables the action. The skill/item is triggered once before searching.

Return value

void - no return value, do not assign the call to a variable. When completed, GetFoundedTextIndex >= 0 means that the selected entry is still available; -1 - not found/record deleted. GetFoundedTextID shows the matching alternative only if the selection is successful.

Behavior

  • Search and Journal/GetJournal/LastJournalMessage save the text and fields of a single entry in the current script. New messages do not replace these fields. If a record is evicted from a limited journal, the retained fields remain, but LineIndex/GetFoundedTextIndex return -1. The next search or read selects another entry; an unsuccessful search, an invalid index, and clearing through this script reset the selection.
  • Poll with pause up to 25 ms; stopping the script interrupts it. An empty list of alternatives does not find text. For a bool result, use WaitJournalLine with its own parameters and the meaning of a zero timeout.

Standalone C# scripts

Each example can be saved as a separate file .csx and run in IDE. The UO object and wait functions provide the host of the current game session. Replace demo serial names, coordinates and addresses with your own.

Simple example

Run this code as a separate .csx file. Arguments appear directly in the call; replace demonstration names, serials and addresses with your own.

The command is a separate statement. The message before it marks the start of the call; it does not confirm a server action.

UO.Print("Calling UO.WaitingForJournalText");
UO.WaitingForJournalText(Now(), 2000, "notice");

1. Expect one substring - direct script

Parameters and execution flow:

  • startTime — mark before waiting; maxDelay=2000 ms; case-sensitive substring comparison.
  • The command does not return true/false: the selected entry is checked.
var started = Now();
UO.WaitingForJournalText(started, 2000, "notice");
if (Truth(UO.GetFoundedTextIndex() >= 0))
{
    UO.Print(UO.GetFoundedText());
}

bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;

2. Exact match without case - script function

Parameters and execution flow:

  • startTime=0; maxDelay=0 - one pass. equals=1 — all text, ignoreCase=1 — no case.
  • The alternative number 0 or 1 is displayed; a long line with additional words will not work.
return  RunScenario();
 object? RunScenario()
{
    UO.WaitingForJournalText(0, 0, "success|failed", 1, 1);
    if (Truth(UO.GetFoundedTextIndex() >= 0))
    {
        UO.Print(Convert.ToString(UO.GetFoundedTextID()));
    }

    return null;
}

bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;

3. Run the skill and expect the result - script class

Parameters and execution flow:

  • The sixth argument of Hiding runs the skill once. equals=0 — substring, ignoreCase=1 — no case.
  • The words hidden/failed are examples, replace them with the text of your server. Instead of a skill, you can specify serial or lastobject to use the item.
return  new ScriptScenario(UO, WaitAsync, Args, Cancellation, Checkpoint).RunScenario();
class ScriptScenario
{
    private readonly global::ClassicUO.CSharp.CSharpGameApi UO;
    private readonly Func<int, Task> WaitAsync;
    private readonly string[] Args;
    private readonly CancellationToken Cancellation;
    private readonly Action Checkpoint;
    public ScriptScenario(global::ClassicUO.CSharp.CSharpGameApi api, Func<int, Task> wait, string[] args, CancellationToken cancellation, Action checkpoint)
    {
        UO = api;
        WaitAsync = wait;
        Args = args;
        Cancellation = cancellation;
        Checkpoint = checkpoint;
    }

     public object? RunScenario()
    {
        var started = Now();
        UO.WaitingForJournalText(started, 3000, "hidden|failed", 0, 1, "Hiding");
        if (Truth(UO.GetFoundedTextIndex() >= 0))
        {
            UO.Print(UO.GetFoundedText());
        }

        return null;
    }

    bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;
    private int Now() => global::ClassicUO.CSharp.CSharpScriptContext.Current.Now();
}

Command implementation

C# is case sensitive. Use the exact UO name. Compare numeric flags with 0; use bool only where the signature returns bool.

UO.WaitingForJournalText(startTime, maxDelay, text) — UO.WaitingForJournalText(Integer,Integer,String)

Parameters: startTime (Integer), maxDelay (Integer), text (String)

Result: void / Unit.

During a call:

Internal implementation code; this is not a standalone script.

public void WaitingForJournalText(int startTime, int maxDelay, string text)

            => WaitingForJournalText(startTime, maxDelay, text, 0, 0, InjectionValue.Zero);

UO.WaitingForJournalText(startTime, maxDelay, text, equals) — UO.WaitingForJournalText(Integer,Integer,String,Integer)

Parameters: startTime (Integer), maxDelay (Integer), text (String), equals (Integer)

Result: void / Unit.

During a call:

Internal implementation code; this is not a standalone script.

public void WaitingForJournalText(int startTime, int maxDelay, string text, int equals)

            => WaitingForJournalText(startTime, maxDelay, text, equals, 0, InjectionValue.Zero);

UO.WaitingForJournalText(startTime, maxDelay, text, equals, ignoreCase) — UO.WaitingForJournalText(Integer,Integer,String,Integer,Integer)

Parameters: startTime (Integer), maxDelay (Integer), text (String), equals (Integer), ignoreCase (Integer)

Result: void / Unit.

During a call:

Internal implementation code; this is not a standalone script.

public void WaitingForJournalText(int startTime, int maxDelay, string text, int equals, int ignoreCase)

            => WaitingForJournalText(startTime, maxDelay, text, equals, ignoreCase, InjectionValue.Zero);

UO.WaitingForJournalText(startTime, maxDelay, text, equals, ignoreCase, skillNameOrObjectId) — UO.WaitingForJournalText(Integer,Integer,String,Integer,Integer,Any)

Parameters: startTime (Integer), maxDelay (Integer), text (String), equals (Integer), ignoreCase (Integer), skillNameOrObjectId (Any)

Result: void / Unit.

During a call:

Internal implementation code; this is not a standalone script.

public void WaitingForJournalText(int startTime, int maxDelay, string text, int equals, int ignoreCase, InjectionValue skillNameOrObjectId)

        {

            int timeout = Math.Max(0, maxDelay);

            bool exactMatch = equals != 0;

            bool caseInsensitive = ignoreCase != 0;

            string pattern = text ?? string.Empty;

            DateTime deadline = timeSource.Now.AddMilliseconds(timeout);

            SelectJournalEntry(null);



            TriggerWaitAction(skillNameOrObjectId);



            do

            {

                int journalCount = Math.Max(0, bridge.JournalEntryCount());

                for (int index = 0; index < journalCount; index++)

                {

                    JournalEntrySnapshot entry = ReadJournalSnapshot(index);

                    int lineTime = entry == null ? -1 : JournalEntryTime(entry.Timestamp);

                    if (lineTime < 0 || lineTime < startTime)

                        continue;



                    string journalText = entry.Text;

                    int matchId = FindJournalPatternId(journalText, pattern, exactMatch, caseInsensitive);

                    if (matchId >= 0)

                    {

                        SelectJournalEntry(entry);

                        foundedTextId = matchId;

                        return;

                    }

                }

                if (timeSource.Now >= deadline)

                    break;

                bridge.Wait(Math.Min(25, Math.Max(1, timeout)));

            }

            while (true);

        }

Clone this wiki locally