Thread Tools Display Modes
11-18-10, 11:58 AM   #21
Dzib
A Deviate Faerie Dragon
Join Date: Nov 2010
Posts: 16
Doesnt work for me....
  Reply With Quote
11-18-10, 04:39 PM   #22
Xubera
A Cobalt Mageweaver
 
Xubera's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 207
post your .toc and your .lua file

you could just copy and paste it, but put the toc and lua in different [code] tags.
__________________
Chat Consolidate is the solution to any out of control trade chat. Ignore lines, throttle chat, consolidate posts!Follow the link to find out how!

▲ ▲ WoWInterface wont let me triforce >.>
  Reply With Quote
11-19-10, 07:54 PM   #23
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
You should have:

Code:
AddOns
  - NameOfAddOn
      - NameOfAddOn.toc
      - SomeFileName.lua
Remember that your folder name and TOC file name must match exactly. You can change "NameOfAddOn" to whatever you want, as long as it matches. The name of the Lua file does not matter, as long as you call it correctly in your TOC file.

Your TOC file should look like this:
Code:
## Interface: 40000
## Title: Name Of Addon

SomeFileName.lua
Your Lua file should look like this:
Code:
local channelsToProcess = {
	["GUILD"] = true,
	["SAY"] = true,
	["YELL"] = true,
}

local old = SendChatMessage

local new = function(message, channel, ...)
	if channel and channelsToProcess[channel] and message:len() > 0 and not message:match("^/") then
		message = message:replace("r", "rr"):replace("rrrr", "rr"):replace("R", "RR"):replace("RRRR", "RR")
	end
	old(message, channel, ...)
end

SendChatMessage = new

SLASH_RRR1 = "/rrr"

SlashCmdList.RRR = function()
	if SendChatMessage == new then
		SendChatMessage = old
		DEFAULT_CHAT_FRAME:AddMessage("RRR addon disabled.")
	else
		SendChatMessage = new
		DEFAULT_CHAT_FRAME:AddMessage("RRR addon enabled.")
	end
end
If that still doesn't work, install the addon BugSack and post the error message(s) being triggered.

Last edited by Phanx : 11-21-10 at 10:38 PM.
  Reply With Quote
11-20-10, 09:41 AM   #24
Dzib
A Deviate Faerie Dragon
Join Date: Nov 2010
Posts: 16
Got it:

Code:
local new = function(message, channel, ...)
	if channel and channelsToProcess[channel] and message:len() > 0 and not message:match("^/") then
		message = message:replace("r", "rr"):replace("rrrr", "rr"):replace("R", "RR"):replace("RRRR", "RR")
	end
	old(message, ...)
end
Thanks Bugsack and thanks to all of you

One last question: you think it would be possible to leave the text between () or ** unchanged? (for RP purpose )


Oups: there's a mistake when I hit enter to send a message:

1x SendChatMessage(): Unknown chat type:
<in C code>: ?
<in C code>: ?
Rrr\Rrr.lua:13: in function `SendChatMessage'
Interface\FrameXML\ChatFrame.lua:3763: in function `ChatEdit_SendText':
Interface\FrameXML\ChatFrame.lua:3775: in function `ChatEdit_OnEnterPressed':
<string>:"*:OnEnterPressed":1: in function <[string "*:OnEnterPressed"]:1>

Locals:
(*temporary) = "bonjourr"
(*temporary) = "Orc"

Last edited by Dzib : 11-20-10 at 09:51 AM.
  Reply With Quote
11-21-10, 12:47 AM   #25
Xubera
A Cobalt Mageweaver
 
Xubera's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 207
the 2nd temp value is "Orc"... is the language not called "Orcish"?
__________________
Chat Consolidate is the solution to any out of control trade chat. Ignore lines, throttle chat, consolidate posts!Follow the link to find out how!

▲ ▲ WoWInterface wont let me triforce >.>
  Reply With Quote
11-21-10, 03:27 AM   #26
Dzib
A Deviate Faerie Dragon
Join Date: Nov 2010
Posts: 16
Orc in french, Orcish in english
  Reply With Quote
11-21-10, 11:48 AM   #27
Xubera
A Cobalt Mageweaver
 
Xubera's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 207
oh i see

Code:
old(message, ...)

its suppose to be
old(message,channel,...)

its passing "Orc" as the chatType instead of channel.
__________________
Chat Consolidate is the solution to any out of control trade chat. Ignore lines, throttle chat, consolidate posts!Follow the link to find out how!

▲ ▲ WoWInterface wont let me triforce >.>
  Reply With Quote
11-21-10, 12:56 PM   #28
Dzib
A Deviate Faerie Dragon
Join Date: Nov 2010
Posts: 16
Yes, it works
Thanks a lot

you think it would be possible to leave the text between () or ** unchanged? (for RP purpose )
  Reply With Quote
11-21-10, 10:42 PM   #29
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Dzib View Post
you think it would be possible to leave the text between () or ** unchanged? (for RP purpose )
If your RP messages always begin with a ( or a *, then that's easy:

Code:
local new = function(message, channel, ...)
	if channel and channelsToProcess[channel] and message:len() > 0 and not message:match("^[%(*/]") then
		message = message:replace("r", "rr"):replace("rrrr", "rr"):replace("R", "RR"):replace("RRRR", "RR")
	end
	old(message, channel, ...)
end
If you're inserting () and ** wrapped text in the middle of messages, that's a bit trickier...
  Reply With Quote
11-21-10, 11:47 PM   #30
Ketho
A Pyroguard Emberseer
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,026
Originally Posted by Phanx View Post
If your RP messages always begin with a ( or a *, then that's easy:
Code:
not message:match("^[%(*/]")
If you're inserting () and ** wrapped text in the middle of messages, that's a bit trickier...
.. everytime I see one of those patterns, I get the feeling pattern matching is the craziest thing about Lua itself.
It looks like leetspeak to me but then for Lua gods ><
  Reply With Quote
11-22-10, 10:30 AM   #31
Xubera
A Cobalt Mageweaver
 
Xubera's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 207
don't fret, Regular Expressions was invented by the devil himself to torture anyone who looks at it. If you look directly at it, rumor has it you turn to stone.


anyways...
"^[%(%*/]"
lets break it down

^ is a character that says match this only if its at the BEGINNING of the string.
so "^a" would match apple, but not bear

"%" is an escape character, you usually see stuff like "%d" for integers or "%w" for alphanumerics. but some characters are special like () and *, and they need to be escaped to match them, %( and %* mean they are actually looking for those characters.
"%(hello%)" would match (hello) but not hello

"[ ]" are character sets, as in, the character must match only one of the characters in here. As earlier in this example [Rr] means that it must either be a "R" or a "r"
"[AB][pe][pa][lr]" would match "Appl" and "Bear"

so finally, we mush it all together
"^[%(%*/]" means if either ( or * or / are found at the beginning of the string, we found a match!
"/help" finds a match
"*me" finds a match
"() Hello" finds a match
"The equation is 12/4" does not find a match because the '/' was not at the beginning
__________________
Chat Consolidate is the solution to any out of control trade chat. Ignore lines, throttle chat, consolidate posts!Follow the link to find out how!

▲ ▲ WoWInterface wont let me triforce >.>
  Reply With Quote
11-22-10, 12:25 PM   #32
Dzib
A Deviate Faerie Dragon
Join Date: Nov 2010
Posts: 16
Originally Posted by Phanx View Post
If you're inserting () and ** wrapped text in the middle of messages, that's a bit trickier...
That was the idea but anyway, it's already very kind of you to help me so much, Thanks
  Reply With Quote
11-22-10, 03:23 PM   #33
Ketho
A Pyroguard Emberseer
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,026
Originally Posted by Xubera View Post
don't fret, Regular Expressions was invented by the devil himself to torture anyone who looks at it. If you look directly at it, rumor has it you turn to stone.

anyways...
"^[%(%*/]"
lets break it down
[...]
Thanks Xub, for the clear explanation on the pattern/regex! (n_n)
Still wondering though, why Phanx included the slash /, is it maybe also used for Out of Character messages?
  Reply With Quote
11-22-10, 04:41 PM   #34
Xubera
A Cobalt Mageweaver
 
Xubera's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 207
Originally Posted by Ketho View Post
Thanks Xub, for the clear explanation on the pattern/regex! (n_n)
Still wondering though, why Phanx included the slash /, is it maybe also used for Out of Character messages?
because it would turn

"/reload" into "/rreload" and then the chat frame would be like "no such command"

"/e turns around" still gets turned to "/e turrns arround" because when you type "/e " you dont send the "/e" it gets parsed out automatically while typing (it changes the font to emote color (orange by default) and changes the chatType to emote.
__________________
Chat Consolidate is the solution to any out of control trade chat. Ignore lines, throttle chat, consolidate posts!Follow the link to find out how!

▲ ▲ WoWInterface wont let me triforce >.>
  Reply With Quote
09-11-11, 12:57 AM   #35
Dzib
A Deviate Faerie Dragon
Join Date: Nov 2010
Posts: 16
Hi there

After quitting WoW for a long time, I went back a few weeks ago and wanted to use this little addon but it doesn't work anymore.... I don't really understand why. Here's the code used:

Code:
local channelsToProcess = {
	["GUILD"] = true,
	["SAY"] = true,
	["YELL"] = true,
}

local old = SendChatMessage

local new = function(message, channel, ...)
	if channel and channelsToProcess[channel] and message:len() > 0 and not message:match("^[%(*/]") then
		message = message:replace("r", "rr"):replace("rrrr", "rr"):replace("R", "RR"):replace("RRRR", "RR")
	end
	old(message, channel, ...)
end

SendChatMessage = new

SLASH_RRR1 = "/rrr"

SlashCmdList.RRR = function()
	if SendChatMessage == new then
		SendChatMessage = old
		DEFAULT_CHAT_FRAME:AddMessage("RRR addon disabled.")
	else
		SendChatMessage = new
		DEFAULT_CHAT_FRAME:AddMessage("RRR addon enabled.")
	end
end
And here's the error message bugsack gives me:
Code:
5x Teuto\teuto.lua:11: attempt to call method 'replace' (a nil value)
Interface\FrameXML\ChatFrame.lua:3864: in function `ChatEdit_SendText':
Interface\FrameXML\ChatFrame.lua:3876: in function `ChatEdit_OnEnterPressed':
<string>:"*:OnEnterPressed":1: in function <[string "*:OnEnterPressed"]:1>

nil

Locals:
editBox = ChatFrame1EditBox {
 0 = <userdata>
 at3matches = <table> {
 }
 focusLeft = ChatFrame1EditBoxFocusLeft {
 }
 focusRight = ChatFrame1EditBoxFocusRight {
 }
 chatFrame = ChatFrame1 {
 }
 addSpaceToAutoComplete = true
 lDrag = <unnamed> {
 }
 focusMid = ChatFrame1EditBoxFocusMid {
 }
 MAParent = "ChatEditBoxesMover"
 at3curMatch = 0
 text = "/"
 hookedByAceTab3 = true
 setText = 0
 header = ChatFrame1EditBoxHeader {
 }
 tabCompleteIndex = 1
 headerSuffix = ChatFrame1EditBoxHeaderSuffix {
 }
 frame = <unnamed> {
 }
 language = "Commun"
 rDrag = <unnamed> {
 }
}
addHistory = 1
type = "SAY"
text = "bonjour"
  Reply With Quote
09-11-11, 01:01 AM   #36
Nibelheim
local roygbi-
 
Nibelheim's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 1,600
The replace function was removed in 4.2, so someone will have to rewrite that particular line for you
  Reply With Quote
09-11-11, 03:49 AM   #37
Haleth
This Space For Rent
 
Haleth's Avatar
Featured
Join Date: Sep 2008
Posts: 1,173
I think it was replaced (derp) by gsub, though I'm not sure if it does exactly the same.
  Reply With Quote
09-11-11, 05:08 AM   #38
Dzib
A Deviate Faerie Dragon
Join Date: Nov 2010
Posts: 16
Works with gsub... thanks
  Reply With Quote
10-08-11, 01:11 AM   #39
Dzib
A Deviate Faerie Dragon
Join Date: Nov 2010
Posts: 16
I'd like to have the addon working also on a "RP" channel (which is number 7), so I've add

local channelsToProcess = {
["GUILD"] = true,
["SAY"] = true,
["YELL"] = true,
["RP"] = true,

but that doesn't work....
  Reply With Quote
10-08-11, 01:16 AM   #40
Nibelheim
local roygbi-
 
Nibelheim's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 1,600
Originally Posted by Dzib View Post
I'd like to have the addon working also on a "RP" channel (which is number 7), so I've add

local channelsToProcess = {
["GUILD"] = true,
["SAY"] = true,
["YELL"] = true,
["RP"] = true,

but that doesn't work....
It probably relies on proper channel names (GUILD, SAY, PARTY, etc), or channel numbers for non-recognized channels. Would have to look at how the addon does it.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Transforming an existing addon


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