Repository navigation
ZH TW API UO WaitingForJournalText
Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
家 · C# · IDE · UO API · A–Z · 範例 · Languages
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和負值意味著立即通過而不是無限等待。 -
text— 透過 | 搜尋到的子字串或多個替代項,例如 success|failed。每個替代項邊緣的空格將被刪除,空替代項將被跳過。這是純文本,而不是正規表示式。使用非空模板。 -
equals- 可選int:0(預設)- 子字串;非零值 - 所有文字必須符合一種替代文字。 -
ignoreCase- 可選int:0(預設)- 區分大小寫;非零 - 忽略。 -
skillNameOrObjectId- 依名稱、serial/十六進位字串或可解析物件別名的可選技能。首先識別技能名稱,否則使用物件。 0/空行禁用該操作。技能/物品在搜尋前觸發一次。
void - 無回傳值,不要將呼叫指派給變數。完成後,GetFoundedTextIndex >= 0 表示所選條目仍然可用; -1 - 未找到/記錄已刪除。僅當選擇成功時,GetFoundedTextID才會顯示匹配的選項。
- 搜尋並Journal/GetJournal/LastJournalMessage儲存目前腳本中單一條目的文字和欄位。新訊息不會取代這些欄位。如果一筆記錄被從有限日誌中逐出,則保留的欄位仍然存在,但LineIndex/GetFoundedTextIndex返回-1。下一次搜尋或讀取會選擇另一個條目;不成功的搜尋、無效的索引以及透過此腳本清除都會重設選擇。
- 輪詢暫停時間長達 25 毫秒;停止腳本會中斷它。空的替代列表找不到文字。對於bool結果,使用WaitJournalLine及其自己的參數和零超時的意義。
每個範例都可以儲存為單獨的檔案.csx並在IDE中運行。 UO物件和等待函數提供當前遊戲會話的主機。將演示 serial 名稱、座標和地址替換為您自己的。
將這段程式碼存為獨立的 .csx 檔案執行。參數直接出現在呼叫中;請將範例名稱、serial 和網址替換成自己的值。
指令是獨立的陳述式。前面的訊息表示呼叫開始,並非伺服器已完成動作的確認。
UO.Print("Calling UO.WaitingForJournalText");
UO.WaitingForJournalText(Now(), 2000, "notice");參數與執行流程:
- 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;參數與執行流程:
- startTime=0; maxDelay=0 - 一次通過。 equals=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;參數與執行流程:
- 隱藏的第六個參數運行該技能一次。 equals=0 — 子字串,ignoreCase=1 — 無大小寫。
- 隱藏/失敗一詞是範例,請將其替換為您伺服器的文字。您可以指定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.
呼叫時:
-
InjectionScript.Runtime.InjectionApiUO.WaitingForJournalText. -
InjectionScript.Runtime.InjectionApiUO.WaitingForJournalText:WaitingForJournalText(startTime, maxDelay, text, 0, 0, InjectionValue.Zero).
內部實作程式碼,不能作為獨立腳本執行。
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.
呼叫時:
-
InjectionScript.Runtime.InjectionApiUO.WaitingForJournalText. -
InjectionScript.Runtime.InjectionApiUO.WaitingForJournalText:WaitingForJournalText(startTime, maxDelay, text, equals, 0, InjectionValue.Zero).
內部實作程式碼,不能作為獨立腳本執行。
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.
呼叫時:
-
InjectionScript.Runtime.InjectionApiUO.WaitingForJournalText. -
InjectionScript.Runtime.InjectionApiUO.WaitingForJournalText:WaitingForJournalText(startTime, maxDelay, text, equals, ignoreCase, InjectionValue.Zero).
內部實作程式碼,不能作為獨立腳本執行。
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.
呼叫時:
-
InjectionScript.Runtime.InjectionApiUO.WaitingForJournalText. -
InjectionScript.Runtime.InjectionApiUO.SelectJournalEntry:SelectJournalEntry(null). -
InjectionScript.Runtime.InjectionApiUO.TriggerWaitAction:TriggerWaitAction(skillNameOrObjectId). -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.JournalEntryCount:bridge.JournalEntryCount(). -
InjectionScript.Runtime.InjectionApiUO.ReadJournalSnapshot:ReadJournalSnapshot(index). -
InjectionScript.Runtime.InjectionApiUO.JournalEntryTime:JournalEntryTime(entry.Timestamp). -
InjectionScript.Runtime.InjectionApiUO.FindJournalPatternId:FindJournalPatternId(journalText, pattern, exactMatch, caseInsensitive). -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.Wait:bridge.Wait(Math.Min(25, Math.Max(1, timeout))).
內部實作程式碼,不能作為獨立腳本執行。
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);
}ClassicUO — Bad Newbie & C# Scripts IDE