JordyMoos / JMTradingHouseSnapshot

Creates a snapshot of all your guild trading houses so it can be used by other addons
MIT License
4 stars 0 forks source link

JMTradingHouseSnapshot

Addon for elder scroll online that makes a snapshot of your trading houses. Other addons can request a new snapshot or register on events so they are notices when a new snapshot is created.

Snapshot structure

snapshot =
{
    -- Holds the items grouped per guild
    tradingHouseItemList =
    {
        -- First guild
        1 =
        {
            -- First item
            {
                itemId = '',
                guildName = '',
                itemLink = '',
                sellerName = '',
                quality = '',
                stackCount = '',
                price = '',
                pricePerPiece = '',
                expiry = '',

                -- Deprecated. guildId will be removed in version 2.0
                -- You should use the guildName
                guildId = '',
            },

            -- Next item etc
            {
                -- ..
            }
        },

        -- Next guild etc
        2 =
        {
            -- ..
        }
    },

    -- Will list the guilds with their information
    guildList =
    {
        -- First guild
        1 =
        {
            id = '',
            name = '',
            alianceId = '',
        },

        -- Next guild etc
        2 =
        {
            -- ..
        }
    },

    -- The creation timestamp of when the snapshot was finished building
    creationTimestamp = nil,
}

API

createSnapshot

JMTradingHouseSnapshot.createSnapshot()

Allows you to create a new snapshot. The snapshot will not be returned because it will take a while.

getSnapshot

local snapshot = JMTradingHouseSnapshot.getSnapshot()

Will return the latest successful snapshot or false if no snapshot was ever made.

abort

JMTradingHouseSnapshot.abort()

Will abort the snapshot if running.

registerForEvent

JMTradingHouseSnapshot.registerForEvent(event, callback)

Allows you to listen to an event. See Events for list of possible events. The callback function will be called when the events triggers.

unregisterForEvent

JMTradingHouseSnapshot.unregisterForEvent(event, callback)

Stop listening to an event.

Events

All possible events are listen in JMTradingHouseSnapshot.events.

SCAN_STARTED

JMTradingHouseSnapshot.events.SCAN_STARTED

Will be triggered when the scanner is starting to create a snapshot.

JMTradingHouseSnapshot.registerForEvent(JMTradingHouseSnapshot.events.SCAN_STARTED, function ()
    d('Scan started')
end)

SCAN_SUCCEEDED

JMTradingHouseSnapshot.events.SCAN_SUCCEEDED

Will be triggered when the snapshot has finished successfully. The function will have one argument with the snapshot.

JMTradingHouseSnapshot.registerForEvent(JMTradingHouseSnapshot.events.SCAN_SUCCEEDED, function (snapshot)
    d('Scan finished successfully')
    d(snapshot)
end)

SCAN_FAILED

JMTradingHouseSnapshot.events.SCAN_FAILED

Will be triggered when the scanner got aborted.

JMTradingHouseSnapshot.registerForEvent(JMTradingHouseSnapshot.events.SCAN_FAILED, function ()
    d('Scan failed')
end)

SCAN_ALREADY_RUNNING

JMTradingHouseSnapshot.events.SCAN_ALREADY_RUNNING

Will be triggered when the scanner is already making a snapshot.

JMTradingHouseSnapshot.registerForEvent(JMTradingHouseSnapshot.events.SCAN_ALREADY_RUNNING, function ()
    d('Scan already running')
end)

ADDON_LOADED

JMTradingHouseSnapshot.events.ADDON_LOADED

Will be triggered when the addon is fully setup. So you know that you can ask for a scan.

JMTradingHouseSnapshot.registerForEvent(JMTradingHouseSnapshot.events.ADDON_LOADED, function ()
    d('Addon is loaded')
end)

Disclaimer

This Add-on is not created by, affiliated with or sponsored by ZeniMax Media Inc. or its affiliates. The Elder Scrolls® and related logos are registered trademarks or trademarks of ZeniMax Media Inc. in the United States and/or other countries. All rights reserved.