Skip to content
silvereyes333 edited this page Aug 30, 2016 · 4 revisions

Developer API

Table of Contents

How to Use

Introduction

Beginning with version 2.0.0, Craft Bag Extended exposes a public API that other addons can use to integrate extra functionality into Craft Bag Extended.

Checking for Craft Bag Extended

To check to see if Craft Bag Extended is available, just check that the CraftBagExtended global variable exists.

if CraftBagExtended then
    -- do stuff
end

API Version

Current Version

1.0

The API will always follow semantic versioning standards: minor versions will be backwards-compatible, major versions introduce breaking changes.

To check the current version installed, use CraftBagExtended.apiVersion:

if CraftBagExtended
   and CraftBagExtended.apiVersion >= 1.0
   and CraftBagExtended.apiVersion < 2.0
then
    -- do stuff
end

Callbacks

Unless otherwise specified, all callback functions specified as parameters in the following APIs can be assumed to use the following signature:

function callback( transferItem )
    -- Do stuff
end

The single passed parameter, transferItem, will be of the following type:

CraftBagExtended.classes.TransferItem

bag

the source bag id of the item for the most recent transfer

slotIndex

the source slot index of the item four the most recent transfer

quantity

the stack size that was transferred

itemId

the ESO base item id of the item that was transferred

itemLink

a human-readable ESO link for the item

targetBag

the destination bag id the item was transferred to

targetSlotIndex

the destination slot index the item was transferred to

The following fields are for internal use only

callback

a function or ordered list of functions to be called whenever a slot action like a bag transfer or mail attachment completes

queue

CraftBagExtended.classes.TransferQueue instance that created this item

noAutoReturn

used by the main inventory Retrieve commands to indicate that the stack should not be marked for automatic return to the craft bag on certain operations, such as detaching from mail or withdrawing from the player bank

Player Bank API

CraftBagExtended:BankDeposit(…​)

Moves mats from the craft bag and immediately deposits them without a quantity dialog.

slotIndex

index in the craft bag of the slot to move

quantity

number of items to deposit, or nil for maximum stack size

backpackCallback

reference to function that gets raised after the stack arrives in the backpack

bankCallback

reference to function that gets raised after the stack arrives in the player bank

return

false if the stack cannot be deposited for any reason; otherwise true


CraftBagExtended:BankDepositDialog(…​)

Same as CraftBagExtended:BankDeposit(), but with a quantity dialog prompt.

slotIndex

index in the craft bag of the slot to move

backpackCallback

reference to function that gets raised after the stack arrives in the backpack

bankCallback

reference to function that gets raised after the stack arrives in the player bank

return

false if the stack cannot be deposited for any reason; otherwise true


CraftBagExtended:BankWithdraw(…​)

Moves a given stack of mats from the player bank and then automatically stows them in the craft bag.

slotIndex

index in the player bank of the slot to move

backpackCallback

reference to function that gets raised after the stack arrives in the backpack

craftBagCallback

reference to function that gets raised after the stack arrives in the craft bag

return

false if the stack cannot be withdrawn for any reason; otherwise true


Guild Bank API

CraftBagExtended:GuildBankDeposit(…​)

Moves mats from the craft bag to the backpack and then immediately deposits them in the currently-selected guild bank.

slotIndex

index in the craft bag of the slot to move

quantity

number of items to deposit, or nil for maximum stack size

backpackCallback

reference to function that gets raised after the stack arrives in the backpack

guildBankCallback

reference to function that gets raised after the stack arrives in the guild bank

return

false if the stack cannot be deposited for any reason; otherwise true


CraftBagExtended:GuildBankDepositDialog(…​)

Same as CraftBagExtended:GuildBankDeposit(), but with a quantity dialog prompt.

slotIndex

index in the craft bag of the slot to move

backpackCallback

reference to function that gets raised after the stack arrives in the backpack

guildBankCallback

reference to function that gets raised after the stack arrives in the guild bank

return

false if the stack cannot be deposited for any reason; otherwise true


Mail Send API

CraftBagExtended:MailAttach(…​)

Moves mats from the craft bag to the backpack and then immediately attaches them to the pending mail message.

slotIndex

index in the craft bag of the slot to move

quantity

number of items to deposit, or nil for maximum stack size

backpackCallback

reference to function that gets raised after the stack arrives in the backpack

attachedCallback

reference to function that gets raised after the stack is attached to the pending mail message. Receives two parameters (transferItem, attachmentIndex).

return

false if the stack cannot be attached for any reason; otherwise true


CraftBagExtended:MailAttachDialog(…​)

Same as CraftBagExtended:MailAttach(), but with a quantity dialog prompt.

slotIndex

index in the craft bag of the slot to move

backpackCallback

reference to function that gets raised after the stack arrives in the backpack

attachedCallback

reference to function that gets raised after the stack is attached to the pending mail message. Receives two parameters (transferItem, attachmentIndex).

return

false if the stack cannot be attached for any reason; otherwise true


CraftBagExtended:MailDetach(…​)

Detaches an attached stack of mats and immediately returns it to the craft bag.

slotIndex

index in the backpack of the attached slot to move

detachedCallback

reference to function that gets raised after the stack is detached. Receives two parameters (transferItem, attachmentIndex).

craftBagCallback

reference to function that gets raised after the stack arrives in the craft bag

return

false if the stack cannot be detached for any reason; otherwise true


Inventory API

CraftBagExtended:Retrieve(…​)

Moves a given quantity from the given craft bag inventory slot index into the backpack without a dialog prompt.

slotIndex

index in the craft bag of the slot to move

quantity

number of items to retrieve, or nil for maximum stack size

callback

reference to function that gets raised after the stack arrives in the backpack

return

false if the stack cannot be retrieved for any reason; otherwise true


CraftBagExtended:RetrieveDialog(…​)

Opens the "Retrieve" from craft bag dialog with a custom action name for the transfer button.

slotIndex

index in the craft bag of the slot to move

dialogTitle

The custom title to display at the top of the dialog

buttonText

The custom text to display on the "Retrieve" button

callback

reference to function that gets raised after the stack arrives in the backpack

return

false if the stack cannot be retrieved for any reason, or the dialog is cancelled; otherwise true


CraftBagExtended:Stow(…​)

Moves a given quantity from the given backpack inventory slot index into the craft bag without a dialog prompt.

slotIndex

index in the backpack of the slot to move

quantity

number of items to move, or nil for the whole stack

callback

reference to function that gets raised after the stack arrives in the craft bag

return

false if the stack cannot be moved for any reason; otherwise true


CraftBagExtended:StowDialog(…​)

Opens the "Stow" to craft bag dialog with a custom action name for the transfer button.

slotIndex

index in the backpack of the slot to move

dialogTitle

The custom title to display at the top of the dialog

buttonText

The custom text to display on the "Stow" button

callback

reference to function that gets raised after the stack arrives in the craft bag

return

false if the stack cannot be moved for any reason, or if the dialog is cancelled; otherwise true


Trade API

CraftBagExtended:TradeAddToOffer(…​)

Moves a given quantity of a craft bag slot to the backpack and then adds it to the current trade offer.

slotIndex

index in the craft bag of the slot to move

quantity

number of items to retrieve, or nil for maximum stack size

backpackCallback

reference to function that gets raised after the stack arrives in the backpack

addedCallback

reference to function that gets raised after the stack is added to the trade offer. Receives two parameters (transferItem, tradeOfferSlotIndex).

return

false if the stack cannot be retrieved for any reason; otherwise true


CraftBagExtended:TradeAddToOfferDialog(…​)

Opens a retrieve dialog for a given craft bag slot index, and then automatically adds it to the current trade offer.

slotIndex

index in the craft bag of the slot to move

backpackCallback

reference to function that gets raised after the stack arrives in the backpack

addedCallback

reference to function that gets raised after the stack is added to the trade offer. Receives two parameters (transferItem, tradeOfferSlotIndex).

return

false if the stack cannot be retrieved for any reason or the dialog is cancelled; otherwise true


CraftBagExtended:TradeRemoveFromOffer(…​)

Removes the stack at the given backpack index from the player’s trade offer and returns the stack to the craft bag.

slotIndex

index in the backpack of the slot to remove and stow

backpackCallback

reference to function that gets raised after the stack arrives in the backpack. Receives two parameters (transferItem, tradeOfferSlotIndex).

stowedCallback

reference to function that gets raised after the stack arrives in the craft bag

return

false if the stack cannot be removed for any reason or the dialog is cancelled; otherwise true


Trading House / Guild Store API

CraftBagExtended:TradingHouseAddToListing(…​)

If Awesome Guild Store is not running, retrieves a given quantity of mats from a given craft bag slot index, and then automatically adds them to a new pending guild store sale posting.

slotIndex

index in the craft bag of the slot to move

quantity

number of items to retrieve, or nil for maximum stack size

backpackCallback

reference to function that gets raised after the stack arrives in the backpack

addedCallback

reference to function that gets raised after the stack is added to the listing

return

false if the stack cannot be retrieved for any reason; otherwise true


CraftBagExtended:TradingHouseAddToListingDialog(…​)

If Awesome Guild Store is not running, opens a retrieve dialog for a given craft bag slot index, and then automatically adds the selected quantity to a new pending guild store sale posting.

slotIndex

index in the craft bag of the slot to move

backpackCallback

reference to function that gets raised after the stack arrives in the backpack

addedCallback

reference to function that gets raised after the stack is added to the listing

return

false if the stack cannot be retrieved for any reason, or if the dialog is cancelled; otherwise true


CraftBagExtended:TradingHouseRemoveFromListing(…​)

If Awesome Guild Store is not running, removes the currently-pending stack of mats from the guild store sales listing and then automatically stows them in the craft bag.

slotIndex

index in the backpack of the slot to remove

removedCallback

reference to function that gets raised after the stack is removed from the listing

craftbagCallback

reference to function that gets raised after the stack arrives in the craft bag

return

false if the stack cannot be retrieved for any reason; otherwise true