I was going to create a new topic, but it's about the same subject (help on LUA, also for SNES9x).
On the Lua Scripting
page, there's a TODO section to cover about joypad.set (which is what I'm interested on).
I want to create a script for Final Fantasy V where you press every single combination of buttons (all 12: up, down, left, right, select, start, B, A, X, Y, L, R) in a single frame to see how the RNG advances when entering a battle. When I try this manually, it doesn't seem to act like each button advances the RNG by determined amount, so I can't calculate it and must go with trial and error (hence a need for a script to automate this part).
I want to try to see if I can get a lucky path to beat Omniscient as Solo Berserker using Mage Masher to silence him. Since Berserkers doesn't need any input when playing (and doing so doesn't affect the RNG in any way), only part you can manipulate is the startup (which any other Job setup can benefit from, so the script could be used later for any other battle in particular and not just for this case...)
Here's the steps I want to try:
1. Load save state
2. Press new combination of buttons for 1 frame
3. Advance (say 30 frames) and check values of 2 addresses
4. Send information to a file so I can analyze
5. Repeat steps
If the output is to big to try manually, then it'll be both good and bad news. (Good because fights can have many paths, hence more outcomes; Bad because it wouldn't be practical to test manually, so the script would need to updated, but I suppose that would be easy - just need to wait more time before trying a new input...)
I know these are some of the instructions, but I'm not sure how to use them:
1. savestate.load(object savestate) -- <-- Guess I replace with the name of the save
2. Update "ButtonSequence" -- <-- This part is where I'm most lost
Joypad.set(1, ButtonSequence)
3. emu.frameadvance() -- <-- Place it inside a FOR to advance X frames?
A = memory.readbyte( 0x7E003A )
B = memory.readbyte( 0x7E003B )
4. print (ButtonSequence, A, B) -- <-- Since BS is likely a table and not a number, this isn't straightforward
I would later check the first instance of A,B having the same value in different button sequence, or maybe could be included first and print the results at the end...
5. Repeat until every button sequence is covered (2^12 times).
Any help or better suggestion would be appreciated.