From 9ca936ea7690dd5c4035dc0fb76108ec216674ae Mon Sep 17 00:00:00 2001 From: AardCrowley <12467582+AardCrowley@users.noreply.github.com> Date: Sun, 17 Feb 2019 18:28:14 -0500 Subject: [PATCH] Update AardClock2.0_Beta.xml --- AardClock2.0_Beta.xml | 57 +++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/AardClock2.0_Beta.xml b/AardClock2.0_Beta.xml index fed6018..cde647d 100644 --- a/AardClock2.0_Beta.xml +++ b/AardClock2.0_Beta.xml @@ -6,7 +6,7 @@ - + @@ -440,40 +440,45 @@ require 'mw_theme_base' print("Mouseup!") end -function update_plugin() - raw = "https://raw.githubusercontent.com/AardCrowley/Aardwolf-Scripts/master/Auction_Utilities/AardClock2.0_Beta.xml" + function OnPluginInstall() + PLUGIN_VERSION = GetPluginInfo(GetPluginID(), 19) + PLUGIN_NAME = GetPluginInfo(GetPluginID(), 1) + end - async_ok, async = pcall (require, "async") + function update_plugin() + raw = "https://raw.githubusercontent.com/AardCrowley/Aardwolf-Scripts/master/Auction_Utilities/AardClock2.0_Beta.xml" - if async_ok then - plugin_page = async.doAsyncRemoteRequest(raw, raw_get, "HTTPS") - else - ColourNote("white", "blue", "Error on plugin update!") - end + async_ok, async = pcall (require, "async") + + if async_ok then + plugin_page = async.doAsyncRemoteRequest(raw, raw_get, "HTTPS") + else + ColourNote("white", "blue", "Error on plugin update!") + end end function raw_get(retval, page, status, headers, full_status, request_url) - if status == 200 then - raw_version = tonumber(string.match(page, '%s%s+version="([0-9%.]+)"')) - end + if status == 200 then + raw_version = tonumber(string.match(page, '%s%s+version="([0-9%.]+)"')) + end - if raw_version == PLUGIN_VERSION then - ColourNote("white", "blue", PLUGIN_NAME .. " is up-to-date.") - elseif raw_version > PLUGIN_VERSION then - ColourNote("white", "blue", "Updating from version " .. PLUGIN_VERSION .. " to " .. raw_version .. ". Do not touch anything!") - local file = io.open(GetPluginInfo(GetPluginID(), 6), "w") - file:write(page) - file:close() - end + if raw_version == PLUGIN_VERSION then + ColourNote("white", "blue", PLUGIN_NAME .. " is up-to-date.") + elseif raw_version > PLUGIN_VERSION then + ColourNote("white", "blue", "Updating from version " .. PLUGIN_VERSION .. " to " .. raw_version .. ". Do not touch anything!") + local file = io.open(GetPluginInfo(GetPluginID(), 6), "w") + file:write(page) + file:close() + end - raw_version = nil + raw_version = nil - if "" == GetAlphaOption("script_prefix") then - SetAlphaOption("script_prefix", "\\\\\\") - end + if "" == GetAlphaOption("script_prefix") then + SetAlphaOption("script_prefix", "\\\\\\") + end - Execute(GetAlphaOption("script_prefix") .. "DoAfterSpecial(1, \"ReloadPlugin('" .. GetPluginID() .. "')\", sendto.script)") - ColourNote("white", "blue", "Update complete!") + Execute(GetAlphaOption("script_prefix") .. "DoAfterSpecial(1, \"ReloadPlugin('" .. GetPluginID() .. "')\", sendto.script)") + ColourNote("white", "blue", "Update complete!") end -- end Update code ]]>