KO 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 Β· μ Β· μΈμ΄
Π£ΠΊΡΠ°ΡΠ½ΡΡΠΊΠ° Β· Π ΡΡΡΠΊΠΈΠΉ Β· 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β |λ₯Ό ν΅ν΄ κ²μλ νμ λ¬Έμμ΄ λλ μ¬λ¬ λμ(μ: μ±κ³΅|μ€ν¨). κ° λμμ κ°μ₯μ리μ μλ 곡백μ μ κ±°λκ³ , λΉ λμμ 건λλλλ€. μ΄λ μ κ·μμ΄ μλ μΌλ° ν μ€νΈμ λλ€. λΉμ΄ μμ§ μμ ν νλ¦Ώμ μ¬μ©νμΈμ. λμλ¬Έμλ₯Ό ꡬλΆνμ§ μλ κ²μ. -
maxWaitTimeMSβ νμ int μκ° μ΄κ³Ό(λ°λ¦¬μ΄). μμ κ°μ λκΈ°λ₯Ό μ ννκ³ , 0λ μ ν μλ λκΈ°λ₯Ό μλ―Έν©λλ€. μμ κ°μ 0λ‘ μ νλ©λλ€. μ€ν¬λ¦½νΈλ₯Ό μ€μ§νλ©΄ λκΈ°κ° μ€λ¨λ©λλ€.
bool - true ν μ€νΈκ° λ°κ²¬λλ©΄ false μΌμΉνμ§ μκ³ κΈμ μ μΈ μκ° μ΄κ³Όκ° λ°μν κ²½μ°μ λλ€. μ΄κ²μ μ§μλ μμ΄ μλλλ€. λΆλ¦¬μΈ κ°μ μ€ν¬λ¦½νΈμμ 1/0λ‘ νμν μλ μμ΅λλ€.
λͺ λ Ήμ κ²°κ³Όλ μ«μ νλκ·Έμ λλ€. 1λ μΆ©μ‘±λ 쑰건μ μλ―Ένκ³ , 0λ μΆ©μ‘±λμ§ μμ 쑰건μ μλ―Έν©λλ€. var result = command(...) νμ (κ²°κ³Ό != 0) λλ (κ²°κ³Ό == 0)μΈμ§ νμΈνμΈμ. ν λ²μ νΈμΆ κ²°κ³Όλ₯Ό μ μ₯ν©λλ€. λ°λ³΅λ νΈμΆμ ν΅ν΄ ν΄λΉ μμ μ λ€μ μννκ±°λ μ΄λ―Έ λ³κ²½λ μνλ₯Ό μ½μ μ μμ΅λλ€.
- κ²μ λ° Journal/GetJournal/LastJournalMessageλ νμ¬ μ€ν¬λ¦½νΈμμ λ¨μΌ νλͺ©μ ν μ€νΈμ νλλ₯Ό μ μ₯ν©λλ€. μ λ©μμ§λ μ΄ νλλ₯Ό λ체νμ§ μμ΅λλ€. μ νλ μ λμμ λ μ½λκ° μ κ±°λλ©΄ μ μ§λ νλλ μ μ§λμ§λ§ LineIndex/GetFoundedTextIndexλ -1λ₯Ό λ°νν©λλ€. λ€μ κ²μ λλ μ½κΈ°μμλ λ€λ₯Έ νλͺ©μ΄ μ νλ©λλ€. μ€ν¨ν κ²μ, μλͺ»λ μμΈ λ° μ΄ μ€ν¬λ¦½νΈλ₯Ό ν΅ν μμ λ μ νμ μ¬μ€μ ν©λλ€.
- νΈμΆ μ μ΄κΈ° κ²½κ³λ κ³ μ λλ©° ν΄λ§μ λλ΅ 25msλ§λ€ λ°μν©λλ€. κΈ°λ μμ²΄κ° μ€ν¬μ΄λ μμ΄ν μ λ°λμν€μ§λ μμ΅λλ€. 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;λ§€κ°λ³μμ μ€ν νλ¦:
- μ€ν¬νλ Convert.ToInt32/Convert.ToString μμ΄ double LineTimeλ₯Ό μ μ₯ν©λλ€. μ΄λ 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β |λ₯Ό ν΅ν΄ κ²μλ νμ λ¬Έμμ΄ λλ μ¬λ¬ λμ(μ: μ±κ³΅|μ€ν¨). κ° λμμ κ°μ₯μ리μ μλ 곡백μ μ κ±°λκ³ , λΉ λμμ 건λλλλ€. μ΄λ μ κ·μμ΄ μλ μΌλ° ν μ€νΈμ λλ€. λΉμ΄ μμ§ μμ ν νλ¦Ώμ μ¬μ©νμΈμ. λμλ¬Έμλ₯Ό ꡬλΆνμ§ μλ κ²μ. -
maxWaitTimeMSβ νμ int μκ° μ΄κ³Ό(λ°λ¦¬μ΄). μμ κ°μ λκΈ°λ₯Ό μ ννκ³ , 0λ μ ν μλ λκΈ°λ₯Ό μλ―Έν©λλ€. μμ κ°μ 0λ‘ μ νλ©λλ€. μ€ν¬λ¦½νΈλ₯Ό μ€μ§νλ©΄ λκΈ°κ° μ€λ¨λ©λλ€.
bool - true ν μ€νΈκ° λ°κ²¬λλ©΄ false μΌμΉνμ§ μκ³ κΈμ μ μΈ μκ° μ΄κ³Όκ° λ°μν κ²½μ°μ λλ€. μ΄κ²μ μ§μλ μμ΄ μλλλ€. λΆλ¦¬μΈ κ°μ μ€ν¬λ¦½νΈμμ 1/0λ‘ νμν μλ μμ΅λλ€.
λͺ λ Ήμ κ²°κ³Όλ μ«μ νλκ·Έμ λλ€. 1λ μΆ©μ‘±λ 쑰건μ μλ―Ένκ³ , 0λ μΆ©μ‘±λμ§ μμ 쑰건μ μλ―Έν©λλ€. var result = command(...) νμ (κ²°κ³Ό != 0) λλ (κ²°κ³Ό == 0)μΈμ§ νμΈνμΈμ. ν λ²μ νΈμΆ κ²°κ³Όλ₯Ό μ μ₯ν©λλ€. λ°λ³΅λ νΈμΆμ ν΅ν΄ ν΄λΉ μμ μ λ€μ μννκ±°λ μ΄λ―Έ λ³κ²½λ μνλ₯Ό μ½μ μ μμ΅λλ€.
- κ²μ λ° Journal/GetJournal/LastJournalMessageλ νμ¬ μ€ν¬λ¦½νΈμμ λ¨μΌ νλͺ©μ ν μ€νΈμ νλλ₯Ό μ μ₯ν©λλ€. μ λ©μμ§λ μ΄ νλλ₯Ό λ체νμ§ μμ΅λλ€. μ νλ μ λμμ λ μ½λκ° μ κ±°λλ©΄ μ μ§λ νλλ μ μ§λμ§λ§ LineIndex/GetFoundedTextIndexλ -1λ₯Ό λ°νν©λλ€. λ€μ κ²μ λλ μ½κΈ°μμλ λ€λ₯Έ νλͺ©μ΄ μ νλ©λλ€. μ€ν¨ν κ²μ, μλͺ»λ μμΈ λ° μ΄ μ€ν¬λ¦½νΈλ₯Ό ν΅ν μμ λ μ νμ μ¬μ€μ ν©λλ€.
- νΈμΆ μ μ΄κΈ° κ²½κ³λ κ³ μ λλ©° ν΄λ§μ λλ΅ 25msλ§λ€ λ°μν©λλ€. κΈ°λ μμ²΄κ° μ€ν¬μ΄λ μμ΄ν μ λ°λμν€μ§λ μμ΅λλ€. 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;λ§€κ°λ³μμ μ€ν νλ¦:
- μ€ν¬νλ Convert.ToInt32/Convert.ToString μμ΄ double LineTimeλ₯Ό μ μ₯ν©λλ€. μ΄λ 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μλ λΌλ²¨μ΄ 0μΈ νλͺ©μ΄ ν¬ν¨λμ΄ μμ΅λλ€. -
maxDelayβ νμ μ΅λ λκΈ° μκ°(λ°λ¦¬μ΄)μ λλ€. 0 λ° μμ κ°μ 무ν λκΈ°κ° μλ μ¦μ 1ν ν΅κ³Όλ₯Ό μλ―Έν©λλ€. -
textβ |λ₯Ό ν΅ν΄ κ²μλ νμ λ¬Έμμ΄ λλ μ¬λ¬ λμ(μ: μ±κ³΅|μ€ν¨). κ° λμμ κ°μ₯μ리μ μλ 곡백μ μ κ±°λκ³ , λΉ λμμ 건λλλλ€. μ΄λ μ κ·μμ΄ μλ μΌλ° ν μ€νΈμ λλ€. λΉμ΄ μμ§ μμ ν νλ¦Ώμ μ¬μ©νμΈμ. -
equals- μ ν μ¬ν int: 0 (κΈ°λ³Έκ°) - νμ λ¬Έμμ΄; 0μ΄ μλ κ° - λͺ¨λ ν μ€νΈλ νλμ λμκ³Ό μΌμΉν΄μΌ ν©λλ€. -
ignoreCaseβ μ νμ int: 0 (κΈ°λ³Έκ°) β λμλ¬Έμλ₯Ό ꡬλΆν©λλ€. 0μ΄ μλ - 무μν©λλ€. -
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/λΉ μ€μ μμ μ λΉνμ±νν©λλ€. The skill/item is triggered once before searching.
void - λ°ν κ°μ΄ μμ΅λλ€. νΈμΆμ λ³μμ ν λΉνμ§ μμ΅λλ€. μλ£λλ©΄ GetFoundedTextIndex >= 0λ μ νν νλͺ©μ κ³μ μ¬μ©ν μ μμμ μλ―Έν©λλ€. -1 - μ°Ύμ μ μμ/κΈ°λ‘μ΄ μμ λμμ΅λλ€. GetFoundedTextID μ νμ΄ μ±κ³΅ν κ²½μ°μλ§ μΌμΉνλ λμμ νμν©λλ€.
- κ²μ λ° Journal/GetJournal/LastJournalMessageλ νμ¬ μ€ν¬λ¦½νΈμμ λ¨μΌ νλͺ©μ ν μ€νΈμ νλλ₯Ό μ μ₯ν©λλ€. μ λ©μμ§λ μ΄ νλλ₯Ό λ체νμ§ μμ΅λλ€. μ νλ μ λμμ λ μ½λκ° μ κ±°λλ©΄ μ μ§λ νλλ μ μ§λμ§λ§ LineIndex/GetFoundedTextIndexλ -1λ₯Ό λ°νν©λλ€. λ€μ κ²μ λλ μ½κΈ°μμλ λ€λ₯Έ νλͺ©μ΄ μ νλ©λλ€. μ€ν¨ν κ²μ, μλͺ»λ μμΈ λ° μ΄ μ€ν¬λ¦½νΈλ₯Ό ν΅ν μμ λ μ νμ μ¬μ€μ ν©λλ€.
- μ΅λ 25 ms λμ μΌμ μ μ§νμ¬ ν΄λ§ν©λλ€. μ€ν¬λ¦½νΈλ₯Ό μ€μ§νλ©΄ μ€ν¬λ¦½νΈκ° μ€λ¨λ©λλ€. λΉ λμ λͺ©λ‘μμλ ν μ€νΈλ₯Ό μ°Ύμ μ μμ΅λλ€. bool κ²°κ³Όλ₯Ό μ»μΌλ €λ©΄ μ체 λ§€κ°λ³μμ μ λ‘ νμμμμ μλ―Έμ ν¨κ» WaitJournalLineλ₯Ό μ¬μ©νμΈμ.
κ° μμ λ λ³λμ νμΌ .csxλ‘ μ μ₯νκ³ IDEμμ μ€νν μ μμ΅λλ€. UO κ°μ²΄μ λκΈ° κΈ°λ₯μ νμ¬ κ²μ μΈμ
μ νΈμ€νΈλ₯Ό μ 곡ν©λλ€. λ°λͺ¨ serial μ΄λ¦, μ’ν, μ£Όμλ₯Ό μμ μ κ²μΌλ‘ λ°κΎΈμΈμ.
μ΄ μ½λλ₯Ό λ³λμ .csx νμΌλ‘ μ€ννμΈμ. μΈμλ νΈμΆμ μ§μ νμλ©λλ€. μμ μ μ΄λ¦, serial, μ£Όμλ₯Ό μμ μ κ°μΌλ‘ λ°κΎΈμΈμ.
λͺ λ Ήμ λ 립λ λ¬Έμ λλ€. μμ λ©μμ§λ νΈμΆ μμμ λνλ΄λ©° μλ² λμμ μλ£λ₯Ό νμΈνμ§ μμ΅λλ€.
UO.Print("Calling UO.WaitingForJournalText");
UO.WaitingForJournalText(Now(), 2000, "notice");λ§€κ°λ³μμ μ€ν νλ¦:
- startTime β κΈ°λ€λ¦¬κΈ° μ μ νμν©λλ€. maxDelay=2000 ms; λμλ¬Έμλ₯Ό ꡬλΆνλ νμ λ¬Έμμ΄ λΉκ΅.
- λͺ λ Ήμ΄ 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 - 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;λ§€κ°λ³μμ μ€ν νλ¦:
- Hidingμ μ¬μ― λ²μ§Έ μΈμλ μ€ν¬μ ν λ² μ€νν©λλ€. κ°μ=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);
}