Page 6 of 8
Re: How to capture and store data (and view it via an alias)?
Posted: Sun Jul 29, 2018 2:50 pm
by Vooku
I get that just on the price. The other options work fine. I ran that lua command to convert but it didn't take I guess.
Re: How to capture and store data (and view it via an alias)?
Posted: Sun Jul 29, 2018 2:51 pm
by Vooku
Oh, I haven't merged any files yet, so I'm thinking it's saving as a string still.
Re: How to capture and store data (and view it via an alias)?
Posted: Sun Jul 29, 2018 7:44 pm
by Vooku
I removed the [[ and ]] from the numbers and it works fine. Could this be the issue causing my new data to be added as a string?
"price = tonumber(price)"
change to:
"price = tonumber(v.price)"
??
Re: How to capture and store data (and view it via an alias)?
Posted: Sun Jul 29, 2018 7:47 pm
by Jor'Mox
Can I see that in context of all the code?
Re: How to capture and store data (and view it via an alias)?
Posted: Mon Jul 30, 2018 1:03 am
by Vooku
auction_data = auction_data or {}
function add_auction_data(item, price, buyer)
local date = os.date("%b %d, %Y")
price = tonumber(v.price)
table.insert(auction_data,{item = item, price = price, buyer = buyer, date = date})
table.save(getMudletHomeDir() .. "/auction_data.lua", auction_data)
end
function show_auction_data(sort_by)
local sort_func
sort_by = sort_by or "default"
local sort_orders = {
default = {'item','price','date'},
date = {'date','item','price'},
price = {'price','item','date'},
buyer = {'buyer','item','date'},
}
local order = sort_orders[sort_by] or sort_orders.default
sort_func = function (a,b)
if a[ order[1] ] ~= b[ order[1] ] then return a[ order[1] ] < b[ order[1] ] end
if a[ order[2] ] ~= b[ order[2] ] then return a[ order[2] ] < b[ order[2] ] end
if a[ order[3] ] ~= b[ order[3] ] then return a[ order[3] ] < b[ order[3] ] end
return false
end
table.sort(auction_data,sort_func)
print(string.format("%-60s: %8s, %8s, %s", "ITEM", "PRICE", "DATE", " BUYER"))
for k,v in ipairs(auction_data) do
print(string.format("%-60s: %8s, %8s, %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
Re: How to capture and store data (and view it via an alias)?
Posted: Mon Jul 30, 2018 1:05 am
by Jor'Mox
Yup. That is it. Just make that price instead of v.price and it should be good.
Re: How to capture and store data (and view it via an alias)?
Posted: Fri Aug 03, 2018 10:06 pm
by Vooku
One small issue I am seeing. How can I get it to stop capturing my prompt at times? It doesn't do it often and I'm not sure what causes it.
Re: How to capture and store data (and view it via an alias)?
Posted: Fri Aug 03, 2018 10:07 pm
by Jor'Mox
Change your trigger pattern so that instead of starting like this: ^(.*)
It starts like this: Auction: (.*)
Re: How to capture and store data (and view it via an alias)?
Posted: Mon Aug 06, 2018 2:20 am
by Vooku
That didn't work for some reason. Changed to Auction: (.*) and it wouldn't capture. Right now my trigger is ^(.+)
Would there be an easy way to have it display how many items are in the table at the bottom of the print alias?
Re: How to capture and store data (and view it via an alias)?
Posted: Mon Aug 06, 2018 10:44 am
by Jor'Mox
To show how many items are in the list, do this: print(#auction_data)
As for the trigger, can you show me your full trigger pattern?