Jump to content
LaunchBox Community Forums

How to Automatically Clear High Scores in an Arcade Circuit?


JoelGhanem

Recommended Posts

Hi everyone,

This is my first time posting here, and I'm not sure if anyone has tried something like this before. I'm setting up an arcade park where my friends can come and play. The idea is to create a kind of decathlon where we combine all the scores from all the machines in the circuit.

The problem I'm facing is that we have more than 10 players, but the .hi file only saves the top 10 scores. I'm currently saving the high scores in a .csv file and then inserting them into a MySQL database. However, the last step I'm missing is how to automatically clear the scores while we're playing, the file rewrites itself all the time,  as I don't want to keep stopping to manually delete the .hi file and restart the game each time.

Does anyone know a better way to handle this? Any suggestions would be greatly appreciated.

Link to comment
Share on other sites

2 hours ago, JoelGhanem said:

how to automatically clear the scores while we're playing, the file rewrites itself all the time,  as I don't want to keep stopping to manually delete the .hi file and restart the game each time.

MAME saves to the hi file at the end of each gameplay (after your last player dies and it's ready for you to press player 1 start).  vs. saving only when exiting the game.

If you're good, you create a Lua script plugin for MAME that would delete/move/whatever the hi file after saving.  

Alternately, you could create an AutoHotkey script that loads when you start a game [that uses the MAME emulator].  The script could... when you press the assigned hotkey, it would delete/move/whatever the hi file for the current game.  You'd just need to place the script in the emulators Running Script section.

The problem with that is, you can't pass any parameters to a Running Script (like the emulators path or the ROM name).  So you'd need to get very creative.  Maybe something like this.   Note: This WILL DELETE the games hi file when you press Alt+A while a game is loaded!

sleep 2000
queryEnum := ComObjGet("winmgmts:").ExecQuery(""
           . "Select * from Win32_Process where caption='mame.exe'")
           ._NewEnum()[p]

CommandLine = % p.commandline
StringSplit, rom, CommandLine, "%A_Space%-
StringSplit, mame, CommandLine,","
StringReplace, path, mame2, mame.exe
hi = % path "hiscore\" rom%rom0% ".hi"

; Press Alt+A to delete the current games .hi file
!a::FileDelete, % hi

This assumes

  • You're using standalone MAME (vs RA MAME [ugh])
  • You're using regular MAME (mame.exe vs mameui.exe)
  • Your high scores are being saved to the emulators 'hiscore' subfolder
    • D:\Emulators\MAME\mame.exe
    • D:\Emulators\MAME\hiscore\1942.hi
  • You can press Alt+A
Link to comment
Share on other sites

Hi, thanks so much for your response. Unfortunately, I'm still having some issues.

The problem is that even after I change the file, the game rewrites it with what seems to be cached data while it's still running. It appears to detect the changes and overrides them.

I’m considering modifying the machines to require a fake coin to play, and then restarting the emulator until someone inserts another coin.

I’m using the standalone MAME with the regular mame.exe and the hiscores subfolder.

Thanks again for your help! If I manage to solve this issue, I'll be sure to post the solution here.

Link to comment
Share on other sites

2 hours ago, JoelGhanem said:

The problem is that even after I change the file, the game rewrites it with what seems to be cached data while it's still running.

Ahh. Ya, that makes sense that it'd still be in cache. At least until MAME is exited.

 

2 hours ago, JoelGhanem said:

I’m considering modifying the machines to require a fake coin to play, and then restarting the emulator until someone inserts another coin.

Don't think you be able to do that via LaunchBox. The auto-restarting part. 

You could add a 'coin limiter' to the Running Script that will only allow 1 (or however many coins) to be inserted.  Take that a step further to, exit the game if a 2nd coin is inserted. (change 'Return' to 'WinClose, ahk_exe mame.exe')  Example allowing 2 coins.

SetKeyDelay, 125, 50
global coin := 0

5::
{
    if (coin = 2)  ;Max 2 coins can be inserted
       Return

    coin++
    5::5
    Sleep 750
}

 

An alternate to the previously posted Running Script for the emulator, add [a variation of] it as an Additional App to the games.  Set the Additional App to Run After Main Application Has Exited.  Then when the game exits, it'll 'automatically' delete the hi file.  You'll still need to launch the game and then exit between each player (or at whatever frequency).

 

Combine the coin limiter with the Additional App and GreatStone’s 'hi2txt' utility, you could almost have the cvs file populated for you.  And get the hi file deleted between rounds. ;) 

 

Anyway, love spitballing ideas.  Hopefully you come up with something that suits your needs.

Link to comment
Share on other sites

Join the conversation

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

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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...