Post subject: Quick weapon select in Mega Man games via LUA
Joined: 2/3/2011
Posts: 4
Location: Lexington, KY
Hey guys, I've recently started getting into LUA scripting for NES games, and oh my god it's so much fun. I've been playing around with using the select button in Mega Man games to quickly switch weapons. It can be a pain figuring out where in memory some of this stuff takes place though. Here's the script and a link to the video. Let me know what you think. I'll be updating this thread as I make progress. video -> http://www.youtube.com/watch?v=cBcOoNtULVQ the script -> https://gist.github.com/614747
Joined: 10/20/2006
Posts: 1248
I'd code it like this: weapon_names = {"Arm Cannon","Atomic Fire",...} Then use "if next_weapon > max_weapon" or "if next_weapon > table.maxn(...)" or "> #weapon_names" Keep in mind that in lua arrays (which really are tables) start with 1 as their lowest index (which really is a key) per default though. Nice work.
Player (121)
Joined: 2/11/2007
Posts: 1522
For what it's worth I dug up an old script I was working on for MM 1, 2 and 3. Not sure if it is even in a working state, though it was at some point. I got hung up on the graphical issues. Would love to see a TAS using your script someday! http://lua.pastebin.com/Y5MS2nyR
I make a comic with no image files and you should read it. While there is a lower class, I am in it, and while there is a criminal element I am of it, and while there is a soul in prison, I am not free. -Eugene Debs
Player (206)
Joined: 5/29/2004
Posts: 5712
Soon you will recreate all the features of Complete Works without the need for PlayStation emulation!
put yourself in my rocketpack if that poochie is one outrageous dude
Joined: 2/3/2011
Posts: 4
Location: Lexington, KY
Kuwaga wrote:
I'd code it like this: weapon_names = {"Arm Cannon","Atomic Fire",...} Then use "if next_weapon > max_weapon" or "if next_weapon > table.maxn(...)" or "> #weapon_names" Keep in mind that in lua arrays (which really are tables) start with 1 as their lowest index (which really is a key) per default though. Nice work.
awesome. the script has been updated to define the tables in a single line (and all the array indexes fixed likewise)
Alden wrote:
For what it's worth I dug up an old script I was working on for MM 1, 2 and 3. Not sure if it is even in a working state, though it was at some point. I got hung up on the graphical issues. Would love to see a TAS using your script someday! http://lua.pastebin.com/Y5MS2nyR
looks awesome (same as mine, but for mm1 2 and 3, correct?), but i could not get it to work :(
Player (121)
Joined: 2/11/2007
Posts: 1522
Hmm yeah it might not be working at all. But perhaps you could decode some of the memory addresses for the other games? I guess you could figure it out for yourself anyways :P Anyway, good luck!
I make a comic with no image files and you should read it. While there is a lower class, I am in it, and while there is a criminal element I am of it, and while there is a soul in prison, I am not free. -Eugene Debs
ventuz
He/Him
Player (126)
Joined: 10/4/2004
Posts: 940
Ok maybe I'm crazy trying to crack memory address that affect sprite issue. Here my finding: 03B6 - PPU row pointer (I think you need to set it to 09 for weapon graphic) 03B7 - PPU column pointer (00, 20, 40, 60, 80, A0, C0, E0 in order from left to right) 0008 - I think it may have something to do with graphic 00FD - I think it also may have something to do with graphic or pausing No idea if you can change them frame for frame, or all at once with lua memory.writebyte(). If you put 03B7 in debugger, make it break on WRITE, then try open or close menu in game, you'll notice it'll pause each time a tile in PPU viewer is changed. Set PPU viewer refresh rate to max.