A Namespaces Script

macman104

Member
First off, wow it's been a long time since I've posted a script or anything. Anyway though. This is a namespaces script. What it does is allow functions written in this script to be called from the gCLI or CLI like a regular function. It is a utility script. To read about namespaces, you can read holatuwol's post here. I now present the script, most of the functions should be pretty obvious in what they do. I've personally used all the functions except for buyMaxSeltz. The buySeltz is awesome, and I've been using it since earlier tonight and it's nice to just give mafia a price I'm willing to spend it for it to buy those seltzer. For these function, you should not need to include things in parentheses. If you need to pass a string that is more than one word, you will need to include it in quotes however.

Feel free to ask questions or suggest additional utility functions to add, cause if you think it's helpful, I probably will as well, and want to add it myself.

To use this script in your CLI, you have to add the script to your namespace. To do this, you simply type

using Namespaces.ash

This will put the namespaces script into your, well..namespace.
 

Attachments

  • Namespaces.ash
    1.6 KB · Views: 70

izchak

Member
How about changing the fam() function to a more varied (and modern) familiar roster?
Not everyone uses a CPM and an ADD, you know...

Also, I changed the string recognition to contains_text, so that the following all work:
fam bitten
fam cheshire bitten
fam bugbear
fam pygmy bugbear shaman
fam MPsuckingwhoreofabugbear
fam tick
fam nervoustick
fam nervuss tick
fam FOOFLARBLARtickFLARBLAR
and so on.
My theory is: make the code smart, so the user can be stupid. I'm stupid, and I appreciate it when smart code figures out what my stupid command *should* be.
Code:
void fam(string famString) {
	if(contains_text(famString),        "cpm" )  {
		cliE("familiar cymbal-playing monkey");
	} else if(contains_text(famString), "bitt" ) {
		cliE("familiar Cheshire Bitten");
	} else if(contains_text(famString, "tick"  ) {
		cliE("familiar nervous tick");
	} else if(contains_text(famString), "add"  ) { 
		cliE("familiar attention-deficit demon");
	# a better nickname for a coffee pixie? cofpix?
	} else if(contains_text(famString, "coffee") {
		cliE("familiar Coffee Pixie");
	} else if(contains_text(famString, "jitt"  ) {
		cliE("familiar Jitterbug");
	} else if(contains_text(famString), "bugb" ) {
		cliE("familiar pygmy bugbear shaman");
	} else if(contains_text(famString, "lion"  ) {
		cliE("familiar Dandy Lion");
	} else if(contains_text(famString, "troll" ) {
		cliE("familiar Ancient Yuletide Troll");
	} else if(contains_text(famString), "somb" ) {
		cliE("familiar hovering sombrero");
	#} else if(contains_text(famString, ""     ) {
	#	cliE("familiar ");
	} else {
		cliE("familiar " + famString);
	}
}

And finally, where is this mythical "Pulverize Antiques.ash"? If it's sufficiently small, maybe just incorporate it into the script?
 

macman104

Member
Hah, hadn't even realized I left in the pulverize antiques code. Right now it's sufficiently small, it's just a script that has pulverize * antique item. I suppose I could just add the code for it in there. For the fam thing....eh. I mean, I could make it smarter like that, so you *could* type "bfoefijfCPMfoiewwjfe", but that proves no usefulness, since it's a silly case. Also, the point of the fam code is not to add all possible abbreviations, it's adding abbreviations that kolmafia's fuzzy matching won't find. So while all those abbreviations make sense, I believe that simply typing "fam suggested_abbreviation" will work already since mafias fuzzy matching will find it anyway. Mafia doesn't find add and cpm. If you find a common abbreviation that mafia won't find please do let me know and I'll certainly add it.

Please don't feel like I "shot down" the suggestions, just like everyone else I'm here for suggestions, and maybe if I had made the intent of the fam function clearer initially, it would have made more sense.

However, I have updated the first post to include code for the pulverize command, right now it's basic with just the antique items, however, I've added a commented line of what the command used to be, but I didn't like how rigid that command was, so I took it out. The idea initially was only to pulverize items that would give you wads.

Regardless of whether I put them in or not, I really do appreciate the suggestions and comments.
Update! I've added a few new functions, mainPane() is for me to bring up the main adventuring pane. queue() *should* print out your current queue, costOf(int amount, int price) should print how much a given quantity of a given item will cost, costOfSeltz(int amount), since I buy seltzers often. I updated the fam command, and also added an import of my Auto Attack Skills functions as well. Check the first post for attachments.
 
Top