Jump to content
LaunchBox Community Forums

Coin limiter for Arcade games


martijnsx
 Share

Recommended Posts

Hi to all Retro Gamers,

Since a couple of years i have been looking for some script/program in which you can limit the amount of coins you can spend in MAME. Games are no challenge if you have unlimited coins.

I have not found a solution so i began trying to write my own AHK script. And that is not as easy as i thought it would be. 

I hope we can all contribute to making a script that can do this (or hint to a program that does this already).

What i want is very simple. Suppose your coin key is the Q key. If Q is pressed for example 5 times AHK must disable that key.

The script must be active only when MAME is running. For this last requirement we have 2 options. 1. start the script when MAME is started / kill the script when MAME is closed. 2. write a script that checks if MAME is running or not. Starting and killing a script may be possible from within Launchbox (with launching/closing emulator). Killing a script might be also possible if we define the exit emulator key in the script. 

There is one more requirement. There may be more coin keys. If you have a 2 or 4 player system then there are 2 or 4 coin keys. I am not sure but i think arcade games have coins adressed differently. You have cabinets that add coins to a global counter and cabinets that have coins dedicated for player 1, 2, 3, and 4. In the first version it does not matter where you input a coin, in the last it does. I think most cabinets have a global counter (all coins add up and you can start all players). TMNT however does have dedicated coin inputs for 4 players (example).  

So who will join me in making this AHK script work? 

Step 1. Find AHK code that will block the input of a key if it is pressed more than X times

Step 2. Make it work only when MAME is active

Step 3. Make it work with multiple coin keys. 

Who has the solution or part of the solution and wants to share the first line of code? Let's do this together!

 

 

 

 

 

 

 

 

 

 

 

Link to comment
Share on other sites

"Q" seems like an odd key assigned to inserting a coin. But who am I to knock it?

MAME's default coin inputs for players one thru four are keys 5, 6, 7 and 8, respectively.

image.png.9d11eaaca6b573a385df5b617d458616.png

Here's coin 1 and 2 (per MAME keyboard assignments) to get you started.  Study it carefully and YOU can add coin 3 & 4 (or change it back to "Q" and whatever ;)).

global coin1 := 0
global coin2 := 0

; Player one coin input = "5"
5::
{
   if (coin1 = 5)        ; Max 5 coins
      Return

   coin1++
   5::5
   Sleep 750
}

; Player 2 coin input = "6"
6::
{
   if (coin2 = 5)
      Return

   coin2++
   6::6
   Sleep 750
}

Copy this into the Running [AutoHotkey] Script section of your MAME emulator and limit those little hoodlum's allowance (at least until they learn they can exit, then restart the game with 5 more quarters. lol).

Link to comment
Share on other sites

31 minutes ago, martijnsx said:

why do we need the sleep 750?

Because I was too lazy to try to remember how to set the delay repeat-click thingy. (still am. lol) 

This way if you press and hold "coin", you have to wait 750ms before it detects another press/click. Which is usually long enough if you press and release the button.  But if you presssssss and then release, the script may detect it as more than one press. At this point, MAME probably only gives you the one coin while the script counted 2 or 3.

It's not the "proper" way to do it. But it does work. As cheesy as it may be. ;) 

 

And ya, Coin1++  looks a lot cooler than  Coin1 = Coin1 + 1

 

Glad it's working!!! (because I didn't really test it. lol)

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
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.

 Share

×
×
  • Create New...