Page 1 of 8

How to capture and store data (and view it via an alias)?

Posted: Sat Jul 21, 2018 6:28 pm
by Vooku
I'd like to start tracking sell prices for auction times and be able to view them via alias or even export to excel. The auctions end in this format:

"<item name> sold to <winner> for <#> platinum!"

Example: "a gaudy golden crown sold to Rahas for 50 platinum!"

How would I go about capturing the item, the buyer and the price and saving it for future reference?

Thanks in advice!

Re: How to capture and store data (and view it via an alias)?

Posted: Sat Jul 21, 2018 9:34 pm
by Jor'Mox
So, the pattern for that should be relatively simple, like so: ^(.+) sold to ([A-Z][\w'-]+) for (\d+) platinum!

As to how you should go about storing/displaying/exporting this data, there are a few things. Basically, the ideal method is going to depend on two main factors, how quickly are you gathering new data points, and how many total data points are you expecting?

So, for example, perhaps you see some daily record of sales, and you get 100+ records essentially at the same instant, and you are checking every day, so you expect in the range of hundreds of thousands to maybe even millions of records. For that much data, you definitely want to use a database, which is a bit of work to get setup, but it is fast enough that you should be able to add all the data points as they come in. Alternatively, you could be seeing one record every few minutes while you play, and expect to have maybe a few thousand total datapoints after playing for a while. For something like that, i would probably just recommend using a table, and saving that table whenever a new datapoint comes in.

So, what do you expect to be seeing in those terms?

Re: How to capture and store data (and view it via an alias)?

Posted: Sun Jul 22, 2018 3:04 am
by Vooku
These would be the latter. Mostly between 10 and 50 per day. So a table would suffice.

How would I go about setting that up and pulling data from it to display via an alias?

And another thing I thought of... how to handle multiple entries for the same item at different sell prices.

Re: How to capture and store data (and view it via an alias)?

Posted: Sun Jul 22, 2018 10:37 am
by Jor'Mox
So I’m assuming all you care about is the item sold and the price it was sold at, and you don’t care about who purchased it. Given that, would you want an individual line for each sale, even for identical items, of would you prefer to combine identical items into a single line, showing the lowest, highest, and average sell values, or perhaps all sell values sorted from lowest to highest (or highest to lowest)?

Re: How to capture and store data (and view it via an alias)?

Posted: Sun Jul 22, 2018 11:04 am
by Vooku
I would like to capture the buyer also to see who has all the money... lol. The easiest way to cross reference would be to have the list displayed by sell item in alphabetical order. Duplicates of the same item on their own line, sorted by date or sell price.

Another thought, it would be nice to capture the date also, to see pricing trends over time.

Re: How to capture and store data (and view it via an alias)?

Posted: Sun Jul 22, 2018 11:32 am
by Jor'Mox
Okay, so I threw together a very simple script (i.e. paste this into a script, which you will then use your aliases and triggers to call the functions of), which should at least get you close to what you are looking for.
Code: [show] | [select all] lua
auction_data = auction_data or {}

function add_auction_data(item, price, buyer)
    local date = os.date("%b %d, %Y")
    table.insert(auction_data,{item = item, price = price, buyer = buyer, date = date})
    local sort_func = function (a,b)
            if a.item ~= b.item then return a.item < b.item end
            if a.price ~= b.price then return a.price < b.price end
            if a.date ~= b.date then return a.date < b.date end
            return false
        end
    table.sort(auction_data,sort_func)
    table.save(getMudletHomeDir() .. "/auction_data.lua", auction_data)
end

function show_auction_data()
    print(string.format("%-50s: %5s, %12s, %s", "ITEM", "PRICE", "DATE", "BUYER"))
    for k,v in ipairs(auction_data) do
        print(string.format("%-50s: %5s, %12s, %s",v.item,v.price,v.date,v.buyer))
    end
end

if io.exists(getMudletHomeDir() .. "/auction_data.lua") and table.is_empty(auction_data) then
    table.load(getMudletHomeDir() .. "/auction_data.lua", auction_data)
end
Then your trigger that captures the auction info should use this for its code: add_auction_data(matches[2],matches[4],matches[3])

And whatever alias you setup to display your auction data should have this for its code: show_auction_data()

Re: How to capture and store data (and view it via an alias)?

Posted: Sun Jul 22, 2018 12:37 pm
by Vooku
Awesome! Thanks.

Re: How to capture and store data (and view it via an alias)?

Posted: Sun Jul 22, 2018 1:01 pm
by Vooku
Got it working! How would I go about deleting data already captured and stored?

Re: How to capture and store data (and view it via an alias)?

Posted: Sun Jul 22, 2018 1:04 pm
by Jor'Mox
As in, some of the data is bad? Use this in the command line: lua auction_data = {}

Then the next time it gathers data, it will save over whatever it had before, leaving you with just stuff you capture from that point on.

Re: How to capture and store data (and view it via an alias)?

Posted: Sun Jul 22, 2018 1:08 pm
by Vooku
I was using an in game 'emote' to add data just for testing. Thanks again!