Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

index 0 error in filter magic string #547

Open
estivalet opened this Issue Mar 14, 2019 · 18 comments

Comments

Projects
None yet
4 participants
@estivalet
Copy link

estivalet commented Mar 14, 2019

Hi, I was writing a layout for me and in AM 2.4 it works ok, but in AM 2.5.1 it is thowing an error in a line with the command below

local text = fe.filters[fe.list.filter_index].name;

String error in magic string function: filter - the index '0' does not exist

The code of the layout is exact the same and it works in AM 2.4. Has anything changed in AM2.5.1?

I am using Windows version.

Is this a bug or can I fix the code? Thanks

@oomek

This comment has been minimized.

Copy link
Collaborator

oomek commented Mar 14, 2019

Does the following code work for you?

function filter() {
	return fe.filters[fe.list.filter_index].name;
}
fe.add_text("[!filter]", 0, 0, 400, 50 )

Could you post a minimalistic example of the code that throws this error?

@estivalet

This comment has been minimized.

Copy link
Author

estivalet commented Mar 14, 2019

yes the code is very similar:

local listtext = fe.add_text( "[!filter] Games", 33, 45, 240, 21);
listtext.set_rgb( 211, 250, 255 );
listtext.font="Ticketbook W01 Bold";
listtext.align = Align.Centre;

// Change filter name to upper case
 function filter(){
	local text = fe.filters[fe.list.filter_index].name;

		return text.toupper();
 }

it fails in local text = fe.filters[fe.list.filter_index].name;

@oomek

This comment has been minimized.

Copy link
Collaborator

oomek commented Mar 14, 2019

The code you have posted do not throw any errors. I believe it was fixed recently in the following commit 0b98531

Would you please try it in the daily build http://forum.attractmode.org/index.php?topic=2324.0

@estivalet

This comment has been minimized.

Copy link
Author

estivalet commented Mar 14, 2019

@oomek I've run attract-64console_03_14_2019.exe and the same error is thrown

@estivalet

This comment has been minimized.

Copy link
Author

estivalet commented Mar 14, 2019

I am also using the Platforms plugin don't know if it is related

@estivalet

This comment has been minimized.

Copy link
Author

estivalet commented Mar 14, 2019

this is the setup I am using in my attract.cfg

general
	language             en
	exit_command         
	default_font         arial
	font_path            %SYSTEMROOT%/Fonts/
	screen_saver_timeout 600
	displays_menu_exit   no
	hide_brackets        no
	startup_mode         displays_menu
	confirm_favourites   yes
	confirm_exit         yes
	mouse_threshold      10
	joystick_threshold   75
	window_mode          default
	filter_wrap_mode     default
	track_usage          yes
	multiple_monitors    yes
	smooth_images        yes
	accelerate_selection yes
	selection_speed_ms   40
	scrape_snaps         yes
	scrape_marquees      yes
	scrape_flyers        yes
	scrape_wheels        yes
	scrape_fanart        no
	scrape_videos        no
	scrape_overview      no
	hide_console         no
	video_decoder        software
	menu_prompt          Displays Menu
	menu_layout          Pandoras Box
         


display	Consoles
    layout               Pandoras Box
    romlist              Consoles
    in_cycle             no
    in_menu              yes
    global_filter
            rule                 FileIsAvailable equals 1
    filter               All
    filter               Favourites
            rule                 Favourite equals 1


display	Atari 2600
    layout               Pandoras Box
    romlist              Atari 2600
    in_cycle             no
    in_menu              no
    global_filter
            rule                 FileIsAvailable equals 1
    filter               All
    filter               Favourites
            rule                 Favourite equals 1

@estivalet

This comment has been minimized.

Copy link
Author

estivalet commented Mar 14, 2019

and my Consoles.txt:

Atari 2600;Atari 2600;@;;;;;;;;;0;;;;;

and the Atari 2600 contains the normal romlist games for Atari

@zpaolo11x

This comment has been minimized.

Copy link

zpaolo11x commented Mar 14, 2019

I had the same issue recently when I checked the latest build by Oomek, that happened because I’m that installation I had no filters defined. Check if installing 2.5.1 you created at least an ALL filter. I solved this first checking if fe.filters.len() > 0

@oomek

This comment has been minimized.

Copy link
Collaborator

oomek commented Mar 14, 2019

Maybe your index is out of range. Are you sure you have at least 1 filter defined?
If this is the case the array index might be going out of range.
you can try adding one line in your function.
if( fe.filters.len() == 0 ) return ""

@estivalet

This comment has been minimized.

Copy link
Author

estivalet commented Mar 14, 2019

I think maybe there's something related to the config "startup_mode displays_menu"... not sure... if I change it to "startup_mode default" attract mode loads up but does not show anything:

*** Initializing display: 'Consoles'
 - Loaded master romlist 'Consoles' in 0 ms (0 entries kept, 1 discarded)
 - Constructed 2 filters in 0 ms (0 comparisons)
 - Loaded layout: C:\Temp\attract\layouts/Pandoras Box/ (layout.nut)
Error getting emulator info for launch
@estivalet

This comment has been minimized.

Copy link
Author

estivalet commented Mar 14, 2019

@zpaolo11x but I have defined filters for the top category Consoles and also for the system Atari 2600. See my attract.cfg above

@randombyt

This comment has been minimized.

Copy link

randombyt commented Mar 14, 2019

Which is the line with error in last_run?
This > local listtext = fe.add_text( "[!filter] Games", 33, 45, 240, 21);
or This > local text = fe.filters[fe.list.filter_index].name;

If the first line try this >
local listtext = fe.add_text( "[!filter]" + "Games", 33, 45, 240, 21);

@randombyt

This comment has been minimized.

Copy link

randombyt commented Mar 14, 2019

Platforms plugin functions were added in base AM.

@estivalet

This comment has been minimized.

Copy link
Author

estivalet commented Mar 14, 2019

no the error is in this line -> local text = fe.filters[fe.list.filter_index].name;

And about the platforms plugin do I need to enable it somewhere or it is built in attract mode and using a romlist like Atari 2600;Atari 2600;@;;;;;;;;;0;;;;; it detects?

@randombyt

This comment has been minimized.

Copy link

randombyt commented Mar 14, 2019

its built-in you don't need the "0" but do need to use "@" for emulator. The romlist example will become
Atari 2600;Atari 2600;@;;;;;;;;;;;;;; and will work without anything else

@estivalet

This comment has been minimized.

Copy link
Author

estivalet commented Mar 14, 2019

found the issue... for some reason if I remove the filter

    global_filter
            rule                 FileIsAvailable equals 1

from the Platform it works (in this example Consoles). If I put it back the error is thrown

@estivalet estivalet closed this Mar 14, 2019

@estivalet

This comment has been minimized.

Copy link
Author

estivalet commented Mar 14, 2019

also another thing is that if I put all displays with the same layout and also the menu_layout with this same layout the bug happens... maybe someone should look if possible

@estivalet estivalet reopened this Mar 14, 2019

@estivalet

This comment has been minimized.

Copy link
Author

estivalet commented Mar 14, 2019

the problem persists when using the same layout for all displays including the same display for menu_layout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.