VooDooUdo2
Posts: 1
Joined: Sun Feb 19, 2023 4:24 pm

MAME LUA/Debugger Question

I'm trying to develop a LUA script to take action based on a memory address in a game. Specifically, Area 51, and I'm looking at the ammunition count. I've determined this lives in the maincpu program space at address 0x9000876F. If I run the debugger, start a game, then run the debug command print maincpu.pb@9000876F it outputs 8, which is what I expect. In my LUA script I'm trying to access this via manager.machine.devices[":maincpu"].spaces["program"]:read_u8(0x9000876F)), but it always returns 0, and I'm racking my brain trying to figure out what I'm doing wrong. I am new to programming in MAME, so I'm sure it's something simple, any help would be much appreciated!
User avatar
Tafoid
Posts: 366
Joined: Thu Nov 06, 2014 12:50 pm
Location: USA
Contact: Website

Re: MAME LUA/Debugger Question

VooDooUdo2 wrote: Thu Sep 11, 2025 2:12 am I'm trying to develop a LUA script to take action based on a memory address in a game. Specifically, Area 51, and I'm looking at the ammunition count. I've determined this lives in the maincpu program space at address 0x9000876F. If I run the debugger, start a game, then run the debug command print maincpu.pb@9000876F it outputs 8, which is what I expect. In my LUA script I'm trying to access this via manager.machine.devices[":maincpu"].spaces["program"]:read_u8(0x9000876F)), but it always returns 0, and I'm racking my brain trying to figure out what I'm doing wrong. I am new to programming in MAME, so I'm sure it's something simple, any help would be much appreciated!

While I can't help you directly, there is a rather lengthy documentation file (as well as the files provided with MAME) which can act as a guide:
https://docs.mamedev.org/luascript/index.html

Hope this helps.

Return to “MAME Discussion”