TimeSpinner functions

ckb

Minion
Staff member
In case anyone needs to script TimeSpinner use (before it is implemented natively), I wrote a few functions you may find useful.

PHP:
//Fight a monster based on ID #
boolean TimeFight(int mid) {
	monster mon = to_monster(mid);
	print("TimeFighting a "+mon,"maroon");
	buffer page = visit_url("inv_use.php?pwd=&whichitem=9104");
	if (get_property("_timeSpinnerMinutesUsed").to_int()>7) {
		print("TimeFighting failed, not enough minutes","red");
		return false;
	}
	page = run_choice(1);
	if (contains_text(page,"option value=\""+mid+"\"")) {
		//print("TimeFighting "+mon,"blue");
		page = visit_url("choice.php?pwd=&whichchoice=1196&option=1&monid="+mid);
		page = run_combat();
		return true;
	} else {
		print("TimeFighting failed, "+mon+" not available","red");
		return false;
	}
}

//Fight a $monster[]
boolean TimeFight(monster mon) {
	return TimeFight(to_int(mon.id));
}

//Eat a remembered food
boolean TimeEat(item fud) {
	int iid = to_int(fud);
	buffer page = visit_url("inv_use.php?pwd=&whichitem=9104");
	if (get_property("_timeSpinnerMinutesUsed").to_int()>7) {
		print("TimeEating failed, not enough minutes","red");
		return false;
	}
	page = run_choice(2);
	if (contains_text(page,"option value=\""+iid+"\"")) {
		print("TimeEating "+fud,"blue");
		page = visit_url("choice.php?pwd=&whichchoice=1197&option=1&foodid="+iid);
		return true;
	} else {
		print("TimeEating failed, "+fud+" not available","red");
		return false;
	}
}

//Fight a scaling back in time monster
boolean TimePower() {
	buffer page = visit_url("inv_use.php?pwd=&whichitem=9104");
	if (get_property("_timeSpinnerMinutesUsed").to_int()>9) {
		print("TimePower failed, not enough minutes","red");
		return false;
	}
	print("TimePower leveling","maroon");
	page = run_choice(3);
	run_combat();
	if (item_amount($item[compounded experience])>0) {
		return true;
	} else {
		print("TimePower failed","red");
		return false;
	}
}
 

Bale

Minion
Thank you for sharing. I am learning to dislike using the time-spinner without CLI commands, particularly for eating food.
 

lostcalpolydude

Developer
Staff member
If you're going to check for the food being valid, you can check _timeSpinnerFoodAvailable before loading the page.

I've already failed at figuring out how to get that working as a built-in mafia command, hopefully someone else can tackle it.
 

Veracity

Developer
Staff member
I'll take a look at what you posted, again. Didn't see anything obvious the first time.
 

ckb

Minion
Staff member
If you're going to check for the food being valid, you can check _timeSpinnerFoodAvailable before loading the page.
I've already failed at figuring out how to get that working as a built-in mafia command, hopefully someone else can tackle it.

I could do that, but there seems to be some issue where _timeSpinnerMinutesUsed gets out of sync with actual minutes used, and hitting the page will refresh and get the correct value. And while I am hitting that page, it is easy to look at the food list too.

So this is a long-winded way of me remembering I should file a bug report about that and trying to figure out when it happens.
 

ckb

Minion
Staff member
Do you still need to file a bug report?

I don't know. I've been automating my runs and not paying much attention to "_timeSpinnerMinutesUsed", but this reminds me to add some additional checks for next time.
 
Top