besteon / Ironmon-Tracker

A Lua script for the Bizhawk/mGBA emulator compatible with Pokemon Fire Red, Leaf Green, Ruby, Sapphire, and Emerald that tracks relevant data for the IronMon challenge.
MIT License
122 stars 44 forks source link

[Custom Code Extension]: Auto Nicknamer #387

Closed Mixone-FinallyHere closed 4 months ago

Mixone-FinallyHere commented 1 year ago

Are you submitting an extension, or an idea?

Extension

Tell us about your extension / idea

Unsure if this fully fits parameters for Ironmon as it performs a memory write to set nicknames.

The idea with this extension is that since users sometimes play at fast speeds, and the text input in Gen3 is not great, this will allow to simply not have to nickname and automatically ensures the mon gets a nickname, in theory avoiding accidental errors that might make a mon "illegal" as it wouldn't have a nickname.

Additionally it allows content creators to have an easier way of having their mons named after viewers at random from a list instead of having to manually input them each time

Link to extension

https://github.com/Mixone-FinallyHere/AutoNicknamer-IronmonExtension

Additional Information

No response

UTDZac commented 1 year ago

Thanks for this cool tracker extension idea Mixone, it's pretty sweet and simple!

There are a few code suggestion and changes I'd like to make. I'll outline them below:

1. Avoid having any print statements anywhere in the final extension release

Often the Lua Console output is reserved for the tracker for any important messages. Printing to it might push those out of view. In addition, printing in quick succession can cause notoriously bad performance from Bizhawk, slowing down the game tremendously.

2. I'm not sure how to actually use the nicknames.txt file

Based on the nicknames.txt that comes with the extension download, I don't actually know how to add new nicknames to it. I'm not familiar with what format it expects, nor can i really figure it out based on the contents of the file itself. I recommend having at least three pokemon and their associated nicknames in the files so that it is more clear how the user should expect to enter in new information.

For example

Bulbasaur: Flowersaur
Charmander: LittleRed
Squirtle: Leonardo

I know this isn't the format you're using, I merely picked something to showcase legibility and ease of use.

3. Use PokemonData instead of DataHelper

In some places you use the DataHelper class for some data. This is primarily a helper class for sharing screen data between Bizhawk and MGBA, so that it only has to be calculated once. It appears you really only need some basic information about a Pokemon, which you can get easily from PokemonData

4. Verify the nicknames.txt file exists before using it

In the unlikely event the nicknames.txt file was moved or not supplied, this will throw a nil error. The Tracker code safely captures this error to prevent the application from freezing up, but perhaps you want to handle it useful. You can easily check if a file exist via FileManager.fileExists() which will work on any operating system or emulator.

Other Thoughts

It's easy enough to have the user open up the nicknames.txt file to edit it and add in new names or change existing ones. However, if you want to go the extra step, you can include this as part of the extension itself. This can be done by including a self.configureOptions and have that function open up a bizhawk forms prompt. To see example prompt template, you can copy the one from LogOverlay.openRandomizerShareWindow(). By including the configureOptions function, the tracker will automatically add an OPTIONS button to the extension page on the tracker screen.

Mixone-FinallyHere commented 1 year ago

Thanks, will be adding quite a few of these and some more (special characters stuff and name lengths)

I think can close this PR/Issue and when i finalize v1.5 or v2.0 I will just recreate a new one?

Thanks for the insightful feedback!

UTDZac commented 1 year ago

Feel free to keep this one open, since the link to the extension still works fine.

Another quick idea I thought of for this extension is to automatically save nicknames that the user enters in-game to your text file storage. In this way, they can just play the game normally and enter nicknames. They can name Pikachu "Sparky", the extension will record that, and then on future runs they can skip naming Pikachu since it will just default to "Sparky". Though, now that I typed this out, maybe that might be tricky to use if you can't remember if you saved a name for a particular Pokemon or not.

As for the special characters, an upcoming Tracker project that deals with multiple languages and resource management is going to eventually get merged in for 8.0.0 release of the Tracker. Unsure if it helps, but figured I'd bring it up if you were looking for some answers to things.

UTDZac commented 4 months ago

Closing this to cleanup the Issues page. If you'd like to continue working on this and have it updated, I'll gladly take a look at it again and get it added to the extensions page.

Mixone-FinallyHere commented 4 months ago

Will do Been busy with other stuff so this and my other extension need a proper redo tbh

If I do advance ill probably reach out on discord