TirianLib.Ash (Sell_item)

I don't know if this command has been updated, but I'm trying to run a script using TirianLib.ash,


The .ash is old, and I can't find a newer version (That would solve my problems)

So if anyone knows of any, or would guide me to an old to new ASH reference guide, that would be amazing.

Thanks.


-Duff
 

hippymon

Member
Well, pretty much the whole "tirianlib.ash" is no longer needed... Most of the functions (if not all) have already been incorporated into the hard code that makes up KoLmafia. But in your case the function is "boolean autosell(int, item);"
 
Well, I fixed the tirianlib through trial and error to this point,



however, I'm still having troubles with another script....
Oh well, maybe I'll re-write them. =[
 

tebee

Member
The nice thing about the Tirianlib Autosell function was that it would sell all but x of an item

Code:
void autosell (item it, int leave)
{
	int count;
	count = item_amount(it);
	if (count>leave)
	{
		int difference;
		difference = count-leave;
		sell_item(difference, it);
	}
}

I used as a basis for my own function which does the same thing but takes the item name as a string.

Code:
// auto sells all but "leave" of an item

void auto_sell(string item_string, int leave)
{
        item item_item;
	int count;
	item_item = to_item(item_string);
	count = item_amount(item_item);
	if (count>leave)
	{
		int difference;
		difference = count-leave;
		print ("Now auto selling " + to_string(difference) +" of " + item_string, "red");
		autosell(difference, item_item);
	}
}

I've also got ones to mall sell, put to clan stash and use all but x of an item and at some point will get round to writing pulverise and send to someone versions.

Code:
void mall_sell(string item_string, int leave, int price)
{
        item item_item;
	int count;
	item_item = to_item(item_string);
	count = item_amount(item_item);
	if (count>leave)
	{
		int difference;
		difference = count-leave;
		put_closet(leave, item_item);
		put_shop(price, 0 , item_item);
		take_closet(leave, item_item);
	}
}





// Uses all but "leave" of an item

void use_item(string item_string, int leave)
{
        item item_item;
	int count;
	item_item = to_item(item_string);
	count = item_amount(item_item);
	if (count>leave)
	{
		int difference;
		difference = count-leave;
		use(difference, item_item);
	}
}


// puts in clan all but "leave" of an item

void to_stash(string item_string, int leave)
{
        item item_item;
	int count;
	item_item = to_item(item_string);
	count = item_amount(item_item);
	if (count>leave)
	{
		int difference;
		difference = count-leave;
		put_stash(difference, item_item);
	}
}
 

macman104

Member
cli_execute("sell -" + numberToLeave + " " + itemName);
"sell -5 chaos butterfly" leaves all but 5 chaos butterflies.
 
[quote author=macman104 link=topic=1486.msg6932#msg6932 date=1201826216]
cli_execute("sell -" + numberToLeave + " " + itemName);
"sell -5 chaos butterfly" leaves all but 5 chaos butterflies.
[/quote]
I think you meant:
"sell -5 chaos butterfly" sells all but 5 chaos butterflies.
 

tebee

Member
[quote author=macman104 link=topic=1486.msg6932#msg6932 date=1201826216]
cli_execute("sell -" + numberToLeave + " " + itemName);
"sell -5 chaos butterfly" sells all but 5 chaos butterflies.
[/quote]

So would autosell( item_amount($item[Itemname]) - numbertoleave , $item[Itemname]) but I'm basically lazy, I mean I re-wrote the function so I didn't have to type $item[itemname] but just "itemname". It's a lot more to type each time if you are typing a long list!


Tom
 

hippymon

Member
Well, if you are typing a list you may want to explore the world of maps... Or simply use a script such as: http://kolmafia.us/index.php/topic,1282.msg6263.html#msg6263

Ok, so it turns out it doesn't have a sell function, but try this:
Code:
string filename = "itemlist.txt";
item [string, int] itemMap;
if(!file_to_map(filename, itemMap))
	abort("Map load failed.");
void manage_items(string action){
	foreach keep in itemMap[action]{
		item it = itemMap[action, keep];
		int amount = item_amount(it) - keep;
		if(item_amount(it) > amount){
			if(action == "mall")
				put_shop(0, 0, it);
			if(action == "stash")
				put_stash(amount, it);
			if(action == "display")
				put_display(amount, it);
			if(action == "sell")
				autosell(amount, it);
		}
	}
}
void main(){
##	manage_items("mall");
##	manage_items("display");
##	manage_items("stash");
##	manage_items("sell");
}
 
Top