ID:159623
 
Well, I'm trying to go through member pages and parse through HTML to find the game they're playing. I have no clue where I would start. I could hear some copytext()'s and findtext()'s possibly screaming at me but that's all.
Maybe this could help

Click here
In response to Haywire
Thanks.
In response to Haywire
Actually..What I meant was finding the complete hub using copytext() and findtext(), but that link does help. =D

Here's what I think it should look like:
var/hub = world.Export("http://byond.com/members/[key]?format = text")
if(findtext(hub, "hub ="))
copytext(...)

EDIT:
The only problem is I can't figure out how I'd find the length of the name of the game their on. Or else it'd just be blindly copytexting stuff that's not part of the URL.
In response to Choka
Choka wrote:
The only problem is I can't figure out how I'd find the length of the name of the game their on. Or else it'd just be blindly copytexting stuff that's not part of the URL.

Why would you need to use find/copytext() here?
"I'm gonna let everyone in on a little secret. The format=text stuff is designed in BYOND savefile format." Nadrew id:639687
In response to Schnitzelnagler
So I could make a savefile and extract from there? Narrlyyyyy =D.
In response to Schnitzelnagler
How am I to export the vars? I tried the following:
friend.game_name = data["name"]

//exporting from http://byond.com/members/[friend.name]?format=text Why is it returning null? Do I have to call the type of var? Like...data["world/1.name"]?
In response to Choka
data is a save file, correct? You would use data["name"] >> var, then.
In response to Jeff8500
So...
var/name = ""
data["name"] >> name

?
In response to Jeff8500
It didn't work like that D:. It was still null. I know, I have it set to show up in the output chat as a test =D.
In response to Jeff8500
Apparently >> is virtually useless/superfluous except when dealing with objects, since I've seen people just using SF["dir"] directly to access the value there (basically like with an associative list).
Though, more insight on this definitely won't hurt.
In response to Kaioken
Hub()
for(var/friend/name in usr.friends)
var/hub_info = world.Export("http://byond.com/members/[name]?format=text")
var
savefile/data = new()
information = file2text(hub_info["CONTENT"])
data.ImportText("/",information)
var/Game = ""
data["name"] >> Game
name.desc = "[Game]"
world << "Game: [Game]"
world << "[data["name"]]"
if(findtext(file2text(data), "name"))
world<<"Bob does exist!"

I just used findtext to see if it was even in there ;D. You can ignore it if you want... and the world stuff. THat was also to see if it was null.
In response to Choka
Naturally if the directory isn't in the root of the savefile, you can't just access it immediately and expect DM to find it on its own throughout the savefile; you need to navigate to it first, or specify the path to it, whether relative or full.
Also, setting a var to any value just before reading a value from a savefile into it is completely pointless; it has no effect and the value is immediately overwritten by the value from the savefile. So it's really quite equivalent to setting a var to 1, and then immediately to 2; incidentally the only ways to set a var's value in DM are the >> and = (and its 'family') operators.
In response to Kaioken
Navigate to it?
var/savefile/data = file("File.sav")//??
In response to Choka
...Well, look up savefile, cd and file() and file2text() for that matter, since you should look up any proc you're using. file() isn't for dealing with savefiles, and I don't think you're supposed to directly read them with file2text() either; you're probably abusing luck there.
In response to Kaioken
file() is used to find a specific file within the game's directory with the path name you identify. If you type in just the file's name, it'll search the game's main directory, while if you type in something like "Savefiles/text.txt" it'll find the text.txt file in the Savefiles folder in the game's directory. But you already knew that, right? ;p
In response to Kaioken
What about...ExportText to replace file2text. Sound better?
In response to Spunky_Girl
Yeah... Could you explain ExportText? OR rather just what the "\" bit is for.
In response to Kaioken
Abusing luck? And can I replace file2text with ExportText or what?

EDIT: Nevermind on ExportText, not even related. But what would i use instead of file2text then?
In response to Choka
I just compiled (and tested) a little snippet that I created using Nadrews posting that I linked to earlier ( id:639687 ).

mob
verb
MemberCheck(keyname as text)
var/hub_download[] = world.Export("http://www.byond.com/members/[keyname]?format=text")
if(!hub_download)
CRASH("Failed to connect to the BYOND Hub, please check your network settings.")
else
if(hub_download["CONTENT-TYPE"] != "text/plain; charset=ISO-8859-1")
usr << "This is not a valid BYOND key."
else
var/information = file2text(hub_download["CONTENT"])
var/finfo = copytext(information, findText(information, "general"))
/* cutting the received data is essential for me, because of the bug I randomly encounter with world.Export (id:686660) */
var/savefile/data = new()
data.ImportText("/",finfo)
data.cd = "/"
if("world" in data.dir)
data.cd = "/world"
for(var/wodi in data.dir)
data.cd = "[wodi]"
var/wona
data["name"] >> wona
usr << "World-name: [wona]"
else
usr << "The player is currently not playing any game."


This should enable you to change it to your needs.

Edit:
Gah! Evil! Just saw that you had made another post and got an answer there already as well... *sighs*