WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   General Authoring Discussion (https://www.wowinterface.com/forums/forumdisplay.php?f=20)
-   -   Making a custom channel sticky (https://www.wowinterface.com/forums/showthread.php?t=20394)

knifesideleft 02-02-09 12:44 PM

Making a custom channel sticky
 
I haven't programmed in 4 years (vb6 shouldn't be considered a language though) and I've started again trying to do my first mod mod for wow. This mod is for me and my friends and basicly it creates a sort of fake guild chat. It automaticly joins a channel and allows us to chat.

Anyway one really important feature that I'd like it to have is be set to sticky when used. I've tried ChatTypeInfo["Custom chan namestring here"]={sticky=1}; but it doesn't seem to work with anything other then say guild raid or whisper. Not only that it has the tendency to change the text colors. Am I just doing this wrong or is this not supported.

I figured I could just go around this somehow but I have yet to figure it out.
Unless theres a way to take the text from the msgbox after being entered then stopping it from being set and then send it to whereever I want via sendchatmessage

Akryn 02-02-09 01:42 PM

There are already addons that do this, although I can't think of the names off the top of my head. Look in the chat mods section here.

If you want to do it yourself, you probably need to hook ChatFrameEditBox's OnTextChanged and OnShow handlers, and actually modify its OnEnterPressed handler... (http://www.wowwiki.com/UIHANDLER_OnTextChanged)

i.e. ChatFrameEditBox:HookScript("OnTextChanged", myFunction)

etc...

To do the sticky channel stuff and also watch for: 1. other sticky channel changes so you can disable your override, 2. anything else starting with / so you can ignore it.

Sekrin 02-02-09 03:03 PM

Prat does this, amongst other things.

Cirk 02-02-09 04:02 PM

As does Chatmanager :)

knifesideleft 02-03-09 04:54 PM

bah
 
Alright so here is what ice come up with so far on a testing mod

Code:

function Dmodtest_OnLoad()
DEFAULT_CHAT_FRAME:AddMessage("Testing Mod Running")
ChatEditBox = getglobal("ChatFrameEditBox");
ChatEditBox:HookScript("OnShow", Dmodtest_OnShow)
ChatEditBox:HookScript("OnTextSet",Dmodtest_SetText)
end

function Dmodtest_OnShow()
ChatEditBox:SetText(" ")
SetEnabled = true
end

function Dmodtest_SetText()

DEFAULT_CHAT_FRAME:AddMessage("Set Text Activated")
if SetEnabled == true then
ChatEditBox:SetText("text")
SetEnabled = false
end

end


So basically every time I open the edit box it fires a blank settext to trigger what I really want in the box, and then it disables it from happening again

It works pretty good except for the Dmodtest_SetText being fired several times but its considerably better then when I had hooked OnTextChanged because it would go on firing forever. It would of worked well if I could have figured out how to unhook them after the text was posted but unless I did it wrong I guess UnHookScript doesn't exit. What I was originally going to do was Untextchanged then set text. Then use Gettext and if it matched what I wanted I would unhook it. Im just surprised it workes considering anything I used to program was just a bunch of functions with 100's of if statements and duplicate peices of code used over and over again that could of been set as just 1 function itself. I'm pretty sure that there's some obvious improvements sitting right in front of my eyes though.

Akryn 02-04-09 12:29 PM

If it's working for you so far then great. If you want to use OnTextChanged, you can't unhook the script, but you can set a variable and use an if statement in your function so that it doesn't do anything.

Kleo 02-04-09 02:40 PM

StickyChannel does that, without all the other functions.


All times are GMT -6. The time now is 06:16 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI