Jump to content

All my products and services are free. All my costs are met by donations I receive from my users. If you enjoy using any of my products, please donate to support me. Thank you for your support. Tom Speirs

Patreon

[OBSOLETE] [GUIDE] Automated Custom Lists


scutters

Recommended Posts

********** EDIT - This functionality now superseded by PinballX v4.50 Filtered Lists - https://www.gameex.info/forums/topic/25021-news-pinballx-450/   ************

 

 

I've been aware of custom lists for a while but have never really used them because of the work required to create them initially and then to keep them maintained after adding tables - i'm too lazy for that and i wanted a 'set and forget' solution where i could quickly select EM, SS or Original tables from my Visual Pinball X system without the maintenance (i had actually considered splitting them out into their own systems but again was put off by the work required, i.e. the same lazy reason).

So, here's what i came up with as a method to create and maintain the custom lists i wanted;

  1. Downloaded xml starlet from http://xmlstar.sourceforge.net/ and copy the xml.exe onto the cab (i have attached the file in case of link changes, but the attached version probably won't be the latest)
  2. Made sure that my Visual Pinball X xml file had the Type field correctly populated for all non Original tables (i leave blank for Originals) in Game Manager
  3. Backed up my current database xml files (just in case i screwed up somewhere!)
  4. Created a batch file to call xml.exe to create my custom lists. The batch file is just a notepad file saved with a .bat extension rather than .txt. The batch file contents are; 
    REM set to folder where you copied xml.exe
    set XMLexePATH="c:\CustomScripts"
    cd %XMLexePATH%
    
    REM set database xml source and output names
    set SOURCEXML1="c:\pinballx\Databases\Visual Pinball X\Visual Pinball X.xml"
    set OUTPUTXML1="c:\pinballx\Databases\Visual Pinball X\VPX Solid State.xml"
    
    REM create outputxml file
    ECHO ^<menu^> > %OUTPUTXML1%
    xml sel -t -c "/menu/game[type='SS']"  %SOURCEXML1% >> %OUTPUTXML1%
    ECHO ^</menu^> >> %OUTPUTXML1%
    
    REM set 2nd database xml source and output names
    set SOURCEXML2="c:\pinballx\Databases\Visual Pinball X\Visual Pinball X.xml"
    set OUTPUTXML2="c:\pinballx\Databases\Visual Pinball X\VPX Electro-Mechanical.xml"
    
    REM create 2nd outputxml file
    ECHO ^<menu^> > %OUTPUTXML2%
    xml sel -t -c "/menu/game[type='EM']"  %SOURCEXML2% >> %OUTPUTXML2%
    ECHO ^</menu^> >> %OUTPUTXML2%
    
    REM set 3rd database xml source and output names
    set SOURCEXML3="c:\pinballx\Databases\Visual Pinball X\Visual Pinball X.xml"
    set OUTPUTXML3="c:\pinballx\Databases\Visual Pinball X\VPX Original.xml"
    
    REM create 3rd outputxml file
    ECHO ^<menu^> > %OUTPUTXML3%
    xml sel -t -c "/menu/game[manufacturer='Original']"  %SOURCEXML3% >> %OUTPUTXML3%
    ECHO ^</menu^> >> %OUTPUTXML3%
    .. which is pretty much the same thing repeated 3 times as i'm creating 3 custom lists using xml.exe.  The main things to note are the paths which need changing to suit your build, xml.exe location etc and the xpath queries (the xml set -t -c lines).
  5. Added the batch file as a Startup Setting in Pinballx (i named the batch file xmlstarlet) so that the batch re-runs every time i start pinballx so that the lists are recreated (adding any new tables [assuming i've populate Game Manager correctly!]) ;   

image.png.fde987a55072edf9b88291c6d3a62efc.png

And that's it, i now have custom lists for SS, EM and Original Tables under the Lists menu option in PinballX which are maintained automatically. I may revisit later and update my VPX tables in Game Manager so that i enter Type as SS LED or SS DMD rather than just SS and then amend the batch file so that i create different custom lists for each.

image.thumb.png.cf5770f860e9b8f809b90acf2cbf57cc.png

 

You might want different custom lists on your setup and the batch file can be amended to suit your requirements. You could create your own decades lists if you wanted (going further back than the default pinballx lists) by using syntax like "/menu/game[year>=1950 and year<1960]",  or match all tables with a common description part with syntax like "/menu/game[description [contains(text(),"star wars")]]" (which could be used for different systems and then combined into a custom group to show all tables of that type for any system in one list), or split visual pinball tables by versions if you're using the <alternateexe> tag in your database files. The syntax for queries can be tested by pasting you database xml and query into https://codebeautify.org/Xpath-Tester

More advanced use would be to create your own tags for playlists and enter them for your games in the description or type fields and then use them to build custom playlists.

I haven't covered the basics of custom lists in this topic deliberately, if you don't know what they are or need more info on how they work check out the custom lists and custom groups section in the pinballx documentation;

 

xml.zip

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

  • 2 months later...

I'm only using the custom lists now for playing tables, but the All Tables list is handy to hide tables from these lists by changing the Rating in PinballX.

After adding [rating>0] to the Xpath queries in the first post (e.g. "/menu/game[type='SS'][rating>0]") i can then go through the All Tables list in PinballX and set any games i want hidden to a rating of 0. As the batch file runs on PinballX startup the next time i start PinballX any tables set to rating =0 will be hidden from the lists. Effectively on my setup this has the effect of disabling the table, but without having to go into Game Manager and remember which table(s) to disable.   And if i ever want to try the table again it's still there in All Tables, so i can 're-enable' it during the next PinballX startup just by changing the rating. 

It's a pretty handy alternative to actually disabling the tables :)

EDIT - And if you're using ALT CODE type characters in database xml then you may also want to include the encoding in the xmlstarlet cmd. E.g. the "E Windows-1252" here;

xml sel -E Windows-1252 -t -c "/menu/game[type!='EM'][rating>0]"  %SOURCEXML1% >> %OUTPUTXML1%

 

Link to comment
Share on other sites

  • 4 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...