Help to create a script to find which drinks you're missing from Trophy #106

slyz

Developer
I had completely forgot about this, but here is my version of the script. I took Bale's version from post 16, and the script now prints in the gCLI a CLI command for you to copy/paste, like this:
Code:
(...)
Have NOT consumed Extra-slimy Slimosa, which you can purchase for 39000 meat.
Have NOT consumed Candicaine, which you can purchase for 55000 meat.
Have NOT consumed Sazuruk-hai, which you can purchase for 77776 meat.

You have yet to drink 3 of the drinks the spirit medium can produce.

buy 1 Extra-slimy Slimosa; drink 1 Extra-slimy Slimosa; buy 1 Candicaine; drink 1 Candicaine; buy 1 Sazuruk-hai; drink 1 Sazuruk-hai;
I found it was a convenient way for the script to help with consumption without fully automating the process (with those prices, I think most users would want a little bit of control).

Here it is:
PHP:
#
#		Happy Medium Drink Checker
#
#		V 0.01				4/25/2012		by Ethelred. Modified by ereinion and Bale
#		

void main() {
	item it;
	boolean [item] consumed;
	item [int] missing;
	boolean [item] possess;
	string exec;
	int drunk_left = inebriety_limit() - my_inebriety();
	string consumables = visit_url("showconsumption.php");
		
	for i from 5573 to 5638 {
		it = to_item( i );
		if( !contains_text(consumables, ">" + to_string( it ) + "<" )) {
			if(item_amount( it ) > 0)
				possess [it] = true;
			else
				missing [count(missing)] = it;
		} else consumed [it] = true;
	}
	if (count(consumed) == 66) {
		print( "You have drunk all the drinks the spirit medium can produce!", "blue");
	} else {
		foreach i in consumed
		{
			print("Already drunk: "+i, "green");
		}
		foreach i in possess
		{
			if ( drunk_left >= i.inebriety )
			{
				drunk_left -= i.inebriety;
				exec += "drink 1 " + i + "; ";
			}
			print( "Have NOT consumed " + i + ", of which you have " + item_amount( i ) + " in your inventory.", "#FBB117");
		}
		sort missing by mall_price(value);
		foreach n,i in missing
		{
			if ( drunk_left >= i.inebriety )
			{
				drunk_left -= i.inebriety;
				exec += "buy 1 " + i + "; drink 1 " + i + "; ";
			}
			print( "Have NOT consumed " + i + ", which you can purchase for "+ mall_price(i) +" meat.", "red");
		}
		print(" ");
		print("You have yet to drink " + to_string(66 - count(consumed)) + " of the drinks the spirit medium can produce.", "blue");
		print(" ");
		print( exec );
	}
}
 

Donavin69

Member
There are several (Locust-2, Firewater-3, Caipiranha-3, Humanitini-3, Mohobo-3, Punchplanter-2, Sazerorc-2, Aye Aye-3, Slimosa-2) duplicate names in the 66 for the trophy, how does this script break those out while searching the consumption page?

In mine, I gave up on that and just manually checked them...if there is a way to check for the specifics, I'd like to add it to Omnivore

*edit* - nevermind, I found it in Post 14 and 16...(*Blush*)
 
Last edited:
That's nice. With a little more work that could be awesome! (I particularly would like un-tasted drinks to have mall price listed on a buy&drink button.)

Small bug: You need to add target='_blank' to links so that they open in a new tab.

So, after Boris, I've been using the medium quite a bit cuz the drinks are awesome. Taking bordemstirs script, I added the target and the available_amount and historical_price to each drink. I'm afraid to do a buy&drink link. :eek:

The one thing I'd still like to add, it's in the Phylum column and I can't figure out how to do it, is to add the effect description the booze gives, since only the # of turns of the effect changes with the quality.

If it was python, I'd create a dictionary effects with the phylum as the key and a string with the effect description as the value. Then foreach s in $strings[...], I'd tack on effects in the write line. So if anyone can explain to me how that translates into ash, I could learn something new today.
 

Attachments

  • relay_Spirits.ash
    1.8 KB · Views: 32

Theraze

Active member
Couldn't you make a map with something like:
Code:
	string [phylum] description;
Then you could just set them by phylum, and pull them back out by phylum later?

Looks like it would work...
> ash string [phylum] description;

Returned: aggregate string [phylum]
 
Hey, that works!

Lol, I read this and was like "the script already has that.... insolent fools!" but then I remembered that I never uploaded it because the [buy] links work but the [drink] links do not work. Because I'm trying to do so with visit_url... I'm sure it could be easily done with ASH commands, now that I think about it (not sure why I didn't think about it before for an entire week while I was actually using this script... I feel retarded) so here's what I have with not-working links. I'll upload again once I put in real drink links.

EDIT: There are no [buy] links, heh. So yeah, links don't work. Sorry.
EDIT: TADA! Now there are, and now all the links work! Yay!
 

Attachments

  • relay_Spirits.ash
    4.4 KB · Views: 91
Last edited:

krunch0

New member
This is really nice work! Thanks for putting it together. I learned a lot about relay scripts from it, because I had my own small program I wrote. It doesn't have as many bells and whistles, but I've found it useful for tracking and making drinks as I ascend and knowing which not to make. It's interesting to see how others did things more efficiently, or more user-friendly-like, than I did. But I would like to include my script (written before I found this topic) for posterity, and to say--thanks.

By the way, I don't see too many scripts with text files on the side--is there a reason for this? Is it more convenient just to have everything in one script? I'm not sure what best coding practices are for KoLMafia.
 

Attachments

  • drinks.ash
    1.9 KB · Views: 47
  • drinks.txt
    1.2 KB · Views: 57

Bale

Minion
By the way, I don't see too many scripts with text files on the side--is there a reason for this? Is it more convenient just to have everything in one script? I'm not sure what best coding practices are for KoLMafia.

Actually there are a lot of script with text data files. It's just that we store them HERE for automatic download of latest updates using THIS. All hail zarqon! That's why he is worth his weight in bats.

The way you did it is fine.

Edit: Congratulations on activating your account.
 
Last edited:

Catch-22

Active member
Edit: Ninja'd by Bale.

By the way, I don't see too many scripts with text files on the side--is there a reason for this? Is it more convenient just to have everything in one script? I'm not sure what best coding practices are for KoLMafia.

file_to_map() actually works with URLs, many popular scriptwriters tend to host their map files externally in order to keep the map files up to date without the user having to download the map manually.

For smaller maps, or maps that are populated on the fly, they'd probably just define them in the script itself.
 

Paragon

Member
Here's something i have been using for that trophy, It doesn't know how much of any of them I have drank already, but it does tell me which ones I have in inventory.. and what type of creature i have to syphon to get it.
phylum paste_to_phylum(item it)
{
if(it.to_int()<5198 || it.to_int()>5219)
return $phylum[none];
switch (it.to_int())
{
case 5198: return $phylum[humanoid]; //gooey paste
case 5199: return $phylum[beast]; //beastly paste
case 5200: return $phylum[object]; //oily paste
case 5201: return $phylum[undead]; //ectoplasmic paste
case 5202: return $phylum[demihuman]; //greasy paste
case 5203: return $phylum[bug]; //bug paste
case 5204: return $phylum[hippy]; //hippy paste
case 5205: return $phylum[orc]; //orc paste
case 5206: return $phylum[demon]; //demonic paste
case 5207: return $phylum[horror]; //indescribably horrible paste
case 5208: return $phylum[fish]; //fishy paste
case 5209: return $phylum[goblin]; //goblin paste
case 5210: return $phylum[pirate]; //pirate paste
case 5211: return $phylum[plant]; //chlorophyll paste
case 5212: return $phylum[strange]; //strange paste
case 5213: return $phylum[mer-kin]; //Mer-kin paste
case 5214: return $phylum[slime]; //Slimy paste
case 5215: return $phylum[penguin]; //penguin paste
case 5216: return $phylum[elemental]; //elemental paste
case 5217: return $phylum[constellation]; //cosmic paste
case 5218: return $phylum[hobo]; //hobo paste
case 5219: return $phylum[crimbo]; //Crimbo paste
}
return $phylum[none];
}


phylum drink_to_phylum(item it)
{
int r=(it.to_int()-5573)/3;
switch(r)
{
case 0: return $phylum[undead]; //ectoplasmic paste
case 1: return $phylum[goblin]; //goblin paste
case 2: return $phylum[bug]; //bug paste
case 3: return $phylum[demihuman]; //greasy paste
case 4: return $phylum[pirate]; //pirate paste
case 5: return $phylum[humanoid]; //gooey paste
case 6: return $phylum[horror]; //indescribably horrible paste
case 7: return $phylum[beast]; //beastly paste
case 8: return $phylum[demon]; //demonic paste
case 9: return $phylum[elemental]; //elemental paste
case 10: return $phylum[slime]; //Slimy paste
case 11: return $phylum[object]; //oily paste
case 12: return $phylum[hippy]; //hippy paste
case 13: return $phylum[orc]; //orc paste
case 14: return $phylum[plant]; //chlorophyll paste
case 15: return $phylum[hobo]; //hobo paste
case 16: return $phylum[strange]; //strange paste
case 17: return $phylum[constellation]; //cosmic paste
case 18: return $phylum[penguin]; //penguin paste
case 19: return $phylum[crimbo]; //Crimbo paste
case 20: return $phylum[fish]; //fishy paste
case 21: return $phylum[mer-kin]; //Mer-kin paste
}
return $phylum[none];
}


Phylum to_phylum(item it)
{
phylum ret=$phylum[none];
ret = paste_to_phylum(it);
if (ret != $phylum[none]) return ret;
return drink_to_phylum(it);
}


void PrintInfo(item it)
{
string color="green";
if (available_amount(it)==0)
color="red";
print_html("<span style='color:"+color+"'>"+it.to_int()+" "+it +" " +it.to_phylum()+"</span>");
}








void main()
{
print ("DRINKS");
int startNum=5572;
for i from 1 to 3*22 by 1
{
PrintInfo(to_item(i+startNum));
}
//print ("PASTES");
//startNum=5197;
//for i from 1 to 22 by 1
//{
// PrintInfo(to_item(i+startNum));
//}
}
 
Top