Repository navigation
FR API UO WaitingForJournalText
Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
Accueil · C# · IDE · UO API · A–Z · Exemples · Langues
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);Attend du texte avec des modes de comparaison supplémentaires et un lancement optionnel de compétences/objets.
-
startTime— Étiquette obligatoire Now(), int millisecondes à partir du début de l'exécution. Les lignes avec une étiquette au moins startTime sont vérifiées ; 0 inclut les entrées avec une étiquette zéro. -
maxDelay— Attente maximale obligatoire en millisecondes. 0 et les valeurs négatives signifient un passage immédiat plutôt qu'une attente infinie. -
text— La sous-chaîne recherchée ou plusieurs alternatives via |, par exemple success|failed. Les espaces aux bords de chaque alternative sont supprimés, les alternatives vides sont ignorées. Il s'agit d'un texte brut, pas d'une expression régulière. Utilisez un modèle non vide. -
equals- Facultatif int : 0 (par défaut) - sous-chaîne ; valeur non nulle - tout le texte doit correspondre à une alternative. -
ignoreCase- Facultatif int : 0 (par défaut) - sensible à la casse ; différent de zéro - ignorer. -
skillNameOrObjectId- Compétence facultative par nom, serial/chaîne hexadécimale ou alias d'objet résoluble. Le nom de la compétence est reconnu en premier, sinon l'objet est utilisé. 0/ligne vide désactive l'action. La compétence/l'objet est déclenché une fois avant la recherche.
void - pas de valeur de retour, n'attribue pas l'appel à une variable. Une fois terminé, GetFoundedTextIndex >= 0 signifie que l'entrée sélectionnée est toujours disponible ; -1 - introuvable/enregistrement supprimé. GetFoundedTextID affiche l'alternative correspondante uniquement si la sélection est réussie.
- Recherche et Journal/GetJournal/LastJournalMessage enregistrent le texte et les champs d'une seule entrée dans le script actuel. Les nouveaux messages ne remplacent pas ces champs. Si un enregistrement est expulsé d'un journal limité, les champs conservés restent, mais LineIndex/GetFoundedTextIndex renvoie -1. La recherche ou la lecture suivante sélectionne une autre entrée ; une recherche infructueuse, un index invalide et un effacement via ce script réinitialisent la sélection.
- Sondage avec pause jusqu'à 25 ms ; l'arrêt du script l'interrompt. Une liste d'alternatives vide ne trouve pas de texte. Pour le résultat bool, utilisez WaitJournalLine avec ses propres paramètres et la signification d'un timeout nul.
Chaque exemple peut être enregistré dans un fichier séparé .csx et exécuté dans IDE. Les fonctions d'objet UO et d'attente fournissent l'hôte de la session de jeu en cours. Remplacez les noms, coordonnées et adresses de la démo serial par les vôtres.
Exécutez ce code dans un fichier .csx séparé. Les arguments sont visibles dans l’appel ; remplacez les noms, serials et adresses d’exemple par les vôtres.
La commande forme une instruction séparée. Le message précédent indique le début de l’appel et ne confirme aucune action du serveur.
UO.Print("Calling UO.WaitingForJournalText");
UO.WaitingForJournalText(Now(), 2000, "notice");Paramètres et déroulement de l’exécution :
- startTime — marquez avant d'attendre ; maxDelay=2000 ms ; comparaison de sous-chaînes sensibles à la casse.
- La commande ne renvoie pas true/false : l'entrée sélectionnée est vérifiée.
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;Paramètres et déroulement de l’exécution :
- startTime=0; maxDelay=0 - un passage. equals=1 — tout le texte, ignoreCase=1 — aucun cas.
- Le numéro alternatif 0 ou 1 s'affiche ; une longue ligne avec des mots supplémentaires ne fonctionnera pas.
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;Paramètres et déroulement de l’exécution :
- Le sixième argument de Hiding exécute la compétence une fois. equals=0 — sous-chaîne, ignoreCase=1 — aucun cas.
- Les mots masqué/échec sont des exemples, remplacez-les par le texte de votre serveur. Au lieu d'une compétence, vous pouvez spécifier serial ou lastobject pour utiliser l'objet.
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# distingue les majuscules. Utilisez le nom UO exact. Comparez les indicateurs numériques à 0 ; utilisez bool seulement si la signature renvoie bool.
UO.WaitingForJournalText(startTime, maxDelay, text) — UO.WaitingForJournalText(Integer,Integer,String)
Paramètres: startTime (Integer), maxDelay (Integer), text (String)
Résultat: void / Unit.
Pendant un appel:
-
InjectionScript.Runtime.InjectionApiUO.WaitingForJournalText. -
InjectionScript.Runtime.InjectionApiUO.WaitingForJournalText:WaitingForJournalText(startTime, maxDelay, text, 0, 0, InjectionValue.Zero).
Code interne de l’implémentation ; ce n’est pas un script autonome.
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)
Paramètres: startTime (Integer), maxDelay (Integer), text (String), equals (Integer)
Résultat: void / Unit.
Pendant un appel:
-
InjectionScript.Runtime.InjectionApiUO.WaitingForJournalText. -
InjectionScript.Runtime.InjectionApiUO.WaitingForJournalText:WaitingForJournalText(startTime, maxDelay, text, equals, 0, InjectionValue.Zero).
Code interne de l’implémentation ; ce n’est pas un script autonome.
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)
Paramètres: startTime (Integer), maxDelay (Integer), text (String), equals (Integer), ignoreCase (Integer)
Résultat: void / Unit.
Pendant un appel:
-
InjectionScript.Runtime.InjectionApiUO.WaitingForJournalText. -
InjectionScript.Runtime.InjectionApiUO.WaitingForJournalText:WaitingForJournalText(startTime, maxDelay, text, equals, ignoreCase, InjectionValue.Zero).
Code interne de l’implémentation ; ce n’est pas un script autonome.
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)
Paramètres: startTime (Integer), maxDelay (Integer), text (String), equals (Integer), ignoreCase (Integer), skillNameOrObjectId (Any)
Résultat: void / Unit.
Pendant un appel:
-
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))).
Code interne de l’implémentation ; ce n’est pas un script autonome.
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