Pascal Methods
Pascal-only methods that have no Python equivalent.
Методы, доступные только в Pascal (DWS / PascalScript). В Python отсутствуют.
procedure AddToDebugJournal(Msg: String);
Writes a message to the debug journal in the Stealth Editor. The debug journal panel is visible only when a script is executed in Debug mode from the Editor.
Записывает сообщение в журнал отладки редактора Stealth. Панель журнала отладки видна только при запуске скрипта в режиме Debug из редактора.
begin
AddToDebugJournal('Entering main loop');
while Connected do
begin
AddToDebugJournal('HP = ' + IntToStr(HP));
Wait(1000);
end;
end.
function BMSearch(StartPos: Integer; const S: String; const P: String): Integer;
Searches for substring P in string S, starting from position StartPos (1-based). If StartPos is 0, the search starts from position 1.
Returns the 1-based position of the first occurrence, or -1 if not found.
Ищет подстроку P в строке S, начиная с позиции StartPos (1-based). Если StartPos равен 0, поиск начинается с позиции 1.
Возвращает позицию первого вхождения (1-based), или -1 если не найдено.
var
Pos: Integer;
begin
Pos := BMSearch(1, 'Hello World', 'World');
if Pos > 0 then
AddToSystemJournal('Found at position: ' + IntToStr(Pos))
else
AddToSystemJournal('Not found');
end.
function ClipboardGetString: String;
Returns the current text content of the system clipboard.
Возвращает текущее текстовое содержимое системного буфера обмена.
var
S: String;
begin
S := ClipboardGetString;
AddToSystemJournal('Clipboard: ' + S);
end.
procedure ClipboardSetString(S: String);
Copies the string S to the system clipboard.
Копирует строку S в системный буфер обмена.
begin
ClipboardSetString('$' + IntToHex(Self, 8));
AddToSystemJournal('Character ID copied to clipboard');
end.
function CurrentLine: Integer;
Returns the line number currently being executed in the script. Useful for debugging.
Возвращает номер текущей выполняемой строки скрипта. Полезно для отладки.
begin
AddToSystemJournal('Now at line: ' + IntToStr(CurrentLine));
end.
CurrentScriptPath, AddToDebugJournal
function CurrentScriptPath: String;
Returns the directory path of the currently running script file.
Возвращает путь к директории текущего выполняемого файла скрипта.
var
DataFile: String;
begin
DataFile := CurrentScriptPath + 'data.txt';
AddToSystemJournal('Data file: ' + DataFile);
end.
function InputBox(ACaption: String; APrompt: String; ADefault: String): String;
Displays a modal input dialog and waits for user input. Script execution is paused until the dialog is closed.
ACaption — dialog window title.
APrompt — prompt text displayed above the input field.
ADefault — default value in the input field.
Returns the entered string, or the default value if the dialog was cancelled.
Показывает модальный диалог ввода и ожидает ввода пользователя. Выполнение скрипта приостанавливается до закрытия диалога.
ACaption — заголовок окна диалога.
APrompt — текст подсказки над полем ввода.
ADefault — значение по умолчанию в поле ввода.
Возвращает введённую строку, или значение по умолчанию при отмене.
var
Target: String;
begin
Target := InputBox('Move To', 'Enter coordinates (X,Y):', '1500,1200');
AddToSystemJournal('User entered: ' + Target);
end.
ShowMessage, MessageBoxTimeOut
function IsFigureText(S: String): Boolean;
Checks whether the string S consists entirely of digit characters. Returns True if every character in the string is a digit (0–9), False otherwise. Returns False for empty strings.
Проверяет, состоит ли строка S целиком из цифр. Возвращает True, если каждый символ строки — цифра (0–9), False в противном случае. Для пустых строк возвращает False.
begin
if IsFigureText('12345') then
AddToSystemJournal('Is a number')
else
AddToSystemJournal('Not a number');
// IsFigureText('12.5') -> False (dot is not a digit)
// IsFigureText('') -> False
// IsFigureText('100') -> True
end.
function MessageBoxTimeOut(Msg: String; DlgType: TMsgDlgType;
Buttons: TMsgDlgButtons; TimeOutInterval: Cardinal): Integer;
Displays a message dialog with a timeout. If the user does not click a button within TimeOutInterval milliseconds, the dialog closes automatically.
Msg — message text.
DlgType — dialog type (mtWarning, mtError, mtInformation, mtConfirmation, mtCustom).
Buttons — set of buttons to display (mbYes, mbNo, mbOK, mbCancel, mbAbort, mbRetry, mbIgnore, mbAll, mbHelp).
TimeOutInterval — auto-close timeout in milliseconds.
Returns the modal result corresponding to the button clicked, or the default result on timeout.
Показывает диалог сообщения с таймаутом. Если пользователь не нажмёт кнопку в течение TimeOutInterval миллисекунд, диалог закроется автоматически.
Msg — текст сообщения.
DlgType — тип диалога (mtWarning, mtError, mtInformation, mtConfirmation, mtCustom).
Buttons — набор кнопок (mbYes, mbNo, mbOK, mbCancel, mbAbort, mbRetry, mbIgnore, mbAll, mbHelp).
TimeOutInterval — таймаут автозакрытия в миллисекундах.
Возвращает модальный результат нажатой кнопки, или результат по умолчанию при истечении таймаута.
var
Res: Integer;
begin
Res := MessageBoxTimeOut('Continue script?', mtConfirmation,
[mbYes, mbNo], 10000);
if Res = mrYes then
AddToSystemJournal('User confirmed')
else
AddToSystemJournal('Cancelled or timed out');
end.
procedure PauseCurrentScript;
Pauses the currently running script. The script can be resumed from the Stealth UI.
Execution is suspended via the character’s event queue — the pause takes effect after the current statement completes.
Приостанавливает выполнение текущего скрипта. Возобновить работу можно из интерфейса Stealth.
Приостановка выполняется через очередь событий персонажа — пауза вступает в силу после завершения текущей инструкции.
begin
AddToSystemJournal('Pausing script...');
PauseCurrentScript;
AddToSystemJournal('Script resumed!');
end.
PauseResumeScript, GetScriptsCount
function RandomRange(const AFrom: Integer; ATo: Integer): Integer;
Returns a random integer in the range [AFrom .. ATo).
Standard Delphi System.Math.RandomRange — the upper bound is exclusive.
Возвращает случайное целое число в диапазоне [AFrom .. ATo).
Стандартная функция Delphi System.Math.RandomRange — верхняя граница не включается.
var
Delay: Integer;
begin
Delay := RandomRange(500, 1500);
AddToSystemJournal('Random delay: ' + IntToStr(Delay) + 'ms');
Wait(Delay);
end.
procedure ShowMessage(const Msg: String);
Displays a modal message dialog with an OK button. Script execution is paused until the dialog is closed.
Показывает модальный диалог сообщения с кнопкой OK. Выполнение скрипта приостанавливается до закрытия диалога.
begin
ShowMessage('Script finished! Found ' + IntToStr(FindCount) + ' items.');
end.
procedure StrBreakApart(const S: String; Delimeter: String; Parts: TStringList);
Splits the string S by the specified Delimeter and fills the Parts list with the resulting substrings. The TStringList must be created before calling and freed after use.
Разбивает строку S по указанному разделителю Delimeter и заполняет список Parts полученными подстроками. TStringList должен быть создан до вызова и освобождён после использования.
var
Parts: TStringList;
i: Integer;
begin
Parts := TStringList.Create;
StrBreakApart('apple|banana|cherry', '|', Parts);
for i := 0 to Parts.Count - 1 do
AddToSystemJournal('Part ' + IntToStr(i) + ': ' + Parts[i]);
Parts.Free;
end.