Help with my breakfast script

HasteBro

Member
Is there a way to make the script detect if I'm at or over basement level 500? I want to call another script for power leveling after getting the telescope part, so that I reach 30 without wasting meat on the basement.

I already state that I'm very inexperienced, so please explain things so that I understand and possibly apply on my own in later scripts ;)

The code I have right now, it's the part I want to change:
Code:
else if (my_name() == "HasteBro")
{
	if (my_level () >= 13 && my_inebriety () <=19)
	{
		if (my_level () <= 19)
		{
			print ("Welcome Haste Bro. Starting Personalized Farming Routine", "blue");
			cli_execute("call 0 - HasteBro farming.txt");
		}
		else
		{
			print ("Welcome Haste Bro. You're ready to face the Basement. Calling AutoBasement.ash", "blue");
			cli_execute ("call 1 - HASTEBRO Consumption.txt");
			cli_execute("call autobasement.ash");
		}
	}
	else
	{
		print ("Welcome Haste Bro. You can start you daily activities.", "blue");
	}
}
 
When in doubt, steal stuff from people who know better!

slightly modified code from autobasement:

Code:
		string page = visit_url("basement.php");

		int basementLevel = -1;
	
		if (page.contains_text("<b>Fernswarthy's Basement, Level "))
		{
			int start_index = index_of(page, "<b>Fernswarthy's Basement, Level ") + "<b>Fernswarthy's Basement, Level ".length();
	
			string sub = substring(page, start_index);
			sub = substring(sub, 0, index_of(sub, "</b>"));
	
			basementLevel = sub.to_int();
		}

//do more stuff here now that you know basementLevel
 
Well... You can set autoBasement to stop at floor 500 (zlib autoBasement_break_on_floor = 500) and thus it will exit that script. This means that if you can do a check in your else-statement like the following:
Code:
else
{
	print ("Welcome Haste Bro. You're ready to face the Basement. Calling AutoBasement.ash", "blue");
	cli_execute ("call 1 - HASTEBRO Consumption.txt");
	cli_execute("call autobasement.ash");
	if(my_adventures() > 0)
	{
		"Whatever you want to do next"
	}
}
 
Oh, I thought that the break_on_floor would completely stop Mafia, as it has done before, but I guess it was something else that did that.

And I'm sorry roippi, I really have no idea how and where to use that, like I said, I'm REALLY inexperienced with any kind of scripting. I'll just use Winterbay's tip and do that instead.

Thank you both for the help =D
 
Oh, I thought that the break_on_floor would completely stop Mafia, as it has done before, but I guess it was something else that did that.

There are no aborts in the autobasement code so it shouldn't do that. It might exit for other reasons than getting to the designated floor though (such as not managing to get buffed high enough for a test) so it might be a good idea to use roippi's snippet instead.

In that case your script (as it stands with the pieces here) would look like:
Code:
int basement_level()
{
	string page = visit_url("basement.php");
	int basementLevel = -1;
	
	if (page.contains_text("<b>Fernswarthy's Basement, Level "))
	{
		int start_index = index_of(page, "<b>Fernswarthy's Basement, Level ") + "<b>Fernswarthy's Basement, Level ".length();

		string sub = substring(page, start_index);
		sub = substring(sub, 0, index_of(sub, "</b>"));

		basementLevel = sub.to_int();
	}
	return basementLevel;
}

else if (my_name() == "HasteBro")
{
	if (my_level () >= 13 && my_inebriety () <=19)
	{
		if (my_level () <= 19)
		{
			print ("Welcome Haste Bro. Starting Personalized Farming Routine", "blue");
			cli_execute("call 0 - HasteBro farming.txt");
		}
		else
		{
			print ("Welcome Haste Bro. You're ready to face the Basement. Calling AutoBasement.ash", "blue");
			cli_execute ("call 1 - HASTEBRO Consumption.txt");
			cli_execute("call autobasement.ash");
		}
		if(basement_level() < 500 && my_adventures() > 0 && my_level() < 30)
			print("Exited autoBasement too early. Check what went wrong.", "red");
		else
			Do what you want to do now.
	}
	else
	{
		print ("Welcome Haste Bro. You can start you daily activities.", "blue");
	}
}

i.e. incorporate roippi's code as a function that returns the basementlevel as an integer.
 
Back
Top