Buffbot Script help.

HasteBro

Member
I'm trying to make a buffbot script which relies on the time_to_string() function, trying to make it work from 00:50 AM to 00:00 AM (rollover is at around 00:30 AM for me).

I started messing around with that function figuring out how to work it into the script, until I got to this:

Code:
boolean time1 = time_to_string() >= "00:00:00 BRT";
boolean time2 = time_to_string() <= "00:50:00 BRT";
boolean time3 = time_to_string() > "00:50:00 BRT";
boolean time4 = time_to_string() < "23:59:59 BRT";

if (my_inebriety() >= 20)
{
	boolean use_familiar() ($familiar[disembodied hand]);
	boolean maximize(string MP);
	boolean equip() ($item[jewel-eyed wizard hat]);
	boolean use() ($item[WANG]);
	void chat_clan() ("HastyBuffer is online and Buffing!");
	
	while (time3 == true && time4 == true)
	{
		boolean cli_execute() ("buffbot 10");
		repeat until (time1 == true && time2 == true)
	}
	boolean maximize(string adv);
	boolean cli_execute() ("exit");
}

Now, I've run into a wall, because of the repeat until, which always returns this:

KoLMafia gCLI said:
Function 'until( boolean )' undefined. This script may require a more recent version of KoLmafia and/or its supporting scripts. (TESTBUFFING.ash, line 19)

Now, I can't figure out what I'm doing wrong there. Another thing I can't figure out is, if I remove the repeat, the script works, but the script does nothing at all, not even the stuff before the while. How do I fix this?


On another note. Would it be possible to have the script add the people who got buffed by my buffbot throughout the day to a list, which would later be used in buff raffles (kind of like KingdomOfBuffing did)?

Thanks for all the help.
 

Theraze

Active member
You keep redefining values that shouldn't be redefined... try this:
Code:
boolean time1 = time_to_string() >= "00:00:00 BRT";
boolean time2 = time_to_string() <= "00:50:00 BRT";
boolean time3 = time_to_string() > "00:50:00 BRT";
boolean time4 = time_to_string() < "23:59:59 BRT";

if (my_inebriety() >= 20)
{
	use_familiar($familiar[disembodied hand]);
	maximize(string MP);
	equip($item[jewel-eyed wizard hat]);
	use($item[WANG]);
	chat_clan("HastyBuffer is online and Buffing!");
	
	while (time3 && time4 && !time1 && !time2)
		cli_execute("buffbot 10");
	maximize(string adv);
	cli_execute("exit");
}
Note that, since you only call time_to_string outside this loop, it will run forever, despite your checks... I'd probably do something more like this:
Code:
boolean bufftime = time_to_string() > "00:50:00 BRT";

if (my_inebriety() >= 20)
{
	use_familiar($familiar[disembodied hand]);
	maximize(string MP);
	equip($item[jewel-eyed wizard hat]);
	use($item[WANG]);
	chat_clan("HastyBuffer is online and Buffing!");
	
	while (bufftime)
	{
		cli_execute("buffbot 10");
		bufftime = time_to_string() > "00:50:00 BRT";
	}
	maximize(string adv);
	cli_execute("exit");
}
Note that since the only non-buffing time is <00:50 BRT, we just need to check if you're above that and if so, start buffing. No need to validate the rest of the time stuff. We also need to, inside the loop, update our check. We could just do the time_to_string() check on the line and not define bufftime at all, but that comes down to whether you'd ever like to report on it... you could report the start time by putting bufftime into your chat_clan line and put an offline notification complete with time after the while-loop ends.
 
Last edited:

HasteBro

Member
Ahh, I see. Would adding a conditional for the time within the while loop make it run the maximize and exit at the end? Like this:

Code:
boolean bufftime = time_to_string() > "00:50:00 BRT";

if (my_inebriety() >= 20)
{
	use_familiar($familiar[disembodied hand]);
	boolean maximize(string MP);
	equip($item[jewel-eyed wizard hat]);
	use(1, $item[WANG]);
	chat_clan("HastyBuffer is online and Buffing!");
	while (bufftime)
	{
		cli_execute("buffbot 10");
		bufftime = time_to_string() > "00:50:00 BRT";
		if (time_to_string() == "23:55:00 BRT")
		{
			chat_clan("HastyBuffer will be logging out in 5 minutes.");
		}
		if (time_to_string() >= "00:00:00 BRT" && time_to_string() <= "00:25:00 BRT")
		{
			boolean maximize(string adv);
			cli_execute("exit");
		}
	}
}
 

Theraze

Active member
Sort of... the problem with that is more that you're in very specific times for the logout message, and the ending maximization is much more touchy in your example. I'd probably consider something more like this:
Code:
if (my_inebriety() >= 20)
{
	use_familiar($familiar[disembodied hand]);
	maximize("MP", false);
	equip($item[jewel-eyed wizard hat]);
	use(1, $item[WANG]);
	chat_clan("HastyBuffer is online and Buffing!");
	boolean quitting = false;
	while (time_to_string() > "00:50:00 BRT")
	{
		cli_execute("buffbot 10");
		if (time_to_string() > "23:55:00 BRT" && !quitting)
		{
			chat_clan("HastyBuffer will be logging out in 5 minutes.");
			quitting = true;
		}
	}
	maximize("adv", false);
	cli_execute("exit");
}
The benefit of this is that it doesn't depend on the buffbot hitting the exact second... Also, since you always maximize for mp... wait, that's supposed to be a maximization, right? Changing the above so that should actually work... Anyways, since you maximize for mp before, you should probably always maximize for adventures after...
 

HasteBro

Member
Oh right, didn't really think about that. Well, it seems to be working now, but I'll only be certain after tonight's rollover.

Thanks for all the help Theraze!
 

slyz

Developer
Does comparing the return value of time_to_string() and another string give the results your are expecting?

Shouldn't you be using gametime_to_int() for this sort of thing?
 
Last edited:

Theraze

Active member
Not a clue... but he gave that as the "working" one, so I kept using it. It's relatively easy to calculate out using gatetime_to_int... just remember that a full day/rollover involves 86400000ms, and work out from there. Each minute is 86400000/24/60=60000 (60k), so 5 minutes would be 300k off from the 86.4 million bringing it to 86.1 million...
 
Code:
...
	boolean use_familiar() ($familiar[disembodied hand]);
	boolean maximize(string MP);
	boolean equip() ($item[jewel-eyed wizard hat]);
	boolean use() ($item[WANG]);
	void chat_clan() ("HastyBuffer is online and Buffing!");
...
...if I remove the repeat, the script works...

Really? If this works then I seriously don't understand ASH as well as I thought I did.

Anyway, as to your other question regarding a list, yes you can. I'm not sure what "buffbot 10" does, but if you manage the buffbot manually with a script (and not through the kmail interface provided by mafia) then you'd already know who was requesting buffs when they request it, and you'd need to only store that data in a map and save it to file.
 

Theraze

Active member
I think as long as your redefinition matches the original definition, it should probably work. In the cases where it's different though... those would likely fail. Miserably. :) So the only one that might work would be maximize, and probably not since it's missing the second variable.
 

heeheehee

Developer
Staff member
I think as long as your redefinition matches the original definition, it should probably work. In the cases where it's different though... those would likely fail. Miserably. :) So the only one that might work would be maximize, and probably not since it's missing the second variable.

If I remember correctly, if your redefinition matches the original definition of a built-in (parameter-wise), your redefinition is ignored. Otherwise, it works just fine.
 
Top