ereinion
Member
I'm trying to write a function to extract what image-number hobopolis is at. I came up with the following, which works, but I have a suspicion it's not very efficient. Therefore I wondered if any of the skilled people here at the forums had any suggestions on how I could improve it.
From what I've read at the mafia-wiki I suspect using regular expressions might do the trick, but since I've never used them before nor have any idea of how they work, I would prefer to avoid using them.
* Edit * Remembered that it might be useful for people with a wish to help to see the html for "clan_hobopolis.php?place=2". So here you go (this is for a hobopolis-instance which hasn't been adventured in yet):
From what I've read at the mafia-wiki I suspect using regular expressions might do the trick, but since I've never used them before nor have any idea of how they work, I would prefer to avoid using them.
Code:
void hoboAvailable() {
int beginning; int finish; string hobopolis;
if(visit_url("town_clan.php").contains_text("clanbasement.gif") || !visit_url("clan_basement.php?fromabove=1").contains_text("not allowed")) {
if(visit_url("clan_basement.php").contains_text("opengrate.gif")) {
print("Found the sewers!", "blue");
if(visit_url("clan_hobopolis.php").contains_text("snarfblat=166")) {
print("Only the sewers are open","blue");
} else {
hobopolis = visit_url("clan_hobopolis.php?place=2");
beginning = index_of(hobopolis, "hobopolis/townsquare") + 10;
hobopolis = substring(hobopolis, beginning);
finish = index_of(hobopolis, ".gif");
beginning = 10;
hobopolis = substring(hobopolis, beginning, finish);
print("Hobopolis image " + hobopolis, "blue");
}
}
} else {
print("Can't find the sewers!","red");
}
}
* Edit * Remembered that it might be useful for people with a wish to help to see the html for "clan_hobopolis.php?place=2". So here you go (this is for a hobopolis-instance which hasn't been adventured in yet):
Code:
<html><head><script language=Javascript><!--if (parent.frames.length == 0) location.href="game.php";//--></script><script language=Javascript src="http://images.kingdomofloathing.com/scripts/keybinds.min.2.js"></script><script language=Javascript src="http://images.kingdomofloathing.com/scripts/window.20111231.js"></script><script language="javascript">function chatFocus(){if(top.chatpane.document.chatform.graf) top.chatpane.document.chatform.graf.focus();}defaultBind(47, CTRL, chatFocus); defaultBind(190, CTRL, chatFocus);defaultBind(191, CTRL, chatFocus); defaultBind(47, META, chatFocus);defaultBind(190, META, chatFocus); defaultBind(191, META, chatFocus);</script><script language=Javascript src="http://images.kingdomofloathing.com/scripts/jquery-1.3.1.min.js"></script><link rel="stylesheet" type="text/css" href="http://images.kingdomofloathing.com/styles.css"></head><body><centeR><table width=95% cellspacing=0 cellpadding=0><tr><td style="color: white;" align=center bgcolor=blue><b>Hobopolis Town Square</b></td></tr><tr><td style="padding: 5px; border: 1px solid blue;"><center><table><tr><td><map name="townsquare"><area shape="rect" coords="120,265,378,435" href="adventure.php?snarfblat=167" alt="Hobopolis Town Square (1)"><area shape="rect" coords="427,602,500,647" href="clan_hobopolis.php?place=1" alt="Back to the Sewers"><area shape="poly" coords="371,670,437,539,298,530,244,600,255,694" href="clan_hobopolis.php?place=3" alt="Richard's Redoubt"></map><center><img src="http://images.kingdomofloathing.com/otherimages/hobopolis/townsquare0.gif" width=500 height=744 border=0 usemap="#townsquare" alt="Hobopolis Town Square (picture #0)" title="Hobopolis Town Square (picture #0)"></td></tr></table><center><p><a href="clan_basement.php">Go back to your Clan Basement</a></center></td></tr></table></center></td></tr><tr><td height=4></td></tr></table></center></body></html>
Last edited: