View Single Post
Unread 12-18-12, 11:32 AM   #1
Aanson
A Flamescale Wyrmkin
Join Date: Aug 2009
Posts: 123
Dividing hundreds and thousands by a comma

Hi again all!

This isn't really too essential, and I'm maybe just being a bit too picky here, but is there any way to do the following:

Convert 123123 to 123,123 ?

I created the following function for use on the AUCTION_HOUSE_CLOSED event:

Lua Code:
  1. M.GetData_CalculateListingValue = function()
  2.     local announce = C.GetActiveProfile().Modules[module].sayListingValueOnClose;
  3.     if (not announce) then return nil; end
  4.     local value = 0;
  5.     local pageAuctions, totalAuctions = GetNumAuctionItems("owner");
  6.     for i = 1, totalAuctions do
  7.         value = ( value + select(10, GetAuctionItemInfo("owner", i)) );
  8.     end
  9.     if (value > 0) then
  10.         return GetCoinTextureString(value);
  11.     end
  12.     return nil;
  13. end

I've discovered though that GetCoinTextureString() returns the number format described above. I've tried my hand at using string.format but I've not had any luck so far.


One other completely unrelated question while I'm here. When a variable is expressed within a function (for example "announce" in the function above; I understand it to be local to that function only. What I'm not sure of though is, what if I omitted the 'local'? Would it become a Global and pollute the global namespace, or will it still be local only to that function?

Also, what about this example?:

Lua Code:
  1. M.GetData_CalculateListingValue = function(announce)
  2. local announce = (announce or false);
  3. -- doing stuff with announce
  4. end

Am I still required to prefix 'announce' with 'local' or should I not be doing that?

Thanks in advance for any help you guys could give with this.
__________________
__________________
Aanson is offline   Reply With Quote