Main Restorations Software Audio/Jukebox/MP3 Everything Else Buy/Sell/Trade
Project Announcements Monitor/Video GroovyMAME Merit/JVL Touchscreen Meet Up Retail Vendors
Driving & Racing Woodworking Software Support Forums Consoles Project Arcade Reviews
Automated Projects Artwork Frontend Support Forums Pinball Forum Discussion Old Boards
Raspberry Pi & Dev Board controls.dat Linux Miscellaneous Arcade Wiki Discussion Old Archives
Site News

Unread posts | New Replies | Recent posts | Rules | Chatroom | Wiki | File Repository | RSS | Submit news


  

Author Topic: MAME Lua Plugins  (Read 3252 times)

0 Members and 1 Guest are viewing this topic.

headkaze

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 2927
  • 0x2b|~0x2b?
MAME Lua Plugins
« on: September 29, 2016, 07:07:08 pm »
Recently I created a ShowCP lua plugin script for MAME that will toggle a CP image created using CPWizards "Export Bezels" feature.

Code: [Select]
-- license:BSD-3-Clause
-- copyright-holders:Ben Baker
local exports = {}
exports.name = "showcp"
exports.version = "0.0.1"
exports.description = "ShowCP plugin"
exports.license = "The BSD 3-Clause License"
exports.author = { name = "Ben Baker" }

local showcp = exports

function showcp.startplugin()
emu.register_pause(function()
manager:machine():render().targets[0].view = 1
end)

emu.register_resume(function()
manager:machine():render().targets[0].view = 0
end)
end

return exports

All you need to enable it is to edit plugin.ini in the MAME folder.

This is a basic example showing how to toggle a render_target during MAMEs pause and resume events.

There are many more classes, functions and properties exposed using Lua which can be seen by examining luaengine.cpp.

There are already a number of useful plugins distributed with MAME such as "hiscore" (which no longer requires a custom compile) and "cheat" for applying cheat codes.

There is an example plugin in MAME called "dummy" which shows how to use register_menu to create a custom menu. This is available when you press TAB in MAME and select the the Plugin Options->Dummy (Ive attached some screenshots showing it).

The main limitations that I can see at this point is there is no way to show a custom menu except in the Plugin Options. It would be more useful to be able to show a menu during a pause event. The other limitation is there seems to be no way to display an image except for using the bezel (or possibly overlay) system.

Please post any useful information you discover playing with Lua plugins in MAME.
« Last Edit: September 29, 2016, 07:27:55 pm by headkaze »

headkaze

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 2927
  • 0x2b|~0x2b?
Re: MAME Lua Plugins
« Reply #1 on: September 29, 2016, 07:16:18 pm »
Here are all the known events you can currently attach handlers to:

Code: [Select]
function test.startplugin()
emu.register_prestart(function()
end)

emu.register_start(function()
end)
   
emu.register_stop(function()
end)

emu.register_pause(function()
end)

emu.register_resume(function()
end)

emu.register_frame(function()
end)

emu.register_frame_done(function()
end)
end

headkaze

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 2927
  • 0x2b|~0x2b?
Re: MAME Lua Plugins
« Reply #2 on: November 30, 2016, 03:40:02 am »
MAMEDev recently applied a patch of mine (thanks to Miodrag) to MAME 0180. It exposes render_target::view_name() so my showcp plugin can check the name of the view before toggling.

Here is the new script:

Code: [Select]
-- license:BSD-3-Clause
-- copyright-holders:Ben Baker
local exports = {}
exports.name = "showcp"
exports.version = "0.0.2"
exports.description = "ShowCP plugin"
exports.license = "The BSD 3-Clause License"
exports.author = { name = "Ben Baker" }

local showcp = exports

function showcp.startplugin()
emu.register_pause(function()
local target = manager:machine():render():targets()[0]

if target:view_name(1) == "Show CP" then
target.view = 1
end
end)

emu.register_resume(function()
local target = manager:machine():render():targets()[0]

if target:view_name(1) == "Show CP" then
target.view = 0
end
end)
end

return exports

You can see based on this 1942.lay file how the view name is referred in the xml:

Code: [Select]
<?xml version="1.0"?>
<mamelayout version="2">
  <element name="CP">
    <image file="CP.png" />
  </element>
  <element name="Bezel">
    <image file="Bezel.png" />
  </element>
  <view name="Hide CP">
    <screen index="0">
      <bounds left="140" top="0" right="500" bottom="480" />
    </screen>
    <bezel element="Bezel">
      <bounds left="0" top="0" right="640" bottom="480" />
    </bezel>
  </view>
  <view name="Show CP">
    <screen index="0">
      <bounds left="140" top="0" right="500" bottom="480" />
    </screen>
    <bezel element="Bezel">
      <bounds left="0" top="0" right="640" bottom="480" />
    </bezel>
    <bezel element="CP">
      <bounds left="0" top="0" right="640" bottom="480" />
    </bezel>
  </view>
</mamelayout>

showcp.zip
« Last Edit: November 30, 2016, 04:32:06 pm by headkaze »

headkaze

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 2927
  • 0x2b|~0x2b?
Re: MAME Lua Plugins
« Reply #3 on: November 30, 2016, 04:05:52 am »
The most interesting feature of my recent patch for MAME 0180 is the ability to show a custom menu from your lua plugin.

To test this I wrote a simple plugin that communicates with the GameEx front end to display various assets for a game in a browser. When you press pause it will show a custom menu. I then use luasocket to send a http POST request to GameEx's server. It will then display the appropriate asset in a browser.

Here is the plugin code:
Code: [Select]
-- license:BSD-3-Clause
-- copyright-holders:Ben Baker
local exports = {}
exports.name = "gameex"
exports.version = "0.0.1"
exports.description = "GameEx plugin"
exports.license = "The BSD 3-Clause License"
exports.author = { name = "Ben Baker" }

local gameex = exports
local host, port = "127.0.0.1", 8383
local socket = require("socket.core")
local tcp = assert(socket.tcp())
local gameex_menu = {{ "Show Marquee", "", 0 }, { "Show Snap", "", 0 }, { "Show Title", "", 0 }, { "Show Cabinet", "", 0 }, { "Show PCB", "", 0 }, { "Show CP", "", 0 }}
local rom = nil

function gameex.startplugin()
emu.register_prestart(function()
--emu.print_error("gameex: Prestart")
--emu.print_error(socket._VERSION)
end)

emu.register_start(function()
--emu.print_error("gameex: Starting " .. emu.gamename())
rom = emu.romname()
end)
   
emu.register_stop(function()
--emu.print_verbose("gameex: Exiting " .. emu.gamename())
end)

emu.register_pause(function()
--emu.print_error("gameex: Pause")
emu.show_menu("GameEx")
end)

emu.register_resume(function()
--emu.print_error("gameex: Resume")
end)

local function gameex_menu_populate()
return gameex_menu
end

local function gameex_menu_callback(index, event)
if event == "select" then
local menu_item = gameex_menu[index][1]
local asset = nil

if menu_item == "Show Marquee" then asset = "marquee"
elseif menu_item == "Show Snap" then asset = "snap"
elseif menu_item == "Show Title" then asset = "title"
elseif menu_item == "Show Cabinet" then asset = "cab"
elseif menu_item == "Show PCB" then asset = "pcb"
elseif menu_item == "Show CP" then asset = "cp"
end

tcp:connect(host, port)
tcp:send(string.format("GET /setmameimage?rom=%s&asset=%s HTTP/1.0\n", rom, asset))
local s, status, partial = tcp:receive(5000)
--emu.print_error(s or partial)
tcp:close()
end
return false
end

emu.register_menu(gameex_menu_callback, gameex_menu_populate, "GameEx")
end

return exports

gameex_plugin.zip
« Last Edit: January 15, 2017, 01:26:36 am by headkaze »

Howard_Casto

  • Idiot Police
  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 15382
  • Your Post's Soul is MINE!!! .......Again??
    • The Dragon King
Re: MAME Lua Plugins
« Reply #4 on: November 30, 2016, 10:38:27 pm »
That's really nice man.  I had thought of CP integration into mame ever since the lua scripts were added, but you beat me to it. 

I'm thinking of using it to read memory locations to add unofficial outputs to games.  Stuff like a speedo reading in a racing game, ect. 

B2K24

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 131
Re: MAME Lua Plugins
« Reply #5 on: December 01, 2016, 02:38:20 am »
Very nice work :)

BadMouth

  • Trade Count: (+6)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 7989
  • My arcade cabinet has a cup holder.
Re: MAME Lua Plugins
« Reply #6 on: December 01, 2016, 11:45:33 am »
How about displaying move lists for each player of a fighting game on the unused edges of a widescreen?
Auto-detecting the chosen character would be nice, but cycling through all characters would still work.


Howard_Casto

  • Idiot Police
  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 15382
  • Your Post's Soul is MINE!!! .......Again??
    • The Dragon King
Re: MAME Lua Plugins
« Reply #7 on: December 02, 2016, 11:21:01 pm »
It seems fairly doable.  Generally a menu selection in a game is just a numerical value, so the character could be set when it's selected in the menu.

headkaze

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 2927
  • 0x2b|~0x2b?
Re: MAME Lua Plugins
« Reply #8 on: December 03, 2016, 08:43:09 am »
The only way to display a custom picture in MAME at the moment is to use an artwork file and toggle the layers (like how my showcp plugin works).

What we really need though is the ability to load an image dynamically and display it onscreen. We'd probably need to write up a patch and submit it to MAMEDev.

Howard_Casto

  • Idiot Police
  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 15382
  • Your Post's Soul is MINE!!! .......Again??
    • The Dragon King
Re: MAME Lua Plugins
« Reply #9 on: December 03, 2016, 06:53:55 pm »
That should be possible assuming mame doesn't do a lot of post-processing to the image.  Sometimes that can make loading an image on the fly unbearably long.

But for move lists custom text is currently possible correct?

headkaze

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 2927
  • 0x2b|~0x2b?
Re: MAME Lua Plugins
« Reply #10 on: December 03, 2016, 07:22:55 pm »
But for move lists custom text is currently possible correct?

Yes, but how do you support the glyph icons for the moves?

If we made a custom .ttf font with the move glyphs it could work. Although I think you have to compile custom fonts into MAME?

EDIT: Apparently you can place a ui.bdf font file into the MAME folder and it should work. So we need to create a custom .ttf with the glyph icons and then convert it using otf2bdf.
EDIT2: I don't think MAME supports coloured text so it wouldn't work anyway.
« Last Edit: December 03, 2016, 07:27:47 pm by headkaze »

Howard_Casto

  • Idiot Police
  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 15382
  • Your Post's Soul is MINE!!! .......Again??
    • The Dragon King
Re: MAME Lua Plugins
« Reply #11 on: December 03, 2016, 10:19:35 pm »
Yeah I was thinking the custom font route with arrows taking place of some of the useless symbols like the dollar sign, ect. 

millercentral

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 90
  • I want to build my own arcade controls!
Re: MAME Lua Plugins
« Reply #12 on: December 04, 2016, 01:16:46 pm »
Can you simulate inputs from a lua script?

It would be interesting to have simple plugin ("quarterup") that attempted to add 2 quarters at the launch of the game.

Howard_Casto

  • Idiot Police
  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 15382
  • Your Post's Soul is MINE!!! .......Again??
    • The Dragon King
Re: MAME Lua Plugins
« Reply #13 on: December 05, 2016, 01:44:11 am »
Probably not, or at least not easily. 

crazyc

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 9
  • I want to build my own arcade controls!
Re: MAME Lua Plugins
« Reply #14 on: December 05, 2016, 09:19:21 am »
Probably not, or at least not easily.
Not that hard for most machines.  Just walk the ioport field table and look for "Coin 1" and then use ioport.write() to set the insert coin port.  As an example http://www.mamecheat.co.uk/forums/viewtopic.php?f=2&t=12245 is a script to try to find addesses that store the coin counter for credit cheats.
Quote
Yes, but how do you support the glyph icons for the moves?
Isn't that like what command.dat already does?

headkaze

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 2927
  • 0x2b|~0x2b?
Re: MAME Lua Plugins
« Reply #15 on: December 05, 2016, 09:58:25 pm »
Isn't that like what command.dat already does?

What version of MAME is that screenshot from?

crazyc

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 9
  • I want to build my own arcade controls!
Re: MAME Lua Plugins
« Reply #16 on: December 06, 2016, 08:27:44 am »
A build from just after 0.179 but it's been there since mewui was brought in.  See https://github.com/mamedev/mame/blob/master/plugins/data/button_char.lua for the list of glyphs and use them as utf8 0xe000 + <glyphid>.

Howard_Casto

  • Idiot Police
  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 15382
  • Your Post's Soul is MINE!!! .......Again??
    • The Dragon King
Re: MAME Lua Plugins
« Reply #17 on: December 06, 2016, 12:42:44 pm »
Probably not, or at least not easily.
Not that hard for most machines.  Just walk the ioport field table and look for "Coin 1" and then use ioport.write() to set the insert coin port.  As an example

Pro Tip:  When noobs ask if it's possible to auto insert coins the correct answer is "no".  We don't need another surge of bootleg cabinets in arcades running mame.  ;)

I wasn't aware of command.dat being included.  The mame team has done a really crappy job of alerting the public about additions lately.  Stuff will be changed and won't get a mention in what's new or be buried real deep and get a single sentence. 

Howard_Casto

  • Idiot Police
  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 15382
  • Your Post's Soul is MINE!!! .......Again??
    • The Dragon King
Re: MAME Lua Plugins
« Reply #18 on: December 06, 2016, 12:50:43 pm »
Hmm.... ok with command.dat icons in place here is what I propose.  I have no clue if there is enough lua scripting to support this.  Make a grid setup to define a control panel layout, where a section of the grid represents a keyboard key and/or joystick input and has an icon assigned to it, ect.  (like 0,1 is the C key and a button with "c" inside is binded to it). The grid can be used to essentially re-create the user's control panel layout. Have a generic script read the value of each input and if it's on of the values in a section of a grid, print that icon, else print a blank gray button.  Then have a legend below The uses the aforementioned icons and assigns a label from controls.dat.  It would be decidedly low-res, but it would essentially make controls.dat parsing internal to mame.  It could be combined with command.dat, but that might become confusing.

crazyc

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 9
  • I want to build my own arcade controls!
Re: MAME Lua Plugins
« Reply #19 on: December 06, 2016, 02:16:10 pm »
I wasn't aware of command.dat being included.  The mame team has done a really crappy job of alerting the public about additions lately.  Stuff will be changed and won't get a mention in what's new or be buried real deep and get a single sentence.
The scope of the project has gotten quite large (I say for better as my interests mostly lie outside arcade stuff but many would say for worse I'm sure) it becomes hard to know what to focus on in the release notes.  Other things that might be interesting to you guys, I moved the dat parsing into lua scripts https://github.com/mamedev/mame/tree/master/plugins/data so if anyone has any other useful data to add you can write a lua script (rather than having to write it in c++) and it'll show right in mame. The parsed data is then stored in an sqlite database called history.dat which frontends can share and even add to.  People can also write fully scripted data like https://github.com/mamedev/mame/blob/master/plugins/data/data_hiscore.lua which is a converter for hi2txt xml to lua scripts that can then display the hiscore info in the data view (this is still quite untested as I don't play many arcade games, bug reports and better yet patches are welcome).
Quote
Hmm.... ok with command.dat icons in place here is what I propose.  I have no clue if there is enough lua scripting to support this.  Make a grid setup to define a control panel layout, where a section of the grid represents a keyboard key and/or joystick input and has an icon assigned to it, ect.  (like 0,1 is the C key and a button with "c" inside is binded to it). The grid can be used to essentially re-create the user's control panel layout. Have a generic script read the value of each input and if it's on of the values in a section of a grid, print that icon, else print a blank gray button.  Then have a legend below The uses the aforementioned icons and assigns a label from controls.dat.  It would be decidedly low-res, but it would essentially make controls.dat parsing internal to mame.  It could be combined with command.dat, but that might become confusing.
I'm not familiar with controls.dat but you can draw text, lines and rectangles to the screen on a per-frame basis.  Here's an example that ports the mame-rr lua sf2 hitbox script to the lua cheat engine:

emu.register_frame_done() is used so the stuff is drawn after the frame.

Howard_Casto

  • Idiot Police
  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 15382
  • Your Post's Soul is MINE!!! .......Again??
    • The Dragon King
Re: MAME Lua Plugins
« Reply #20 on: December 06, 2016, 11:13:39 pm »
Well it used to be that the what's new featured everything that had been added... some things were summarized of course, but at least they got a mention.  The what's new was also 2 pages long or more in some instances. 

I did know about the drawing features, which are really cool.  Circles is what we really need though.  ;)

I always appreciate hard work, so don't take my criticism the wrong way when I mention things I would like to see changed. 

crazyc

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 9
  • I want to build my own arcade controls!
Re: MAME Lua Plugins
« Reply #21 on: December 07, 2016, 09:15:03 am »
Well it used to be that the what's new featured everything that had been added... some things were summarized of course, but at least they got a mention.  The what's new was also 2 pages long or more in some instances. 
Somebody has to write it though and with the very large diversity of changes (the last whatsnew was larger than 2 pages) there really isn't any way for one or two people to really understand everything that changed.  Haze used to do a decent summary but that was still just a subset and he's been busy with other things.

I did know about the drawing features, which are really cool.  Circles is what we really need though.  ;)
There's a pixel drawing primitive that can be exposed to lua, the script author would then have to provide a circle algorithm which shouldn't be hard.

I always appreciate hard work, so don't take my criticism the wrong way when I mention things I would like to see changed.
No worries, I welcome constructive criticism.

Howard_Casto

  • Idiot Police
  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 15382
  • Your Post's Soul is MINE!!! .......Again??
    • The Dragon King
Re: MAME Lua Plugins
« Reply #22 on: December 07, 2016, 01:50:31 pm »
Back in the day if you submitted source code you had to include a summary of what it did.  That description was then copy-pasted into the what's new. 

Arbee

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 48
Re: MAME Lua Plugins
« Reply #23 on: December 07, 2016, 03:13:28 pm »
If we made a custom .ttf font with the move glyphs it could work. Although I think you have to compile custom fonts into MAME?

MAME has supported arbitrary .ttf loading for, geez, 4 or 5 years now?  It also can just be fed a font name ("Courier New Italic") and it'll look it up through the appropriate OS mechanism.

Arbee

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 48
Re: MAME Lua Plugins
« Reply #24 on: December 07, 2016, 03:16:30 pm »
Back in the day if you submitted source code you had to include a summary of what it did.  That description was then copy-pasted into the what's new.

And now if you submit source code Github requires you to include a description and it's automatically added to the whatsnew.txt unless you include the [nw] magic cookie.

Howard_Casto

  • Idiot Police
  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 15382
  • Your Post's Soul is MINE!!! .......Again??
    • The Dragon King
Re: MAME Lua Plugins
« Reply #25 on: December 08, 2016, 12:30:49 am »
And yet there have been more than a couple core changes over the past several cycles that have gone virtually unmentioned.  I'm not trying to argue man, I'm just sayin'.....

Anyway the lua stuff looks promising.  After the nightmare of X-mas shopping is over maybe Headkaze and myself can get together on this (and perhaps drag SirP out of retirement?) and build a lua-friendly controls.dat.  We have tons of data, it just needs to be altered into a better format. 

Hagure

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 2
  • I want to build my own arcade controls!
Re: MAME Lua Plugins
« Reply #26 on: January 14, 2017, 09:55:14 pm »
I'm not familiar with controls.dat but you can draw text, lines and rectangles to the screen on a per-frame basis.  Here's an example that ports the mame-rr lua sf2 hitbox script to the lua cheat engine:

emu.register_frame_done() is used so the stuff is drawn after the frame.

Hello, I'm coming from the Fighting Game Community & have just fallen down the rabbit hole of MAME emulation. I've been looking to port over a bunch of the mame-rr lua scripts we've been using, to the newer versions of MAME for wider platform compatibility. I know this is all new territory for most people, but I was wondering if you have this ported sf2 script available anywhere so that I could use it as a basis to port over some others. I know documentation is pretty sparse right now outside of the official wiki & old mame-rr resources; it's quite an uphill climb for a newcomer like me so any help would be appreciated.

Thank you very much for your time & attention, and thanks for all your contributions! (I've seen your username around many of the MAME/emulation forums regarding lua scripting!)

crazyc

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 9
  • I want to build my own arcade controls!
Re: MAME Lua Plugins
« Reply #27 on: January 15, 2017, 12:59:33 pm »
You can get it with the package over at http://cheat.retrogames.com/ (there's tons of files in the 7zip, sf2.json is the only one you need to extract) but the limitations of json make it a bit hard to read so https://gist.github.com/cracyc/145ae60b9e6ac1d1bd7ce26c60f250c6 is the meat of the script nicely formatted.

Hagure

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 2
  • I want to build my own arcade controls!
Re: MAME Lua Plugins
« Reply #28 on: January 15, 2017, 11:07:31 pm »
Awesome! Thank you so much!

Necro

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1029
  • Building a 'Classic' MAME Cab
Re: MAME Lua Plugins
« Reply #29 on: February 15, 2017, 01:07:09 pm »
Probably not, or at least not easily.
Not that hard for most machines.  Just walk the ioport field table and look for "Coin 1" and then use ioport.write() to set the insert coin port.  As an example http://www.mamecheat.co.uk/forums/viewtopic.php?f=2&t=12245 is a script to try to find addesses that store the coin counter for credit cheats.
Quote
Yes, but how do you support the glyph icons for the moves?
Isn't that like what command.dat already does?

Is this no longer working in 0.182 or is something special needed to configure?  From a straight install of MAME64, I can NOT get something like this to display at all.  The Data plugin seems to be autoinstalled and enabled, but still not getting this with any of the included files in their default locations and a default mame.ini/ui.ini.  Baffled somewhat.

crazyc

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 9
  • I want to build my own arcade controls!
Re: MAME Lua Plugins
« Reply #30 on: February 16, 2017, 03:42:27 pm »
What is the historypath in ui.ini and the directories you have them in?

Necro

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1029
  • Building a 'Classic' MAME Cab
Re: MAME Lua Plugins
« Reply #31 on: February 16, 2017, 07:01:35 pm »
The defaults.  So in ui.ini it's "historypath               history;dats;." and the history.dat, command.dat, etc. are in the dats folder.  I've tried moving them to the MAME root directory and still nothing.

Should they be showing something?  Because it's not totally clear if something should be showing in the plugin menu at all, or if it should be in the main mame64.exe UI, or nothing should be showing at all - that plugin isn't documented and I'm not certain the screenshots I THINK are associated with displaying those dats actually are.

crazyc

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 9
  • I want to build my own arcade controls!
Re: MAME Lua Plugins
« Reply #32 on: February 16, 2017, 07:37:59 pm »
There's a bug in the last release where only the first dir in historypath is checked so move them into history or make dats the first one.

Necro

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1029
  • Building a 'Classic' MAME Cab
Re: MAME Lua Plugins
« Reply #33 on: February 17, 2017, 12:48:35 am »
...this seriously needs to be documented SOMEWHERE.  moving the dats to a history folder made them appear in both the ui and the in-game tab menu. 

Crazyc, where did you see that bug?

Ilitirit

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 6
  • no i'm not
Re: MAME Lua Plugins
« Reply #34 on: February 23, 2017, 11:21:38 am »
Is there a way to automatically close the menu and unpause after an item is selected?

B2K24

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 131
Re: MAME Lua Plugins
« Reply #35 on: February 23, 2017, 07:29:32 pm »
...this seriously needs to be documented SOMEWHERE.  moving the dats to a history folder made them appear in both the ui and the in-game tab menu. 

Crazyc, where did you see that bug?

The dat placeholder locations are stupid.

Access ui.ini and simply change the entire line to the root of your mame path and drop all DATs in same location as your executable and you'll be fine.
In windows you can right click in your mame folder and choose sort by name and group by type to have everything nicely organized.

Code: [Select]
historypath               J:\MAME

headkaze

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 2927
  • 0x2b|~0x2b?
Re: MAME Lua Plugins
« Reply #36 on: July 17, 2017, 09:54:34 pm »
A simple SaveState plugin. When you pause MAME you get a menu where you can select to load or save the game's state.

Code: [Select]
-- license:BSD-3-Clause
-- copyright-holders:Ben Baker
local exports = {}
exports.name = "savestate"
exports.version = "0.0.1"
exports.description = "SaveState plugin"
exports.license = "The BSD 3-Clause License"
exports.author = { name = "Ben Baker" }

local savestate = exports
local savestate_menu = {{ "Load State", "", 0 }, { "Save State", "", 0 }}

function savestate.startplugin()
emu.register_prestart(function()
end)

emu.register_start(function()
end)
   
emu.register_stop(function()
end)

emu.register_pause(function()
emu.show_menu("SaveState")
end)

emu.register_resume(function()
end)

local function savestate_menu_populate()
return savestate_menu
end

local function savestate_menu_callback(index, event)
if event == "select" then
local menu_item = savestate_menu[index][1]

if menu_item == "Load State" then manager:machine():load("auto")
elseif menu_item == "Save State" then manager:machine():save("auto")
end
end
return false
end

emu.register_menu(savestate_menu_callback, savestate_menu_populate, "SaveState")
end

return exports

  
 

Sitemap 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31