- 1,748
- Posts
- 15
- Years
- Age 28
- Nearby my feet.
- Seen Apr 18, 2021
Simply put, this script just checks if the game needs to be updated when you start it up.
The instructions are located within the script, please make sure you follow them.
NOTE: Make sure your webpage/thread/ect. contains "Version = 1.0.0 or whatever your version is."
NOTE: This does not actually update the game if needed, it only tells the player to update the game if there is a newer version.
NOTE: The Version may only contain numbers and decimal points.
EDIT: I added dragonnite's suggestion on adding to download the update (Instructions are in the comments to set it up) (I also didn't test this with an actual zip/rar/7z/exe file but in theory it should work, if to doesn't please let me know and I'll fix it)
For anyone looking for an example on how the version and download URLs should look like on your Thread/Wiki/ect. here's one:
The instructions are located within the script, please make sure you follow them.
NOTE: Make sure your webpage/thread/ect. contains "Version = 1.0.0 or whatever your version is."
NOTE: This does not actually update the game if needed, it only tells the player to update the game if there is a newer version.
NOTE: The Version may only contain numbers and decimal points.
EDIT: I added dragonnite's suggestion on adding to download the update (Instructions are in the comments to set it up) (I also didn't test this with an actual zip/rar/7z/exe file but in theory it should work, if to doesn't please let me know and I'll fix it)
Code:
################################################################################
# Version Check
# By Hansiec
################################################################################
# Checks your current game version and compares it to the latest
#
# Instructions:
# 1. Copy your Thread URL (or the url that will contain the current version of
# your game, examples are: PokeCommunity threads, Wikis, and your own Website)
#
# 2. Paste the URL in step 1 into the "ThreadURL" variable below.
#
# 3. Make sure that anywhere in your given URL it contains "Version = VersionID"
#
# 4. Edit the "GameVersion" variable below to the version of the game.
#
# 5. Edit the "UpdateMessage" variable below if you want a custom warning when the
# game needs an update
#
# 6. Test it out (it should automatically check updates at the startup of the
# game)
#
# 7. If you want to automatically download updates, add in your given URL
# "DownloadUrl = "DirectDownloadLinkToGame" " (there must be double quotes around your actual link)
#
#
#
################################################################################
ThreadURL = "Game URL Here"
GameVersion = "Game Version Here"
UpdateMessage = "There is an update available for this game, please download" +
" the latest version to experience the game's full potential."
UpdateDownloadedMessage = "The update has been downloaded, plase look in the" +
"game folder for the file"
def pbCheckVersion
string = pbDownloadToString(ThreadURL).downcase
if string.include?("version=")
string = string.split("version=")[1]
string = string[/([0-9\.]+)/]
elsif string.include?("version = ")
string = string.split("version = ")[1]
string = string[/([0-9\.]+)/]
elsif $DEBUG
print "The given URL is either invalid or does not contain " +
"the data for finding the current version (it should be Version = "+
"CurrentVersion)."
end
if string == GameVersion
return true
end
Kernel.pbMessage(_INTL(UpdateMessage))
return false
rescue
return true
end
def pbDownloadUpdate
string = pbDownloadToString(ThreadURL).downcase
if string.include?("downloadurl=")
string = string.split("downloadurl=")[1]
string = string[/([a-zA-z0-9\.\\\/ :]+)/]
elsif string.include?("downloadurl = ")
string = string.split("downloadurl = ")[1]
string = string[/([a-zA-z0-9\.\\\/ :]+)/]
else
return
end
string.gsub!("\\", "/")
split = string.split("/")
pbDownloadData(string, split[split.length - 1])
Kernel.pbMessage(_INTL(UpdateDownloadedMessage))
end
if !pbCheckVersion
pbDownloadUpdate
end
For anyone looking for an example on how the version and download URLs should look like on your Thread/Wiki/ect. here's one:
Code:
Version = 1.0.0
DownloadURL = "https://myWebHost.com/Downloads/MyGame.zip"
Last edited: