AshRef functions

mredge73

Member
Hello
I am new to java scripting and Kol scripting but I am not new to programming.
I have always thought of myself as a fairly good programmer but I have run into a few issues making an item handling script:

Question 1
I found this command from typing Ashref in the cli:
boolean hippy_store_available( )

what exactly does it do; I was assuming that it would return true if the hippy store was available as the name suggest. It returned true for me although I did not even have a dingy or dingy planks or dingy plans or hippy outfit. Does it just check level, I was level 6 but I could not get to the island?

Question 2
Does there exist any documentation on the commands in ashref? With 266 available commands it would help to know which would be useful for each situation since http://wiki.kolmafia.us/ is very incomplete. (I just started scripting so I do not know about all of the work that has gone on with documentation.)

Question 3
Does there exist a list somewhere with the url locations and actions?
I have had to reach out an bother you guys for help on the simple subroutine (below) used to autosell whiskers because I did not know the action part of the url (I even had to search the forums for the visit_url location name). Maybe I am missing something here because when I rollover the location in the relay browser I do not get always get the .php reference. I even tried viewing the source for the page and nothing useful was there. (using latest version of firefox)
Thanks in Advance

//AutoSell whiskers
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
boolean soldwhiskers=false;
int whiskers =item_amount ($item[rat whisker]);
int whiskermeat= 50 * whiskers;

if (whiskers > 0)
{
print("Trading Whiskers for Meat...", "blue");

//This is what I am talking about; where do I find the below references on my own; the &action=whisker part was given to me in the forums by Veracity

visit_url("town_wrong.php?place=artist&action=whisker");

if (item_amount($item[rat whisker])==0)
soldwhiskers=true;

}
 
1) Unless I'm mistaken, it should be making sure that you really are able to use the hippy store. If not, I would recommend reporting this as a bug.

2) http://wiki.kolmafia.us/ is currently the most updated reference. As far as I know, most people learn much of ash scripting by trial and error.

3) Look at the form action and the fields in the forms. Specifically in this case:
Code:
<form action="town_wrong.php" method="post"><input name="action" value="whisker" type="hidden">
 
The easiest way to find these URLs is to use the mini browser :) That's the easiest way for a lot of things.

And yes, trial and error :)
 
I went through the wiki a while back and updated the entire first category with examples and complete descriptions, and I've been meaning to make it back to keep that project growing. Unfortunately, I've lacked both time and motivation.

It would be helpful if people who find the wiki to be lacking certain information would create an account and contribute that information once they find it through other means. It doesn't matter if its poorly formatted; more important is that the information is available to all. I don't mind editing and formatting, it's all the raw creation that tires me out.
 
I'm in agreement with zarqon. A long while back I updated some of the string parsing sections that were depressingly bare, but since then I haven't had time. I'd like to implore any scripter who happens to come across something that isn't specifically on the wiki to add it, even if it is just a rough outline.
 
The easiest way to find these URLs is to use the mini browser :) That's the easiest way for a lot of things.

And yes, trial and error :)

I've actually noticed that if you have a location name, you could use to_url($location["Places name here!"]) to figure out what the url is.
 
That only works with locations that mafia actually knows how to adventure at. You rarely need to use visit_url() to go to those places--hence kain's advice about the mini browser.
 
Last edited:
You can even go to the cli and type "ash to_url($location["Places name here!"]);" and avoid having to write a dummy script to find it.
 
I had to use Zarqon's advice for automating the gourd since "ash to_url" does not work on the gourd.

For future reference here is how I did it:
//Gourd
//##############################################
if (item_amount($item[Knob Goblin firecracker])>4 || item_amount($item[spider web])>4 || item_amount($item[razor-sharp can lid])>4)
{
visit_url("town_right.php?place=gourd&action=gourd");
if(item_amount($item[gourd potion])>0)
print("Defended the Gourd!","blue");
}

Here is another question to keep the thread rolling:

How do I send a message without attaching items?
Is there a Null item or do I need to "borrow" part of Zarqon's kmail script?
http://www.kolmafia.us/showthread.php?t=1203&highlight=kmail

For example:
All I need to do right now is to send a cashout request to wadbot but I may need to use it for something else in the future to take advantage of all of the information bots out there:

int [item] nothing;
cli_execute("send "+to_string(nothing)+" to wadbot || cashout);

This returns an error, I am assuming it is because nothing is an empty set.

cli_execute("send to wadbot || cashout);

This also returns an error because there is no item being sent.

Thanks.
 
I haven't sent kmails using mafia's built-in functionality for ages, since 1) sending meat doesn't work (and hasn't for ages), 2) sending a message with no items is impossible, 3) there is no useful return value, and 4) evidently mafia will not intelligently split a long list of items (more than 11 types) into multiple kmails.

If you're looking to hardcode a specific message to a specific player, you can just borrow a single line from the kmail script (the actual visit_url() line, with the appropriate variables filled in). No sweat.
 
Thanks Guys,

I got another question:
I want an easy way to un-equip an item, has anyone written a function like this?

I want to do this:

if(have_equipped( thingy ))
unequip (thingy);
 
Last edited:
To unequip something, you equip $item[none] in the same slot. If you don't know which slot your thingy is in, I think the easiest solution would be to use the CLI unequip command, which does accept item names as well as slots:
cli_execute("unequip " + to_string(thingy));
 
that is exactly what I was looking for, I did not know how to find out which slot "thingy" was in to unequip it, I am going to use the cli command
Thanks.
 
Well, the to_slot(item) command can be useful for figuring that out, but of course if it is an accessory, then it will only return acc1 and you'd have to test out each each accessory slot with equipped_item(slot) to find out which accessory slot it is in.

While that makes it possible to do without cli_execute(string), I think you're best using jason's advice, unless you need to know which slot was just vacated.
 
Back
Top