JMTradingHouseSnapshot
Addon for elder scroll online that makes a snapshot of your trading houses.
Other addons can request the existing snapshot or a new snapshot and register on events so they are notices when a new snapshot is created.
Snapshot structure
Code:
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
Code:
JMTradingHouseSnapshot.createSnapshot()
Allows you to create a new snapshot. The snapshot will not be returned because it will take a while.
getSnapshot
Code:
local snapshot = JMTradingHouseSnapshot.getSnapshot()
Will return the latest successful snapshot or false if no snapshot was ever made.
abort
Code:
JMTradingHouseSnapshot.abort()
Will abort the snapshot if running.
registerForEvent
Code:
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
Code:
JMTradingHouseSnapshot.unregisterForEvent(event, callback)
Stop listening to an event.
Events
All possible events are listen in JMTradingHouseSnapshot.events.
Code:
JMTradingHouseSnapshot.events
SCAN_STARTED
Code:
JMTradingHouseSnapshot.events.SCAN_STARTED
Will be triggered when the scanner is starting to create a snapshot.
Code:
JMTradingHouseSnapshot.registerForEvent(JMTradingHouseSnapshot.events.SCAN_STARTED, function ()
d('Scan started')
end)
SCAN_SUCCEEDED
Code:
JMTradingHouseSnapshot.events.SCAN_SUCCEEDED
Will be triggered when the snapshot has finished successfully. The function will have one argument with the snapshot.
Code:
JMTradingHouseSnapshot.registerForEvent(JMTradingHouseSnapshot.events.SCAN_SUCCEEDED, function (snapshot)
d('Scan finished successfully')
d(snapshot)
end)
SCAN_FAILED
Code:
JMTradingHouseSnapshot.events.SCAN_FAILED
Will be triggered when the scanner got aborted.
Code:
JMTradingHouseSnapshot.registerForEvent(JMTradingHouseSnapshot.events.SCAN_FAILED, function ()
d('Scan failed')
end)
SCAN_ALREADY_RUNNING
Code:
JMTradingHouseSnapshot.events.SCAN_ALREADY_RUNNING
Will be triggered when the scanner is already making a snapshot.
Code:
JMTradingHouseSnapshot.registerForEvent(JMTradingHouseSnapshot.events.SCAN_ALREADY_RUNNING, function ()
d('Scan already running')
end)
ADDON_LOADED
Code:
JMTradingHouseSnapshot.events.ADDON_LOADED
Will be triggered when the addon is fully setup. So you know that you can ask for a scan.
Code:
JMTradingHouseSnapshot.registerForEvent(JMTradingHouseSnapshot.events.ADDON_LOADED, function ()
d('Addon is loaded')
end)