Register
Results 1 to 7 of 7
  1. #1
    avlox's Avatar
    Posts
    56
    Reputation
    2
    Tagged in
    0 Posts
    Add to this user's reputation

    Question addon question...

    is there a way to get an items value? something like....
    GetMarketPrice(ITEMID) ?
    im trying to write my first addon (and learning lua in the process now) and its going to be a liquid wealth type, adding up the prices for all items in bags and bank.. and spitting out a total.. thought it'd be a fun little project for my first addon.. and would LOVE to use the data from your addon as my base.. :-D
    http://avlox.com/ - My WoW blog, AH/Economy related.

  2. #2
    avlox's Avatar
    Posts
    56
    Reputation
    2
    Tagged in
    0 Posts
    Add to this user's reputation
    ok, sorry, i just thought about actually opening the files and found my answer...

    tuj=LibStub('TheUndermineJournal-1')
    o=tuj:MarketInfo(52719)
    print(o['market'])


    please ignore
    http://avlox.com/ - My WoW blog, AH/Economy related.

  3. #3
    avlox's Avatar
    Posts
    56
    Reputation
    2
    Tagged in
    0 Posts
    Add to this user's reputation
    ok, gotta ask another 'scripting' question....
    tuj=LibStub('TheUndermineJournal-1');

    local liquid_assets = 0;
    for b=0,4 do
    slotz = GetContainerNumSlots(b);
    for i=1,slotz do
    itemPr = tuj:MarketInfo(GetContainerItemID(b, i));
    liquid_assets = liquid_assets + itemPr['market'];
    end
    end
    why does that error with "attempt to index local 'itemPr' (a nil value)" ? i cant quite figure it out..
    http://avlox.com/ - My WoW blog, AH/Economy related.

  4. #4
    Sapu94's Avatar
    Posts
    7,114
    Reputation
    345
    Blog Entries
    25
    Tagged in
    1928 Posts
    Add to this user's reputation
    Without knowing how TUJ addon works...I'd guess it returns nil when it's passed nil as this is a common practice. GetContainerItemID(bag, slot) returns nil when there's nothing in that bag / slot. Just put an if statement like this:

    if itemPr then
    liquid_assets = liquid_assets + itemPr.market; -- yes .market is the same as ['market']
    end


    Follow me and TSM on Twitter for important updates, news, and giveaways!
    TSM Website | /r/woweconomy & TSM Discord | Go Premium | TSM FAQ

    "A good programmer is someone who always looks both ways before crossing a one-way street."

  5. #5
    avlox's Avatar
    Posts
    56
    Reputation
    2
    Tagged in
    0 Posts
    Add to this user's reputation
    ahhh! ty. that clears ALOT up.. now to write a bit for ignoring nil.
    http://avlox.com/ - My WoW blog, AH/Economy related.

  6. #6
    avlox's Avatar
    Posts
    56
    Reputation
    2
    Tagged in
    0 Posts
    Add to this user's reputation
    oh you already did!!! ty again.. haha
    http://avlox.com/ - My WoW blog, AH/Economy related.

  7. #7
    avlox's Avatar
    Posts
    56
    Reputation
    2
    Tagged in
    0 Posts
    Add to this user's reputation
    ok, so the code isnt returning errors at all.. but now im getting 'nil' printed...

    tuj=LibStub('TheUndermineJournal-1');


    local liquid_assets = 0;
    for b=0,4 do
    slotz = GetContainerNumSlots(b);
    for i=1,slotz do
    local idSys = GetContainerItemID(b, i);
    local itemPr = tuj:MarketInfo(idSys);
    if itemPr then
    liquid_assets = liquid_assets + itemPr.market;
    end
    end
    end

    print(liquid_assets);

    TheUndermineJournal addon, v 1.1

    Now uses LibStub, so you should be able to query this DB from other addons:

    tuj=LibStub('TheUndermineJournal-1')
    o=tuj:MarketInfo(52719)
    print(o['market'])

    Prints the market price of Greater Celestial Essence.

    ^--- from the addon.lua file


    nvm, there was a typo.. got it all working now.. awesome work.. ty.. :-D

    now to wrap it up in a gui.. :-D
    Last edited by avlox; March 6th, 2011 at 01:02 AM. Reason: adding in lua info from the addon itself
    http://avlox.com/ - My WoW blog, AH/Economy related.

 

 

Similar Threads

  1. The Consortium Addon Series: TradeSkillMaster Addon
    By Sinshroud in forum Outdated Guides Archive
    Replies: 68
    Last Post: January 25th, 2012, 10:41 AM
  2. The Consortium Addon Series: How to Install an Addon
    By Sinshroud in forum Consortium Quality Guides
    Replies: 3
    Last Post: November 5th, 2011, 03:19 AM
  3. Replies: 13
    Last Post: September 26th, 2011, 07:31 AM

Tags for this Thread