SourMesen / Mesen-S

Mesen-S is a cross-platform (Windows & Linux) SNES emulator built in C++ and C#
GNU General Public License v3.0
415 stars 102 forks source link

Feature Request: Option to auto-run Lua script on "Reload ROM" #115

Closed binarycounter closed 4 years ago

binarycounter commented 4 years ago

I'm using the Lua scripting feature to draw debug info for my homebrew game over the gameplay. Right now i have to restart the script every time i reload the ROM. Meaning i have to bring the script window to the foreground, hit Run and minimize it again. I'm using v0.4. I'd be awesome if there was a option to automatically reload/restart the script on "Reload ROM".

Thank you for making such excellent emulation and debugging tools!

SourMesen commented 4 years ago

Thanks for the request!

I've added an option for this in the script window (defaults to being enabled) - you can grab the latest dev build off appveyor (link is in the readme)

binarycounter commented 4 years ago

Thanks so much!

binarycounter commented 4 years ago

Hi, i just tested this and while the script does auto-reload on "Reload ROM", debugger labels from LD65 .dbg files do not, resulting in label not found lua errors. To fix this i have to open the debugger and re-import the labels from the File menu. Previously in v0.4 labels automatically reloaded if i kept the debugging window open in the background. Version 0.4.0.7 Build Date 03.05.2020 19:18

EDIT: Actually the script still loads labels without reimporting them, if i leave the debugger window open and manually Run the script. So maybe the script starts before labels are loaded. I'll test with delaying label loading for a few frames.

EDIT2: Delaying label use in the Lua script by a single frame seems to have done the trick.

SourMesen commented 4 years ago

@binarycounter Thanks for the report! Labels should be fixed either way, whether the debugger window is opened or not, as of the latest commit.

Let me know if you still have issues with it.