Transforming an existing addon
Hi
I'd like to make an addon which add the letters "rr" after each "r" detected in the chat (like someone who's rolling r's) Being a total newbie in programming, I took an addon which adds an "o" after every consonant and tried to modify it. Here's the original code: Code:
function doRoevar(str) Code:
function doRoevar(str) Thanks |
That can't be all the code, in order for us to help you could you provide the full code.
|
Sorry, here's the full code:
Code:
function InitRoevar() |
Sorry to go off-topic, but I really laughed that someone made an addon for 'Rövarspråket'.
http://en.wikipedia.org/wiki/Rövarspråket Guess we need one for Pig Latin now too. :) |
Quote:
To the OP I vaguely remember someone else having a issue with a chat type program for role playing. I think they had to add a function for each of the other types of chat RAID PARTY. I think you need to find the index of the trade channel first in order to do this. I will play with the code later. |
If all you want to do is double the letter "r", then your code is way more complicated than it needs to be. Try this:
Code:
local old = SendChatMessage |
Can't
Code:
message = message:replace("r", "rr"):replace("rrrr", "rr"):replace("R" "RR"):replace("RRRR", "RR") Code:
message = message:replace("[Rr]", "rr"):replace("[Rr][Rr][Rr][Rr]", "rr") |
Only if you don't care about the resulting case. Your pattern would change "CARE" to "CArrE" which isn't really a desirable result. I guess you could do:
Code:
message = message:gsub("([Rr])", "%1%1"):gsub("([Rr])([Rr])([Rr])([Rr])", "%1%2") |
Quote:
Thanks for the responses.... what about applying the modification only if I'm talking in the guild/say/yell channel? Is it possible? |
Code:
local old = SendChatMessage |
Thanks, I think I tried something like that but it didn't worked... I'll try your solution as soon as the servers will be online :)
So, here's the full code modified with another addon name, but it doesn't work, seems it doesn't load cos when I type /rrr nothing happens (and of course the text I type in /say isn't modified) Code:
function InitRrr() |
well the main concept behind this is that "new" is actually now SendChatMessage() so "new" takes 4 parameteres.
Message, chatType, language, and channel i made an error in judgement when i named my variable channel, i switched the two around in my head when iwrote that last night. either way its important to know that "channel" in the above code accepts the 2nd parameter "chatType" when the snippet was originally written, we were never gonna use the last 3 parameters, so the vararg (...) was used, we could also write it like this Code:
local new = function(message, chatType, ...) |
Well, you defined /doubler as your slash command, not /rrr. ;)
|
Also, you don't need this:
Code:
function InitRrr() |
Quote:
|
Quote:
Code:
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ |
But you don't have a function called rrrToggle - aren't you getting a nil error there?
|
You don't get an error by setting something to nil; only if you then try to do something with the nil something.
But, nothing in your InitRrr function has any purpose, so you should just get rid of it (and get rid of the similarly useless XML file). |
But I need an xml file, no? so what should be in it?
|
actually, you dont need an XML fille, you dont even need a frame. You dont listen for any events and you dont need any sort of timer. The only thing you need is a .toc and that .lua that phanx posted and it works.
|
All times are GMT -6. The time now is 10:13 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI