Skip to content

JA API UO WaitingForJournalText

LIHACHTETAN edited this page Nov 28, 2026 · 3 revisions

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

UO.WaitingForJournalText

家 · C# · IDE · UO API · A–Z · 例 · Languages

C# のシグネチャ

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);

追加の比較モードとオプションのスキル/アイテムの起動を含むテキストが期待されます。

引数

  • startTime — 必須ラベル Now()、ランタイムの開始からの int ミリ秒。 startTime 以上のラベルが付いた行がチェックされます。 0 には、ラベルがゼロのエントリが含まれます。
  • maxDelay — ミリ秒単位の必須の最大待機時間。 0 と負の値は、無限待機ではなく 1 回の即時パスを意味します。
  • text — 検索された部分文字列または | によるいくつかの代替 (例: success|failed)。各選択肢の端にあるスペースは削除され、空の選択肢はスキップされます。これは正規表現ではなくプレーンテキストです。空ではないテンプレートを使用してください。
  • equals - オプションの int: 0 (デフォルト) - 部分文字列。ゼロ以外の値 - すべてのテキストは 1 つの選択肢と一致する必要があります。
  • ignoreCase — オプションの int: 0 (デフォルト) — 大文字と小文字を区別します。ゼロ以外 - 無視します。
  • skillNameOrObjectId - 名前によるオプションのスキル、serial/16 進文字列または解決可能なオブジェクトのエイリアス。スキルの名前が最初に認識され、それ以外の場合はオブジェクトが使用されます。 0/空行はアクションを無効にします。スキル/アイテムは検索前に一度発動します。

戻り値

void - 戻り値なし。呼び出しを変数に割り当てません。完了すると、GetFoundedTextIndex >= 0 は、選択したエントリがまだ使用可能であることを意味します。 -1 - 見つからない/レコードが削除されました。 GetFoundedTextID は、選択が成功した場合にのみ、一致する代替案を表示します。

動作

  • Search and Journal/GetJournal/LastJournalMessage は、現在のスクリプト内の 1 つのエントリのテキストとフィールドを保存します。新しいメッセージはこれらのフィールドを置き換えません。レコードが制限付きジャーナルから削除された場合、保持されたフィールドは残りますが、LineIndex/GetFoundedTextIndex は -1 を返します。次の検索または読み取りでは、別のエントリが選択されます。検索の失敗、インデックスの無効、およびこのスクリプトによるクリアにより、選択がリセットされます。
  • 最大 25 ミリ秒まで一時停止してポーリングします。スクリプトを停止すると中断されます。空の代替リストではテキストが見つかりません。 bool の結果には、独自のパラメーターとゼロ タイムアウトの意味を持つ WaitJournalLine を使用します。

単独で実行できる C# スクリプト

各サンプルは個別のファイル .csx として保存し、IDE で実行できます。 UO オブジェクトと待機関数は、現在のゲーム セッションのホストを提供します。デモの serial の名前、座標、アドレスを自分のものに置き換えます。

簡単な例

このコードを独立した .csx ファイルとして実行します。引数は呼び出しに直接記載されています。例の名前、serial、アドレスを自分の値に置き換えてください。

コマンドは独立した文です。直前のメッセージは呼び出しの開始を示し、サーバーの動作完了を確認するものではありません。

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

1。 1 つの部分文字列が必要です - 直接スクリプト

引数と実行の流れ:

  • startTime — 待機する前にマークを付けます。 maxDelay=2000 ミリ秒;大文字と小文字を区別する部分文字列の比較。
  • このコマンドは true/false を返しません。選択されたエントリがチェックされます。
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。大文字と小文字を区別しない完全一致 - スクリプト関数

引数と実行の流れ:

  • startTime=0; maxDelay=0 - 1 パス。等しい=1 — すべてのテキスト、ignoreCase=1 — 大文字と小文字は区別されません。
  • 代替番号 0 または 1 が表示されます。追加の単語を含む長い行は機能しません。
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。スキルを実行して結果を期待する - スクリプトクラス

引数と実行の流れ:

  • Hiding の 6 番目の引数はスキルを 1 回実行します。等しい=0 — 部分文字列、ignoreCase=1 — 大文字と小文字は区別されません。
  • 「hidden/failed」という単語は例です。サーバーのテキストに置き換えてください。スキルの代わりに、serial または lastobject を指定してアイテムを使用することもできます。
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();
}

コマンドの実装

C# は大文字と小文字を区別します。正確な UO 名を使用してください。数値フラグは 0 と比較し、戻り値が bool の場合だけ bool を使います。

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

引数: startTime (Integer), maxDelay (Integer), text (String)

結果: void / Unit.

呼び出し時:

内部実装のコードです。単独のスクリプトとして実行できません。

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)

引数: startTime (Integer), maxDelay (Integer), text (String), equals (Integer)

結果: void / Unit.

呼び出し時:

内部実装のコードです。単独のスクリプトとして実行できません。

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)

引数: startTime (Integer), maxDelay (Integer), text (String), equals (Integer), ignoreCase (Integer)

結果: void / Unit.

呼び出し時:

内部実装のコードです。単独のスクリプトとして実行できません。

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)

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

結果: void / Unit.

呼び出し時:

内部実装のコードです。単独のスクリプトとして実行できません。

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