I made an example plugin:
//auto updating plugin
global.curVersion = 1;
global.versionChecker = object_add()
object_set_persistent(global.versionChecker,true);
object_event_add(global.versionChecker,ev_create,0,'
checkVersion = true;
host = "dl.dropbox.com";
path = "/u/61252990/TestPluginVersion.txt";
event_user(0);
');
object_event_add(global.versionChecker,ev_other,ev_user0,'
socket = noone;
update = false;
// downloads a text file off the internet, and parses it for instructions
// from the developers
// If any are found, they will be shown/executed/whatever
var CRLF;
CRLF = chr(13) + chr(10);
socket = tcp_connect(host, 80);
response = "";
// Send HTTP Request (HTTP 1.0, so we can just read until the server closes the connection)
write_string(socket, "GET " + path + " HTTP/1.0" + CRLF);
write_string(socket, "Host: " + host + CRLF + CRLF);
socket_send(socket);
');
object_event_add(global.versionChecker,ev_step,ev_step_normal,'
response += read_string(socket, tcp_receive_available(socket));
if(tcp_eof(socket)) {
if(socket_has_error(socket)) {
instance_destroy();
exit;
}
// Process the received file
var CRLF, LF, CR;
CR = chr(13);
LF = chr(10);
CRLF = CR + LF;
// find where the header ends, so we can chop it off
// and just return the important stuff
var headerlength;
headerlength = string_pos(CRLF + CRLF, response) + 2 * string_length(CRLF);
if(headerlength == 0) {
instance_destroy()
exit;
} else {
response = string_copy(response, headerlength, string_length(response) - headerlength + 1);
if checkVersion {
if real(response) > global.curVersion {
global.curVersion = real(response);
checkVersion = false;
show_message("A new version (v"+response+") of testplugin will now be downloaded");
host = "dl.dropbox.com";
path = "/u/61252990/TestPlugin_"+response+".gml";
event_user(0);
} else instance_destroy();
} else {
var file;
file = file_text_open_write("Plugins/Testplugin_"+string(global.curVersion));
file_text_write_string(file,response);
file_text_close(file);
instance_destroy();
}
}
}
');
object_event_add(MainMenuController,ev_create,0,"instance_create(0,0,global.versionChecker)");
It's linked to my dropbox (but it could also work with github stuff i guess)
First it downloads the current version number from TestPluginVersion.txt (it's just a textfile with the number in it)
If the version is higher it will download the new version (it can currently only download textfiles so no images and stuff)
This testplugin doesn't remove the old file when it updated and it doesn't restart gg2 when the new version is downloaded so you would have to add that too if you were to use this. Also i made this for vanilla gg2 where the plugins get loaded at startup, in randomizer you can just create the object directly in the plugin i guess.