I made it a separate .rpy file so you should be able to use it. Expert programmers only sorry, don't have time to explain how it works in details. Also, right now is probably not a good idea to use it except for testing.
I think the problem are in the threading. Not sure, since here on my PC works fine except if I shut down the game window!
Quick explanation:
since the system uses renpy.utter_restart() (line 155) to restart the game once it has finished applying the update, you need to run the updater BEFORE the main menu screen.
In the label splashscreen: if you comment the return on line 85, will run the autoupdater (and then go on with your game).
I made a simple system, I check an URL that has a index.php (had to upload as index.txt because won't let me, but rename that to index.php).
That php simply reads the directory content ON SERVER. The updates are numbered files 000000.zip,000001.zip,000002.zip and so on.
The game has a variable in options.rpy:
Code: Select all
python early:
GameVersion=2Example, I have gameversion=3, and latest file is 000010.zip, it will download all the zips from 4 to 10, then unzip and extract the contents into the game_dir (in mac, is inside the bundle).
NOTE: of course when you do the update you must update that value in the options.rpy file too. If you leave it to old version the program once restarts will think it still needs updating, and enter an infinite loop! So the latest .zip should contain a options.rpy with the matching GameVersion value.
A more nice way would have been to check the files on server, use a diff, or something else but as I said, I'm not a great programmer (just good
The downloading uses a threading code to refresh a bar showing the percentage progress of the download.
More in detail:
line 90 - calls the function servercheck which returns ok (if has trouble connecting is false) and lastV variable which sets the last version available on server
line 112 - starts a loop, downloads all the zips from current version number to latest version available
line 122 - is_downloading is a variable True if the program is still downloading the files
line 136 - program finished downloading all files, can now proceed to extract all the zips, of course from version older to more recent
On line 158 I also download from server a text file called releasenotes.txt but that's completely optional, if you want you can skip that part (I do it because is nice to show the player what has changed).
Now, I have NO CLUE why for some people it doesn't work. Here works on Pc/Mac, and I remember pytom tested it on linux and worked fine. So, if you find and fix the bug please repost the code so everyone can benefit from this, in the name of opensource development!

