Thread Tools Display Modes
02-12-11, 04:27 AM   #1
Haleth
This Space For Rent
 
Haleth's Avatar
Featured
Join Date: Sep 2008
Posts: 1,173
Loot strings problem

Hello.

Sorry for creating an other topic in such a short period of time, but there's something that's been bugging me and I can't really figure out what's wrong with it.

These are defined in GlobalStrings.lua:

Code:
COPPER_AMOUNT = "%d Copper";
COPPER_AMOUNT_SYMBOL = "c";
COPPER_AMOUNT_TEXTURE = "%d\124TInterface\\MoneyFrame\\UI-CopperIcon:%d:%d:2:0\124t";

GOLD_AMOUNT = "%d Gold";
GOLD_AMOUNT_SYMBOL = "g";
GOLD_AMOUNT_TEXTURE = "%d\124TInterface\\MoneyFrame\\UI-GoldIcon:%d:%d:2:0\124t";

SILVER_AMOUNT = "%d Silver";
SILVER_AMOUNT_SYMBOL = "s";
SILVER_AMOUNT_TEXTURE = "%d\124TInterface\\MoneyFrame\\UI-SilverIcon:%d:%d:2:0\124t";
So to get coin icons to show in the chat frame rather than text, I simply did this:

Code:
COPPER_AMOUNT = COPPER_AMOUNT_TEXTURE
SILVER_AMOUNT = SILVER_AMOUNT_TEXTURE
GOLD_AMOUNT = GOLD_AMOUNT_TEXTURE
Or this:

Code:
COPPER_AMOUNT = "%d\124TInterface\\MoneyFrame\\UI-CopperIcon:%d:%d:2:0\124t"
SILVER_AMOUNT = "%d\124TInterface\\MoneyFrame\\UI-SilverIcon:%d:%d:2:0\124t"
GOLD_AMOUNT = "%d\124TInterface\\MoneyFrame\\UI-GoldIcon:%d:%d:2:0\124t"
The strange thing is that most of the time, it works just fine, but about 20% of the time it'll simply print the entire texture path, like this:



Anyone have an idea how I can prevent this?

Thanks.
  Reply With Quote
02-12-11, 07:04 AM   #2
Ailae
A Rage Talon Dragon Guard
 
Ailae's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2007
Posts: 318
Looks like there's a value passed to the format that it doesn't like, in your example it's the 6904978~ part, which probably makes the texture far too wide and as such it fails. Dunno where that number is coming from though.. guess overwriting GlobalStrings can have unexpected results. Maybe you can try setting the size-related %d's to 0.

Like this:
Code:
COPPER_AMOUNT = "%d\124TInterface\\MoneyFrame\\UI-CopperIcon:0:0:2:0\124t"
SILVER_AMOUNT = "%d\124TInterface\\MoneyFrame\\UI-SilverIcon:0:0:2:0\124t"
GOLD_AMOUNT = "%d\124TInterface\\MoneyFrame\\UI-GoldIcon:0:0:2:0\124t"
__________________
Oh, the simulated horror!
  Reply With Quote
02-12-11, 08:14 AM   #3
Haleth
This Space For Rent
 
Haleth's Avatar
Featured
Join Date: Sep 2008
Posts: 1,173
That worked, thank you.
  Reply With Quote
02-12-11, 01:04 PM   #4
Moxie
A Cobalt Mageweaver
 
Moxie's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 206
Thanks for this! Was looking for a way to do it for a long time.
__________________
"Someday we'll look back on this, laugh nervously and quickly change the subject."

"The truth is like sunlight: people used to think it was good for you."
  Reply With Quote
02-12-11, 09:24 PM   #5
Moxie
A Cobalt Mageweaver
 
Moxie's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 206
Something that's bugging me about this is, how would I remove the comma in the printed chat message?

Before, it printed as "+ 27g 34s 23c" but now it's printing as ""+ 27[gold icon], 34[silver icon], 23[copper icon]".

The snippets below are what I'm using (credit to both previous posters in this thread):

Code:
"|cffffffff+|r |cffffffff%s"
Code:
COPPER_AMOUNT = "%d\124TInterface\\MoneyFrame\\UI-CopperIcon:0:0:2:0\124t"
SILVER_AMOUNT = "%d\124TInterface\\MoneyFrame\\UI-SilverIcon:0:0:2:0\124t"
GOLD_AMOUNT = "%d\124TInterface\\MoneyFrame\\UI-GoldIcon:0:0:2:0\124t"
__________________
"Someday we'll look back on this, laugh nervously and quickly change the subject."

"The truth is like sunlight: people used to think it was good for you."
  Reply With Quote
02-12-11, 09:53 PM   #6
Nibelheim
local roygbi-
 
Nibelheim's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 1,600
Originally Posted by Decabah View Post
Something that's bugging me about this is, how would I remove the comma in the printed chat message?

Before, it printed as "+ 27g 34s 23c" but now it's printing as ""+ 27[gold icon], 34[silver icon], 23[copper icon]".

The snippets below are what I'm using (credit to both previous posters in this thread):

Code:
"|cffffffff+|r |cffffffff%s"
Code:
COPPER_AMOUNT = "%d\124TInterface\\MoneyFrame\\UI-CopperIcon:0:0:2:0\124t"
SILVER_AMOUNT = "%d\124TInterface\\MoneyFrame\\UI-SilverIcon:0:0:2:0\124t"
GOLD_AMOUNT = "%d\124TInterface\\MoneyFrame\\UI-GoldIcon:0:0:2:0\124t"
A gsub may work:
Code:
COPPER_AMOUNT = gsub(COPPER_AMOUNT, ",", "")
  Reply With Quote
02-12-11, 10:11 PM   #7
Moxie
A Cobalt Mageweaver
 
Moxie's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 206
That didn't seem to do anything. : (
__________________
"Someday we'll look back on this, laugh nervously and quickly change the subject."

"The truth is like sunlight: people used to think it was good for you."
  Reply With Quote
02-13-11, 05:32 PM   #8
Akkorian
A Flamescale Wyrmkin
 
Akkorian's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2010
Posts: 111
Hi Decabah,

There’s nothing in the code you posted that actually adds any text to the chat frame. If you’re doing that yourself, could you post the rest of the code? If you’re letting Blizzard do it, and you’re just changing the global strings, which global string are you overwriting with "|cffffffff+|r |cffffffff%s" ?
__________________
“Be humble, for you are made of earth. Be noble, for you are made of stars.”
  Reply With Quote
02-13-11, 05:36 PM   #9
Moxie
A Cobalt Mageweaver
 
Moxie's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 206
Pretty much every string involving looting that I need:

Code:
LOOT_ITEM = "%s |cffffffff+|r %s"
LOOT_ITEM_SELF = "|cffffffff+|r %s"
LOOT_ITEM_CREATED_SELF = "|cffffffff+|r %s"
LOOT_ITEM_PUSHED_SELF = "|cffffffff+|r %s"
LOOT_MONEY = "|cffffffff+|r |cffffffff%s"
YOU_LOOT_MONEY = "|cffffffff+|r |cffffffff%s"
CHAT_MSG_MONEY = "|cffffffff+|r |cffffffff%s"
LOOT_MONEY_SPLIT_GUILD = "|cffffffff+|r |cffffffff%s"
YOU_LOOT_MONEY_GUILD = "|cffffffff+|r |cffffffff%s"
CURRENCY_GAINED = "|cffffffff+|r |cffffffff%s""
LOOT_MONEY_SPLIT = "|cffffffff+|r |cffffffff%s"
ERR_QUEST_REWARD_ITEM_S = "|cffffffff+|r %s"
ERR_QUEST_REWARD_MONEY_S = "|cffffffff+|r |cffffffff%s"
__________________
"Someday we'll look back on this, laugh nervously and quickly change the subject."

"The truth is like sunlight: people used to think it was good for you."
  Reply With Quote
02-15-11, 10:23 AM   #10
Moxie
A Cobalt Mageweaver
 
Moxie's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 206
Still looking for a way to remove the comma from the loot string.

Did I go wrong somewhere with the code for the comma to all of a sudden be appearing, or is there something I need to add now that textures are in the equation?
__________________
"Someday we'll look back on this, laugh nervously and quickly change the subject."

"The truth is like sunlight: people used to think it was good for you."
  Reply With Quote
02-15-11, 11:29 AM   #11
Ailae
A Rage Talon Dragon Guard
 
Ailae's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2007
Posts: 318
Post

Well, the commas are there in the original message, so it's possible you can't remove them via changing the GlobalStrings.

I suppose you could do it via a chat-filter though, something like this (drycoded).

Code:
local function nocommas(self, event, msg, ...)
	local s = string.gsub(msg, ",", "")
	return false, s, ...
end
ChatFrame_AddMessageEventFilter("CHAT_MSG_MONEY", nocommas)
__________________
Oh, the simulated horror!
  Reply With Quote
02-15-11, 02:45 PM   #12
Moxie
A Cobalt Mageweaver
 
Moxie's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 206
That worked like a charm. I am once again comma-less. Thanks!
__________________
"Someday we'll look back on this, laugh nervously and quickly change the subject."

"The truth is like sunlight: people used to think it was good for you."
  Reply With Quote
02-16-11, 10:17 AM   #13
Moxie
A Cobalt Mageweaver
 
Moxie's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 206
One very last thing. The comma doesn't appear in the chat output when I loot gold from mobs and such, but appears everywhere else -- when I receive gold from quests, in the actual loot box itself, etc.

I've butchered the code provided above to resemble what I think should work but my knowledge is limited if that -- and I'm obviously missing something fundamental. Any help would be super!

Code:
local function nocommas(self, event, msg, ...)
	local s = string.gsub(msg, ",", "")
	return false, s, ...
end
ChatFrame_AddMessageEventFilter("CHAT_MSG_MONEY", nocommas)
ChatFrame_AddMessageEventFilter("LOOT_MONEY", nocommas)
ChatFrame_AddMessageEventFilter("YOU_LOOT_MONEY", nocommas)
ChatFrame_AddMessageEventFilter("LOOT_MONEY_SPLIT_GUILD", nocommas)
ChatFrame_AddMessageEventFilter("YOU_LOOT_MONEY_GUILD", nocommas)
ChatFrame_AddMessageEventFilter("CURRENCY_GAINED", nocommas)
ChatFrame_AddMessageEventFilter("LOOT_MONEY_SPLIT", nocommas)
ChatFrame_AddMessageEventFilter("ERR_QUEST_REWARD_ITEM_S", nocommas)
ChatFrame_AddMessageEventFilter("ERR_QUEST_REWARD_MONEY_S", nocommas)
__________________
"Someday we'll look back on this, laugh nervously and quickly change the subject."

"The truth is like sunlight: people used to think it was good for you."
  Reply With Quote
02-16-11, 11:55 AM   #14
Ailae
A Rage Talon Dragon Guard
 
Ailae's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2007
Posts: 318
You're kinda mixing apples with oranges there. CHAT_MSG_MONEY is an actual game event (like PLAYER_ENTERING_WORLD), while YOU_LOOT_MONEY is a constant containing formatting for that particular message.

As for your actual question, I'm guessing that there's a different event that fires when you earn money from quests (CHAT_MSG_SYSTEM perhaps?). This is probably pretty easy to fix, just using the code above with CHAT_MSG_SYSTEM would however remove all commas from system messages regardless if the message is about money or not.

As for the loot-frame (assuming you mean the little box that opens when looting a mob/object) that's a different story altogether and would probably require hooking the function that sets the monetary value. Although I don't see the commas myself in that scenario, only that there's a new line.

But I've been wrong many times before, so let's hope someone swoops in a tells you how to fix it in an easy way. :P
__________________
Oh, the simulated horror!
  Reply With Quote
02-16-11, 12:35 PM   #15
Moxie
A Cobalt Mageweaver
 
Moxie's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 206
I'm assuming that the phantom commas appearing had something to do with adding the textures for the coinage, since everything was comma-less before that (including the loot frame). I'm not sure why, though, because I'm not a coder, but that's literally all I'd changed before the commas started appearing.

I basically tried everything I could think of to fix it, hence the above butcher job.

I'll give your suggestion a whirl.
__________________
"Someday we'll look back on this, laugh nervously and quickly change the subject."

"The truth is like sunlight: people used to think it was good for you."
  Reply With Quote
02-16-11, 12:50 PM   #16
Ailae
A Rage Talon Dragon Guard
 
Ailae's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2007
Posts: 318
To be fair, it would probably be easier to just use a filter to convert the values into using textures instead of overwriting the global. That still wouldn't make the loot-box money use the textures but at least there wouldn't be any ghostly commas floating around.
__________________
Oh, the simulated horror!
  Reply With Quote
02-16-11, 01:03 PM   #17
Moxie
A Cobalt Mageweaver
 
Moxie's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 206
Well I've pretty much admitted -- and shown -- that I have no idea how to write that sort of involved code so .. how would I go about doing that?
__________________
"Someday we'll look back on this, laugh nervously and quickly change the subject."

"The truth is like sunlight: people used to think it was good for you."
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Loot strings problem


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off