My Programming Project

Date:  July 20, 2019

Today, “hao-lian” in front of my son.

I told him, Daddy can write a Python script in 2 hours to sync my Pokemon Ruby (for Nintendo Gameboy Advanced) between my handheld device and Retropie (Raspberry Pi) desktop.

Actually, I took more than 2 hours.  Because (here comes the excuses), I too long never write programs, and I never really write a script in Python before.  I am actually new to Python.  I am more a C programmer or Perl scripts programmer.  Hahahahaha

UNADJUSTEDNONRAW_thumb_a9f2e.jpg

But eventually, I did finished my Python script today.

And I finished in 84 lines (with new lines).  hahahhaha

  • ping both game consoles to see if there are online, if either off-line, don’t do anything.
  • check the Pokemon Ruby save file (i.e. .srm file) to see which one is newer.
  • always backup the latest files to the backup directory.
  • copy the new file and sync to the other console.

At the same time, I also re-learn how to do the following… which is quite cool…

  • ssh to these game console without logging in.  Using the private and public ssh keys.
  • Python scripts to do date time to time stamps conversions.
  • Crontab to run cronjob to run this every minute.

UNADJUSTEDNONRAW_thumb_a9fea.jpg

So, now, if I save the game on this game console.

Every minute, the cronjob will check both the gaming console for latest file.  If it finds this clockwork gaming console has the latest file, it will first back up a copy to a backup directory, and then, it will make a copy using SCP command to copy itself to another game console.

Like this, both game console will always keep the latest saved file.

UNADJUSTEDNONRAW_thumb_a9f29.jpg

So, when you launch the game on either game console, the save game will always be in sync.

Of course you don’t save the file on one game console and within 1 minute run to another game console and play la.  hahahaha

UNADJUSTEDNONRAW_thumb_a9f28.jpg

Whatever goes wrong, I still got a backup copy I can get.  hahaha

UNADJUSTEDNONRAW_thumb_a9f2a.jpg

My son is quite impress with it, and during the programming time, I actually explain to him what I actually do.

So, I am glad I have written this script.  Now, I don’t have to do so many repetitive steps just to sync the saved file to both gaming machine.  hahaha

Leave a Reply