Thread Tools Display Modes
09-02-15, 09:02 PM   #1
Lesteryoung
A Black Drake
Join Date: Aug 2015
Posts: 81
Modifying an autorepair addon.

I was trying to modify an AutoRepair addon to be more simple since I don't want or need all the extra features like withdraw from guild bank, sell trash, or any savedvariables.

I looked around and there are a few like that on this site but some of them don't work and others don't display the amount in chat.

I have this code, and it does auto repair and the chat works, but I'd like the text to be yellow instead of white, and not to display text unless I actually repaired something.

Code:
local f = CreateFrame("Frame")
f:RegisterEvent("MERCHANT_SHOW")
f:SetScript("OnEvent", function()
	if CanMerchantRepair() then
		local cost = GetRepairAllCost()
		if GetMoney() > cost then
			RepairAllItems()
			DEFAULT_CHAT_FRAME:AddMessage("Repaired your items for"..cost)
		else
			DEFAULT_CHAT_FRAME:AddMessage("Not enough money to repair"..cost)
		end
	end
end)
  Reply With Quote
09-02-15, 11:28 PM   #2
Tosaido
A Fallenroot Satyr
 
Tosaido's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2015
Posts: 23
This should do the job, it will print something like this

Repaired your items for - 0g 25s 83c

if you are unawear of how "format" works check out http://wowwiki.wikia.com/wiki/API_format

Lua Code:
  1. local f = CreateFrame("Frame")
  2. f:RegisterEvent("MERCHANT_SHOW")
  3. f:SetScript("OnEvent", function()
  4.     local cost, canRepair = GetRepairAllCost()
  5.  
  6.     if canRepair and GetMoney() > cost then
  7.         local gold, silver, copper = floor(cost / 10000), mod(floor(cost / 100), 100), mod(floor(cost), 100)
  8.  
  9.         print(format("Repaired your items for - |cffffd700%dg|r |cffc7c7cf%ds|r |cffeda55f%dc|r", gold, silver, copper))
  10.  
  11.         RepairAllItems()
  12.     end
  13. end)
  Reply With Quote
09-03-15, 01:15 AM   #3
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,360
I seem to recall them putting a specialized function to do copper > coin formatting...
GetCoinTextureString
  Reply With Quote
09-03-15, 03:22 AM   #4
Lesteryoung
A Black Drake
Join Date: Aug 2015
Posts: 81
Is it possible to format the chat message to look like this?

http://i.imgur.com/ryDFeAK.jpg
Attached Thumbnails
Click image for larger version

Name:	ryDFeAK.jpg
Views:	208
Size:	18.6 KB
ID:	8635  
  Reply With Quote
09-03-15, 05:17 AM   #5
ObbleYeah
A Cobalt Mageweaver
AddOn Author - Click to view addons
Join Date: Sep 2008
Posts: 210
Lua Code:
  1. local f = CreateFrame'Frame'
  2. f:RegisterEvent'MERCHANT_SHOW'
  3. f:SetScript('OnEvent', function()
  4.     local cost, canRepair = GetRepairAllCost()
  5.     if canRepair and GetMoney() > cost then
  6.         local g, s, c = floor(cost/10000), mod(floor(cost/100), 100), mod(floor(cost), 100)
  7.         ChatFrame1:AddMessage(format('Your items have been repaired for %d Gold, %d Silver, & %d Copper', g, s, c), 1, .8, 0)
  8.         RepairAllItems()
  9.     end
  10. end)
  Reply With Quote
09-03-15, 04:35 PM   #6
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,360
GetCoinText
  Reply With Quote
09-08-15, 10:29 PM   #7
Lesteryoung
A Black Drake
Join Date: Aug 2015
Posts: 81
Originally Posted by Dridzt View Post
So how would you format it?

ChatFrame1:AddMessage(GetCoinText('Your items have been repaired for %d Gold, %d Silver, & %d Copper', ','), 1, 1, 0)?
  Reply With Quote
09-09-15, 02:49 AM   #8
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
Code:
local f = CreateFrame'Frame'
f:RegisterEvent'MERCHANT_SHOW'
f:SetScript('OnEvent', function()
    local cost, canRepair = GetRepairAllCost()
    if canRepair and GetMoney() > cost then
        ChatFrame1:AddMessage('Your items have been repaired for '..GetCoinText(cost, ", "), 1, .8, 0)
        RepairAllItems()
    end
end)
__________________
Grab your sword and fight the Horde!
  Reply With Quote
09-12-15, 03:17 PM   #9
kawe
A Cyclonian
 
kawe's Avatar
Join Date: Sep 2009
Posts: 40
format

Originally Posted by Lesteryoung View Post
So how would you format it?

ChatFrame1:AddMessage(GetCoinText('Your items have been repaired for %d Gold, %d Silver, & %d Copper', ','), 1, 1, 0)?
Lua Code:
  1. local f = CreateFrame("Frame")
  2. f:RegisterEvent("MERCHANT_SHOW")
  3. f:SetScript("OnEvent", function()
  4.     local cost, canRepair = GetRepairAllCost()
  5.     if canRepair and GetMoney() > cost then
  6.         print("Repaired your items for", GetCoinTextureString(cost));
  7.         RepairAllItems()
  8.     end
  9. end)

Last edited by kawe : 09-13-15 at 03:23 AM. Reason: snipped out the calculation, indeed pointless x)
  Reply With Quote
09-12-15, 07:40 PM   #10
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Originally Posted by kawe View Post
Lua Code:
  1. local f = CreateFrame("Frame")
  2. f:RegisterEvent("MERCHANT_SHOW")
  3. f:SetScript("OnEvent", function()
  4.     local cost, canRepair = GetRepairAllCost()
  5.     if canRepair and GetMoney() > cost then
  6.         local gold, silver, copper = floor(cost / 10000), mod(floor(cost / 100), 100), mod(floor(cost), 100)
  7.         print("Repaired your items for", GetCoinTextureString(cost));
  8.         RepairAllItems()
  9.     end
  10. end)
Line 6 is pointless above and does nothing except use resources.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
09-13-15, 03:22 AM   #11
kawe
A Cyclonian
 
kawe's Avatar
Join Date: Sep 2009
Posts: 40
Originally Posted by Seerah View Post
Line 6 is pointless above and does nothing except use resources.
ah well, i just wanted to paste the code for coin textures
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Modifying an autorepair addon.

Thread Tools
Display Modes

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