• 0

    posted a message on SVN Account?
    Go hop on IRC and ask there :P
    Posted in: General Chat
  • 0

    posted a message on Table sorting question.
    As a side note I'm aware it's inefficient, it as sitting in the sort routine simply as a temporary change.

    Also of note, you're all blowing this way out of proportion :P

    At the MOST the table can be 324 entries long (someone with all 20 slot bags in their bag bar and their bank, and having them all filled), and that data is not persistent. It's not being sorted more than once, it's not being used more than once, and is cleared after it's used.
    Posted in: Lua Code Discussion
  • 0

    posted a message on ItemExport (Official Topic)
    About:
    ItemExport is a small addon that will allow you to export a simple list of all of your items in your inventory and/or bank and wrap each entry in customizable text.

    For example, if you wanted to format a list for a forum with itemstats support, you'd simply set the prefix text to "[item]" and the suffix text to "[/item]" and copy the resulting list.

    Usage:
    Slash commands: /itemexport /ie

    /ie bank - Toggles whether or not to include your bank in scans. (The bank window must be open)
    /ie inventory - Toggles whether or not to include your inventory in scans.
    /ie prefix <Any String> - Sets the text to be used before the addon name.
    /ie suffix <Any String> - Sets the text to be used after the addon name.
    /ie scan - Scans your inventory and/or bank and returns the list of items in a window to be copy'd out.

    TODO:
    -Timestamp
    -Include Money
    -More Customization to where and how item count is displayed.

    REQUESTED FEATURES:
    None yet

    BUGS:
    None yet ^_^


    Please post ALL bug reports and feature requests here.
    Posted in: General AddOns
  • 0

    posted a message on Table sorting question.
    Thank you :P

    Helped a ton. It's kind of an odd switch from languages like C, Java, and Scheme to LUA >_<
    Posted in: Lua Code Discussion
  • 0

    posted a message on Table sorting question.
    If that were the case though the sort would be over the index, which isn't what happens when the addon is run.

    When it's run, it acts as if it's sorting over item name.

    That is to say the string returned from ItemExport:FormatItemList() looks like the following (using default options, and my test inventory):

    [item]Acolyte's Robe[/item]
    [item]Hearhstone[/item]
    [item]Netherwhelp Collar[/item]


    yet the order of them in the data table is
    data {
    		{Netherwhelp Collar, 3, 1}
    		{Acolyte's Robe, 1, 1}
    		{Hearthstone, 1, 1}
    }


    If it were sorting over indext shouldn't the order have been?
    [item]Netherwhelp Collar[/item]
    [item]Acolyte's Robe[/item]
    [item]Hearthstone[/item]


    Attached is the source if you're interested.
    Posted in: Lua Code Discussion
  • 0

    posted a message on Table sorting question.
    just for some more background on the issue here are the two relevant functions:
    -- Returns the final item list string
    function ItemExport:FormatItemList()
    	local itemList = ""
    
    	table.sort(data, function(a, b) return a[1] < b[1] end)
    
    	for i,v in ipairs(data) do
    		itemList = itemList .. self.db.profile.prefix .. v[1] .. self.db.profile.suffix .. " x" .. v[3] .. "\n"
    	end
    
    	return itemList
    end
    
    -- Adds the given item to the data table
    function ItemExport:AddItem(itemname, quality, itemcount)
    	local found = false
    
    	for i,v in ipairs(data) do
    		if itemname == v[1] then
    			v[3] = v[3] + itemcount
    			found = true
    			return
    		end
    	end
    
    	if not found then
    		table.insert(data, {itemname, quality, itemcount})
    	end
    
    end


    The first is generating a string based on the item information (works just fine) The second one is the function being called to add the information into the data table (also working just fine).

    The only line that I can't get to work as expected is the "table.sort(data, function(a, b) return a[1] < b[1] end)" That exact phrase does what you'd expect. Take element one from array a, and compare it to element 1 of array b. Changing the element number to anything else causes it to tell me that the array is nil (which it shouldn't be).


    To answer you question the table is laid out as follows:

    {index, {itemname, quality, itemcount}}

    EVERYTHING else works perfectly fine.

    Running an ipairs over the table works exactly as expected for example (i being the index, and v[n] being the value of the current index's array at element n).

    edit:
    Quote from HunterZ »

    In that example, what you're thinking of as the first element in the first row is network[1].name rather than network[1][1], and becomes a.name instead of a[1] in the sort function.


    So what's the difference between network[1].name and network[1][1] then? If that works, then shouldn't network[1].IP and network[1][2] also reference the same thing? (obviously not the case given the nil error when I tried this >_<)

    I mean right out of the lua manual it says that a and b should be the values to be compared. Shouldn't that mean they're both in the format of {itemname, quality, itemcount} already, which would mean callign a[1], a[2], and a[3] would get the appropriate results.

    table.sort (table [, comp])
    Sorts table elements in a given order, in-place, from table[1] to table[n], where n is the size of the table (see 5.4). If comp is given, then it must be a function that receives two table elements, and returns true when the first is less than the second (so that not comp(a[ i+1 ],a[ i ]) will be true after the sort). If comp is not given, then the standard Lua operator < is used instead.
    Posted in: Lua Code Discussion
  • 0

    posted a message on Table sorting question.
    Quote from HunterZ »

    This is just a guess - I really haven't programmed in LUA much :P

    My problem exactly...
    Posted in: Lua Code Discussion
  • 0

    posted a message on Table sorting question.
    How do I sort a table based it's values if the values are stored in an array?

    I have a table data that stores an array of {itemname, quality, itemcount}

    how do I get to the values inside of the array during a sort function?

    I can specify a function to compare the two, but I can't figure out how to reference the array inside it.

    Example:
    table.sort(data, function(a, b) return a[1] < b[1] end)
    works (sorting by the first value of the array (itemname) but using 2 or 3 returns the following error

    Message: ..\AddOns\ItemExport\Core.lua line 175:
      attempt to index local 'a' (a nil value)


    So I guess my question is am I going about this right, and if so, why do I get nil?

    I'd normally just go look up the specification on the comparator function, but I can't seem to find it (the only thing specified is that it must return a bool, but I've found absolutely no information as to what the contents of a and b actually are).
    Posted in: Lua Code Discussion
  • 0

    posted a message on Cartographer Data Module ( unofficial)
    Quote from Ominous »

    Quote from Marroc »

    Quote from Ominous »

    not sure what you mean
    I mean i'm getting 3+ icons for a single node on top of each other.

    That is to say every time I loot the node it adds another icon, regardless of whether there was on there before or not. Like if I loot the same adamantite node say... 20 times, I'll end up with like 10-15 duplicate icons ALL on top of each other (and they're all within like .2 of each other on the map). A simple option for it to not add things fixes this ^_^

    odd as i am not getting this problem with cart_herb
    I'll trash my install and saved variables and see if that corrects the issue, but it's also occurring in mining as well, so i'm not 100% convinced it's with either of the two separate plugins, but rather with either some core functionality, or your addon.
    Posted in: Map/Minimap AddOns
  • 0

    posted a message on Could someone please point out what's wrong with this...
    Yep that was it... TY for your help.

    The one time I use namespacing... I use too much of it >_<

    Guess this is what I get for not programming for a few months.
    Posted in: Lua Code Discussion
  • 0

    posted a message on Could someone please point out what's wrong with this...
    And just for shits and giggles here's the code off the wiki that I used as a reference.

    The only difference being a find/replace on WelcomeHome to ItemExport and the variables being different.

    source: http://www.wowace.com/wiki/WelcomeHome_-_Your_first_Ace2_Addon#Saving_Configuration_Between_Sessions

    WelcomeHome:RegisterDB("WelcomeHomeDB", "WelcomeHomeDBPC")
    WelcomeHome:RegisterDefaults("profile", {
      message = "Welcome Home!",
      showInChat = false,
      showOnScreen = true,
    } )


    edit: note that my toc file includes Ace-DB 2.0 already, and has the appropriate savedVariable names already defined

    ## Interface: 20100
    ## Title: ItemExport
    ## Notes: Creates a list of your items
    ## Author: Marroc
    ## Version: 0.1
    ## X-Category: Inventory
    ## OptionalDeps: Ace2
    ## SavedVariables: ItemExportDB
    ## SavedVariablesPerCharacter: ItemExportDBPC
    
    Libs\AceLibrary\AceLibrary.lua
    Libs\AceOO-2.0\AceOO-2.0.lua
    Libs\AceAddon-2.0\AceAddon-2.0.lua
    Libs\AceDB-2.0\AceDB-2.0.lua
    Libs\AceConsole-2.0\AceConsole-2.0.lua
    Libs\AceEvent-2.0\AceEvent-2.0.lua
    Core.lua
    Posted in: Lua Code Discussion
  • 0

    posted a message on Could someone please point out what's wrong with this...
    assuming it's taking into account white lines it should be:
    	{
    		ItemExport.includeInventory = true,
    Posted in: Lua Code Discussion
  • 0

    posted a message on Could someone please point out what's wrong with this...
    Nope that wasn't it.

    I swear I've tried everything I can think of to get it working...

    Hell that code is right off of the hello world ace addon when it gets to the part about persistent options and saved variables.
    Posted in: Lua Code Discussion
  • 0

    posted a message on Could someone please point out what's wrong with this...
    I'm getting the following error on it, but as far as I can tell everything is correct.

    Message: ..\AddOns\ItemExport\Core.lua line 39: '}' expected (to close '{' at line 38) near '='

    It's probably something really stupid, but for the life of me i can't find it.

    local options = { 
      type='group',
      args = {
    		inventory = {
    			type	=	'toggle',
    			name	=	'Include Inventory',
    			desc	=	"Includes your inventory in scans.",
    			get	=	"IsIncludeInventory",
    			set	=	"ToggleIncludeInventory",
    		},
    		bank = {
    			type	=	'toggle',
    			name	=	'Include Bank',
    			desc	=	"Includes your bank in scans.",
    			get	=	"IsIncludeBank",
    			set	=	"ToggleIncludeBank",
    		},
    		timestamp = {
    			type	=	'toggle',
    			name	=	'Include Timestamp',
    			desc	=	"Includes the date and time of the scan.",
    			get	=	"IsIncludeTimestamp",
    			set	=	"ToggleIncludeTimestamp",
    		},
    	},
    }
    
    
    
    ItemExport = AceLibrary("AceAddon-2.0"):new("AceConsole-2.0", "AceDB-2.0")
    ItemExport:RegisterChatCommand("/itemexport", "/ie", options)
    
    
    
    -- Default Values
    ItemExport:RegisterDB("ItemExportDB", "ItemExportDBPC")
    ItemExport:RegisterDefaults('profile',
    	{
    		ItemExport.includeInventory = true,
    		ItemExport.includeBank = true,
    		ItemExport.includeTimestamp = true,
    	}
    )
    
    -- Called when the addon is loaded
    function ItemExport:OnInitialize()
    
    end
    
    -- Called when the addon is enabled
    function ItemExport:OnEnable()
    
    end
    
    -- Called when the addon is disabled
    function ItemExport:OnDisable()
    
    end
    
    
    
    -- Returns whether or not items in the player's Inventory should be included
    function ItemExport:IsIncludeInventory()
    	return self.db.profile.includeInventory
    end
    
    -- Sets whether or not items in the player's Inventory should be included
    function ItemExport:ToggleIncludeInventory()
    	self.db.profile.includeInventory = not self.db.profile.includeInventory
    end
    
    
    
    -- Returns whether or not the Bank should be included
    function ItemExport:IsIncludeBank()
    	return self.db.profile.includeBank
    end
    
    -- Sets whether or not the Bank should be included
    function ItemExport:ToggleIncludeBank()
    	self.db.profile.includeBank = not self.db.profile.includeBank
    end
    
    
    
    -- Returns whether or not a timestamp should be included
    function ItemExport:IsIncludeTimestamp()
    	return self.db.profile.includeTimestamp
    end
    
    -- Sets whether or not a timestamp should be included
    function ItemExport:ToggleIncludeTimestamp()
    	self.db.profile.includeTimestamp = not self.db.profile.includeTimestamp
    end
    Posted in: Lua Code Discussion
  • 0

    posted a message on Cartographer Data Module ( unofficial)
    Quote from Ominous »

    not sure what you mean
    I mean i'm getting 3+ icons for a single node on top of each other.

    That is to say every time I loot the node it adds another icon, regardless of whether there was on there before or not. Like if I loot the same adamantite node say... 20 times, I'll end up with like 10-15 duplicate icons ALL on top of each other (and they're all within like .2 of each other on the map). A simple option for it to not add things fixes this ^_^
    Posted in: Map/Minimap AddOns
  • To post a comment, please or register a new account.