Skip to content

Return of Reckoning

Wiki

RoR Wiki

API:CanUseDyeItem

From RoR Wiki

UI Lua API · Dye functions
Version: WAR 1.4.8

Returns whether the player's rank is high enough to use an item, such as a dye.

canUse = CanUseDyeItem(location, slot)

Arguments

location
number – Where the item is, as a GameData.ItemLocs value.
slot
number – Slot of the item in location, starting at 1.

Returns

canUse
boolean – true if the player's rank is at least the item's required level.

Details

  • Only the level requirement is compared. The client does not check that the item is a dye or that the slot holds an item.
  • GameData.ItemLocs.BANK is not supported by the slot conversion this function uses.
  • If there is no player object, the Lua state is not available or the argument check fails, the function returns false.
  • The function needs at least two arguments and only reads the last two.

Errors

None besides the generic Invalid Parameters message when an argument is not a number.

Example

From default/ea_modifyitem/source/useitemtargeting.lua:

function UseItemTargeting.CanUseDyeItem(sourceLocation, dyeSlot)
    local canUseDye = false
    -- Check to see if player is able to use the dye Item first
    canUseDye = CanUseDyeItem(sourceLocation, dyeSlot)

    --Display a one dialog box with text saying "Your rank is too low to use this dye!"
    --if they can't use the dye because of their rank
    if(canUseDye == false) then
        ...
        return false
    end

    return true
end

See also