You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
1.2 KiB

3 years ago
-- ------------------------------------------------------------------------------ --
-- TradeSkillMaster --
-- https://tradeskillmaster.com --
-- All Rights Reserved - Detailed license information included with addon. --
-- ------------------------------------------------------------------------------ --
local TSM = select(2, ...) ---@type TSM
local SlotId = TSM.Init("Util.SlotId") ---@class Util.SlotId
3 years ago
local SLOT_ID_MULTIPLIER = 1000
-- ============================================================================
-- Module Functions
-- ============================================================================
---Combines a bag and slot into a slotId.
---@param bag number The bag
---@param slot number The slot
---@return number
function SlotId.Join(bag, slot)
return bag * SLOT_ID_MULTIPLIER + slot
3 years ago
end
---Splits a slotId into a bag and slot
---@param slotId number The slotId
---@return number bag The bag
---@return number slot The slot
3 years ago
function SlotId.Split(slotId)
local bag = floor(slotId / SLOT_ID_MULTIPLIER)
3 years ago
local slot = slotId % SLOT_ID_MULTIPLIER
return bag, slot
3 years ago
end