KeeyanGhoreshi / PokemonPlatinumSingleSequence

A list of inputs that beats Pokemon Platinum
GNU General Public License v3.0
96 stars 4 forks source link

Help with usung the scripts in various emulators #3

Open Peelio opened 1 week ago

Peelio commented 1 week ago

G'day I'm not sure if this is an appropriate place to ask this question, but I'm not very familiar with computer programming or GitHub, so I thought maybe this would be a good place to gain some clarity. If this is not a good place to do this, I'm sorry, and any nudges in the right direction would be wicked.

I love the idea of being able to boot up an emulator, load up the inputs, and just have a solved Pokémon game running in the background. But after a small amount of fiddling around, I have been unable to get the scripts to run in my emulator (DeSmuME). Is this simply because the scripts were written to work with your stripped-down emulator, or am I just missing something that is required?

I loved the video, and it blows my mind every time I think about it and how you've found a set of inputs that completes every single possible version of the game. Just crazy stuff.

Sorry again if this is a waste of time/space on this board.

AdmiralCurtiss commented 1 week ago

It's a Bizhawk lua script. You want to download https://tasvideos.org/Bizhawk, launch the game in that, then go to to Tools -> Lua Console, Script -> Open Script -> startAll.lua.

ZacharyGiguere commented 4 days ago

I'm using Bizhawk 2.9.1 and I have issues with running the script. The save and savestate commands don't seems to work properly on my computer, since I can't find any trace of any saves done through 1.lua with the 'save' command. The savestate.saveslot(id) done before executing the script seems to work (I get Pokemon Platinum Version (US).MelonDS.QuickSave1.State updated each time I start the script) but it keeps crashing when trying to do the save after the script savestate.saveslot(id + 1). In the lua console it says that the slotNum parameter must be between 1 and 10. Am I the only one who this doesn't work?

KeeyanGhoreshi commented 4 days ago

that's strange, the id+1 can only ever be 2 or 4, so no idea why that's failing for you.

To make use of the save function, you have to update the save directory in movement.lua:

https://github.com/KeeyanGhoreshi/PokemonPlatinumSingleSequence/blob/457fc21ded8791646edf976184bdbe51893b36da/commands/movement.lua#L659

Change the path to wherever you want the autosaves to save the files. Only change this part '../../../NDS/State/Platinum/autosaves/' and leave the rest alone.

If you can get the autosaves working, the savestate/saveslots become irrelevant.

ZacharyGiguere commented 4 days ago

Ok so I already found about the path, instead of changing it I just put the script somewhere the path would be valide (and created the missing folders). So the path NDS/State/Platinum/autosaves/ exist, maybe my starting location for the path is wrong and because of that it can't find the NDS folder...

Also, if autosaves work I wouldn't need savestate/saveslots, but my main issue is the crash. Obviously, the crash don't occure because of ID being 2 or 4. Infact, to be sure it was working the first time and not just a default mechanic, I changed the value of ID to 2 instead of 1 for the first savestate of 1.lua and it correctly create Pokemon Platinum Version (US).MelonDS.QuickSave2.State. The crash occurs more probably because of ID getting outside of the range or maybe being not even a number anymore. I am not familiar to lua, but if variable can be global than the value of ID get changed here https://github.com/KeeyanGhoreshi/PokemonPlatinumSingleSequence/blob/457fc21ded8791646edf976184bdbe51893b36da/commands/movement.lua#L660 I'm unsure why ID is asigned the value of client.xpos() in the first place, but if it also affect the value of ID in 1.lua than the number is clearly out of range

Last, unless there are autosaves made somewhere I didn't saw on my PC, it looks like the save commands don't work and don't output error, which is strange and it is probably something on my side, since everyone else seems to have it working. The only odd thing I noticed in the name for the autosave is the id .. '_' .. '_' .. fileName where there is 2 _ without anything between, but it shouldn't affect anything.

KeeyanGhoreshi commented 4 days ago

Nice, variables in lua are global unless declared local so you're right, the save function is overwriting the id. What's interesting is that on my emulator, this issue doesn't cause a crash. It doesn't even produce an error! Logging the id before it tries to save indicates that it is obviously being overwritten, but I don't see any log and everything continues running as expected.

Maybe my version of bizhawk is different and it doesn't throw an error when the saveslot function doesn't work. Either way, this is a pretty simple fix. I was originally going to make the id local, but the saveslots have no use anymore to anybody so I'm just going to remove them.

As an aside, the reason id is set to xpos is to auto-generate a unique id for each emulator I had running on my pc, since I'd run them side by side. There also used to be an additional piece of information saved in each state that I removed, but just forgot to remove the second underscore.

As for the autosaves, I'd recommend just specifying the path you want directly. Also note that the autosave function saves into a directory depending on which script is running. You will want your directory to look like this:

image

ZacharyGiguere commented 4 days ago

The explanation for the xpos was my guess lol. Creating the script folders fix the issue! And since the new version completely remove the saveslot it should no longer crash! Thanks a lot for the help, but most importantly for realising this project!!

Edit: I imagine the point of savestate are incase something goes wrong to not have to start over, but unless I use a savestate done at the end or begin of a file, how can I use those savestate to keep going? Can you ask the emulator on which line to start or you just simply put parts of the code in commentary and hit run?

KeeyanGhoreshi commented 4 days ago

Yep, you'll have to comment out everything before the autosave point so that it starts up from that position. I usually just put the second section into another array called b or c and pass it to movement.executeOrders instead so that I don't have to remember to uncomment a bunch of stuff.