Author Topic: How to set a list filter from a plug-in script  (Read 3053 times)

millercentral

  • Jr. Member
  • **
  • Posts: 13
    • View Profile
How to set a list filter from a plug-in script
« on: September 03, 2020, 05:53:24 PM »
I'm a scripting novice, but I'm trying to programmatically set a filter on the current layout game list from a plug-in, and I'm hoping someone can offer a bit of advice.

If the filter is named "foo", it seems like I should do this (based on the find function described here: https://developer.electricimp.com/squirrel/array/find):

Code: [Select]
filter_id = fe.filters.find("foo");
if ( filter_id != null ) fe.list.filter_index = filter_id;

However, this doesn't seem to work, reporting "AN ERROR HAS OCCURED [the index 'find' does not exist]" in the console when run.

What is the right way to do this? Thanks in advance for any help!
« Last Edit: September 03, 2020, 06:17:11 PM by millercentral »

millercentral

  • Jr. Member
  • **
  • Posts: 13
    • View Profile
Re: How to set a list filter from a plug-in script
« Reply #1 on: September 03, 2020, 09:43:46 PM »
Update: I figured it out. This works:
Code: [Select]
filter_id = null;
for( local i = 0; i < fe.filters.len(); i++ ) {
    if ( fe.filters[i].name == "foo" ) filter_id = i;
}
if ( filter_id != null ) fe.list.filter_index = filter_id;