Attract-Mode Support Forum
Attract-Mode Support => Scripting => Topic started by: millercentral 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 (https://developer.electricimp.com/squirrel/array/find)):
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!
-
Update: I figured it out. This works:
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;