Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help with usung the scripts in various emulators #3

Open
Peelio opened this issue Oct 24, 2024 · 7 comments
Open

Help with usung the scripts in various emulators #3

Peelio opened this issue Oct 24, 2024 · 7 comments

Comments

@Peelio
Copy link

Peelio commented Oct 24, 2024

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
Copy link
Contributor

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
Copy link

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
Copy link
Owner

KeeyanGhoreshi commented Oct 28, 2024

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:

function movement.save(fileName)

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
Copy link

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


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
Copy link
Owner

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
Copy link

ZacharyGiguere commented Oct 28, 2024

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
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants