Attract-Mode Support Forum

Attract-Mode Support => Scripting => Topic started by: rand0m on September 14, 2018, 01:37:58 AM

Title: Error (index "0") while using Leap Plugin
Post by: rand0m on September 14, 2018, 01:37:58 AM
Leap plugin is working as intended (skips empty filters except "All") but an error regarding index "0" is registered in the console window whenever AM is run. I am pasting the error log (on win 8.1):

----------------
AN ERROR HAS OCCURED [the index '0' does not exist]

CALLSTACK
*FUNCTION [logic()] D:\Attract-Mode\Attract-Mode v2.4.0 (x64)\plugins/Leap/plugin.nut line [26]
*FUNCTION [transitions()] D:\Attract-Mode\Attract-Mode v2.4.0 (x64)\plugins/Leap/plugin.nut line [22]

LOCALS
[direction] 2
[this] INSTANCE
[ttime] 0
[var] 2
[ttype] 0
[this] INSTANCE
Script Error in transition function: transitions - the index '0' does not exist

------------

This error message is repeated with different [ttype] and [direction] repeatedly while using AM. Lines pointed out in error in Leap/plugin.nut are:

Line22:    if ((ttype == Transition.StartLayout) || (ttype == Transition.ToNewSelection) || (ttype == Transition.ToNewList)) logic(var);
Line26:    if ((fe.filters[fe.list.filter_index].name != exception) && (fe.list.size == 0)) {

I am using Platform Categories (arcades, consoles etc) could that be the reason for this error? Can anyone please help in this regard or guide me toward a solution.
Title: Re: Error (index "0") while using Leap Plugin
Post by: keilmillerjr on September 14, 2018, 02:30:15 AM
I don’t use platform categories, nor do I understand how it works.

I have 3 displays (neogeo mvs, arcade, vs unisystem).

If you can walk me through setting something up, I’ll try to troubleshoot it for you. I think you might be correct.
Title: Re: Error (index "0") while using Leap Plugin
Post by: rand0m on September 14, 2018, 05:17:06 AM
Firstly thanks a lot for your plugins, they are really handy and have made the AM experience much better. This will be a long post so please bear with me  ;D.

Platforms are primarily used for nesting different systems in a tree like hierarchy for organization. A basic "tree" would be like:

> Platforms (Main Menu/ Root - this is the first screen)
                >Arcades
                             > MAME
                > Consoles
                             > Atari 2600
                > Computers
                             > DOS
                             > MSX
                > Handhelds
                             > GameBoy
                             > PSP etc

If you are for example on "MAME" and press back, you go back to Arcades, if you press back again you go back to Platforms (since its root if you press back again it will display the exit prompt). The main point being to create folders or nests in a hierarchy to keep displays organized. At first platform categories were usable only via using its plugin which is here http://forum.attractmode.org/index.php?topic=1804.0 (http://forum.attractmode.org/index.php?topic=1804.0). In recent versions this capability has been added in AM itself. I am now using the built-in function not the plugin.

We can categorize your collection for sake of testing in: 
Arcades > arcade
Console > neogeo mvs
Computers > unisystem


1. Create or rename a display layout called "Platforms Menu"

2. Create 3 empty romlists (in default location) named Arcades, Consoles and Computers. In place of roms add the (exact) name of displays.
For Arcades (Arcades.txt)
#Name;Title;Emulator;CloneOf;Year;Manufacturer;Category;Players;Rotation;Control;Status;DisplayCount;DisplayType;AltRomname;AltTitle;Extra;Buttons
arcade;arcade;@;;;;;;;;;;;;;;


For Consoles (Consoles.txt)
#Name;Title;Emulator;CloneOf;Year;Manufacturer;Category;Players;Rotation;Control;Status;DisplayCount;DisplayType;AltRomname;AltTitle;Extra;Buttons
neogeo mvs;neogeo mvs;@;;;;;;;;;;;;;;


For Computers (Computers.txt)
#Name;Title;Emulator;CloneOf;Year;Manufacturer;Category;Players;Rotation;Control;Status;DisplayCount;DisplayType;AltRomname;AltTitle;Extra;Buttons
unisystem;unisystem;@;;;;;;;;;;;;;;


3. Open attract.cfg and add Arcades, Consoles and Computers. Mine are as following (layout should be changed):
display   Arcades
   layout               Arcades Menu
   romlist              Arcades
   in_cycle             yes
   in_menu              yes
   filter               ALL
      sort_by              Title

display   Consoles
   layout               Consoles Menu
   romlist              Consoles
   in_cycle             yes
   in_menu              yes
   filter               ALL
      sort_by              Title

display   Computers
   layout               Computers Menu
   romlist              Computers
   in_cycle             yes
   in_menu              yes
   filter               ALL
      sort_by              Title


In my case all other displays are "in_menu = no" since they are nested into above mentioned displays (in_menu = yes would display them twice, once listed with platform categories then in the category display). So you may "change in_menu = no" for arcades, neogeo mvs and unisystem so they are only listed once.

3. Open AM go to
Settings > General > Start Up Mode = Displays Menu
Settings > Displays > 'Display Menu' options > Menu Prompt = Displays Menu
Settings > Displays > 'Display Menu' options > Menu Style/ layout = Platforms Menu

Thats it, you should have the following setup now:
Platforms
         > Arcades
                  > arcade
         > Consoles
                  > neogeo mvs
         > Computers
                  > unisystem 

Title: Re: Error (index "0") while using Leap Plugin
Post by: keilmillerjr on September 14, 2018, 08:45:35 AM
Thank you for your extremely detailed explanation. It was an addition that happened after a few years of already using attractmode and I missed the wagon. I will test this tonight or tomorrow and try to provide a solution for the plugin.
Title: Re: Error (index "0") while using Leap Plugin
Post by: rand0m on September 18, 2018, 11:02:16 AM
I hope platforms worked, due to differences between platform plugin and in-built functionality I might have missed something.
Title: Re: Error (index "0") while using Leap Plugin
Post by: keilmillerjr on September 18, 2018, 05:56:36 PM
I hope platforms worked, due to differences between platform plugin and in-built functionality I might have missed something.

Thank you for your detailed how to on platforms menu. I followed most of it, and have zero issues with the Leap plugin. Unfortunately, this means I can not provide you with a clear solution.

Here’s what I did:

Code: (attract.cfg) [Select]
display Menu
layout               mvscomplete
romlist              menu
in_cycle             yes
in_menu              yes
filter               All
sort_by              Title
Arcade, Neo-Geo MVS, Vs Unisystem displays have in_menu set to no.

Code: (menu.txt) [Select]
#Name;Title;Emulator;CloneOf;Year;Manufacturer;Category;Players;Rotation;Control;Status;DisplayCount;DisplayType;AltRomname;AltTitle;Extra;Buttons
Arcade;Arcade;@;;;;;;;;;;;;;;
Neo-Geo MVS;Neo-Geo MVS;@;;;;;;;;;;;;;;
VS UniSystem;VS UniSystem;@;;;;;;;;;;;;;;


The leap plugin is obviously enabled. Here is my terminal output upon testing.

Code: [Select]
Keils-iMac:MacOS keiljr$ /Applications/Attract.app/Contents/MacOS/launch.sh
Attract-Mode v2.4.0-9 (OSX, SFML 2.4 +SWF)
avcodec 58.18.100 / avformat 58.12.100 / swscale 5.1.100 / swresample 3.1.100

Config: /Users/keiljr/.attract/attract.cfg

*** Initializing display: 'Menu'
 - Loaded master romlist 'menu' in 0 ms (3 entries kept, 0 discarded)
 - Constructed 1 filters in 0 ms (3 comparisons)
 - Loaded layout: /Users/keiljr/.attract/layouts/mvscomplete/ (layout.nut)
 - Loaded layout: /Users/keiljr/.attract/layouts/mvscomplete/ (layout.nut)

*** Initializing display: 'Arcade'
 - Loaded master romlist 'mame' in 12 ms (583 entries kept, 114 discarded)
 - Constructed 10 filters in 1 ms (5830 comparisons)
 - Loaded layout: /Users/keiljr/.attract/layouts/Arcadeflow_23/ (layout.nut)

*** Initializing display: 'Menu'
 - Loaded master romlist 'menu' in 0 ms (3 entries kept, 0 discarded)
 - Constructed 1 filters in 0 ms (3 comparisons)
 - Loaded layout: /Users/keiljr/.attract/layouts/mvscomplete/ (layout.nut)

*** Initializing display: 'Neo-Geo MVS'
 - Loaded master romlist 'mame' in 7 ms (147 entries kept, 550 discarded)
 - Constructed 10 filters in 0 ms (1470 comparisons)

*** Initializing display: 'Menu'
 - Loaded master romlist 'menu' in 0 ms (3 entries kept, 0 discarded)
 - Constructed 1 filters in 0 ms (3 comparisons)

*** Initializing display: 'VS UniSystem'
 - Loaded master romlist 'mame' in 5 ms (27 entries kept, 670 discarded)
 - Constructed 10 filters in 0 ms (270 comparisons)
 - Loaded layout: /Users/keiljr/.attract/layouts/playchoicecomplete/ (layout.nut)

*** Initializing display: 'Menu'
 - Loaded master romlist 'menu' in 0 ms (3 entries kept, 0 discarded)
 - Constructed 1 filters in 0 ms (3 comparisons)
 - Loaded layout: /Users/keiljr/.attract/layouts/mvscomplete/ (layout.nut)
sh: exit_command: command not found
Keils-iMac:MacOS keiljr$


Logic in the leap plugin is very simple. There are two things that it considers, and BOTH must be satisfied:

Based on the setup I created, in reference to the Menu display:

I don’t fully understand the script error. Variables, particularly in reference to the only things with an index, are fe.filters[fe.list.filter_index].name and fe.list.size. Both should be a satisfied variable. Could you post your complete attract.cfg and associated menu romlists files for me?
Title: Re: Error (index "0") while using Leap Plugin
Post by: keilmillerjr on October 14, 2018, 07:15:11 PM
config menu -> startup mode -> show displays menu

Two options: menu and exit attract-mode. I have a shit load of errors within my layout and leap plugin referring to the index '0' does not exist. I didnt create this menu, so it has no “roms”. Not sure whats going on with my understanding of menus. Interesting. Will investigate further. I thought this menu stuff would be simpler.
Title: Re: Error (index "0") while using Leap Plugin
Post by: keilmillerjr on October 15, 2018, 07:12:01 PM
Title: Re: Error (index "0") while using Leap Plugin
Post by: rand0m on October 16, 2018, 12:16:24 AM
Spot on! I also think that since display menu lacks filters thats why leap plugin is showing the index 0 error. I first believed that when no filter is set, romlist defaults to "All" but that doesn't seem to be the case in display menu.

One way to tackle this might be to select specific lists where leap plugin is applied (or select where leap shouldn't apply). In most cases first two tiers of hierarchy "Display menu > Platforms" need to be excluded.




Title: Re: Error (index "0") while using Leap Plugin
Post by: keilmillerjr on October 16, 2018, 02:53:18 AM
Spot on! I also think that since display menu lacks filters thats why leap plugin is showing the index 0 error. I first believed that when no filter is set, romlist defaults to "All" but that doesn't seem to be the case in display menu.

One way to tackle this might be to select specific lists where leap plugin is applied (or select where leap shouldn't apply). In most cases first two tiers of hierarchy "Display menu > Platforms" need to be excluded.

In your case, Platforms is an actual display with filters. So it should be ok. It’s only a “Display Menu” that is the bugger. I can fix this. No worries. Sorry it took so long to get to this point, and thank you for the help.
Title: Re: Error (index "0") while using Leap Plugin
Post by: keilmillerjr on October 16, 2018, 07:15:29 PM
Quote from: https://github.com/keilmillerjr/leap-plugin/commit/a7edfddd07278c3ac5d238ed67adb3a037f2deea
Major code rewrite
* Resolved spelling and formatting errors
* Display menu no longer throws error
* Cleaned up code

@rand0m Please try it and let me know if it works for you as well. Thank you. Pushed a displays menu fix for mvscomplete theme. Will have to hit my other themes too. My themes need some overall updates as well.
Title: Re: Error (index "0") while using Leap Plugin
Post by: rand0m on October 17, 2018, 09:23:00 AM
Its working perfectly now, without any errors. Thanks for helping me out kielmillerjr :)