ID:148251
 
Is there a way to get the contents of a URL within a BYOND game?

For the XML library I'm working on, I would like the demo to show the power of using XML for games by downloading the Dark Age of Camelot XML files (they store server status, guild info, and spell info online in XML to let people put the info on their fan sites) and displaying live info parsed from the XML.

If there isn't a way, then this is a feature request!

(I never played Search Engine Wars, but I'm hoping maybe that did something similar...)
mob
verb
test(var/url as text)
var/text = ""
var/http[] = world.Export(url)
if(!http)
usr << "Failed to connect."
return
var/F = http["CONTENT"]
if(F)
text += html_encode(file2text(F))
usr << browse(text)
In response to Garthor
Garthor wrote:
mob
verb
test(var/url as text)
var/text = ""
var/http[] = world.Export(url)
if(!http)
usr << "Failed to connect."
return
var/F = http["CONTENT"]
if(F)
text += html_encode(file2text(F))
usr << browse(text)

Thanks, I'll try that out. Unfortunately it turns out that the files I was planning to download are too large to realistically turn into XML for the demo (23k lines for spells!)

But the technique should be generally useful anyway.
In response to Deadron
I used this in a few of my games but i found it impractical to use XML downloaded from a server rather than client side saves.
In response to Jinjo21
Jinjo21 wrote:
I used this in a few of my games but i found it impractical to use XML downloaded from a server rather than client side saves.

The purpose of XML on a server doesn't tend to save for saved games and such, it tends to be to communicate things about the status of your game world.