ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   AddOn Search/Requests (https://www.esoui.com/forums/forumdisplay.php?f=165)
-   -   [Request] If/then script (https://www.esoui.com/forums/showthread.php?t=6990)

Granpafishy 04/21/17 07:59 AM

[Request] If/then script
 
I don't think this needs to be a full addon, but there's no reason it couldn't be.
I would like and script to use in Autorun or a seperate addon, that checks to see of the /chatlog command is active, and if not, runs it.

That's it.

Baertram 04/21/17 11:38 AM

AddOns are not allowed to automatically run chat commands. They can put the text for you into the chatbox and you just need to press the RETURN key, but they cannot do it automatically.

sirinsidiator 04/21/17 11:49 AM

Quote:

Originally Posted by Baertram (Post 30661)
AddOns are not allowed to automatically run chat commands. They can put the text for you into the chatbox and you just need to press the RETURN key, but they cannot do it automatically.

I think he means the chatlog feature in general, not the slashcommand.
I started making something like that a while ago, but haven't finished it yet. Maybe I'll upload it this weekend.

Granpafishy 04/23/17 06:47 AM

sirinsidiator, Yes that is exactly what I meant. Thank you for clearing that up.

sirinsidiator 04/23/17 07:28 AM

You can download the addon here once it has been accepted.

manavortex 04/25/17 12:08 AM

I've tweaked my personal ChatLogger Addon like this:

Lua Code:
  1. local playerInCyro = false
  2.  
  3. local listenInTheseChannels = {
  4.     [CHAT_CHANNEL_EMOTE] = true,
  5.     [CHAT_CHANNEL_GUILD_1] = true,
  6.     [CHAT_CHANNEL_SAY] = true,
  7.     [CHAT_CHANNEL_PARTY] = true,
  8.     [CHAT_CHANNEL_WHISPER] = true,
  9.     [CHAT_CHANNEL_WHISPER_SENT] = true,
  10. }
  11.  
  12. local function toggle(value)
  13.     local saveData = ChatLogger_Data[GetDisplayName()] or {}
  14.     ChatLogger_Data[GetDisplayName()] = saveData
  15.     if saveData.enabled == value then return end
  16.     SetChatLogEnabled(value)
  17.     saveData.enabled = value
  18. end
  19.  
  20. local function enable()
  21.    toggle(true)
  22. end
  23.  
  24. local function disable()
  25.     toggle(false)
  26. end
  27.  
  28. local function ChatLogger_ToggleChatLog(eventCode, channelType, fromName, text, isCustomerService, fromDisplayName)
  29.     if listenInTheseChannels[channelType] then
  30.         if not playerInCyro and (channelType == CHAT_CHANNEL_SAY) then
  31.             enable()
  32.         end
  33.     end
  34. end
  35.  
  36. local function ChatLogger_OnZoneChanged(eventCode, zoneName, subZoneName, newSubzone, zoneId, subZoneId)
  37.     playerInCyro = zoneName == "Cyrodiil"
  38. end
  39.  
  40. EVENT_MANAGER:RegisterForEvent("ChatLogger", EVENT_ZONE_CHANGED, ChatLogger_OnZoneChanged)
  41. EVENT_MANAGER:RegisterForEvent("ChatLogger", EVENT_CHAT_MESSAGE_CHANNEL, ChatLogger_ToggleChatLog)


You can simply run SetChatLogEnabled(true) via binder though. No need for an if-statement.

Also, if you separate the lines by ; you can make inline statements: If (condition) then do this; else do that; end

Hope that helps you :)

sirinsidiator 04/25/17 01:41 PM

Is your "filter" really working?
As far as I am aware the chat log automatically logs all channels. I don't think you can influence that from the addon side, as the logging is done in C and most likely before you see the message in Lua. I am also not sure if shutting off the log in cyrodiil is desireable, as it would again affect all channels.

p.s. You do not need ; when you put if/else statements into one line:
Lua Code:
  1. if something then doThis() else doThat() end
works the same with or without semicolon. ;)

manavortex 04/25/17 01:45 PM

Err, it is working in so far as it turns the chatlog on when there's activity in one of the channels :)

sirinsidiator 04/25/17 02:05 PM

Ah. I was confused by the method name. Toggle usually means it turns it on and off, but your method only turns it on. :D
Did you test if the first message that triggers enable() shows up in the log?

There also seems to be a small mistake in your code. You ignore the values in listenInTheseChannels and only enable the chatlog when channelType == CHAT_CHANNEL_SAY.
Lua Code:
  1. local function ChatLogger_ToggleChatLog(eventCode, channelType, fromName, text, isCustomerService, fromDisplayName)
  2.     if not playerInCyro and listenInTheseChannels[channelType]  then
  3.             enable()
  4.     end
  5. end

I am still not sure why this would be preferable to just turning the log on when the player logs in. :P

Granpafishy 04/28/17 12:27 PM

sirinsidiator, thank you so much for making this.


All times are GMT -6. The time now is 10:14 AM.

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