Справочник › Справочник функций › Conditions

Conditions.equipment.matches

зависимость

Как вызывать

Conditions.equipment.matches(value, record)

Запишите зависимость Conditions.equipment.matches и вызывайте её по этому имени. Вызов через пространство имён не передаёт self: используйте вызов через двоеточие или передайте объект сами.

Что делает

Tests one equipment slot record against a WEAPON_TYPE condition: empty slot, shield, any weapon, holdable, one-hand, two-hand, ranged, or a specific weapon subclass. Returns nil with a reason when the item's class or equip location is not known yet.

Аргументы

ИмяТипЧто делает
valuetableCondition settings: kind (empty, shield, weapon, holdable, onehand, twohand or ranged) or a weapon subclass ID in subclass.
recordtable | booleanSlot record with classID, subClassID, equipLoc and an optional typeReason, or false for an empty slot.

Возвращает

1boolean | nilWhether the slot matches, or nil when it cannot be decided.
2string | nilReason for nil: the record's typeReason, item-data-unavailable or invalid-weapon-type.

Издания

Встроенные помощники регистрируются во всех изданиях. Различается игровой API, который они читают; если нужного API нет, помощник использует запасной вариант или возвращает nil с причиной.

Не читает игровой API напрямую.

Как его вызывает аддон

Зависимости

Исходный код

Conditions/equipment.lua, строка 119. В игре только для чтения; «Дублировать» создаёт редактируемую копию.

Conditions.equipment.matches(value, record)
    if record == false then return value.kind == "empty" end
    if value.kind == "empty" then return false end
    if record.classID == nil then return nil, record.typeReason or "item-data-unavailable" end
    if value.subclass ~= nil then
        return record.classID == WEAPON_CLASS and record.subClassID == value.subclass
    end
    local kind = value.kind
    if kind == "shield" then return record.classID == ARMOR_CLASS and record.subClassID == SHIELD_SUBCLASS end
    if kind == "weapon" then return record.classID == WEAPON_CLASS end
    if record.equipLoc == nil then return nil, "item-data-unavailable" end
    if kind == "holdable" then return record.equipLoc == "INVTYPE_HOLDABLE" end
    if record.classID ~= WEAPON_CLASS then return false end
    if kind == "onehand" then return ONEHAND[record.equipLoc] == true end
    if kind == "twohand" then return record.equipLoc == "INVTYPE_2HWEAPON" end
    if kind == "ranged" then return RANGED[record.equipLoc] == true end
    return nil, "invalid-weapon-type"

Назад: Справочник функций