Simple? script question... Would love a pointer in the right direction please.

JohnnyRamrod

New member
Folks, I'm not a scripter or dev. I'm just keen to get a bit of help on something I think might be simple. I do occasionally hack a script if i understand enough of it to try. That's about it. To me it's like trying to read a book in French after doing 1 year of high school classes. :)

I have created a VERY basic script though, in order to handle a couple of potion creation activities i want to do when i'm farming, (and then just use a mood to trigger them as needed). it's just to set things up a bit more easily.

I got a start by reading the mafia readme on things like basic and advanced scripting. That at least meant i could easily work out how to buy something i wanted - eg.

Code:
buy( 11, $item[Delectable Catalyst] );

or do a check for qty i have of something and buy the difference - eg.

Code:
if ( item_amount( $item[Knob Goblin nasal spray] ) < 33 )
    {
        buy( 33 - item_amount( $item[Knob Goblin nasal spray] ), $item[Knob Goblin nasal spray] );
    }
Then my complete lack of genuine understanding kicks in and confuses me. I (naively) assumed if obvious things like 'buy' work, then i could use something like 'make' or 'cook', or 'acquire' or other things that work in the CLI. Alas i was wrong. What I can't easily find is a list of the key things i can call.

For example, I'd like the script to make cranberry cordial. I know how to check to see if i've got the components, and get them if i don't. But how do i then actually make the cordials? I clearly can't add a line like

Code:
make( 6, $item[Cranberry Cordial] );

because i found out the hard way that doesn't work... I'm guessing it's not that simple given the 'make' CLI command does a whole lot of stuff like check for ingredients etc. Can someone point me in the right direction?

I'm VERY aware of my scripting limitations, and therefore i do want to keep this pretty simple. But i figure SURELY i can learn a bit more than i know now, right? I'm happy to read to learn, just not really finding resources or script samples that are helpful. Not looking for someone to write me the script or anything that lame. Just not really sure what to actually do.

Anyway, thanks for reading - any constructive help would be greatly appreciated!
 

heeheehee

Developer
Staff member
Alternately, if you experiment in the gCLI, you can use "ashref" to list all functions, or apply a filter, e.g. "ashref item" to return only lines with "item" in them (which ends up being all the functions that have to do with items).

The wiki page is a few years out of date, but it should have core functions like create and retrieve_item.
 

ckb

Minion
Staff member
Also, you can write non-ash scripts. These use a series of CLI commands and are saved as a .txt file. For simple scripts, these can be really easy.
This works:

Code:
buy 11 Delectable Catalyst
make 6 Cranberry Cordial

Also, as mentioned previously, the CLI command 'ashref filter' will search through ash commands and show you what they are. Each one ic a clickable link to the Ash Wiki. Likewise the 'help filter' command will give you details on CLI commands you can use in a .txt script.
 

Grabuge

Member
Just to add to everything. If you don't care how it is made specifically, retrieve_item(int qty ,item get ) will use a kolmafia logic to acquire the item. I think it follows the same principle as acquire.
 
Top