ZH TW UO Topic journal Part 2 - LIHACHTETAN/ClassicUO-Bad-Newbie-CSharp-Scripts-IDE GitHub Wiki
Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
家 · C# · IDE · UO API · A–Z · 範例 · Languages
Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
dynamic UO.WaitJournalLine(object? startTime, object? str, object? maxWaitTimeMS);等待本地日誌中的合適訊息。
-
startTime- 所需的開始標籤:int Now()(以毫秒為單位),0 - 執行開始。也接受從 LineTime 開始的 double OLE 日期(現代日期 20000…100000 天)。整個20000…100000始終是毫秒,而不是日期。不要透露條目的年齡。 -
str— 透過 | 搜尋到的子字串或多個替代項,例如 success|failed。每個替代項邊緣的空格將被刪除,空替代項將被跳過。這是純文本,而不是正規表示式。使用非空模板。不區分大小寫的搜尋。 -
maxWaitTimeMS— 強制 int 超時(以毫秒為單位);正值限制等待,0表示無限制等待。負值僅限於0。停止腳本會中斷等待。
bool - true(如果找到文字),false(如果存在未匹配的正超時)。這不是指數或數量。布林值也可以在腳本中顯示為1/0。
該命令的結果是一個數字標誌: 1 表示滿足條件, 0 - 未實現。後 var 結果=命令(...)檢查是否(結果!= 0) 或 if (結果 == 0)。儲存一次呼叫的結果:重複呼叫可以再次執行該操作或讀取已經變更的狀態。
- 搜尋並Journal/GetJournal/LastJournalMessage儲存目前腳本中單一條目的文字和欄位。新訊息不會取代這些欄位。如果一筆記錄被從有限日誌中逐出,則保留的欄位仍然存在,但LineIndex/GetFoundedTextIndex返回-1。下一次搜尋或讀取會選擇另一個條目;不成功的搜尋、無效的索引以及透過此腳本清除都會重設選擇。
- 呼叫時初始邊界是固定的,輪詢大約每25 ms 發生一次。預期本身不會觸發技能或物品。 wait後的LineCount指的是最後一次搜尋。
- 若要僅過濾系統字串,請使用WaitJournalLineSystem。
每個範例都可以儲存為單獨的檔案.csx並在IDE中運行。 UO物件和等待函數提供當前遊戲會話的主機。將演示 serial 名稱、座標和地址替換為您自己的。
將這段程式碼存為獨立的 .csx 檔案執行。參數直接出現在呼叫中;請將範例名稱、serial 和網址替換成自己的值。
將一次呼叫的結果輸出到日誌。數值不會轉換成 bool;若結果是陣列,則顯示元素數量。
object? result = UO.WaitJournalLine(Now(), "success|failed", 3000);
UO.Print(result is Array values ? "Count: " + values.Length : Convert.ToString(result));參數與執行流程:
- 開始 - 等待之前的限制。 3000 — 最长等待时间(以毫秒为单位)。此模式包含兩個結果。
- false — 在此期間找不到文字;伺服器可以使用不同的措詞。
var started = Now();
var found = UO.WaitJournalLine(started, "success|failed", 3000);
if (Truth(found))
{
UO.Print(UO.GetFoundedText());
}
else
{
UO.Print("Timeout");
}
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;參數與執行流程:
- 0 - 運行時開始,不停用逾時。 100 - 超時。
- 找到的行可能在呼叫之前已經存在於日誌中。
return RunScenario();
object? RunScenario()
{
if (Truth(UO.WaitJournalLine(0, "notice", 100)))
{
var author = UO.LineName();
UO.Print(author);
}
return null;
}
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;參數與執行流程:
- stamp 保存 double LineTime 而不使用 Convert.ToInt32/Convert.ToString:這是日曆日期,而不是 Now()。 1500 — 等待毫秒數。
- 邊框已開啟。如果所選字串包含回應,則它本身可能是合適的。
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 text = UO.Journal(0);
if (Truth(UO.LineIndex() >= 0))
{
var stamp = UO.LineTime();
var found = UO.WaitJournalLine(stamp, "response", 1500);
UO.Print(Convert.ToString(found));
}
return null;
}
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;
}C# 區分大小寫。請使用正確的 UO 名稱。數值旗標應與 0 比較;只有回傳型別為 bool 時才使用 bool。
參數: startTime (Any), str (Any), maxWaitTimeMS (Any)
結果: dynamic / Any.
呼叫時:
-
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility. -
InjectionScript.Runtime.InjectionApiUO.WaitJournalLine:WaitJournalLine(arguments, false).
內部實作程式碼,不能作為獨立腳本執行。
case "waitjournalline": return WaitJournalLine(arguments, false);Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
dynamic UO.WaitJournalLineSystem(object? startTime, object? str, object? maxWaitTimeMS);等待帶有作者係統名稱的合適訊息。
-
startTime- 所需的開始標籤:int Now()(以毫秒為單位),0 - 執行開始。也接受從 LineTime 開始的 double OLE 日期(現代日期 20000…100000 天)。整個20000…100000始終是毫秒,而不是日期。不要透露條目的年齡。 -
str— 透過 | 搜尋到的子字串或多個替代項,例如 success|failed。每個替代項邊緣的空格將被刪除,空替代項將被跳過。這是純文本,而不是正規表示式。使用非空模板。不區分大小寫的搜尋。 -
maxWaitTimeMS— 強制 int 超時(以毫秒為單位);正值限制等待,0表示無限制等待。負值僅限於0。停止腳本會中斷等待。
bool - true(如果找到文字),false(如果存在未匹配的正超時)。這不是指數或數量。布林值也可以在腳本中顯示為1/0。
該命令的結果是一個數字標誌: 1 表示滿足條件, 0 - 未實現。後 var 結果=命令(...)檢查是否(結果!= 0) 或 if (結果 == 0)。儲存一次呼叫的結果:重複呼叫可以再次執行該操作或讀取已經變更的狀態。
- 搜尋並Journal/GetJournal/LastJournalMessage儲存目前腳本中單一條目的文字和欄位。新訊息不會取代這些欄位。如果一筆記錄被從有限日誌中逐出,則保留的欄位仍然存在,但LineIndex/GetFoundedTextIndex返回-1。下一次搜尋或讀取會選擇另一個條目;不成功的搜尋、無效的索引以及透過此腳本清除都會重設選擇。
- 呼叫時初始邊界是固定的,輪詢大約每25 ms 發生一次。預期本身不會觸發技能或物品。 wait後的LineCount指的是最後一次搜尋。
- 在此改編中,系統由作者姓名標識,不區分大小寫;此指令適用於普通日誌ClassicUO。
每個範例都可以儲存為單獨的檔案.csx並在IDE中運行。 UO物件和等待函數提供當前遊戲會話的主機。將演示 serial 名稱、座標和地址替換為您自己的。
將這段程式碼存為獨立的 .csx 檔案執行。參數直接出現在呼叫中;請將範例名稱、serial 和網址替換成自己的值。
將一次呼叫的結果輸出到日誌。數值不會轉換成 bool;若結果是陣列,則顯示元素數量。
object? result = UO.WaitJournalLineSystem(Now(), "success|failed", 3000);
UO.Print(result is Array values ? "Count: " + values.Length : Convert.ToString(result));參數與執行流程:
- 開始 - 等待之前的限制。 3000 — 最长等待时间(以毫秒为单位)。此模式包含兩個結果。
- false — 在此期間找不到文字;伺服器可以使用不同的措詞。
var started = Now();
var found = UO.WaitJournalLineSystem(started, "success|failed", 3000);
if (Truth(found))
{
UO.Print(UO.GetFoundedText());
}
else
{
UO.Print("Timeout");
}
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;參數與執行流程:
- 0 - 運行時開始,不停用逾時。 100 - 超時。
- 找到的行可能在呼叫之前已經存在於日誌中。
return RunScenario();
object? RunScenario()
{
if (Truth(UO.WaitJournalLineSystem(0, "notice", 100)))
{
var author = UO.LineName();
UO.Print(author);
}
return null;
}
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;參數與執行流程:
- stamp 保存 double LineTime 而不使用 Convert.ToInt32/Convert.ToString:這是日曆日期,而不是 Now()。 1500 — 等待毫秒數。
- 邊框已開啟。如果所選字串包含回應,則它本身可能是合適的。
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 text = UO.Journal(0);
if (Truth(UO.LineIndex() >= 0))
{
var stamp = UO.LineTime();
var found = UO.WaitJournalLineSystem(stamp, "response", 1500);
UO.Print(Convert.ToString(found));
}
return null;
}
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;
}C# 區分大小寫。請使用正確的 UO 名稱。數值旗標應與 0 比較;只有回傳型別為 bool 時才使用 bool。
參數: startTime (Any), str (Any), maxWaitTimeMS (Any)
結果: dynamic / Any.
呼叫時:
-
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility. -
InjectionScript.Runtime.InjectionApiUO.WaitJournalLine:WaitJournalLine(arguments, true).
內部實作程式碼,不能作為獨立腳本執行。
case "waitjournallinesystem": return WaitJournalLine(arguments, true);Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
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);
}