• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM JSON reading from URL.

N

NoFontNL

Guest
Hi.
Code:
var wrjson = '{"status":"Success.","p1":"NoFontNL","s1":"26"}';
wrjsonlist = json_decode(wrjson);
var worldrecord = wrjsonlist[? "s1"];
var wrowner = wrjsonlist[? "p1"];
draw_text_outline(x-240,y+52,string(worldrecord) + " by " + string(wrowner),4,c_black);
works, but
Code:
var wrjson = http_get('the_url_which_contains_the_same_text_as_above') // (raw text without html)
wrjsonlist = json_decode(wrjson);
var worldrecord = wrjsonlist[? "s1"];
var wrowner = wrjsonlist[? "p1"];
draw_text_outline(x-240,y+52,string(worldrecord) + " by " + string(wrowner),4,c_black);
doesn't work.

How would I make method 2 work?
 

jo-thijs

Member
Hi.
Code:
var wrjson = '{"status":"Success.","p1":"NoFontNL","s1":"26"}';
wrjsonlist = json_decode(wrjson);
var worldrecord = wrjsonlist[? "s1"];
var wrowner = wrjsonlist[? "p1"];
draw_text_outline(x-240,y+52,string(worldrecord) + " by " + string(wrowner),4,c_black);
works, but
Code:
var wrjson = http_get('the_url_which_contains_the_same_text_as_above') // (raw text without html)
wrjsonlist = json_decode(wrjson);
var worldrecord = wrjsonlist[? "s1"];
var wrowner = wrjsonlist[? "p1"];
draw_text_outline(x-240,y+52,string(worldrecord) + " by " + string(wrowner),4,c_black);
doesn't work.

How would I make method 2 work?
http_get works asynchronously and thus does not return the results of the http request, but instead returns an ID you can use in the "asynchronous HTTP event".
In that event, you'll get the results from the request inside the async_load map.
 
Top