API UO SetEvent - LIHACHTETAN/ClassicUO-BadNewbie-BasicIDE GitHub Wiki

UO.SetEvent

ClassicUO / Basic IDE

Оглавление · Алфавитный указатель · Scripts & Runtime

Registers or removes a legacy Basic event handler. Registration captures the current state and does not execute the handler immediately. Supported live events are SeeNewPlayer, Death, ChangeHitPoints, ChangeMana, and ChangeStamina; they are evaluated while the script yields through UO.Wait. repeat=FALSE/0 is one-shot and is automatically disabled after the first matching transition; repeat=TRUE/1 remains armed. For historical compatibility, a non-numeric third argument such as 'exec OnChange' is treated as the handler name and enables repeating mode.

Синтаксис

UO.SetEvent(name:Any, stateValue:Any) -> Unit
UO.SetEvent(name:Any, stateValue:Any, repeatOrHandler:Any) -> Unit
UO.SetEvent(nameValue:Any, stateValue:Any, repeatValue:Any, subNameValue:Any) -> Unit

Регистр имени не важен. Any — динамическое значение Basic; Unit — отсутствие возвращаемого значения. Integer — знаковое 32-битное число, Decimal — число с плавающей точкой. Правила типов, serial, индексов и ожиданий.

Параметры

Имя Назначение
name Значение для данной позиции; назначение и поддерживаемые варианты показаны в описании и примерах.
stateValue Позиционный аргумент этой перегрузки. Подробности использования указаны в описании/фактической ветви runtime ниже.
repeatOrHandler Third-argument compatibility union: repeat flag or handler SUB string.
nameValue Позиционный аргумент этой перегрузки. Подробности использования указаны в описании/фактической ветви runtime ниже.
repeatValue Позиционный аргумент этой перегрузки. Подробности использования указаны в описании/фактической ветви runtime ниже.
subNameValue Позиционный аргумент этой перегрузки. Подробности использования указаны в описании/фактической ветви runtime ниже.

Параметры обязательны внутри каждой показанной сигнатуры. Опустить аргумент можно только при наличии более короткой перегрузки; пропуск позиции посередине не подразумевается.

Допустимые значения

eventName — Legacy Basic event name: SeeNewPlayer, Death, ChangeHitPoints, ChangeMana, or ChangeStamina (case-insensitive; optional leading ev is normalized).

  • enabled — TRUE/FALSE or 1/0.
  • repeatOrHandler — TRUE/FALSE or 1/0 repeat flag; alternatively a SUB name or historical exec <SUB> / _exec <SUB> handler string.
  • repeat — FALSE/0 = one-shot; TRUE/1 = remain armed after each matching event.
  • handler — Loaded Basic SUB name, or historical exec <SUB> / _exec <SUB> form.

Пропущенные аргументы

Two arguments register/enable state tracking with repeat enabled but no handler. In the 3-argument form a non-numeric third value is the handler with repeat enabled; numeric/Boolean third value is the repeat flag. The 4-argument form explicitly supplies repeat and handler. enabled=FALSE unregisters the event.

Ограничения

enabled=FALSE/0 unregisters the event. Handler strings may be a SUB name or the historical exec <SUB> / _exec <SUB> form. The handler runs only if that SUB exists. SeeNewPlayer fires when a newly loaded non-self mobile appears relative to the registration/previous poll snapshot. Change events fire only on value transitions; Death fires on the alive-to-dead transition. Event dispatch is guarded against recursive re-entry while a handler is executing.

Возвращает: Unit — значения нет. Выполняйте вызов отдельной строкой; его нельзя использовать как проверку успеха. Эффект и ограничения зависят от команды.

Примеры

Каждый блок — самостоятельный скрипт из мануала проекта. Параметры демонстрационного объекта/контейнера и условия действия необходимо сопоставить с вашей игровой ситуацией.

Пример 1

SUB Main()
    UO.SetEvent('ChangeHitPoints', TRUE, TRUE, 'OnHpChange')
END SUB

Пример 2

SUB Main()
    UO.SetEvent('SeeNewPlayer', TRUE, 'exec OnPlayer')
END SUB

Пример 3

SUB Main()
    UO.SetEvent('ChangeMana', FALSE)
END SUB

Пример 4

SUB Main()
    UO.SetEvent('example', 2)
END SUB

Пример 5

SUB Main()
    VAR arg1 = 1 # nameValue
    VAR arg2 = 2 # stateValue
    VAR arg3 = 3 # repeatValue
    VAR arg4 = 4 # subNameValue
    UO.SetEvent(arg1, arg2, arg3, arg4)
END SUB

Пример 6

SUB Main()
    UO.SetEvent('example', 2, 3)
END SUB

Пример 7

SUB Main()
    IF UO.Connected THEN
        VAR arg1 = 'example' # name
        VAR arg2 = 2 # stateValue
        UO.SetEvent(arg1, arg2)
    END IF
END SUB

Пример 8

SUB RunAction()
    VAR arg1 = 'example' # name
    VAR arg2 = 2 # stateValue
    UO.SetEvent(arg1, arg2)
END SUB

SUB Main()
    # Запуск процедуры выполняет действие:
    RunAction()
END SUB
Реализация и проверка контракта
  • InjectionScript.Runtime.InjectionApiUO.SetEvent

Источник реестра и отчёт сверки. Примеры проверяются загрузчиком/парсером включённого runtime. Действия на игровом сервере этой проверкой не исполняются.

⚠️ **GitHub.com Fallback** ⚠️