Pixel-Composer/scripts/async_functions/async_functions.gml
2024-07-19 10:20:18 +07:00

18 lines
473 B
Plaintext

function asyncInit() {
global.asyncCalls = ds_map_create();
}
function asyncCall(aid, callback = noone, parameters = {}) {
global.asyncCalls[? aid] = [ callback, parameters ];
}
function asyncLoad(data) {
if(!ds_map_exists(global.asyncCalls, data[? "id"])) return;
var cal = global.asyncCalls[? data[? "id"]];
var callback = cal[0];
var parameters = cal[1];
if(callback != noone) callback(parameters, data);
ds_map_delete(global.asyncCalls, data[? "id"]);
}