Thread Tools Display Modes
04/21/17, 07:59 AM   #1
Granpafishy
Join Date: Mar 2016
Posts: 18
[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.
  Reply With Quote
04/21/17, 11:38 AM   #2
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,913
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.
  Reply With Quote
04/21/17, 11:49 AM   #3
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,568
Originally Posted by Baertram View Post
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.
  Reply With Quote
04/23/17, 06:47 AM   #4
Granpafishy
Join Date: Mar 2016
Posts: 18
sirinsidiator, Yes that is exactly what I meant. Thank you for clearing that up.
  Reply With Quote
04/23/17, 07:28 AM   #5
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,568
You can download the addon here once it has been accepted.
  Reply With Quote
04/25/17, 12:08 AM   #6
manavortex
 
manavortex's Avatar
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 138
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
  Reply With Quote
04/25/17, 01:41 PM   #7
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,568
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.
  Reply With Quote
04/25/17, 01:45 PM   #8
manavortex
 
manavortex's Avatar
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 138
Err, it is working in so far as it turns the chatlog on when there's activity in one of the channels
  Reply With Quote
04/25/17, 02:05 PM   #9
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,568
Ah. I was confused by the method name. Toggle usually means it turns it on and off, but your method only turns it on.
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
  Reply With Quote
04/28/17, 12:27 PM   #10
Granpafishy
Join Date: Mar 2016
Posts: 18
sirinsidiator, thank you so much for making this.
  Reply With Quote

ESOUI » AddOns » AddOn Search/Requests » [Request] If/then script

Thread Tools
Display Modes

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