Using faxbot

jwylot

Member
One of the routines in my afterbore script requests a clod hopper from faxbot. The code I use leaves the possibility of picking up the wrong monster from the clan fax machine. Is there a safer alternative to using the "wait" command?

PHP:
void clodhoppering()
{
	//...
	chat_private ("faxbot", "clodhopper");
	wait (60);
       //...
	
}
 

slyz

Developer
You could wait, retrieve the fax and check if the fax contained the monster you wanted:
PHP:
void clodhoppering() 
{ 
    //... 
    chat_private ("faxbot", "clodhopper"); 
    wait (60); 
    cli_execute( "fax get" );
    if( get_property( "photocopyMonster" ).to_monster() != $monster[ clodhopper ] )
        abort( "Wrong monster faxed!" );
    // ...
}
 

lostcalpolydude

Developer
Staff member
Ideally, http://kolmafia.us/showthread.php?5892-Request-a-Fax-from-CLI would get implemented, and then everything would be simplified. Since faxbot won't visit a clan more than once per minute, waiting some amount of time up to a minute should work fine. If you got the wrong monster, you could even have it dump the fax in The Fax Dump and repeat the process until it succeeds, but that leads to horrible results if faxbot isn't logged in (not too horrible, but an endless loop of server hits at least).
 

jwylot

Member
I settled on just one try as it's not worth facing the consequences of faxbot being offline.
PHP:
void clodhoppering() 
{
	chat_private ("faxbot", "clodhopper");
	wait (60);
	cli_execute ("fax get");
	if( get_property( "photocopyMonster" ).to_monster() != $monster[ clodhopper ] )
	{
	cli_execute ("fax put");
	abort ("Couldn't get a cloddhopper");
	}
    //...
}
 

jwylot

Member
For someone who has no programming experience and is struggling to get to grips with ash, you guys are an awesome resource. So I finally settled on this which seems to work and should prevent fighting the wrong monster.

PHP:
void clodhoppering()
{
	if( !is_online( "faxbot" ) ) abort( "Faxbot is dead!" );
	while ( get_property( "photocopyMonster" ).to_monster() != $monster[ clodhopper ] )
	{
	if (item_amount ( $item[photocopied monster] ) != 0)
	{
	cli_execute ("fax put");
	}
	chat_private ("faxbot", "clodhopper");
	wait (60);
	cli_execute ("fax get");
	}
	//buffing and combat routine
}
 
Top