Thread Tools Display Modes
04/23/15, 07:25 PM   #1
stAjora
Join Date: Apr 2015
Posts: 20
Manipulate the Chat

I'm looking at the chat functions and I was wondering what the extra chat channels are for and how do you access/use them? http://wiki.esoui.com/Globals#MsgChannelType
CHAT_CHANNEL_USER_CHANNEL_1
CHAT_CHANNEL_USER_CHANNEL_2
CHAT_CHANNEL_USER_CHANNEL_3
etc

Is there a way for an add on to BLOCK a message from appearing? (I know there is probably a in game IGNORE) but for design purposes, what would blocking a message from a particular player look like in an add on?
  Reply With Quote
04/23/15, 07:59 PM   #2
Ayantir
 
Ayantir's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 1,019
They're for GM's when they talk to you (sometimes).
You cannot use them, because nobody listens on them.. except gm's.
And no, you can't use them to send messages, because we can't "join" "users channels".

--

If you want to block messages, you can use a library that I wrote, libChat2

Here you can register library with the parameter you're interested in.

ex :
Lua Code:
  1. -- Registering librairies
  2. local LC = LibStub('libChat-1.0')
  3. LC:registerName(deleteifnotafriend, "myAddon")
  4.  
  5. local function deleteifnotafriend(channelId, from)
  6.  
  7.     -- will delete all messages wich don't come from a friend
  8.     if (not IsFriend()) return false end
  9.    
  10.    -- if friend, just return from
  11.    return from
  12.  
  13. end

Last edited by Ayantir : 04/23/15 at 08:03 PM.
  Reply With Quote
04/23/15, 09:16 PM   #3
stAjora
Join Date: Apr 2015
Posts: 20
Your pChat add on is amazing!!

Also, thanks for the information!
  Reply With Quote
04/24/15, 01:16 PM   #4
stAjora
Join Date: Apr 2015
Posts: 20
Originally Posted by Ayantir View Post
They're for GM's when they talk to you (sometimes).
You cannot use them, because nobody listens on them.. except gm's.
And no, you can't use them to send messages, because we can't "join" "users channels".

--

If you want to block messages, you can use a library that I wrote, libChat2

Here you can register library with the parameter you're interested in.

ex :
Lua Code:
  1. -- Registering librairies
  2. local LC = LibStub('libChat-1.0')
  3. LC:registerName(deleteifnotafriend, "myAddon")
  4.  
  5. local function deleteifnotafriend(channelId, from)
  6.  
  7.     -- will delete all messages wich don't come from a friend
  8.     if (not IsFriend()) return false end
  9.    
  10.    -- if friend, just return from
  11.    return from
  12.  
  13. end

I got the library and example function registered and working but how do I specify that the effect should only take place in one type of chat window /zone /say /guild etc. ? Currently (the block function example) works for every chat window. What I'm trying to do is detect certain words in a /whisper message and stop them from being displayed.
  Reply With Quote
04/23/15, 09:58 PM   #5
stAjora
Join Date: Apr 2015
Posts: 20
Why do the CHAT_SYSTEM functions not work? I can get CHAT_SYSTEM:AddMessage() to work but things like CHAT_SYSTEM:Clear() and CHAT_SYSTEM:GetMaxHistoryLines() throw an error.

Also, I thought I was crazy but am I right in that there are a **** ton of functions, specifically ZO_ functions that have no documentation? I'm finding threads and a bunch of code using or referencing these functions but I have no idea how people are figuring out how to use them.
  Reply With Quote
04/23/15, 11:23 PM   #6
Ayantir
 
Ayantir's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 1,019
CHAT_SYSTEM:Clear() doesn't exists. :GetMaxHistoryLines() neither.


And yes, 99% of ZO functions are undocumented, each addon author after some releases get it's own expertise on its domain of coding, so we do like that, it's maybe not really good but making docs is not the favorite task of an unpaid developper.
  Reply With Quote
04/24/15, 09:56 AM   #7
Sasky
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 231
Originally Posted by stAjora View Post
I'm finding threads and a bunch of code using or referencing these functions but I have no idea how people are figuring out how to use them.
In some cases, it's looking at the source code[1]. There's a bit more documentation there, though some is just reading the code to see what it does. Or searching the source for the function to see how it's used. I've done that in particular to get something tightly integrated in the standard UI.

One thing to keep in mind is some of the stuff people utilize isn't so much API anymore as hooking into the ingame UI code. The main difference is (theoretically) using the API would be more stable and less likely to break.

[1] - Online at http://esodata.uesp.net/current/src/luadir.html . Also some links to ZIPs on these forums.
  Reply With Quote
04/24/15, 01:19 PM   #8
stAjora
Join Date: Apr 2015
Posts: 20
Originally Posted by Sasky View Post
In some cases, it's looking at the source code[1]. There's a bit more documentation there, though some is just reading the code to see what it does. Or searching the source for the function to see how it's used. I've done that in particular to get something tightly integrated in the standard UI.

One thing to keep in mind is some of the stuff people utilize isn't so much API anymore as hooking into the ingame UI code. The main difference is (theoretically) using the API would be more stable and less likely to break.

[1] - Online at http://esodata.uesp.net/current/src/luadir.html . Also some links to ZIPs on these forums.
Oh so ZO_ functions aren't even part of the API but functions that actually do **** with the actual game and people are just stealing them and using them in their add ons?
  Reply With Quote
04/24/15, 03:57 PM   #9
Ayantir
 
Ayantir's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 1,019
yes we do.
  Reply With Quote
04/25/15, 08:11 PM   #10
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
Originally Posted by stAjora View Post
Why do the CHAT_SYSTEM functions not work? I can get CHAT_SYSTEM:AddMessage() to work but things like CHAT_SYSTEM:Clear() and CHAT_SYSTEM:GetMaxHistoryLines() throw an error.

Also, I thought I was crazy but am I right in that there are a **** ton of functions, specifically ZO_ functions that have no documentation? I'm finding threads and a bunch of code using or referencing these functions but I have no idea how people are figuring out how to use them.
As Ayantir said those don't exist. I think what you wanted was:
Lua Code:
  1. CHAT_SYSTEM.primaryContainer.currentBuffer:Clear()
  2. CHAT_SYSTEM.primaryContainer.currentBuffer:GetMaxHistoryLines()

As for the functions, like they said we find them by reading the games lua files or using /zgoo.
This addon has a feature to search the games global table for global functions. I use it to find functions I might want to use or to just look up a function when I forget its name. As for figuring out how to use the function, once I find a function that sounds like what I want then I go to the lua files and search for it to see how they use it, what the parameters are, and what values it returns if any. Click4Info
  Reply With Quote
04/25/15, 10:46 PM   #11
stAjora
Join Date: Apr 2015
Posts: 20
Originally Posted by circonian View Post
As Ayantir said those don't exist. I think what you wanted was:
Lua Code:
  1. CHAT_SYSTEM.primaryContainer.currentBuffer:Clear()
  2. CHAT_SYSTEM.primaryContainer.currentBuffer:GetMaxHistoryLines()

As for the functions, like they said we find them by reading the games lua files or using /zgoo.
This addon has a feature to search the games global table for global functions. I use it to find functions I might want to use or to just look up a function when I forget its name. As for figuring out how to use the function, once I find a function that sounds like what I want then I go to the lua files and search for it to see how they use it, what the parameters are, and what values it returns if any. Click4Info

You're right those are what I was looking for but from the documentation (or rather the list of functions) I couldn't tell that I needed to dig down to currentBuffer. I loaded up zgoo and my god, I don't see how you can derive anything from that. I did /zgoo mouse over the chat window and I see the currentBuffer and the methods under it but I still am at a loss. I was reading through the source to pchat and X4D_CHAT and I still can't make heads or tails of what's going on in them. My coding skills must be hella weak... When you say you 'go to the lua files and search for it', if you meant the ESO client where are those stored? Mine might be different since I'm using the beta client.
  Reply With Quote
04/25/15, 11:55 PM   #12
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
Originally Posted by stAjora View Post
When you say you 'go to the lua files and search for it', if you meant the ESO client where are those stored? Mine might be different since I'm using the beta client.
Ayantir has posted a copy of the files, you can find them here: 2.0.4
It is near the top, look for the link: ESOUI 2.0.4 CURRENT Live
It is a link to a zip file that contains the lua files for the game.


Originally Posted by stAjora View Post
You're right those are what I was looking for but from the documentation (or rather the list of functions) I couldn't tell that I needed to dig down to currentBuffer.
Yeah, to be honest I'm not sure of the "correct" way to say this, my terminology may not be accurate, maybe someone else could explain it better, but this should hopefully give you an idea of whats going on.

That list of functions you were looking at on the wiki API page are global functions that reside directly in the main area of the global table (not inside of another table). You can call them directly without needing to have any other object.

No other function in the same "area/table" can have the same name.
I think of them like addresses to a location, no two objects (variables, functions, tables, exc..) can have the same address:
When I repeatedly use the word objects below, if it helps to understand, they are all tables in this example.
Lua Code:
  1. -- Everything resides in the global table, nothing exists outside of it:
  2. globalTable = {
  3. -- This is directly in the global table
  4. -- These are the funcitons listed one the wiki API page:
  5.    Clear = ...,
  6. -- We can't have another Clear function here, it would just overwrite the first one
  7. -- because its in the same table as the one above (directly in the main table)
  8.    Clear = ...,
  9.  
  10. -- but we could do this:
  11.    CHAT_SYSTEM = {
  12.       primaryContainer = {
  13.          currentBuffer = {
  14. -- Because this one, although technically is still inside of the global table
  15. -- is also inside of the CHAT_SYSTEM, primaryContainer, & currentBuffer
  16. -- tables...it has a different address/location
  17.             Clear = ...,
  18.          ...
  19.          },
  20.       ...
  21.       },
  22.    ...
  23.    },
  24. }

In order to clear the chat buffer, you have to have the currentBuffer object and you call "it's" Clear() function, which is contained in the buffer object.
If you just called Clear() the game would look for it directly in the global table and if found it would call that one, but it would NOT look inside of any other tables so it would not see the one inside of the CHAT_SYSTEM.primaryContainer.currentBuffer table.
If we want to call that clear function we need to...give it that address/location so it knows which Clear() function we are wanting to call.

Using:
Lua Code:
  1. CHAT_SYSTEM.primaryContainer.currentBuffer:Clear()
Which basically says, go into the CHAT_SYSTEM object and get the object called primaryContainer, then inside of that get the currentBuffer object , then call the Clear() function that is inside that currentBuffer object.

So in short it tells the game to call the Clear() function that belongs to the CHAT_SYSTEM.primaryContainer.currentBuffer object. It also passes that current buffer object to the Clear() function as the first parameter (thats what the : means before the function name).


Originally Posted by stAjora View Post
I loaded up zgoo and my god, I don't see how you can derive anything from that. I did /zgoo mouse over the chat window and I see the currentBuffer and the methods under it but I still am at a loss.
Basically it comes down to understanding the structure that I just..."attempted" to poorly explain above.
When you do /zgoo mouse it just shows all of the tables that belong to the "object" you had your mouse over, often with more & more tables nested inside of it. You just have to search around and try to find what your looking for sometimes.

Last edited by circonian : 04/25/15 at 11:58 PM.
  Reply With Quote
04/27/15, 01:05 PM   #13
stAjora
Join Date: Apr 2015
Posts: 20
I read up on Lua's scoping and I'm pretty sure I understand it. I see the function that allowed us to send chat messages is now protected, is that what all the bot spammers were using? It kind of seems silly to block it, writing a spam bot to send keypresses to the client as a 3rd party tool is still an option.

I'm currently reading through sharedchatsystem.lua, thanks for linking me to the files. I'm trying to figure out how to read the contents of the chat buffer so I can look for specific strings but I'm not seeing where its stored or how to access it.

Can someone explain what the "..." us all about? I'm seeing it a lot, mostly as new(...). Also "#", what does this do?
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Manipulate the Chat


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