Author Topic: Error (index "0") while using Leap Plugin  (Read 11406 times)

rand0m

  • Sr. Member
  • ****
  • Posts: 343
    • View Profile
Error (index "0") while using Leap Plugin
« 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.
« Last Edit: September 14, 2018, 01:40:20 AM by rand0m »

keilmillerjr

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1167
    • View Profile
Re: Error (index "0") while using Leap Plugin
« Reply #1 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.

rand0m

  • Sr. Member
  • ****
  • Posts: 343
    • View Profile
Re: Error (index "0") while using Leap Plugin
« Reply #2 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. 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 


keilmillerjr

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1167
    • View Profile
Re: Error (index "0") while using Leap Plugin
« Reply #3 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.

rand0m

  • Sr. Member
  • ****
  • Posts: 343
    • View Profile
Re: Error (index "0") while using Leap Plugin
« Reply #4 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.

keilmillerjr

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1167
    • View Profile
Re: Error (index "0") while using Leap Plugin
« Reply #5 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:
  • Filter name is NOT the exception specified
  • List size is zero

Based on the setup I created, in reference to the Menu display:
  • The only filter provided is „All"
  • The list size is 3

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?

keilmillerjr

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1167
    • View Profile
Re: Error (index "0") while using Leap Plugin
« Reply #6 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.

keilmillerjr

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1167
    • View Profile
Re: Error (index "0") while using Leap Plugin
« Reply #7 on: October 15, 2018, 07:12:01 PM »
    So I figured out something, I think. Correct me if I am wrong.

    • Display has a romlist.
    • A romlist can be an actual game or another display for nesting.
    • Displays can have multiple nesting of displays.
    • Usage of „displays menu“ sort of simulates a display comprised of actual displays where in_menu is marked as yes.
    • “displays menu“ has no filter or display name, so it will throw errors for an active layout/plugin/module that uses such normal features. Game title will be display name.

    Is there a way to determine if the current display is the „displays menu“? I don’t really like the idea of this menu being auto generated rather than following the normal display syntax and way of working. It would be nice if display name and filter names were just empty strings.

    Edit: Looking at layouts.md real quick, it seems as though I can determine if I am in the display menu, and make adjustments to my themes and plugins accordingly.

rand0m

  • Sr. Member
  • ****
  • Posts: 343
    • View Profile
Re: Error (index "0") while using Leap Plugin
« Reply #8 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.





keilmillerjr

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1167
    • View Profile
Re: Error (index "0") while using Leap Plugin
« Reply #9 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.

keilmillerjr

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1167
    • View Profile
Re: Error (index "0") while using Leap Plugin
« Reply #10 on: October 16, 2018, 07:15:29 PM »
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.

rand0m

  • Sr. Member
  • ****
  • Posts: 343
    • View Profile
Re: Error (index "0") while using Leap Plugin
« Reply #11 on: October 17, 2018, 09:23:00 AM »
Its working perfectly now, without any errors. Thanks for helping me out kielmillerjr :)   

rand0m

  • Sr. Member
  • ****
  • Posts: 343
    • View Profile
Re: Error (index "0") while using Leap Plugin
« Reply #12 on: January 24, 2019, 09:34:10 AM »
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.

I added a new item in displaymenu (Favorites, which was empty) and it seems that an empty list crashes Attract-Mode if opened when leap plugin is enabled. I've tested after disabling leap plugin and AM doesn't crash on opening Favorites plus If Favorite list is not empty Favorite operates as normal with Leap enabled . Seems like being on displaymenu forces leap to open the favorites list and since there are no items it crashes.

keilmillerjr

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1167
    • View Profile
Re: Error (index "0") while using Leap Plugin
« Reply #13 on: January 24, 2019, 11:01:50 AM »
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.

I added a new item in displaymenu (Favorites, which was empty) and it seems that an empty list crashes Attract-Mode if opened when leap plugin is enabled. I've tested after disabling leap plugin and AM doesn't crash on opening Favorites plus If Favorite list is not empty Favorite operates as normal with Leap enabled . Seems like being on displaymenu forces leap to open the favorites list and since there are no items it crashes.

I am not quite sure I understand.

I did a small rewrite and perhaps you can try it. I get a crash when I have no entries in the emulator romlist and try to change filters twice. Plugin isn’t perfect. I think I would have to add logic to see if there is entries in any romlist before sending a signal. Will look at later. If anyone want to help and submit a pull request, please do.

rand0m

  • Sr. Member
  • ****
  • Posts: 343
    • View Profile
Re: Error (index "0") while using Leap Plugin
« Reply #14 on: January 25, 2019, 09:31:34 AM »
I am not quite sure I understand.

I did a small rewrite and perhaps you can try it. I get a crash when I have no entries in the emulator romlist and try to change filters twice. Plugin isn’t perfect. I think I would have to add logic to see if there is entries in any romlist before sending a signal. Will look at later. If anyone want to help and submit a pull request, please do.

Before updated Plugin Sorry, I was not clear. Well I have added a new system "Favorites" in my platforms menu. All other items in my Platforms menu are populated except for favorites. Since favorite is not a "system" which leads to romlist but a romlist in it self, Leap plugin crashes AM when I try to open it. Whats puzzling is why it would try to open Favorites when its empty and not skip it which it does in case of other empty filters perhaps because its in platforms menu/ display menu? 

PS: Updated Plugin:: TY!! Updated plugin is working as intended and skipping empty filters including "Favorites". I'm much grateful!
« Last Edit: January 25, 2019, 11:51:21 AM by rand0m »