Welcome, Guest. Please login or register.
Did you miss your activation email?
January 28, 2022, 06:46:08 pm *

Login with username, password and session length
Pages: [1]
Print
Author Topic: Set filters macro  (Read 1610 times)
Dimur
Hero Member
Hero Member
*****
Posts: 695


View Profile
« on: October 10, 2018, 12:39:38 am »

This is a macro someone suggested that just runs through your Options Window and sets the filters to either show or hide based on 2 pre-configured sets.  The sets comprise of the filter settings I use on my main toon (main) and the filter settings I use on my alts (alt).  You can configure the filter settings any way you like and set another conditional to check for that.

Code:

#Event OptionsWindowFilters "#*#setfilters #1#"

|===============================================================================================
| SUB: Main
|===============================================================================================
Sub Main()
/echo Use the following syntax for executing one of the two pre-defined filter sets
/echo '/echo setfilters main' or '/echo setfilters alt'
:Primeloop
/doevents
/goto :Primeloop
/return

|===============================================================================================
| SUB: Event_OptionsWindowFilters
|===============================================================================================
Sub Event_OptionsWindowFilters(string Line, string Filterset)

|Set a variable named filterSet to hold the input value Filterset
/declare filterSet string local
/declare Proceed int local 0
/declare index int local

|Set up various Filterset values for preset filtering
/if (${Filterset.Equal[main]}) {
/noparse /varset filterSet ${index} == 1 || ${index} == 2 || ${index} == 3 || ${index} == 10 || ${index} == 11 || ${index} == 20 || ${index} == 23 || ${index} == 26 ||${index} == 27 || ${index} == 28 || ${index} == 33
/varset Proceed 1
} else /if (${Filterset.Equal[alt]}) {
/noparse /varset filterSet ${index} == 1 || ${index} == 2 || ${index} == 3 || ${index} == 10 || ${index} == 11 || ${index} == 23 || ${index} == 26 || ${index} == 27 || ${index} == 28
/varset Proceed 1
} else {
/echo You need to use one of the pre-defined filters to apply these changes
/echo By default, the only pre-defined filter sets are either main or alt
/return
}

|Loop through each index in the list of filter options
/for index 1 to ${Window[OptionsWindow].Child[OFP_FilterList].List[stun]}

|Select the index at the value of the iterator named index
/notify OptionsChatPage OFP_FilterList listselect ${Window[OptionsWindow].Child[OFP_FilterList].List[=${Window[OptionsWindow].Child[OFP_FilterList].List[${index}]}]}

|Assign show to the indexes I want the setting to be Show for, if value of index doesn't match then set it to Hide
|If you don't want to be spammed with the settings being applied, comment out the /bc commands, it was used for debugging
/if (${Proceed} == 1) {
/if (${filterSet}) {
/notify OptionsChatPage OFP_FilterComboBox listselect ${Window[OptionsWindow].Child[OFP_FilterComboBox].List[=Show]}

/bc Setting ${Window[OptionsWindow].Child[OFP_FilterList].List[${index}]} to Show
} else {
/notify OptionsChatPage OFP_FilterComboBox listselect ${Window[OptionsWindow].Child[OFP_FilterComboBox].List[=Hide]}

/bc Setting ${Window[OptionsWindow].Child[OFP_FilterList].List[${index}]} to Hide
}
|Add a small delay of .3 seconds so people can see the changes being applied but not be spammed too fast to read
|Feel free to increase or decrease this delay to a value that works for you
/delay 3
}

/next index

/echo Filter set ${Filterset} has been applied, exiting this macro

/end

To explain a bit how this works, here's a super rough ascii chart that shows what settings I have I my main filterset:


1.  Achievements>Show<    Show Mine OnlyHide
2.  Auctions>Show<Hide
3.  Bad Word>Show<Hide
4.  Bard SongsShow  Show Mine OnlyShow Group Only>Hide<
5.  Bard Songs on PetsShow>Hide<
6.  Damage Over TimeShow    Show MineOnly    Show Group Only  >Hide<
7.  Damage ShieldsShow>Hide<
8.  Fellowship MessagesShow>Hide<
9.  Focus EffecttsShow>Hide<
10. Group Chat>Show<Hide
11. Guild Chat>Show<Hide
12. Heal Over TimeShow>Hide<
13. Item SpeechShow>Hide<
14. Melee CriticalsShow>Hide<
15. Mercenary Messages    Show>Hide<
16. Missed MeShow>Hide<
17. My MissesShow>Hide<
18. My Pet HitsShow>Hide<
19. My Pet MissesShow>Hide<
20. NPC Spells>Show<Hide
21. Others' HitsShow>Hide<
22. Others' MissesShow>Hide<
23. Out of Character>Show<Hide
24. PC SpellsShow>Hide<
25. Pet SpellsShow>Hide<
26. PvP Messages>Show<Hide
27. Shouts>Show<Hide
28. Socials>Show<Hide
29. SpamShow>Hide<
30. Spell CriticalsShow>Hide<
31. Spell DamageShow>Hide<
32. Strikethrough MessagesShow>Hide<
33. Stun Messages>Show<Hide

Note that the only ones selected to show are 1, 2, 3, 10, 11, 20, 23, 26, 27, 28, and 33.  All other things are set to hide, including the spell damage, spell crits, melee crits.  If your pulls are smaller these probably won't lag your out that much, but the bigger pulls get, the more the incoming spam is going to wreak havoc on you so that's why they are filtered to hide for me.

In the macro, I loop through all of the different filters in the list and tell it the ones to set to show specifically and anything that I don't specify is automatically set to hide.  Main is set specifically in line 28 of the code assigning a string value to the variable filterSet

/noparse /varset filterSet

with the following conditional:

${index} == 1 || ${index} == 2 || ${index} == 3 || ${index} == 10 || ${index} == 11 || ${index} == 20 || ${index} == 23 || ${index} == 26 ||${index} == 27 || ${index} == 28 || ${index} == 33

${index} is the iterator that increments each time the loop executes, so it's 1 the first time through and 2 the next time through, etc.  This directly corresponds to the index on the filter list posted just above.  NPC Spells is index 20 on the list, so that's included, for example.  The double bar between each equality check is how you code an OR check.  So if index is equal to 1 OR index is equal to 2 OR index is equal to 3...until all the indices I want to set to show are listed.

To modify it for yourself, just add or subtract whatever filter in the list you want to set to show.  You can also use the show group only or show mine only attributes, but I never do so that's outside the scope of this post.  I'm happy to walk anyone through how to do it, I just don't think it's worth wasting time on here.

As with all raw code posted, to make it a macro you open up notepad or any other text editor, File > New and copy/paste the stuff in the code box.  File > Save As > File Name: setfilters.mac and Save As Type: All Files(*.*) and into your MQ2>Macros folder.


« Last Edit: October 10, 2018, 01:03:28 am by Dimur » Logged
Dimur
Hero Member
Hero Member
*****
Posts: 695


View Profile
« Reply #1 on: October 20, 2018, 01:34:46 pm »

I've updated this macro a bit, it now lets you customize your own filter sets and save them to an ini file, once saved to the ini you can also load a filter set from the ini file once it's saved there.  The idea behind it is to give people an option to dynamically alter their filter settings without having to do it manually.

To save a custom filter setting, set up the Filters on the options window to be how you want and then /echo savefilters NameToSaveAs.
To load a custom filter set from the Ini file, /echo loadfilters NameToLoad.

Say you want to set up a filter set that lets your casters to see only their crits, healers can do a set to see their heal over time amounts, etc. The first time you run the macro, it will look for the Ini file, if it's not found then one is created using your current filter settings and is saved to the character's name.

Code:
| Use this to create and load filter sets to and from an ini file.
| /echo savefilters NameToSaveAs to save a filter set named NameToSaveAs to Ini
| /echo loadfilters NameToLoad to load filter set named NameToLoad from Ini
| There are 2 pre-configured sets that are hard coded into the macro from when it was first created.
| These can be accessed with /echo setupfilters main or /echo setupfilters alt

#Event Help "[MQ2] setfilters help"
#Event OptionsWindowFilters "[MQ2] setupfilters #1#"
#Event SetNewFilterSet "[MQ2] savefilters #1#"
#Event SaveBlankSet "[MQ2] savefilters"
#Event ReadFromIni "[MQ2] loadfilters #1#"
#Event ReadBlankSet "[MQ2] loadfilters"

|===============================================================================================
| SUB: Main
|===============================================================================================
Sub Main()
/echo SetFilters macro is running...please /echo setfilters help for help information
/call CreateIni
:Primeloop
/doevents
/goto :Primeloop
/return

|===============================================================================================
| SUB: Event_Help
|===============================================================================================
Sub Event_Help
/bc Macro will build a default filter set if no Ini file is found.
/bc main and alt are 2 pre-configured sets that you can use without modifying the Ini
/bc /echo setupfilters main or /echo setupfilters alt to use these
/bc /echo savefilters NameToSaveAs to save the current filter settings to Ini
/bc /echo loadfilters NameToLoad to load a saved filter set from the Ini
/bc If you can't figure out that NameToSaveAs and NameToLoad can be any name you want, please delete this macro and never reference it again

|===============================================================================================
| SUB: CreateIni
|===============================================================================================
Sub CreateIni
/declare thisFilterSet string outer
/varset thisFilterSet ${Me}

/if (${Ini[SetFilters.ini].Length}) /return

/popup No Ini file found, creating a new one with ${Me} as default filter set

/call FilterSetLoop

/return

|===============================================================================================
| SUB: Event_OptionsWindowFilters
|===============================================================================================
Sub Event_OptionsWindowFilters(Line, Filterset)

|Set a variable named filterSet to hold the input value Filterset
/declare filterSet string local
/declare Proceed int local 0
/declare index int local

|Set up various Filterset values for preset filtering
/if (${Filterset.Equal[main]}) {
/noparse /varset filterSet ${index} == 1 || ${index} == 2 || ${index} == 3 || ${index} == 10 || ${index} == 11 || ${index} == 20 || ${index} == 23 || ${index} == 26 ||${index} == 27 || ${index} == 28 || ${index} == 33
/varset Proceed 1
} else /if (${Filterset.Equal[alt]}) {
/noparse /varset filterSet ${index} == 1 || ${index} == 2 || ${index} == 3 || ${index} == 10 || ${index} == 11 || ${index} == 23 || ${index} == 26 || ${index} == 27 || ${index} == 28
/varset Proceed 1
} else {
/echo You need to use one of the pre-defined filters to apply these changes
/echo By default, the only pre-defined filter sets are either main or alt
/return
}

|Loop through each index in the list of filter options
/for index 1 to ${Window[OptionsWindow].Child[OFP_FilterList].Items}

|Select the index at the value of the iterator named index
/notify OptionsChatPage OFP_FilterList listselect ${Window[OptionsWindow].Child[OFP_FilterList].List[=${Window[OptionsWindow].Child[OFP_FilterList].List[${index}]}]}

|Assign show to the indexes I want the setting to be Show for, if value of index doesn't match then set it to Hide
|If you don't want to be spammed with the settings being applied, comment out the /bc commands, it was used for debugging
/if (${Proceed} == 1) {
/if (${filterSet}) {
/notify OptionsChatPage OFP_FilterComboBox listselect ${Window[OptionsWindow].Child[OFP_FilterComboBox].List[=Show]}

/bc Setting ${Window[OptionsWindow].Child[OFP_FilterList].List[${index}]} to Show
} else {
/notify OptionsChatPage OFP_FilterComboBox listselect ${Window[OptionsWindow].Child[OFP_FilterComboBox].List[=Hide]}

/bc Setting ${Window[OptionsWindow].Child[OFP_FilterList].List[${index}]} to Hide
}
|Add a small delay of .3 seconds so people can see the changes being applied but not be spammed too fast to read
|Feel free to increase or decrease this delay to a value that works for you
/delay 3
}

/next index

/echo Filter set ${Filterset} has been applied, exiting this macro

/end

|=================================================================================================
| SUB: Event_SetNewFilterSet
|=================================================================================================
Sub Event_SetNewFilterSet(Line, SetName)

/varset thisFilterSet ${SetName}

/call FilterSetLoop
/return

|==================================================================================================
| SUB: SaveBlankSet
|==================================================================================================
Sub Event_SaveBlankSet
/echo This logic fails to execute unless a name parameter is entered after /echo savefilters
/return

|==================================================================================================
| SUB: FilterSetLoop
|==================================================================================================
Sub FilterSetLoop

/declare i int local

/for i 1 to ${Window[OptionsWindow].Child[OFP_FilterList].Items}
/notify OptionsChatPage OFP_FilterList listselect ${Window[OptionsWindow].Child[OFP_FilterList].List[=${Window[OptionsWindow].Child[OFP_FilterList].List[${i}]}]}
/echo Setting ${Window[OptionsWindow].Child[OFP_FilterList].List[${i}]} to: ${Window[OptionsChatPage].Child[OFP_FilterList].List[${i},2]}

/ini "SetFilters.ini" "${thisFilterSet}" "${i}. ${Window[OptionsWindow].Child[OFP_FilterList].List[${i}]}" "${Window[OptionsChatPage].Child[OFP_FilterList].List[${i},2]}"

/delay 2

/next i

/bc [ ${thisFilterSet} ] filter set has been created and/or updated in the SetFilters.ini file

/return

|==================================================================================================
| SUB: Event_ReadFromIni
|==================================================================================================
Sub Event_ReadFromIni(Line, FilterSetName)
/echo In ReadFromIni
/if (!${Defined[filterDescription]}) /declare filterDescriptions string outer
/declare i int local
/declare thisDescription string local
/declare descriptionSubstring string local
/declare filterSetting string local
/declare loadFilterSet string local ${FilterSetName}

/varset filterDescriptions ${Ini[SetFilters.ini,"${loadFilterSet}"]}
/echo Reading Filter Set ${loadFilterSet}

/for i 1 to ${Window[OptionsWindow].Child[OFP_FilterList].Items}

|Filter select by name logic, read it from filterDescription and select it
/varset thisDescription ${filterDescriptions.Arg[${i},|]}
/varset descriptionSubstring ${thisDescription.Mid[4,${Math.Calc[${thisDescription.Length}-3]}]}
/notify OptionsChatPage OFP_FilterList listselect ${Window[OptionsChatPage].Child[OFP_FilterList].List[=${descriptionSubstring}]}

|With the filter highlighted, read the value from ini and select it
/varset filterSetting ${Ini[SetFilters.ini,${loadFilterSet},${thisDescription}]}
/notify OptionsChatPage OFP_FilterComboBox listselect ${Window[OptionsChatPage].Child[OFP_FilterComboBox].List[=${filterSetting}]}

/delay 1

/next i

/bc [ ${loadFilterSet} ] filter settings have been applied.

/return

|==================================================================================================
| SUB: Event_ReadBlankSet
|==================================================================================================
Sub Event_ReadBlankSet
/echo This logic fails to execute unless a name parameter is entered after /echo loadfilters
/return
Logged
Pages: [1]
Print
Jump to:  

Recent

Stats

Members
Stats
  • Total Posts: 63207
  • Total Topics: 4903
  • Online Today: 65
  • Online Ever: 774
  • (November 20, 2020, 05:53:56 pm)
Users Online
Users: 1
Guests: 46
Total: 47
TinyPortal v1.0 beta 4 © Bloc